- skipSpaces();
- Token const & t = getToken();
-
- if (t.cs() == "(") {
- matrix = MathAtom(new MathHullInset(LM_OT_SIMPLE));
- parse_into(matrix->cell(0), 0);
- return true;
- }
-
- if (t.cat() == catMath) {
- Token const & n = getToken();
- if (n.cat() == catMath) {
- // TeX's $$...$$ syntax for displayed math
- matrix = MathAtom(new MathHullInset(LM_OT_EQUATION));
- MathHullInset * p = matrix->asHullInset();
- parse_into(p->cell(0), 0);
- p->numbered(0, curr_num_);
- p->label(0, curr_label_);
- } else {
- // simple $...$ stuff
- putback();
- matrix = MathAtom(new MathHullInset(LM_OT_SIMPLE));
- parse_into(matrix->cell(0), 0);
- }
- return true;
- }
-
- if (!t.cs().size()) {
- lyxerr << "start of math expected, got '" << t << "'\n";
- return false;
- }
-
- string const & cs = t.cs();
-
- if (cs == "[") {
- curr_num_ = 0;
- curr_label_.erase();
- matrix = MathAtom(new MathHullInset(LM_OT_EQUATION));
- MathHullInset * p = matrix->asHullInset();
- parse_into(p->cell(0), 0);
- p->numbered(0, curr_num_);
- p->label(0, curr_label_);
- return true;
- }
-
- if (cs != "begin") {
- lyxerr << "'begin' of un-simple math expected, got '" << cs << "'\n";
- return false;
- }
-
- string const name = getArg('{', '}');
-
- if (name == "math") {
- matrix = MathAtom(new MathHullInset(LM_OT_SIMPLE));
- parse_into(matrix->cell(0), 0);
- return true;
- }
-
- if (name == "equation" || name == "equation*" || name == "displaymath") {
- curr_num_ = (name == "equation");
- curr_label_.erase();
- matrix = MathAtom(new MathHullInset(LM_OT_EQUATION));
- MathHullInset * p = matrix->asHullInset();
- parse_into(p->cell(0), FLAG_END);
- p->numbered(0, curr_num_);
- p->label(0, curr_label_);
- return true;
- }
-
- if (name == "eqnarray" || name == "eqnarray*") {
- matrix = MathAtom(new MathHullInset(LM_OT_EQNARRAY));
- return parse_lines(matrix, !stared(name), true);
- }
-
- if (name == "align" || name == "align*") {
- matrix = MathAtom(new MathHullInset(LM_OT_ALIGN));
- return parse_lines(matrix, !stared(name), true);
- }
-
- if (name == "alignat" || name == "alignat*") {
- int nc = 2 * atoi(getArg('{', '}').c_str());
- matrix = MathAtom(new MathHullInset(LM_OT_ALIGNAT, nc));
- return parse_lines(matrix, !stared(name), true);
- }
-
- if (name == "xalignat" || name == "xalignat*") {
- int nc = 2 * atoi(getArg('{', '}').c_str());
- matrix = MathAtom(new MathHullInset(LM_OT_XALIGNAT, nc));
- return parse_lines(matrix, !stared(name), true);
- }
-
- if (name == "xxalignat") {
- int nc = 2 * atoi(getArg('{', '}').c_str());
- matrix = MathAtom(new MathHullInset(LM_OT_XXALIGNAT, nc));
- return parse_lines(matrix, !stared(name), true);
- }
-
- if (name == "multline" || name == "multline*") {
- matrix = MathAtom(new MathHullInset(LM_OT_MULTLINE));
- return parse_lines(matrix, !stared(name), true);
- }
-
- if (name == "gather" || name == "gather*") {
- matrix = MathAtom(new MathHullInset(LM_OT_GATHER));
- return parse_lines(matrix, !stared(name), true);
- }
-
- lyxerr[Debug::MATHED] << "1: unknown math environment: " << name << "\n";
- lyxerr << "1: unknown math environment: " << name << "\n";
- return false;