From a743db94541bebafff23c8a490dbce3f55d69712 Mon Sep 17 00:00:00 2001 From: Bobby Bingham Date: Sat, 14 Jan 2017 12:01:13 -0600 Subject: nqasm: Improve parsing at end of file Bison's implicit $accept rule ends with the END token. The fact that input could also end with END (via the line non-terminal) resulted in a shift reduce conflict. We resolve the conflict by modifying the lexer so that if it encounters end of file partway through a line, it produces a final EOL token before EOF. --- lexer.l | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lexer.l') diff --git a/lexer.l b/lexer.l index 9a34d66..6b6b121 100644 --- a/lexer.l +++ b/lexer.l @@ -55,7 +55,10 @@ EOI [ \t\n#] nop/{EOI} { BEGIN(args); return T_NOP; } {SP}*{COMMENT}?\n { BEGIN(INITIAL); return T_EOL; } -{SP}*{COMMENT} { BEGIN(INITIAL); return T_SPACE; } +{SP}*{COMMENT} { BEGIN(INITIAL); return T_EOL; } {SP}+ { return T_SPACE; } +<> { return 0; } +<> { BEGIN(INITIAL); return T_EOL; } + %% -- cgit v1.2.3