mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-12 22:14:35 +00:00
fix parser bugs
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3525 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
1c3b68bf4b
commit
6748408e65
@ -278,6 +278,8 @@ private:
|
|||||||
///
|
///
|
||||||
void tokenize(string const & s);
|
void tokenize(string const & s);
|
||||||
///
|
///
|
||||||
|
void skipSpaceTokens(istream & is, char c);
|
||||||
|
///
|
||||||
void push_back(Token const & t);
|
void push_back(Token const & t);
|
||||||
///
|
///
|
||||||
void pop_back();
|
void pop_back();
|
||||||
@ -458,6 +460,17 @@ void Parser::tokenize(istream & is)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Parser::skipSpaceTokens(istream & is, char c)
|
||||||
|
{
|
||||||
|
// skip trailing spaces
|
||||||
|
while (catcode(c) == catSpace || catcode(c) == catNewline)
|
||||||
|
if (!is.get(c))
|
||||||
|
break;
|
||||||
|
//lyxerr << "putting back: " << c << "\n";
|
||||||
|
is.putback(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Parser::tokenize(string const & buffer)
|
void Parser::tokenize(string const & buffer)
|
||||||
{
|
{
|
||||||
static bool init_done = false;
|
static bool init_done = false;
|
||||||
@ -471,6 +484,7 @@ void Parser::tokenize(string const & buffer)
|
|||||||
|
|
||||||
char c;
|
char c;
|
||||||
while (is.get(c)) {
|
while (is.get(c)) {
|
||||||
|
lyxerr << "reading c: " << c << "\n";
|
||||||
|
|
||||||
switch (catcode(c)) {
|
switch (catcode(c)) {
|
||||||
case catNewline: {
|
case catNewline: {
|
||||||
@ -499,18 +513,24 @@ void Parser::tokenize(string const & buffer)
|
|||||||
} else {
|
} else {
|
||||||
string s(1, c);
|
string s(1, c);
|
||||||
if (catcode(c) == catLetter) {
|
if (catcode(c) == catLetter) {
|
||||||
|
// collect letters
|
||||||
while (is.get(c) && catcode(c) == catLetter)
|
while (is.get(c) && catcode(c) == catLetter)
|
||||||
s += c;
|
s += c;
|
||||||
if (catcode(c) == catSpace)
|
skipSpaceTokens(is, c);
|
||||||
while (is.get(c) && catcode(c) == catSpace)
|
|
||||||
;
|
|
||||||
is.putback(c);
|
|
||||||
}
|
}
|
||||||
push_back(Token(s));
|
push_back(Token(s));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case catSuper:
|
||||||
|
case catSub: {
|
||||||
|
push_back(Token(c, catcode(c)));
|
||||||
|
is.get(c);
|
||||||
|
skipSpaceTokens(is, c);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case catIgnore: {
|
case catIgnore: {
|
||||||
lyxerr << "ignoring a char: " << int(c) << "\n";
|
lyxerr << "ignoring a char: " << int(c) << "\n";
|
||||||
break;
|
break;
|
||||||
@ -578,8 +598,8 @@ bool Parser::parse_lines(MathAtom & t, bool numbered, bool outmost)
|
|||||||
|
|
||||||
// break if cell is not followed by an ampersand
|
// break if cell is not followed by an ampersand
|
||||||
if (nextToken().cat() != catAlign) {
|
if (nextToken().cat() != catAlign) {
|
||||||
lyxerr << "less cells read than normal in row/col: "
|
//lyxerr << "less cells read than normal in row/col: "
|
||||||
<< row << " " << col << "\n";
|
// << row << " " << col << "\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user