diff --git a/doc/GRAMMAR b/doc/GRAMMAR index 3439b24..4f287ee 100644 --- a/doc/GRAMMAR +++ b/doc/GRAMMAR @@ -1,6 +1,8 @@ program: { section | statement } -section: "." WORD newline +section: "." section_name newline + +section_name: WORD newline: [ space ] NEWLINE @@ -8,17 +10,17 @@ space: SPACE { SPACE } statement: ( function | space [ instruction ] ) newline -function: name [ space ] ":" +function: function_name [ space ] ":" -name: WORD +function_name: WORD -instruction: operator [ operand_list ] +instruction: instruction_name [ space [ operand_list ] ] -operator: WORD +instruction_name: WORD -operand_list: operand { "," operand } +operand_list: operand [ space ] { "," [ space ] operand [ space ] } -operand: [ space ] ( value | address ) [ space ] +operand: value | address value: symbol | register | immediate @@ -26,6 +28,10 @@ symbol: WORD register: "%" WORD -immediate: "$" NUMBER +immediate: "$" [ sign ] NUMBER -address: "[" [ space ] value [ value ] [ "+" [ space ] offset [ space ] ] "]" +address: "[" [ space ] [ sign [ space ] ] value [ space ] [ offset [ space ] ] "]" + +sign: ( "+" | "-" ) + +offset: sign [ space ] value