Dekel, I cannot reproduce a fe of the bugs you reported. Another thing: I have hacked around in the parser (patch attached). Could somebody please check that this does not hurt? Andre' --------------------------- snip ------------------------ Array/eqnarray ?? *- Mutation from inline formula to eqnarray generates a numbered eqnarray :: I can't reproduce this. *- After pressing S-ctrl-M in an eqnarray, the cursor is in invalid position *- The align env. is not read correctly: all contents is lost. Macros: ?? *- When changing the macro definition, all instances are not updated. ?? *- If I have macros \newcommand{\foo}[1]{[#1]} and \newcommand{\foox}{\foo{x} ?? then when an instance of \foox is drawn on screen, ?? there are two black frames ?? While this is "correct", it is annoying. :: I have removed the black frame around macros without argumments now. This :: should remove part of the annoyance *- LyX crashes when you define a recursive macro - When doing a selection with the mouse, a macro instance is opened. The correct behavior is to not open the instance. ?? - When creating a new macro instance (with one or more arguments), ?? typing a letter in the first argument, and typing backspace, the macro is ?? closed. :: I can't reproduce this. ?? - Create a macro \foo with one argument: \newcommand{\foo}[1]{[#1]} ?? Now type 2^\foo{x} and close the macro instance. ?? The inset frame will be too high: ?? +------+ ?? | | ?? | | ?? | [x] | ?? | 2 | ?? +------+ :: I can't reproduce this. Misc: ?? *- 'ctrl-m x <escape> <left> shift+<left> x' crashes lyx. :: I can't reproduce this. *- After insertion of \sum, the cursor is in invalid location ?? *- The height of the frame is often wrong (e.g. x^2) :: I can't reproduce this. *- InsetFormula::validate is broken *- Suppose I have x\sum and the cursor is after the x. When pressing ^, the cursor will go into the superscript of the \sum ?? *- Pressing backspace inside \sqrt{a} (when the cursor is after the a) will exit ?? from the root :: I can't reproduce this. *- Pressing backspace while in math text mode exits math text mode. *- Changing math space length by pressing the space-bar key doesn't work *- After inserting delimiters ,e.g. M-m (, the cursor is to the right of the delimiters, and not between them. - The drawing of decorations on screen is very different than latex. (a low priority bug). - In lyx1.1.6, when I type x^2 <backspace> then the 2 is erased, but the cursor remains in superscript mode, namely there is an empty superscript box. In CVS, when pressing backspace, the cursor returns to normal level, namely the superscript box is erased. - If I change '\alpha' to bold, the result is \mathbf{a} - Just moving the cursor in a math inset causes changing the buffer status to (changed). --------------------------- snip ------------------------ Andre' -- André Pönitz ............................................. [EMAIL PROTECTED]
? todo ? test.log ? mathed100.diff ? mathed101.diff ? test.aux ? test.dvi Index: math_parser.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_parser.C,v retrieving revision 1.63 diff -u -p -r1.63 math_parser.C --- math_parser.C 2001/07/12 07:18:29 1.63 +++ math_parser.C 2001/07/12 11:56:34 @@ -94,9 +94,7 @@ const unsigned char LM_TK_CLOSE = '}'; enum { FLAG_BRACE = 1 << 0, // A { needed //} - FLAG_BRACE_OPT = 1 << 2, // Optional { //} FLAG_BRACE_LAST = 1 << 3, // // { Last } ends the parsing process - FLAG_BRACK_ARG = 1 << 4, // Optional [ //] FLAG_RIGHT = 1 << 5, // Next right ends the parsing process FLAG_END = 1 << 6, // Next end ends the parsing process FLAG_BRACE_FONT = 1 << 7, // // { Next } closes a font @@ -104,8 +102,9 @@ enum { FLAG_AMPERSAND = 1 << 10, // Next & ends the parsing process FLAG_NEWLINE = 1 << 11, // Next \\ ends the parsing process - // Read a (possibly braced token) - FLAG_ITEM = FLAG_BRACE_OPT | FLAG_BRACE_LAST + FLAG_ITEM = 1 << 12, // read a (possibly braced token) + FLAG_LEAVE = 1 << 13, // marker for leaving the + FLAG_OPTARG = 1 << 14 // reads an argument in [] }; } @@ -157,7 +156,8 @@ int const latex_mathenv_num = sizeof(lat void mathPrintError(string const & msg) { - lyxerr[Debug::MATHED] << "Line ~" << yylineno << ": Math parse error: " << msg << endl; + //lyxerr[Debug::MATHED] << "Line ~" << yylineno << ": Math parse error: " << +msg << endl; + lyxerr << "Line ~" << yylineno << ": Math parse error: " << msg << endl; } @@ -502,7 +502,8 @@ void handle_frac(MathArray & array, stri void mathed_parse(MathArray & array, unsigned flags) { - int t = yylex(); + lyxerr << "\n"; + int t = yylex(); bool panic = false; static int plevel = -1; yyvarcode = LM_TC_VAR; @@ -511,19 +512,32 @@ void mathed_parse(MathArray & array, uns ++plevel; while (t) { - //lyxerr << "t: " << t << " flags: " << flags; + //lyxerr << "t: " << t << " flags: " << flags << " i: " << yylval.i << +" " + // << " plevel: " << plevel << " "; //array.dump(lyxerr); //lyxerr << "\n"; - if ((flags & FLAG_BRACE) && t != LM_TK_OPEN) { - if (!(flags & FLAG_BRACK_ARG) || t != '[') { - mathPrintError( - "Expected {. Maybe you forgot to enclose an argument in {}"); - panic = true; - break; + if (flags & FLAG_ITEM) { + flags &= ~FLAG_ITEM; + if (t == LM_TK_OPEN) { + // skip the brace and regard everything to the next +matching + // closing brace + t = yylex(); + ++brace; + flags |= FLAG_BRACE_LAST; + } else { + // regard only this single token + flags |= FLAG_LEAVE; } } + if ((flags & FLAG_BRACE) && t != LM_TK_OPEN) { + mathPrintError( + "Expected {. Maybe you forgot to enclose an argument +in {}"); + panic = true; + break; + } + switch (t) { case LM_TK_ALPHA: @@ -544,11 +558,6 @@ void mathed_parse(MathArray & array, uns case LM_TK_OPEN: ++brace; - if (flags & FLAG_BRACE_OPT) { - flags &= ~FLAG_BRACE_OPT; - flags |= FLAG_BRACE; - } - if (flags & FLAG_BRACE) flags &= ~FLAG_BRACE; else @@ -566,33 +575,22 @@ void mathed_parse(MathArray & array, uns yyvarcode = LM_TC_VAR; flags &= ~FLAG_BRACE_FONT; break; - } - if (brace == 0 && (flags & FLAG_BRACE_LAST)) { - --plevel; - return; } - array.push_back('}', LM_TC_TEX); + if (brace == 0 && (flags & FLAG_BRACE_LAST)) + flags |= FLAG_LEAVE; + else + array.push_back('}', LM_TC_TEX); break; case '[': - if (flags & FLAG_BRACK_ARG) { - flags &= ~FLAG_BRACK_ARG; - unsigned char const rg = LexGetArg('['); - if (rg != ']') { - mathPrintError("Expected ']'"); - panic = true; - break; - } - } else - array.push_back('[', LM_TC_CONST); + array.push_back('[', LM_TC_CONST); break; case ']': - if (flags & FLAG_BRACK_END) { - --plevel; - return; - } - array.push_back(']', LM_TC_CONST); + if (flags & FLAG_BRACK_END) + flags |= FLAG_LEAVE; + else + array.push_back(']', LM_TC_CONST); break; case '^': @@ -673,7 +671,7 @@ void mathed_parse(MathArray & array, uns break; case LM_TK_SQRT: - { + { unsigned char c = getuchar(yyis); if (c == '[') { array.push_back(new MathRootInset); @@ -738,7 +736,7 @@ void mathed_parse(MathArray & array, uns case LM_TK_WIDE: { MathDecorationInset * p = new MathDecorationInset(yylval.l->id); - mathed_parse(p->cell(0), FLAG_BRACE | FLAG_BRACE_LAST); + mathed_parse(p->cell(0), FLAG_ITEM); array.push_back(p); break; } @@ -746,7 +744,7 @@ void mathed_parse(MathArray & array, uns case LM_TK_ACCENT: { MathAccentInset * p = new MathAccentInset(yylval.l->id); - mathed_parse(p->cell(0), FLAG_BRACE | FLAG_BRACE_LAST); + mathed_parse(p->cell(0), FLAG_ITEM); array.push_back(p); break; } @@ -835,7 +833,12 @@ void mathed_parse(MathArray & array, uns break; } // end of big switch - + + if (flags & FLAG_LEAVE) { + flags &= ~FLAG_LEAVE; + break; + } + if (panic) { lyxerr << " Math Panic, expect problems!" << endl; // Search for the end command. @@ -844,11 +847,7 @@ void mathed_parse(MathArray & array, uns } while (t != LM_TK_END && t); } else t = yylex(); - - if (flags & FLAG_BRACE_OPT) { - flags &= ~FLAG_BRACE_OPT; - break; - } + } --plevel; }