!===================================================================================== ! 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} - ["] ! 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 are defined as any series of digits, possibly with a decimal point. NumberLiteral = {Digit}+('.'{Digit}+)? ! 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 | ID ! Support for =, +=, -=, *=, /=, and repeat of these ! This allows expressions like 'x=y+=z*=q=2' etc ::= '=' | '=' ! Note how these chain off each other | ! so we can have 'top item', OR ANY UNDER IT ::= '-=' | '-=' | ::= '+=' | '+=' | ::= '*=' | '*=' | ::= '/=' | '/=' !============================================================================== ! Support for complex expressions ! Operator Precedence is observed for math operators. ! Recommended not to modify this !=============================================== !=============================================== ::= ! Might add more expression types here ::= '>' ! Compare | '<' | '<=' | '>=' | '==' | '<>' | ::= '+' ! Add Sub And Or | '-' | '&' | '|' | ::= '*' ! Mul Div | '/' | ::= '-' ! Sign | !============================================== ! = 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 | NumberLiteral ! integer or float (dotted integer), we dont distinguish yet !================================================================================