!===================================================================================== ! Strings that end up in the CGT File !===================================================================================== "Name" = 'Grandma' "Author" = 'Leith Ketchell' "Version" = '1.1' "About" = 'Experimental Grammar for Parser/Interpreter engine' !===================================================================================== !===================================================================================== ! Parser Settings that end up in the CGT File !===================================================================================== "Case Sensitive" = False "Start Symbol" = !===================================================================================== !===================================================================================== ! Terminal Symbols !===================================================================================== ! String CharSets are defined as any printable character EXCEPT the delimiters (" and ') {StringChar 1} = {Printable} - [''] ! Theres two because we need to 'escape' for ' char {StringChar 2} = {Printable} - ["] {StringChar 3} = {Printable} - [<>] {Hex Digit} = {Digit} + [abcdef] + [ABCDEF] ! Literal Strings are defined as a subset of the above charsets with appropriate delimiters StringLiteral = '' {StringChar 1}* '' | '"' {StringChar 2}* '"' | '<' {StringChar 3}* '>' ! Literal Numbers IntegerLiteral = {Digit}+ HexLiteral = 0x{Hex Digit}+ | {Digit}{Hex Digit}*'h' FloatLiteral = {Digit}*'.'{Digit}+ | {Digit}*'.'{Digit}+ 'f' ! ID is defined as any alphanumeric string beginning with a letter. ! These are usually used for naming things, but can mean 'some word i dont know'. Id = {Letter}{AlphaNumeric} + [_@#$] * RepId = '&'{Letter}{AlphaNumeric}* !ReplaceMe , appears within Macros !User !Some VERY CLEVER redefining of the {Whitespace} terminal !allows us to separately define a "new line" terminal {WS} = {Whitespace} - {CR} - {LF} !WS = Whitespace OTHER THAN CR/LF Whitespace = {WS}+ !Redefine Whitespace as 'any number of WS' NewLine = {CR}{LF}|{CR}|{LF} !We can use this to demand new lines in our grammar !===================================================================================== ! NONTERMINAL SYMBOLS (REDUCTION RULES) !===================================================================================== ::= ';' | NewLine | ';' NewLine | NewLine !Deal with multiple trailing CRLFs ! This is our 'Start Symbol' where our grammar begins. ! Program is defined as any number of Declarations or Statements. ::= | NewLine !Deal with multiple leading CRLFS (at start of program) | NewLine !===================================================================================== ! Statements is defined as one or more statements. ! Note that we try to put the 'lower order' term furthest to the right. ::= | !============================================================================== ::= | | | | | !===================================================================================== ::= ::= macro | macro ::= ',' | | !<-- can be nothing ::= local ::= endm !============================================================================== ::= ::= union ::= ends ::= | ::= '?' | '(?)' | '()' | | '<>' | '' | ::= ::= !============================================================================== ::= ! can be one or more , , or nested /, interleaved in any order. ::= | | | | | | | ::= '?' | '(?)' | '()' | | '<>' | '' | ::= struct ::= ends !===================================================================================== ::= ',' | !One or more comma-delimited IDs ::= if endif | if | while endw ! One or more ELSEIF blocks ::= elseif | elseif endif | else endif !============================================================================== !========================================== ! Arbitrary statements should be added here !========================================== ::= echo | ! Support for =, +=, -=, *=, /=, and repeat of these | '.code' | '.data' | '.Segment' ID | !define (un)labelled data entity ! Assignments are for defining buildtime equates (literals) ::= '=' | 'equ' | '+=' | '-=' | '*=' | '/=' ! Segment Flags ::= ',' | ::= 'Writeable' | 'Executable' | 'BSS' | ! Data Declaration ::= | ::= | ::= | ::= db | dw | dd | dq | dt | byte | word | dword | qword | tword | real4 | real8 | real10 ::= ::= ',' | !============================================================================== ! Support for complex expressions ! Operator Precedence is observed for math operators. ! Recommended not to modify this !=============================================== ::= !=============================================== ::= '=' | 'equ' | '+=' | '-=' | '*=' | '/=' | ::= '>' ! Compare | '<' | '<=' | '>=' | '==' | '<>' | ::= '+' ! Add Sub And Or | '-' | '&' | '|' | ::= '*' ! Mul Div | '/' | ::= '^' ! Powers | 'e' ! Exponents | ::= '<<' ! 'shl' | '>>' ! 'shr' | ::= '-' ! Sign | !============================================== ! CPU REGISTERS AND OTHER DATATYPES !============================================== ::= AL | CL | DL | BL | AH | CH | DH | BH | R8 ::= AX | CX | DX | BX | SP | BP | SI | DI | R16 ::= EAX | ECX | EDX | EBX | ESP | EBP | ESI | EDI | R32 ::= RAX | RCX | RDX | RBX | RSP | RBP | RSI | RDI | R64 ::= ST0 | ST1 | ST2 | ST3 | ST4 | ST5 | ST6 | ST7 ::= CS | DS | ES | FS | GS | SS | segreg ::= CR0 | CR2 | CR3 | CR4 | 'CR0/2/3/4' ::= DR0 | DR1 | DR2 | DR3 | DR6 | DR7 | 'DR0/1/2/3/6/7' ::= TR3 | TR4 | TR5 | TR6 | TR7 | 'TR3/4/5/6/7' ::= mmxreg !need to define these ::= byte ptr '[' ']' | word ptr '[' ']' | dword ptr '[' ']' | qword ptr '[' ']' | tword ptr '[' ']' | real4 ptr '[' ']' | real8 ptr '[' ']' | real10 ptr '[' ']' | ID ptr '[' ']' | ::= | | | | | | | | | | ::= !============================================== ! = ID, Literal or Braced Expression !============================================== ::= ! Could be a simple Literal value (eg integer, string, float etc) | '(' ')' ! Could be a braced (sub)expression (ie nesting support for expressions) | '++' ! Could be Name++ | '--' ! Cound be Name-- | ! Could be Name | ReplaceID | ::= '(' ')' ::= ',' | ::= StringLiteral ! String enclosed in a matched pair of " or ' characters | ! integer or float (dotted integer), we dont distinguish yet ::= IntegerLiteral | FloatLiteral | HexLiteral !================================================================================ ::= RepId | Id ::= ':' !============================================== ! 80x86 OPCODES !============================================== ::= AAA | AAS | AAD | AAD | AAM | AAM | ADC ',' | ADD ',' | AND ',' | ARPL ',' | BOUND ',' | BSF ',' | BSWAP | BT ',' | BTC ',' | BTR ',' | BTS ',' | CALL | CALL FAR | CALL ':' | CBW | CWD | CDQ | CWDE | CLC | CLD | CLI | CLTS | CMC | CMOVcc ',' | CMP ',' | CMPSB | CMPSW | CMPSD | CMPXCHG ',' | CMPXCHG486 ',' | CMPXCHG8B | CPUID | DAA | DAS | DEC | DIV | EMMS | ENTER ',' | F2XM1 | FABS | FADD | FADD ',' | FADD TO | FADDP | FADDP ',' | FBLD | FBSTP | FCHS | FCLEX | FNCLEX | FCMOVB | FCMOVB ',' | FCMOVBE | FCMOVBE ',' | FCMOVE | FCMOVE ',' | FCMOVNB | FCMOVNB ',' | FCMOVNBE | FCMOVNBE ',' | FCMOVNE | FCMOVNE ',' | FCMOVNU | FCMOVNU ',' | FCMOVU | FCMOVU ',' | FCOM | FCOM ',' | FCOMP | FCOMP ',' | FCOMPP | FCOMI | FCOMI ',' | FCOMIP | FCOMIP ',' | FCOS | FDECSTP | FDISI | FNDISI | FENI | FNENI | FDIV | FDIV ',' | FDIV TO | FDIVR | FDIVR ',' | FDIVR TO | FDIVP | FDIVP ',' | FDIVRP | FDIVRP ',' | FFREE | FIADD | FICOM | FICOMP | FIDIV | FIDIVR | FILD | FIST | FISTP | FIMUL | FINCSTP | FINIT | FNINIT | FISUB | FISUBR | FLD | FLD1 | FLDL2E | FLDL2T | FLDLG2 | FLDLN2 | FLDPI | FLDZ | FLDCW | FLDENV | FMUL | FMUL ',' | FMUL TO | FMULP | FMULP ',' | FNOP | FPATAN | FPTAN | FPREM | FPREM1 | FRNDINT | FSAVE | FNSAVE | FRSTOR | FSCALE | FSETPM | FSIN | FSINCOS | FSQRT | FST | FSTP | FSTCW | FNSTCW | FSTENV | FNSTENV | FSTSW | FNSTSW | FSUB | FSUB ',' | FSUB TO | FSUBR | FSUBR ',' | FSUBR TO | FSUBP | FSUBP ',' | FSUBRP | FSUBRP ',' | FTST | FUCOM | FUCOM ',' | FUCOMP | FUCOMP ',' | FUCOMPP | FUCOMI | FUCOMI ',' | FUCOMIP | FUCOMIP ',' | FXAM | FXCH | FXCH | FXCH ',' | FXTRACT | FYL2X | FYL2XP1 | HLT | IBTS ',' | IDIV | IMUL | IMUL ',' | IN ',' | INC | INSB | INSW | INSD | INT | INT1 | ICEBP | INT01 | INT3 | INTO | INVD | INVLPG | IRET | IRETW | IRETD | JCXZ | JECXZ | JMP | JMP SHORT | JMP ':' | JMP FAR | Jcc | Jcc NEAR | LAHF | LAR ',' | LDS ',' | LES ',' | LFS ',' | LGS ',' | LSS ',' | LEA ',' | LEAVE | LGDT | LIDT | LLDT | LMSW | LOADALL | LOADALL286 | LODSB | LODSW | LODSD | LOOP | LOOP ',' | LOOPE | LOOPE ',' | LOOPZ | LOOPZ ',' | LOOPNE | LOOPNE ',' | LOOPNZ | LOOPNZ ',' | LSL ',' | LTR | MOV ',' | MOVD ',' | MOVQ ',' | MOVSB | MOVSW | MOVSD | MOVSX ',' | MOVZX ',' | MUL | NEG | NOT | NOP | OR ',' | OUT ',' | OUTSB | OUTSW | OUTSD | PACKSSDW ',' | PACKSSWB ',' | PACKUSWB ',' | PADDB ',' | PADDW ',' | PADDD ',' | PADDSB ',' | PADDSW ',' | PADDUSB ',' | PADDUSW ',' | PADDSIW ',' | PAND ',' | PANDN ',' | PAVEB ',' | PCMPEQB ',' | PCMPEQW ',' | PCMPEQD ',' | PCMPGTB ',' | PCMPGTW ',' | PCMPGTD ',' | PDISTIB ',' | PMACHRIW ',' | PMADDWD ',' | PMAGW ',' | PMULHRW ',' | PMULHRIW ',' | PMULHW ',' | PMULLW ',' | PMVZB ',' | PMVNZB ',' | PMVLZB ',' | PMVGEZB ',' | POP | POPA | POPAW | POPAD | POPF | POPFW | POPFD | POR ',' | PSLLW ',' | PSLLD ',' | PSLLQ ',' | PSRAW ',' | PSRAD ',' | PSRLW ',' | PSRLD ',' | PSRLQ ',' | PSUBB ',' | PSUBW ',' | PSUBD ',' | PSUBSB ',' | PSUBSW ',' | PSUBUSB ',' | PSUBUSW ',' | PSUBSIW ',' | PUNPCKHBW ',' | PUNPCKHWD ',' | PUNPCKHDQ ',' | PUNPCKLBW ',' | PUNPCKLWD ',' | PUNPCKLDQ ',' | PUSH | PUSHA | PUSHAD | PUSHAW | PUSHF | PUSHFD | PUSHFW | PXOR ',' | RCL ',' | RCR ',' | RDMSR | RDPMC | RDTSC | RET | RET | RETF | RETF | RETN | RETN | ROL ',' | ROR ',' | RSM | SAHF | SAL ',' | SAR ',' | SALC | SBB ',' | SCASB | SCASW | SCASD | SETcc | SGDT | SIDT | SLDT | SHL ',' | SHR ',' | SHLD ',' ',' | SHRD ',' ',' | SMI | SMSW | STC | STD | STI | STOSB | STOSW | STOSD | STR | SUB ',' | TEST ',' | UMOV ',' | VERR | VERW | WAIT | WBINVD | WRMSR | XADD ',' | XBTS ',' | XCHG ',' | XLATB | XOR ','