* src/mathed/InsetMathGrid.C: Don't declare mathed_parse_normal,
include MathParser.h instead
(InsetMathGrid::doDispatch): remove to_utf8, mathed_parse_normal
takes now a docstring
* src/mathed/MathMacroTemplate.C
(MathMacroTemplate::read): restore the version of 1.4.x, since
the new one did only work for macros without whitespace
* src/mathed/MathParser.[Ch]
(Parser): Add constructor from a docstring
(mathed_parse_cell): Create the parser directly from the string,
since the istream variant of tokenize() does only work if reading
from the .lyx file
(mathed_parse_normal): ditto
(mathed_parse_normal): Delete the istream variant (unused)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16334
a592a061-630c-0410-9148-
cb99ea01b6c8
FILE
-* Loading de_Userguide.lyx results in two parse errors:
- Paragraph ended in line 21206
- Missing \end_layout.
- Paragraph ended in line 21301
- Missing \end_layout.
- I don't know if that is a lyx2lyx or LyX problem. LyX 1.4 can read the file.
-
* Change Tools->Preferences->User interface->User interface to something like
"kornel.default.ui"; save prefs; exit LyX; restart LyX; => crash;
in the preferences file, there is an entry \bind_file "/Something/kornel.default"
"margin-right:0px; -qt-block-indent:0; text-indent:0px;\"></p></body></html>"
msgstr ""
FIXED (JSpitzm 2006-12-19)
+
+* Loading de_Userguide.lyx results in two parse errors:
+ Paragraph ended in line 21206
+ Missing \end_layout.
+ Paragraph ended in line 21301
+ Missing \end_layout.
+ I don't know if that is a lyx2lyx or LyX problem. LyX 1.4 can read the file.
+ FIXED (Georg 2006-12-17). It turned out that it was a math parser problem
+ (bug 3034). It was introduced by the conversion of mathed to unicode,
+ because two methods Parser::tokenize() with different semantics existed.
+
#include "InsetMathGrid.h"
#include "MathData.h"
+#include "MathParser.h"
#include "MathStream.h"
#include "BufferView.h"
};
-void mathed_parse_normal(InsetMathGrid &, string const & argument);
-
namespace {
docstring verboseHLine(int n)
int n = 0;
is >> n;
InsetMathGrid grid(1, 1);
- // FIXME UNICODE
- mathed_parse_normal(grid,
- to_utf8(lyx::cap::getSelection(cur.buffer(), n)));
+ mathed_parse_normal(grid, cap::getSelection(cur.buffer(), n));
if (grid.nargs() == 1) {
// single cell/part of cell
recordUndo(cur);
docstring MathMacroTemplate::prefix() const
{
- // FIXME UNICODE
- // delete the conversion when bformat() will return a docstring.
- // delete the conversion when bformat() takes a docstring arg.
return bformat(_(" Macro: %1$s: "), name_);
}
void MathMacroTemplate::read(Buffer const &, LyXLex & lex)
{
MathArray ar;
- lex.next(); // eat \begin_inset FormulaMacro line
- docstring const str = lex.getDocString();
- lex.next(); // eat that macro definition
- lex.next(); // eat the \\end_insrt line
- //lyxerr << "Got to read from: " << to_utf8(str) << endl;
- mathed_parse_cell(ar, str);
+ mathed_parse_cell(ar, lex.getStream());
if (ar.size() != 1 || !ar[0]->asMacroTemplate()) {
lyxerr << "Cannot read macro from '" << ar << "'" << endl;
lyxerr << "Read: " << to_utf8(asString(ar)) << endl;
using std::string;
using std::ios;
using std::istream;
-using std::istringstream;
using std::ostream;
using std::vector;
///
Parser(LyXLex & lex);
- ///
+ /// Only use this for reading from .lyx file format, for the reason
+ /// see Parser::tokenize(std::istream &).
Parser(istream & is);
+ ///
+ Parser(docstring const & str);
///
bool parse(MathAtom & at);
void error(docstring const & msg) { error(to_utf8(msg)); }
/// dump contents to screen
void dump() const;
- ///
+ /// Only use this for reading from .lyx file format (see
+ /// implementation for reason)
void tokenize(istream & is);
///
void tokenize(docstring const & s);
}
+Parser::Parser(docstring const & str)
+ : lineno_(0), pos_(0)
+{
+ tokenize(str);
+}
+
+
void Parser::push_back(Token const & t)
{
tokens_.push_back(t);
{
// eat everything up to the next \end_inset or end of stream
// and store it in s for further tokenization
- std::string s;
+ string s;
char c;
while (is.get(c)) {
s += c;
return;
}
- docstring const arg = getArg('[', ']');
+ docstring const arg = getArg('[', ']');
if (!arg.empty())
nargs = convert<int>(arg);
void mathed_parse_cell(MathArray & ar, docstring const & str)
{
- istringstream is(to_utf8(str));
- mathed_parse_cell(ar, is);
+ Parser(str).parse(ar, 0, InsetMath::MATH_MODE);
}
}
-bool mathed_parse_normal(MathAtom & t, string const & str)
-{
- istringstream is(str);
- return Parser(is).parse(t);
-}
-
-
-bool mathed_parse_normal(MathAtom & t, istream & is)
+bool mathed_parse_normal(MathAtom & t, docstring const & str)
{
- return Parser(is).parse(t);
+ return Parser(str).parse(t);
}
}
-void mathed_parse_normal(InsetMathGrid & grid, string const & str)
+void mathed_parse_normal(InsetMathGrid & grid, docstring const & str)
{
- istringstream is(str);
- Parser(is).parse1(grid, 0, InsetMath::MATH_MODE, false);
+ Parser(str).parse1(grid, 0, InsetMath::MATH_MODE, false);
}
/// parse formula from a string
bool mathed_parse_normal(MathAtom &, docstring const &);
-/// ... a stream
-bool mathed_parse_normal(MathAtom &, std::istream &);
/// ... the LyX lexxer
bool mathed_parse_normal(MathAtom &, LyXLex &);
-/// ... the LyX lexxer
+/// parse formula from a string into a grid
void mathed_parse_normal(InsetMathGrid &, docstring const &);
/// parse a single cell from a string
void mathed_parse_cell(MathArray & ar, docstring const &);
-/// ... a stream
+/// parse a single cell from a stream. Only use this for reading from .lyx
+/// file format, for the reason see Parser::tokenize(std::istream &).
void mathed_parse_cell(MathArray & ar, std::istream &);
void initParser();