mirror of
https://github.com/ksherlock/mpw.git
synced 2025-01-10 05:29:48 +00:00
clean up lexer errors a little more
This commit is contained in:
parent
b707e02295
commit
5aa9f08870
18
bin/lexer.rl
18
bin/lexer.rl
@ -381,12 +381,20 @@ bool ParseLine(const char *iter, Command *command)
|
|||||||
|
|
||||||
%% write exec;
|
%% write exec;
|
||||||
|
|
||||||
if (cs < lexer_first_final /* == lexer_error */)
|
if (cs == lexer_error || cs < lexer_first_final)
|
||||||
{
|
{
|
||||||
putchar(' '); putchar(' '); // 2 leading spaces.
|
if (p == eof)
|
||||||
for (size_t i = 0, l = p - iter; i < l; ++i) putchar(' '); puts("^");
|
{
|
||||||
if (*p == 0) fprintf(stderr, "Unexpected end of line\n");
|
fprintf(stderr, "Unexpected end of line\n");
|
||||||
else fprintf(stderr, "unexpected character: `%c'\n", *p);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (size_t i = 0, l = 2 + (p - iter); i < l; ++i)
|
||||||
|
fputc(' ', stderr);
|
||||||
|
|
||||||
|
fprintf(stderr, "^\nunexpected character: `%c'\n", *p);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
ParseFree(parser, free);
|
ParseFree(parser, free);
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user