Fix grammar not being able to disambiguate some instructions

When two identifiers follow eachother it could be two instruction
mnemonics or one instruction mnemonic and one operand. To fix this
TOKEN_NEWLINE has been reintroduced as a semantic token. The grammar has
been changed to allow empty statements and every instruction and
directive has to end in a newline. Labels do not have to end in a
newline.

In addition to updating the grammar, the implementation of tokenlist,
ast and parser has been updated to reflect these changes.
This commit is contained in:
2025-04-16 12:34:44 +02:00
parent 1574ec6249
commit 242fd9baa5
7 changed files with 18 additions and 8 deletions

View File

@ -1,13 +1,13 @@
<program> ::= <statement>*
<statement> ::= <label> | <directive> | <instruction>
<statement> ::= <label> | <directive> | <instruction> | <newline>
<label> ::= <identifier> <colon>
<directive> ::= <dot> <section_directive>
<directive> ::= <dot> <section_directive> <newline>
<section_directive> ::= "section" <identifier>
<instruction> ::= <identifier> <operands>
<instruction> ::= <identifier> <operands> <newline>
<operands> ::= <operand> ( <comma> <operand> )*