clean up lexer errors a little more

This commit is contained in:
Kelvin Sherlock 2014-12-31 17:42:18 -05:00
parent b707e02295
commit 5aa9f08870

View File

@ -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;