Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void nt_ClassDecl() :
- {}
- {
- LOOKAHEAD(2) <CLASS> <ID> <LBRACE> (nt_FieldDecl())* (nt_MethodDecl())* <RBRACE>
- | <CLASS> <ID> <EXTENDS> <ID> <LBRACE> (nt_FieldDecl())*
- (nt_MethodDecl())* <RBRACE>
- }
- public void nt_FieldDecl() :
- {}
- {
- nt_Type() <ID> <SEMICOLON>
- }
- public void nt_MethodDecl() :
- {}
- {
- nt_ProcDecl() | nt_FunDecl()
- }
- public void nt_ProcDecl() :
- {}
- {
- <PROC> <ID> <LPAREN> nt_FormalList() <RPAREN> <LBRACE>
- (nt_Statement())* <RBRACE>
- }
- public void nt_FunDecl() :
- {}
- {
- <FUN> nt_Type() <ID> <LPAREN> nt_FormalList() <RPAREN>
- <LBRACE> (nt_Statement())* <RETURN> nt_Exp() <SEMICOLON>
- <RBRACE>
- }
- public void nt_FormalList() :
- {}
- {
- nt_Type() <ID> (nt_FormalRest())*
- }
- public void nt_FormalRest() :
- {}
- {
- <COMMA> nt_Type() <ID>
- }
- public void nt_Type() :
- {}
- {
- <ARRAYOF> <LPAREN> nt_Type() <RPAREN>
- | <BOOLEAN>
- | <INT>
- | <ID>
- }
- public void nt_Statement() :
- {}
- {
- nt_Block()
- | LOOKAHEAD(2) nt_Type() <ID> <SEMICOLON>
- | LOOKAHEAD(2)nt_Var() <ASSIGN> nt_Exp() <SEMICOLON>
- | LOOKAHEAD(3)nt_PrimaryExp() <LSBRACE> nt_Exp() <RSBRACE>
- <ASSIGN> nt_Exp()<SEMICOLON>
- | <IF> <LPAREN> nt_Exp() <RPAREN> <THEN>
- nt_Block() <ELSE> nt_Block()
- | <WHILE> <LPAREN> nt_Exp() <RPAREN> <DO> nt_Block()
- | <OUTPUT> nt_Exp() <SEMICOLON>
- | LOOKAHEAD(3)nt_PrimaryExp() <DOT> <ID> <LPAREN> nt_ExpList()
- <RPAREN> <SEMICOLON>
- }
- public void nt_Block() :
- {}
- {
- <LBRACE> (nt_Statement())* <RBRACE>
- }
- public void nt_Exp() :
- {}
- {
- LOOKAHEAD(2) nt_PrimaryExp() nt_Op() nt_PrimaryExp()
- | LOOKAHEAD(3) nt_PrimaryExp() <LSBRACE> nt_Exp() <RSBRACE>
- | LOOKAHEAD(3) nt_PrimaryExp() <DOT> <LENGTH>
- | LOOKAHEAD(3) nt_PrimaryExp() <DOT> <ID> <LPAREN> nt_ExpList()
- <RPAREN>
- | LOOKAHEAD(3)nt_PrimaryExp()
- }
- public void nt_PrimaryExp() :
- {}
- {
- <INTEGER_LITERAL>
- | <TRUE>
- | <FALSE>
- | nt_Var()
- | <SELF>
- | LOOKAHEAD(2) <NEW> <ARRAYOF> <LPAREN> nt_Type()
- <RPAREN> <LSBRACE> nt_Exp() <RSBRACE>
- | LOOKAHEAD(2) <NEW> <OBJECT> <ID> <LPAREN> nt_ExpList() <RPAREN>
- | <NOT> nt_PrimaryExp()
- | <ISNULL> nt_PrimaryExp()
- <LPAREN> nt_Exp() <RPAREN>
- }
- public void nt_Var() :
- {}
- {
- <ID>
- }
- public void nt_ExpList() :
- {}
- {
- nt_Exp() (nt_ExpRest())*
- }
- public void nt_ExpRest() :
- {}
- {
- <COMMA> nt_Exp()
- }
- public void nt_Op() :
- {}
- {
- <AND>
- | <LT>
- | <ASSIGN>
- | <DIV>
- | <PLUS>
- | <MINUS>
- | <MULT>
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement