!===================================================================================== ! Strings that end up in the CGT File !===================================================================================== "Name" = 'Grandma' "Author" = 'Leith Ketchell' "Version" = '1.2' "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' ! Identifiers: These are usually used for naming things, but can mean 'some word i dont know'. ! ID is defined as any string which: !- contains a letter, !- may contain Digits and a handful of 'decoration' characters, !- may not be a single letter 'e' (or 'E') !Note that the single letter 'e' is reserved by the math evaluation rules. {IDSyms} = [_@#$] !Decoration characters {IdPrefix} = {Letter} - [eE] !CharacterSet for names which are a single letter : cannot be e or E Exponent = e | E Id = {IdPrefix} !If its a single letter, it cannot be 'e' or 'E' (exponent) | {Letter}+ {IDSyms}* {AlphaNumeric}+ {IDSyms}* {AlphaNumeric}* !If it starts with a letter, it has to be two characters or longer | {IDSyms}+ {Digit}* {Letter} {AlphaNumeric}* {IDSyms}* {AlphaNumeric}* !If it starts with a decoration, it just needs at least one letter RepId = '&' Id !ReplaceMe , appears within Macros !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 Comment Start = '/*' Comment End = '*/' Comment Line = '//' !===================================================================================== ! 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 | | !Executable programs will have the last statement = "end EntryPointName" ::= 'end' | 'end' ::= !Executable programs will have their first statement(s) = cpu opcode family selection ::= | ::= '.' ::= | ::= 8086 | 186 | 286 | 386 | 486 | CYRIX | PENT | P6 ::= MMX | FPU | PRIV | UNDOC !===================================================================================== ! Statements is defined as one or more statements. ! Note that we try to put the 'lower order' term furthest to the right. ::= | !============================================================================== ::= | | | |