<DEFAULT> SKIP : { " " | "\t" | "\n" | "\r" | "\f" } |
<DEFAULT> SPECIAL : { <SINGLE_LINE_COMMENT: "//" (~["\n","\r"])* ("\n" | "\r" | "\r\n")> | <FORMAL_COMMENT: "/**" (~["*"])* "*" ("*" | ~["*","/"] (~["*"])* "*")* "/"> | <MULTI_LINE_COMMENT: "/*" (~["*"])* "*" ("*" | ~["*","/"] (~["*"])* "*")* "/"> } |
<DEFAULT> TOKEN : { <LPAREN: "("> | <RPAREN: ")"> | <TRUE: "#t"> | <FALSE: "#f"> | <IF: "if"> | <LAMBDA: "lambda"> | <LET: "let"> | <LETREC: "letrec"> | <PLUS: "+"> | <SETBANG: "set!"> } |
<DEFAULT> TOKEN : { <INTEGER_LITERAL: ["1"-"9"] (["0"-"9"])* | "0"> } |
<DEFAULT> TOKEN : { <IDENTIFIER: <LETTER> (<LETTER> | <DIGIT>)*> | <#LETTER: ["$","A"-"Z","_","a"-"z","\u00c0"-"\u00d6","\u00d8"-"\u00f6","\u00f8"-"\u00ff","\u0100"-"\u1fff","\u3040"-"\u318f","\u3300"-"\u337f","\u3400"-"\u3d2d","\u4e00"-"\u9fff","\uf900"-"\ufaff"]> | <#DIGIT: ["0"-"9","\u0660"-"\u0669","\u06f0"-"\u06f9","\u0966"-"\u096f","\u09e6"-"\u09ef","\u0a66"-"\u0a6f","\u0ae6"-"\u0aef","\u0b66"-"\u0b6f","\u0be7"-"\u0bef","\u0c66"-"\u0c6f","\u0ce6"-"\u0cef","\u0d66"-"\u0d6f","\u0e50"-"\u0e59","\u0ed0"-"\u0ed9","\u1040"-"\u1049"]> } |
/************************************** * The MiniScheme Grammar Starts Here * **************************************/ |
||
Goal | ::= | Expression <EOF> |
Expression | ::= | IntegerLiteral |
| | TrueLiteral | |
| | FalseLiteral | |
| | PlusExpression | |
| | IfExpression | |
| | LetExpression | |
| | Identifier | |
| | Assignment | |
| | ProcedureExp | |
| | Application | |
| | RecExpression | |
IntegerLiteral | ::= | <INTEGER_LITERAL> |
TrueLiteral | ::= | "#t" |
FalseLiteral | ::= | "#f" |
PlusExpression | ::= | "(" "+" Expression Expression ")" |
IfExpression | ::= | "(" "if" Expression Expression Expression ")" |
LetExpression | ::= | "(" "let" "(" ( Declaration )* ")" Expression ")" |
Identifier | ::= | <IDENTIFIER> |
Assignment | ::= | "(" "set!" Identifier Expression ")" |
ProcedureExp | ::= | "(" "lambda" "(" ( Identifier )* ")" Expression ")" |
Application | ::= | "(" Expression ( Expression )* ")" |
RecExpression | ::= | "(" "letrec" "(" ( RecDeclaration )* ")" Expression ")" |
Declaration | ::= | "(" Identifier Expression ")" |
RecDeclaration | ::= | "(" Identifier ProcedureExp ")" |