mirror of
https://github.com/ksherlock/mpw.git
synced 2025-01-03 04:30:32 +00:00
fix lexer bugs with bad input.
This commit is contained in:
parent
cbe66b6798
commit
b707e02295
28
bin/lexer.rl
28
bin/lexer.rl
@ -215,6 +215,7 @@ namespace {
|
||||
Parse(parser, tkINTEGER, value, command);
|
||||
};
|
||||
|
||||
# todo -- (\['\]|[^'\]){1,4} ?
|
||||
['] [^']{1,4} ['] {
|
||||
// 4 cc code
|
||||
|
||||
@ -375,28 +376,41 @@ bool ParseLine(const char *iter, Command *command)
|
||||
const char *te;
|
||||
int cs, act;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
|
||||
%% write init;
|
||||
|
||||
|
||||
%% write exec;
|
||||
|
||||
if (cs == lexer_error)
|
||||
if (cs < lexer_first_final /* == lexer_error */)
|
||||
{
|
||||
fprintf(stderr, "illegal character: `%c'\n", *p);
|
||||
putchar(' '); putchar(' '); // 2 leading spaces.
|
||||
for (size_t i = 0, l = p - iter; i < l; ++i) putchar(' '); puts("^");
|
||||
if (*p == 0) fprintf(stderr, "Unexpected end of line\n");
|
||||
else fprintf(stderr, "unexpected character: `%c'\n", *p);
|
||||
|
||||
ParseFree(parser, free);
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
if (cs == lexer_en_error)
|
||||
{
|
||||
ParseFree(parser, free);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cs < lexer_first_final)
|
||||
{
|
||||
fprintf(stderr, "Incomplete command\n");
|
||||
ParseFree(parser, free);
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
|
||||
if (p == pe)
|
||||
{
|
||||
// always true?
|
||||
Parse(parser, tkEOL, 0, command);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Parse(parser, 0, 0, command);
|
||||
|
@ -222,6 +222,12 @@ stmt ::= expr(a) SEMI SEMIT IDENTIFIER(b) EOL.
|
||||
}
|
||||
|
||||
|
||||
stmt ::= expr SEMI SEMIT error EOL.
|
||||
{
|
||||
fprintf(stderr, "usage: expression ; t TemplateName\n");
|
||||
}
|
||||
|
||||
|
||||
stmt ::= DREGISTER(a) EQ expr(b) EOL.
|
||||
{
|
||||
Debug::SetDRegister(a.intValue, b.intValue);
|
||||
|
Loading…
Reference in New Issue
Block a user