!===================================================================================== ! Strings that end up in the CGT File !===================================================================================== "Name" = 'Grandma' "Author" = 'Leith Ketchell' "Version" = '1.0' "About" = 'An experimental grammar template' !===================================================================================== !===================================================================================== ! 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} - ["] {Hex Digit} = {Digit} + [abcdef] + [ABCDEF] ! Literal Strings are defined as a subset of the above charsets, with appropriate delimiters StringLiteral = '' {StringChar 1}* '' ! any string inside 'these' | '"' {StringChar 2}* '"' ! any string inside "these" ! 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}* !===================================================================================== ! NONTERMINAL SYMBOLS (REDUCTION RULES) !===================================================================================== ! This is our 'Start Symbol', where our grammar begins. ! Program is defined as any number of Declarations or Statements. ::= | ! Declarations include things like function and macro definitions. ::= !We dont have any declaration grammars yet ! Statements is defined as one or more statements. ! Note that we try to put the 'lower order' term furthest to the right. ::= | !============================================================================== ! Support for IF/ELSEIF/ELSE/ENDIF and WHILE/ENDW block statements ! DO NOT MODIFY ! Add your statements to instead, ok?? :) ::= | | ::= if else endif | if endif | if else endif | if endif | while endw ! One or more ELSEIF blocks ::= elseif | elseif !============================================================================== !========================================== ! Arbitrary statements should be added here !========================================== ::= display | display read ID | ! Support for =, +=, -=, *=, /=, and repeat of these ! Assignments are for defining buildtime equates (literals) ::= ID '=' | ID 'equ' ! ! ::= '=' ! | '(' ')' ! | 'equ' ! | '+=' ! | '-=' ! | '*=' ! | '/=' ! | ! ! ::= '+=' ! | '-=' ! | '*=' ! | '/=' ! | '=' ! | 'equ' !============================================================================== ! Support for complex expressions ! Operator Precedence is observed for math operators. ! Recommended not to modify this !=============================================== !=============================================== ::= ! Might add more expression types here ::= '=' | 'equ' | '+=' | '-=' | '*=' | '/=' | ::= '>' ! Compare | '<' | '<=' | '>=' | '==' | '<>' | ::= '+' ! Add Sub And Or | '-' | '&' | '|' | ::= '*' ! Mul Div | '/' | ::= '-' ! Sign | !============================================== ! OPCODES !============================================== ::= nop | mov ',' | push | pushad | popad | pop | ret | ret ::= | | Id !Operands for opcodes !============================================== ! CPU REGISTERS !============================================== ::= | | ::= 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 !============================================== ! = 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) | ID '++' ! Could be Name++ | ID '--' ! Cound be Name-- | ID ! Could be Name ::= StringLiteral ! String enclosed in a matched pair of " or ' characters | ! integer or float (dotted integer), we dont distinguish yet ::= IntegerLiteral | FloatLiteral | HexLiteral !================================================================================