Update grammar to match implementation

This commit is contained in:
omicron 2025-04-01 22:01:33 +02:00
parent 03fc44f339
commit 42445338a4

View File

@ -1,12 +1,11 @@
/* string literals are lexer identifier tokens with that particular value */
<program> ::= <statement>*
<statement> ::= <label> | <directive> | <instruction>
<label> ::= <identifier> <colon>
<directive> ::= <dot> <section>
<directive> ::= <dot> <section_directive>
<section> ::= "section" <identifier>
<section_directive> ::= "section" <identifier>
<instruction> ::= <identifier> <operands>
@ -14,11 +13,8 @@
<operand> ::= <register> | <immediate> | <memory>
<register> ::= <register_base> | <register_extra>
<register_base> ::= "rax" | "rbx" | "rcx" | "rdx" | "rsi" | "rdi" | "rbp" | "rsp"
<register_extra> ::= "r8" | "r9" | "r10" | "r11" | "r12" | "r13" | "r14" | "r15"
<immediate> ::= <number> | <label_reference>
<number> ::= <octal> | <binary> | <decimal> | <hexadecimal>
<label_reference> ::= <identifier>
@ -34,3 +30,10 @@
<register_offset> ::= <plus_or_minus> <number>
<plus_or_minus> ::= <plus> | <minus>
/* These are lexer identifiers with the correct string value */
<section> ::= "section"
<register> ::= "rax" | "rbx" | "rcx" | "rdx" | "rsi" | "rdi" | "rbp" | "rsp" |
"r8" | "r9" | "r10" | "r11" | "r12" | "r13" | "r14" | "r15"