Skip to content
esonetec edited this page Nov 14, 2014 · 19 revisions

Abstract Syntax

Program -> epislon | ( class IDENT { ClassMember' } Program ) *

Program :: ClassDeclaration+

  • ClassMember' -> public ClassMember''
  • ClassMember'' -> MainMethod' | Member
  • MainMethod' -> static void IDENT ( String [ ] IDENT ) Block
  • Member -> Type IDENT Member'
  • Member' -> ; | ( Parameters? ) Block
  • Parameters -> Parameter (, Parameters)?
  • Parameter -> Type IDENT
  • Type -> Basictype ([])*
  • BasicType -> int | boolean | void | IDENT
  • Statement -> Block | EmptyStatement | IfStatement | ExpressionStatement | WhileStatement | ReturnStatement
  • Block -> { BlockStatement* }
  • BlockStatement -> Block | EmptyStatement | IfStatement | ExpressionStatement | WhileStatement | ReturnStatement | LocalVariableDeclarationStatement <-- SLL(3)
  • LocalVariableDeclarationStatement -> Type IDENT (= Expression)? ;
  • EmptyStatement -> ;
  • WhileStatement-> while ( Expression ) Statement
  • IfStatement -> if ( Expression ) Statement (else Statement)?
  • ExpressionStatement -> Expression ;
  • ReturnStatement -> return Expression? ;

UnaryExpressions and following

UnaryExpression = LogicalNotExpression | NegateExpression | PostfixExpression

LogicalNotExpression :: Expression

NegateExpression :: Expression

PostfixExpression = PrimaryExpression | ArrayAccessExpression | MethodInvovationExpression | VariableAccessExpression

ArrayAccessExpression :: Expression Expression

MethodInvovationExpression :: Expression Symbol (Expression)*

VariableAccessExpression :: Expression Symbol

Symbol :: Symbol

PrimaryExpression = BooleanConstantExpression | IntegerConstantExpression | NullExpression | ThisExpression | NewArrayExpression | NewObjectExpression

BooleanConstantExpression :: value

IntegerConstantExpression :: value

NullExpression ::

ThisExpression ::

NewArrayExpression :: Type Expression

NewObjectExpression :: Symbol

Clone this wiki locally