fix template lexer errors.

This commit is contained in:
Kelvin Sherlock 2014-12-31 18:46:38 -05:00
parent 427a4a6f31
commit 15d0eded63

View File

@ -228,32 +228,20 @@ bool LoadTemplateFile(const std::string &filename, std::unordered_map<std::strin
const char *te; const char *te;
int cs, act; int cs, act;
for(;;)
{
%% write init; %% write init;
%% write exec; %% write exec;
if (cs == lexer_error) if (cs == lexer_error || cs < lexer_first_final)
{ {
if (p == eof)
fprintf(stderr, "Template error: line %d - unexpected EOF\n", info.LineNumber);
else
fprintf(stderr, "Template error: line %d - illegal character: `%c'\n", info.LineNumber, *p); fprintf(stderr, "Template error: line %d - illegal character: `%c'\n", info.LineNumber, *p);
TemplateParseFree(parser, free); TemplateParseFree(parser, free);
munmap(buffer, st.st_size); munmap(buffer, st.st_size);
return false; return false;
} }
if (cs == lexer_en_error)
{
TemplateParseFree(parser, free);
munmap(buffer, st.st_size);
return false;
}
if (p == pe)
{
// ?
//TemplateParse(parser, tkEOF, 0);
break;
}
}
TemplateParse(parser, 0, 0); TemplateParse(parser, 0, 0);
TemplateParseFree(parser, free); TemplateParseFree(parser, free);