void error(string const & msg);
///
void parse_lines(MathGridInset * p, bool numbered, bool outmost);
- ///
- latexkeys const * read_delim();
private:
///
void Parser::error(string const & msg)
{
lyxerr << "Line ~" << lineno_ << ": Math parse error: " << msg << endl;
+ //exit(1);
}
}
-latexkeys const * Parser::read_delim()
-{
- Token const & t = getToken();
- latexkeys const * l = in_word_set(t.asString());
- return l ? l : in_word_set(".");
-}
-
-
void Parser::parse_into(MathArray & array, unsigned flags, MathTextCodes code)
{
MathTextCodes yyvarcode = LM_TC_MIN;
}
else if (t.cs() == "left") {
- latexkeys const * l = read_delim();
+ string l = getToken().asString();
MathArray ar;
parse_into(ar, FLAG_RIGHT);
- latexkeys const * r = read_delim();
+ string r = getToken().asString();
MathDelimInset * dl = new MathDelimInset(l, r);
dl->cell(0) = ar;
array.push_back(dl);
}
else if (t.cs() == "right") {
- if (!(flags & FLAG_RIGHT))
+ if (!(flags & FLAG_RIGHT)) {
+ lyxerr << "got so far: '" << array << "'\n";
error("Unmatched right delimiter");
+ }
return;
}
break;
}
- else LM_TK_SPECIAL:
- array.push_back(new MathCharInset(ival_, LM_TC_TEX));
- break;
*/
else if (t.cs() == "begin") {
if (array.at(pos)->nucleus()->getChar() == '{')
break;
if (pos >= 0) {
- // found it -> use the part after '{' as "numerator", erase the '{'
+ // found it -> use the part after '{' as "numerator"
p->cell(0) = MathArray(array, pos + 1, array.size());
+ parse_into(p->cell(1), FLAG_BRACE_LAST);
+ // delete denominator and the '{'
array.erase(pos, array.size());
+ } else if (flags & FLAG_RIGHT) {
+ // we are inside a \left ... \right block
+ //lyxerr << "found '" << t.cs() << "' enclosed by \\left .. \\right\n";
+ p->cell(0).swap(array);
+ parse_into(p->cell(1), FLAG_RIGHT);
+ // handle the right delimiter properly
+ putback();
} else {
// not found -> use everything as "numerator"
p->cell(0).swap(array);
+ parse_into(p->cell(1), FLAG_BLOCK);
}
array.push_back(p);
- parse_into(p->cell(1), FLAG_BLOCK);
}
else if (t.cs().size()) {
else {
MathInset * p = createMathInset(t.cs());
- for (int i = 0; i < p->nargs(); ++i)
+ for (unsigned int i = 0; i < p->nargs(); ++i)
parse_into(p->cell(i), FLAG_ITEM);
array.push_back(p);
}
else {
MathInset * p = createMathInset(t.cs());
if (p) {
- for (int i = 0; i < p->nargs(); ++i)
+ for (unsigned int i = 0; i < p->nargs(); ++i)
parse_into(p->cell(i), FLAG_ITEM);
array.push_back(p);
} else {