Module = "module" Label [ Body ] "end".
Body = { Label | Instruction }.
Label = [ "." ] Ident [ ":" ] [ "=" Expr ].
Instruction = OpImp | ( OpArg Arg ) | OpRep.
Expr = ExprBit { OperRel ExprBit }.
OperRel = "<" | "<=" | "=" | "!=" | ">" | ">=".
ExprBit = ExprSum { OperBit ExprSum }.
OperBit = "&" | "|" | "^".
ExprSum = ExprShift { OperSum ExprShift }.
OperSum = "+" | "-".
ExprShift = ExprMul { OperShift ExprMul }.
OperShift = "<<" | ">>".
ExprMul = ExprSign { OperMul ExprSign }.
OperMul = "*" | "/" | "%".
ExprSign = [ OperSign ] ExprVal.
OperSign = "+" | "-" | "~".
ExprVal = "(" Expr ")" | Number | ( [ "." ] Ident ) | "pc".
Ident = Letter { Letter | Digit }.
Letter = "A" | .. | "Z" | "a" .. | "z" | "_".
Digit = "0" | .. | "9".
HexDigit = Digit | "A" | .. | "F" | "a" | .. | "f".
BinDigit = "0" | "1".
Number = DecNumber | HexNumber | BinNumber.
DecNumber = Digit { Digit }.
HexNumber = ( "$" | "0x" ) HexDigit { HexDigit }.
BinNumber = "0b" BinDigit { BinDigit }.
OpImp = "brk" | "clc" | "cld" | "cli" | "clv" | "inx" | "iny" | "dey" | "dex" | "nop" | "pha" | "php" | "pla" | "plp" | "rti" | "rts" | "sec" | "sed" | "sei" | "tax" | "tay" | "tsx" | "txa" | "txs" | "tya".
OpRep = "rep" Expr Instruction.
OpArg = "adc" | "and" | "asl" | "bcc" | "bcs" | "beq" | "bne" | "bpl" | "bmi" | "bvc" | "bvs" | "bit" | "cmp" | "cpx" | "cpy" | "dec" | "eor" | "inc" | "jmp" | "jsr" | "db" | "lda" | "ldx" | "ldy" | "lsr" | "ora" | "rol" | "ror" | "sbc" | "sta" | "stx" | "sty" | "org".
Arg = ( [ "#" ] Expr ) | "A" | ArgExpr.
ArgExprShift = ExprShift | "x" | "y" | ( "[" ArgExpr "]" ).
ArgExpr = "[" ArgExprShift { OperSum ArgExprShift } "]".