diff options
| author | uvok | 2026-01-12 19:33:14 +0100 |
|---|---|---|
| committer | uvok | 2026-01-12 19:33:14 +0100 |
| commit | 126f8afd68fd590ba96d6c94667b6fc29f89bbb2 (patch) | |
| tree | 599688d2dbba60441b84da68ef671da1e5c286e0 | |
| parent | daa280b98a5bcf767c8692ced66bece53577afe4 (diff) | |
automatic newline add
| -rw-r--r-- | nandgame/assembler/lexer.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/nandgame/assembler/lexer.py b/nandgame/assembler/lexer.py index aab2549..1d3043a 100644 --- a/nandgame/assembler/lexer.py +++ b/nandgame/assembler/lexer.py @@ -65,5 +65,15 @@ def t_error(t): print("!!! Illegal character '%s'" % t.value[0]) t.lexer.skip(1) +# EOF handling rule +def t_eof(t): + if not t.lexer.newline_added: + print("Warning, EOF without newline encountered. Trying to add it.") + t.lexer.input("\n") + t.lexer.newline_added = True + return t.lexer.token() + return None + # Build the lexer lexer = lex.lex() +lexer.newline_added = False |
