From 22ade3750e242898684f7197406692cc047ad605 Mon Sep 17 00:00:00 2001 From: John Breaux Date: Tue, 30 Jan 2024 05:29:25 -0600 Subject: [PATCH] grammar.ebnf: Commit incomplete grammar description --- grammar.ebnf | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 grammar.ebnf diff --git a/grammar.ebnf b/grammar.ebnf new file mode 100644 index 0000000..06704d9 --- /dev/null +++ b/grammar.ebnf @@ -0,0 +1,47 @@ +(* Partical grammar for msp430-asm *) + +Line = Label | Directive | Insn ; + +Insn = NoEm | OneEm | Special | OneArg | TwoArg | Jump ; + +(* Instruction formats *) +NoEm = OpNoEm ; +OneEm = OpOneEm Dst ; +Special = "reti" | "br" Src ; +OneArg = OpOneArg Src ; +TwoArg = OpTwoArg Src ','? Dst ; +Jump = OpJump Expr ; + + +(* Addressing modes *) +Src = '#' (SrcSpecial | '-'? Expr) + | Absolute + | PostInc + | Indexed + | Direct ; + +Dst = '#' (SrcSpecial | Expr) + | Absolute + | Indirect + | Indexed + | Direct ; + +Direct = Reg ; +Indirect = '@' Reg ; +PostInc = Indirect '+'? ; +Indexed = Number '(' Reg ')' ; +Immediate = '#' Expr ; +Absolute = '&' Expr ; +SrcSpecial = 0 | 1 | '-' 1 | 0xffff | 2 | 4 | 8 ; +DstSpecial = 0 | 1 ; + +Expr = '-'? Number ; + +(* Pseudo-terminals *) +Reg = "pc" | "sp" | "sr" | "cg" + | "r0" | "r1" | "r2" | "r3" + | "r4" | "r5" | "r6" | "r7" + | "r8" | "r9" | "r10" | "r11" + | "r12" | "r13" | "r14" | "r15" ; +Identifier = ID_START ID_CONTINUE* ; +Number = '-'? DIGIT ;