Commit a3da85b3 authored by Alvarez, Gonzalo's avatar Alvarez, Gonzalo
Browse files

Ainur: use stringContext for better error reporting

parent 8975a8c6
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -219,6 +219,25 @@ public:
		}
	}

	static String stringContext(std::string::iterator it,
	                            std::string::iterator start,
	                            std::string::iterator end,
	                            SizeType before = 5,
	                            SizeType after = 10)
	{
		std::string::iterator alpha = it;
		SizeType counter = 0;
		while (alpha != start && counter++ < before)
			--alpha;

		std::string::iterator omega = it;
		counter = 0;
		while (omega != end && counter++ < after)
			++omega;

		return String(alpha, omega);
	}

private:

	int assignStorageByName(String key)
+9 −6
Original line number Diff line number Diff line
@@ -178,8 +178,11 @@ void AinurState::convertInternal(Matrix<T>& t,
	                          qi::space);

	//check if we have a match
	if (!r)
		err("matrix parsing failed\n");
	if (!r) {
		err("matrix parsing failed near " +
		    stringContext(it, value.begin(), value.end())
		    + "\n");
	}

	if (it != value.end())
		std::cerr << "matrix parsing: unmatched part exists\n";
+1 −0
Original line number Diff line number Diff line
@@ -237,6 +237,7 @@ public:
			str += "string " + istr + "GeometryOptions;\n";
			str += "integer " + istr + "LadderLeg;\n";
			str += "integer " + istr + "LongChainDistance;\n";
			str += "integer " + istr + "BathSitesPerSite;\n";
			for (SizeType j = 0; j < 9; ++j) {
				String jstr = "dir" + ttos(j) + ":";
				str += "vector " + istr + jstr + "Connectors;\n";