Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- grammar mpinter;
- prog :
- ;
- MethodDecl
- : public Type id ( ParamList?) {VarDecl* Statement* return Exp;}
- ParamList
- : Type id ParamRest*
- ;
- ParamRest
- : ',' Type id
- ;
- Type
- : 'int'[]
- | 'boolean'
- | 'int'
- | 'id'
- ;
- Statement
- : '{' Statement* '}'
- | 'if' '(' Exp ')' Statement 'else' Statement
- | 'while' '(' Exp' )' Statement
- | 'System.out.println''(' Exp ')';
- | id = Exp;
- | id '[' Exp ']' = Exp;
- ;
- Exp
- : Exp op Exp
- | Exp '[' Exp ']'
- | Exp . length
- | Exp . id ( ExpList )?
- | 'true'
- | 'false'
- | id
- | 'hinteger' [+|-]? [0-9]*
- | 'this'
- | 'new' 'int' [ Exp ]
- | 'new' id '(' _ ')'
- | '!' Exp
- | '(' Exp ')'
- ;
- ExpList
- : Exp ExpRest*
- ;
- ExpRest
- : ',' Exp
- ;
- id
- : ('a-z' | 'A-Z') ('a-z'|'_'|'0-9')*
- ;
- op
- : &&
- | +
- | -
- | *
- | <
- ;
Add Comment
Please, Sign In to add comment