2025-09-25 21:49:56 -06:00
|
|
|
parser grammar ExprSyntactic;
|
|
|
|
|
|
|
|
|
|
options {
|
|
|
|
|
tokenVocab=ExprLexer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
identifier: IDENTIFIER;
|
|
|
|
|
|
2025-09-26 19:21:46 -06:00
|
|
|
qualifiedIdentifier: identifier (Dot identifier)*;
|
2025-09-25 21:49:56 -06:00
|
|
|
|
|
|
|
|
literal: IntegerLiteral
|
|
|
|
|
| FloatingPointLiteral
|
|
|
|
|
| CharacterLiteral
|
|
|
|
|
| StringLiteral
|
|
|
|
|
| BooleanLiteral
|
|
|
|
|
| NullLiteral;
|
|
|
|
|
|
2025-09-27 15:52:36 -06:00
|
|
|
//expression: assignmentExpression;//expression1 (assignmentOperator expression1)?;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//testy test
|
|
|
|
|
// Top
|
|
|
|
|
expression
|
|
|
|
|
: assignmentExpression
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
// Assignment is right-assoc and restricts LHS
|
|
|
|
|
assignmentExpression
|
|
|
|
|
: leftHandSide assignmentOperator assignmentExpression
|
|
|
|
|
| conditionalExpression
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
// ?: binds looser than ||
|
|
|
|
|
conditionalExpression
|
|
|
|
|
: conditionalOrExpression
|
|
|
|
|
(Question expression Colon conditionalExpression)?
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
// || (left-assoc)
|
|
|
|
|
conditionalOrExpression
|
|
|
|
|
: conditionalAndExpression
|
|
|
|
|
(ConditionalOR conditionalAndExpression)*
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
// && (left-assoc)
|
|
|
|
|
conditionalAndExpression
|
|
|
|
|
: inclusiveOrExpression
|
|
|
|
|
(ConditionalAND inclusiveOrExpression)*
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
// | ^ & (left-assoc, each tier)
|
|
|
|
|
inclusiveOrExpression
|
|
|
|
|
: exclusiveOrExpression
|
|
|
|
|
(BitwiseOR exclusiveOrExpression)*
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
exclusiveOrExpression
|
|
|
|
|
: andExpression
|
|
|
|
|
(BitwiseXOR andExpression)*
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
andExpression
|
|
|
|
|
: equalityExpression
|
|
|
|
|
(BitwiseAND equalityExpression)*
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
// == !=
|
|
|
|
|
equalityExpression
|
|
|
|
|
: relationalExpression
|
|
|
|
|
((EqualTo | NotEqualTo) relationalExpression)*
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
// < > <= >= and instanceof
|
|
|
|
|
relationalExpression
|
|
|
|
|
: shiftExpression
|
|
|
|
|
((LessThan | GreaterThan | LessThanEqualTo | GreaterThanEqualTo) shiftExpression)*
|
|
|
|
|
| shiftExpression InstanceOf type
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
// << >> >>>
|
|
|
|
|
shiftExpression
|
|
|
|
|
: additiveExpression
|
|
|
|
|
((LeftShift | SignedRightShift | UnsignedRightShift) additiveExpression)*
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
// + -
|
|
|
|
|
additiveExpression
|
|
|
|
|
: multiplicativeExpression
|
|
|
|
|
((Addition | Subtraction) multiplicativeExpression)*
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
// * / %
|
|
|
|
|
multiplicativeExpression
|
|
|
|
|
: unaryExpression
|
|
|
|
|
((Multiplication | Division | Remainder) unaryExpression)*
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
// ++x --x +x -x and the rest
|
|
|
|
|
unaryExpression
|
|
|
|
|
: (Increment | Decrement) unaryExpression
|
|
|
|
|
| (Addition | Subtraction) unaryExpression
|
|
|
|
|
| unaryExpressionNotPlusMinus
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
unaryExpressionNotPlusMinus
|
|
|
|
|
: (BitwiseComplement | LogicalComplement) unaryExpression
|
|
|
|
|
| castExpression
|
|
|
|
|
| postfixExpression
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
// (T)expr
|
|
|
|
|
castExpression
|
|
|
|
|
: ParenthesesLeft primitiveType ParanthesesRight unaryExpression
|
|
|
|
|
| ParenthesesLeft referenceType ParanthesesRight unaryExpressionNotPlusMinus
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
// post-inc/dec over your suffix-based primary
|
|
|
|
|
postfixExpression
|
|
|
|
|
: primary (Increment | Decrement)*
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
//end test
|
2025-09-25 21:49:56 -06:00
|
|
|
assignmentOperator: Assignment
|
|
|
|
|
| AddAssign
|
|
|
|
|
| SubtractAssign
|
|
|
|
|
| MultiplyAssign
|
|
|
|
|
| DivideAssign
|
|
|
|
|
| BitwiseANDAssign
|
|
|
|
|
| BitwiseORAssign
|
|
|
|
|
| BitwiseXORAssign
|
|
|
|
|
| RemainderAssign
|
|
|
|
|
| LeftShiftAssign
|
2025-09-27 14:11:33 -06:00
|
|
|
| SignedRightShiftAssign
|
|
|
|
|
| UnsignedRightShiftAssign;
|
2025-09-25 21:49:56 -06:00
|
|
|
|
2025-09-26 19:21:46 -06:00
|
|
|
type: identifier (Dot identifier)* bracketsOpt
|
2025-09-25 21:49:56 -06:00
|
|
|
| basicType;
|
|
|
|
|
|
|
|
|
|
statementExpression: expression;
|
|
|
|
|
|
|
|
|
|
constantExpression: expression;
|
|
|
|
|
|
2025-09-27 15:52:36 -06:00
|
|
|
//expression1: expression2 (expression1Rest)?;
|
|
|
|
|
//
|
|
|
|
|
//expression1Rest: Question expression Colon expression1;
|
|
|
|
|
//
|
|
|
|
|
//expression2: expression3 expression2Rest?;
|
|
|
|
|
//
|
|
|
|
|
//expression2Rest: (infixop expression3)+
|
|
|
|
|
// | InstanceOf type;
|
|
|
|
|
//
|
|
|
|
|
//infixop: ConditionalOR
|
|
|
|
|
// | ConditionalAND
|
|
|
|
|
// | BitwiseOR
|
|
|
|
|
// | BitwiseXOR
|
|
|
|
|
// | BitwiseAND
|
|
|
|
|
// | EqualTo
|
|
|
|
|
// | NotEqualTo
|
|
|
|
|
// | LessThan
|
|
|
|
|
// | GreaterThan
|
|
|
|
|
// | LessThanEqualTo
|
|
|
|
|
// | GreaterThanEqualTo
|
|
|
|
|
// | LeftShift
|
|
|
|
|
// | SignedRightShift
|
|
|
|
|
// | UnsignedRightShift
|
|
|
|
|
// | Addition
|
|
|
|
|
// | Subtraction
|
|
|
|
|
// | Multiplication
|
|
|
|
|
// | Division
|
|
|
|
|
// | Remainder;
|
|
|
|
|
//
|
|
|
|
|
//expression3: prefixOp expression3 // Recursion
|
|
|
|
|
// | ParenthesesLeft type ParenthesesRight expression3
|
|
|
|
|
// | primary (selector)* (postfixOp)*;
|
|
|
|
|
|
|
|
|
|
//primary: (expression)
|
|
|
|
|
// | This (arguments)?
|
|
|
|
|
// | Super superSuffix
|
|
|
|
|
// | literal
|
|
|
|
|
// | New creator
|
|
|
|
|
// | identifier (Dot identifier)* (identifierSuffix)?
|
|
|
|
|
// | basicType bracketsOpt Dot Class
|
|
|
|
|
// | Void Dot Class;
|
|
|
|
|
|
|
|
|
|
//TEST
|
|
|
|
|
primary: primaryAtom primarySuffix*
|
|
|
|
|
| New creator ;
|
|
|
|
|
|
|
|
|
|
primaryAtom: ParenthesesLeft expression ParenthesesRight
|
|
|
|
|
| This
|
|
|
|
|
| literal
|
|
|
|
|
| qualifiedIdentifier
|
|
|
|
|
| qualifiedIdentifier Dot This
|
|
|
|
|
| basicType bracketsOpt Dot Class
|
|
|
|
|
| Void Dot Class
|
|
|
|
|
| Super;
|
|
|
|
|
|
|
|
|
|
// All selectors / postfix pieces (no recursion back to primary)
|
|
|
|
|
primarySuffix: Dot Identifier arguments?
|
|
|
|
|
| SquareBracketLeft expression SquareBracketRight
|
|
|
|
|
| Dot Class;
|
|
|
|
|
////END test
|
2025-09-27 13:28:28 -06:00
|
|
|
|
2025-09-26 23:52:51 -06:00
|
|
|
identifierSuffix: SquareBracketLeft SquareBracketRight bracketsOpt Dot Class //Case []...'.'class
|
|
|
|
|
|SquareBracketLeft expression SquareBracketRight //arr[5]
|
|
|
|
|
|arguments
|
|
|
|
|
|Dot (Class | This | Super arguments New innerCreator);
|
2025-09-25 23:06:20 -06:00
|
|
|
|
|
|
|
|
prefixOp: Increment
|
|
|
|
|
| Decrement
|
|
|
|
|
| LogicalComplement
|
2025-09-27 15:52:36 -06:00
|
|
|
| BitWiseComplement
|
2025-09-25 23:06:20 -06:00
|
|
|
| Addition
|
|
|
|
|
| Subtraction;
|
|
|
|
|
|
|
|
|
|
postfixOp: Increment | Decrement;
|
|
|
|
|
|
2025-09-26 23:52:51 -06:00
|
|
|
selector: Dot identifier (arguments)?
|
|
|
|
|
| Dot This
|
|
|
|
|
| Dot Super superSuffix
|
|
|
|
|
| Dot New innerCreator
|
|
|
|
|
| SquareBracketLeft expression SquareBracketRight;
|
2025-09-25 23:06:20 -06:00
|
|
|
|
|
|
|
|
superSuffix: arguments
|
2025-09-26 23:52:51 -06:00
|
|
|
| Dot identifier (arguments)?;
|
2025-09-27 13:28:28 -06:00
|
|
|
//primitives
|
2025-09-25 23:06:20 -06:00
|
|
|
basicType: Byte
|
|
|
|
|
| Short
|
|
|
|
|
| Char
|
|
|
|
|
| Int
|
|
|
|
|
| Long
|
|
|
|
|
| Float
|
|
|
|
|
| Double
|
|
|
|
|
| Boolean;
|
2025-09-27 15:52:36 -06:00
|
|
|
//TODO: REVIEW ANYTHING BEFORE THIS POINT FOR POTENTIAL CONFUSSION ON TERMINAL SYMBOLS AND GRAMMAR
|
2025-09-26 19:21:46 -06:00
|
|
|
argumentsOpt: (arguments)?;
|
2025-09-25 23:06:20 -06:00
|
|
|
|
2025-09-27 13:28:28 -06:00
|
|
|
arguments: ParenthesesLeft (expression (Comma expression)*)? ParenthesesRight;
|
2025-09-25 23:06:20 -06:00
|
|
|
|
2025-09-26 23:52:51 -06:00
|
|
|
bracketsOpt: (SquareBracketLeft SquareBracketRight)*;
|
2025-09-25 23:06:20 -06:00
|
|
|
|
|
|
|
|
creator: qualifiedIdentifier ( arrayCreatorRest | classCreatorRest);
|
|
|
|
|
|
|
|
|
|
innerCreator: identifier classCreatorRest;
|
|
|
|
|
|
2025-09-26 23:52:51 -06:00
|
|
|
arrayCreatorRest: SquareBracketLeft SquareBracketRight bracketsOpt arrayInitializer
|
|
|
|
|
| SquareBracketLeft expression SquareBracketRight (SquareBracketLeft expression SquareBracketRight)*;
|
|
|
|
|
classCreatorRest: arguments (classBody)?;
|
|
|
|
|
|
|
|
|
|
arrayInitializer: CurlyBracketLeft (variableInitializer(Comma variableInitializer)*(Comma)?)? CurlyBracketRight;
|
|
|
|
|
|
|
|
|
|
variableInitializer: arrayInitializer
|
|
|
|
|
|expression;
|
|
|
|
|
|
|
|
|
|
parExpression: ParenthesesLeft expression ParenthesesRight;
|
|
|
|
|
|
|
|
|
|
block: CurlyBracketLeft blockStatements CurlyBracketRight;
|
|
|
|
|
|
|
|
|
|
blockStatements: (blockStatement)*;
|
|
|
|
|
|
|
|
|
|
blockStatement: localVariableDeclarationStatement
|
|
|
|
|
|classOrInterfaceDeclaration
|
2025-09-27 13:28:28 -06:00
|
|
|
|(identifier Colon)? statement;
|
2025-09-26 23:52:51 -06:00
|
|
|
|
|
|
|
|
localVariableDeclarationStatement: (Final)? type variableDeclarators;
|
|
|
|
|
|
|
|
|
|
statement: block
|
|
|
|
|
| If parExpression statement (Else statement)?
|
2025-09-27 13:28:28 -06:00
|
|
|
| For ParenthesesLeft forInit? Semicolon (expression)? Semicolon forUpdate? ParenthesesRight statement
|
2025-09-26 23:52:51 -06:00
|
|
|
| While parExpression statement
|
|
|
|
|
| Do statement While parExpression Semicolon
|
|
|
|
|
| Try block (catches | (catches)? Finally block)
|
2025-09-27 13:28:28 -06:00
|
|
|
| Switch parExpression CurlyBracketLeft switchBlockStatementGroups? CurlyBracketRight
|
2025-09-26 23:52:51 -06:00
|
|
|
| Synchronized parExpression block
|
|
|
|
|
| Return (expression)? Semicolon
|
|
|
|
|
| Throw expression Semicolon
|
|
|
|
|
| Break (identifier)? Semicolon
|
|
|
|
|
| Continue (identifier)? Semicolon
|
|
|
|
|
| Semicolon
|
2025-09-27 14:11:33 -06:00
|
|
|
//| expressionStatement
|
2025-09-26 23:52:51 -06:00
|
|
|
| identifier Colon statement;
|
|
|
|
|
|
|
|
|
|
catches: catchClause (catchClause)*;
|
|
|
|
|
|
2025-09-27 14:11:33 -06:00
|
|
|
catchClause: Catch ParenthesesLeft formalParameter ParenthesesRight block;
|
2025-09-26 23:52:51 -06:00
|
|
|
|
2025-09-27 13:28:28 -06:00
|
|
|
switchBlockStatementGroups: (switchBlockStatementGroup)*;
|
2025-09-26 23:52:51 -06:00
|
|
|
|
|
|
|
|
switchBlockStatementGroup: switchLabel blockStatements;
|
|
|
|
|
|
|
|
|
|
switchLabel: Case constantExpression Colon
|
|
|
|
|
| Default Colon;
|
|
|
|
|
moreStatementExpressions: (Comma statementExpression)*;
|
|
|
|
|
|
|
|
|
|
forInit: statementExpression moreStatementExpressions
|
|
|
|
|
| (Final)? type variableDeclarators;
|
|
|
|
|
|
|
|
|
|
forUpdate: statementExpression moreStatementExpressions;
|
|
|
|
|
|
|
|
|
|
modifiersOpt: (modifier)*;
|
|
|
|
|
|
|
|
|
|
modifier: Public
|
|
|
|
|
| Protected
|
|
|
|
|
| Private
|
|
|
|
|
| Static
|
|
|
|
|
| Abstract
|
|
|
|
|
| Final
|
|
|
|
|
| Native
|
|
|
|
|
| Synchronized
|
|
|
|
|
| Transient
|
|
|
|
|
| Volatile
|
|
|
|
|
| Strictfp;
|
|
|
|
|
|
2025-09-27 13:28:28 -06:00
|
|
|
variableDeclarators: variableDeclarator (Comma variableDeclarator)*;
|
2025-09-26 23:52:51 -06:00
|
|
|
|
2025-09-27 13:28:28 -06:00
|
|
|
variableDeclaratorsRest: variableDeclaratorRest (Comma variableDeclarator)*;
|
2025-09-26 23:52:51 -06:00
|
|
|
|
2025-09-27 13:28:28 -06:00
|
|
|
constantDeclaratorsRest: constantDeclaratorRest (Comma constantDeclarator)*;
|
2025-09-26 23:52:51 -06:00
|
|
|
|
|
|
|
|
variableDeclarator: identifier variableDeclaratorsRest;
|
|
|
|
|
|
|
|
|
|
constantDeclarator: identifier constantDeclaratorRest;
|
|
|
|
|
|
2025-09-27 13:28:28 -06:00
|
|
|
variableDeclaratorRest: bracketsOpt (Assignment variableInitializer)?;
|
|
|
|
|
|
|
|
|
|
constantDeclaratorRest: bracketsOpt Assignment variableInitializer;
|
|
|
|
|
|
|
|
|
|
variableDeclaratorId: identifier bracketsOpt;
|
|
|
|
|
|
|
|
|
|
compilationUnit: (Package qualifiedIdentifier Semicolon)? (importDeclaration)*;
|
|
|
|
|
|
2025-09-27 14:11:33 -06:00
|
|
|
importDeclaration: Import identifier (Dot identifier)* (Dot Multiplication)? Semicolon;
|
2025-09-27 13:28:28 -06:00
|
|
|
|
|
|
|
|
typeDeclaration: classOrInterfaceDeclaration Semicolon;
|
|
|
|
|
|
|
|
|
|
classOrInterfaceDeclaration: modifiersOpt (classDeclaration | interfaceDeclaration);
|
|
|
|
|
|
|
|
|
|
classDeclaration: Class identifier (Extends type)? (Implements typeList)? classBody;
|
|
|
|
|
|
|
|
|
|
interfaceDeclaration: Interface identifier (Extends typeList)? interfaceBody;
|
|
|
|
|
|
2025-09-27 14:11:33 -06:00
|
|
|
typeList: type (Comma type)*;
|
2025-09-27 13:28:28 -06:00
|
|
|
|
|
|
|
|
classBody: CurlyBracketLeft (classBodyDeclaration)* CurlyBracketRight;
|
|
|
|
|
|
|
|
|
|
interfaceBody: CurlyBracketLeft (interfaceBodyDeclaration)* CurlyBracketRight;
|
|
|
|
|
|
|
|
|
|
classBodyDeclaration: Semicolon
|
|
|
|
|
| (Static)? block
|
|
|
|
|
| modifiersOpt memberDecl;
|
|
|
|
|
memberDecl: methodOrFieldDecl
|
|
|
|
|
| Void identifier methodDeclaratorRest
|
|
|
|
|
| identifier constructorDeclaratorRest
|
|
|
|
|
| classOrInterfaceDeclaration;
|
|
|
|
|
|
|
|
|
|
methodOrFieldDecl: type identifier methodOrFieldRest;
|
|
|
|
|
|
|
|
|
|
methodOrFieldRest: variableDeclaratorRest
|
|
|
|
|
|methodDeclaratorRest;
|
|
|
|
|
|
|
|
|
|
interfaceBodyDeclaration: Semicolon
|
|
|
|
|
| modifiersOpt interfaceMemberDecl;
|
|
|
|
|
|
|
|
|
|
interfaceMemberDecl: interfaceMethodOrFieldDecl
|
|
|
|
|
| Void identifier voidInterfaceMethodDeclaratorRest
|
|
|
|
|
| classOrInterfaceDeclaration;
|
|
|
|
|
|
|
|
|
|
interfaceMethodOrFieldDecl: type identifier interfaceMethodOrFieldRest;
|
|
|
|
|
|
|
|
|
|
interfaceMethodOrFieldRest: constantDeclaratorRest Semicolon
|
|
|
|
|
| interfaceMethodDeclaratorRest;
|
|
|
|
|
|
|
|
|
|
methodDeclaratorRest: formalParameters bracketsOpt (Throws qualifiedIdentifierList)?(methodBody | Semicolon);
|
|
|
|
|
|
|
|
|
|
voidMethodDeclaratorRest: formalParameters (Throws qualifiedIdentifierList)? (methodBody | Semicolon);
|
|
|
|
|
|
|
|
|
|
interfaceMethodDeclaratorRest: formalParameters bracketsOpt (Throws qualifiedIdentifierList)? Semicolon;
|
|
|
|
|
|
|
|
|
|
voidInterfaceMethodDeclaratorRest: formalParameters (Throws qualifiedIdentifierList)?;
|
|
|
|
|
|
|
|
|
|
constructorDeclaratorRest: formalParameters (Throws qualifiedIdentifierList)? methodBody;
|
|
|
|
|
|
|
|
|
|
qualifiedIdentifierList: qualifiedIdentifier (Semicolon qualifiedIdentifier)*;
|
|
|
|
|
|
2025-09-27 14:11:33 -06:00
|
|
|
formalParameters: ParenthesesLeft (formalParameter (Comma formalParameter)*)? ParenthesesRight;
|
2025-09-27 13:28:28 -06:00
|
|
|
|
|
|
|
|
formalParameter: (Final)? type variableDeclaratorId;
|
|
|
|
|
|
|
|
|
|
methodBody: block;
|
|
|
|
|
|
2025-09-27 15:52:36 -06:00
|
|
|
//Things not defined within the final chapter of JSL2
|
|
|
|
|
expressionStatement: statementExpression Semicolon;
|
|
|
|
|
|
|
|
|
|
asssignmentExpression: conditionalExpression
|
|
|
|
|
| assignment;
|
|
|
|
|
assignment: leftHandSide assignmentOperator assignmentExpression;
|
|
|
|
|
|
|
|
|
|
leftHandSide: expressionName
|
|
|
|
|
| fieldAccess
|
|
|
|
|
| primary SquareBracketLeft expression SquareBracketRight(SquareBracketLeft expression SquareBracketRight)*;
|
|
|
|
|
|
|
|
|
|
//conditionalExpression: conditionalOrExpression
|
|
|
|
|
// | conditionalOrExpression Question expression Colon conditionalExpression;
|
|
|
|
|
//
|
|
|
|
|
// conditionalOrExpression:
|
|
|
|
|
// conditionalAndExpression
|
|
|
|
|
// |conditionalOrExpression ConditionalOr conditionalAndExpression;
|
|
|
|
|
// //Conditional And (&&)
|
|
|
|
|
// conditionalAndExpression:
|
|
|
|
|
// inclusiveOrExpression
|
|
|
|
|
// |conditionalAndExpression ConditionalAnd inclusiveOrExpression;
|
|
|
|
|
// inclusiveOrExpression:
|
|
|
|
|
// exclusiveOrExpression
|
|
|
|
|
// inclusiveOrExpression BitwiseOR exclusiveOrExpression;
|
|
|
|
|
////Assignment operators
|
|
|
|
|
//assignmentExpression:conditionalExpression
|
|
|
|
|
// |assignment;
|
|
|
|
|
//
|
|
|
|
|
// relationalExpression:
|
|
|
|
|
// shiftExpression
|
|
|
|
|
// |relationalExpression LessThan shiftExpression
|
|
|
|
|
// |relationalExpression GreaterThan shiftExpression
|
|
|
|
|
// |relationalExpression LessOrEqual shiftExpression
|
|
|
|
|
// |relationalExpression GreaterOrEqual shiftExpression
|
|
|
|
|
// |relationalExpression InstanceOf referenceType;
|
|
|
|
|
|
|
|
|
|
//ShiftExpression:
|
|
|
|
|
//shiftExpression: additiveExpression
|
|
|
|
|
// |shiftExpression LeftShift additiveExpression
|
|
|
|
|
// |shiftExpression SignedRightShift additiveExpression
|
|
|
|
|
// |shiftExpression UnsignedRightShift additiveExpression;
|
|
|
|
|
////Additive Operators
|
|
|
|
|
//additiveExpression: multiplicativeExpression
|
|
|
|
|
// | additiveExpression Addition multiplicativeExpression
|
|
|
|
|
// | additiveExpression Subtraction multiplicativeExpression;
|
|
|
|
|
//
|
|
|
|
|
////Multiplicative Operators
|
|
|
|
|
//multiplicativeExpression: unaryExpression
|
|
|
|
|
// | multiplicativeExpression Multiplication unaryExpression
|
|
|
|
|
// | multiplicativeExpression Division unaryExpression
|
|
|
|
|
// | multiplicativeExpression Remainder unaryExpression;
|
|
|
|
|
////Unary Operators
|
|
|
|
|
//unaryExpression: preIncrementExpression
|
|
|
|
|
// |preDecrementExpression
|
|
|
|
|
// |Addition unaryExpression
|
|
|
|
|
// |Subtraction unaryExpression
|
|
|
|
|
// |unaryExpressionNotPlusMinus;
|
|
|
|
|
|
|
|
|
|
preIncrementExpression: Increment unaryExpression;
|
|
|
|
|
preDecrementExpression: Decrement unaryExpression;
|
|
|
|
|
//unaryExpressionNotPlusMinus: postfixExpression
|
|
|
|
|
// |BitwiseComplement unaryExpression
|
|
|
|
|
// |LogicalComplement unaryExpression
|
|
|
|
|
// | castExpression;
|
|
|
|
|
//castExpression: ParenthesesLeft primitiveType ParanthesesRight unaryExpression
|
|
|
|
|
// | ParenthesesLeft referenceType ParanthesesRight unaryExpressionNotPlusMinus;
|
|
|
|
|
//Primitive types
|
|
|
|
|
primitiveType: numericType
|
|
|
|
|
| Boolean;
|
|
|
|
|
referenceType: classOrInterfaceType
|
|
|
|
|
| arrayType;
|
|
|
|
|
classOrInterfaceType: classType
|
|
|
|
|
| interfaceType;
|
|
|
|
|
classType: typeName;
|
|
|
|
|
interfaceType: typeName;
|
|
|
|
|
//Determining meaning of Name
|
|
|
|
|
typeName: identifier
|
|
|
|
|
| packageOrTypeName Dot Identifier;
|
|
|
|
|
packageOrTypeName: Identifier
|
|
|
|
|
| packageOrTypeName Dot identifier;
|
|
|
|
|
arrayType: type SquareBracketLeft SquareBracketRight;
|
|
|
|
|
numericType: integralType
|
|
|
|
|
| floatingPointType;
|
|
|
|
|
integralType: Byte | Short | Int | Long | Char;
|
|
|
|
|
floatingPointType: Float | Double;
|
|
|
|
|
//postfix expressions
|
|
|
|
|
//postfixExpression: primary
|
|
|
|
|
// | expressionName
|
|
|
|
|
// | postIncrementExpression
|
|
|
|
|
// | postDecrementExpression;
|
|
|
|
|
postfixBase: primary | expressionName ;
|
|
|
|
|
//postfixExpression : postfixBase (Increment | Decrement)* ;
|
|
|
|
|
//postIncrementExpression: postfixExpression Increment;
|
|
|
|
|
//postDecrementExpression: postfixExpression Decrement;
|
|
|
|
|
|
|
|
|
|
// //Equality Operators
|
|
|
|
|
// equalityExpression:
|
|
|
|
|
// relationalExpression
|
|
|
|
|
// |equalityExpression EqualEqual relationalExpression
|
|
|
|
|
// |equalityExpression NotEqualTo relationalExpression;
|
|
|
|
|
|
|
|
|
|
//Bitwise and Logical Operators
|
|
|
|
|
// andExpression:
|
|
|
|
|
// equalityExpression
|
|
|
|
|
// |andExpression BitwiseAND andExpression;
|
|
|
|
|
// exclusiveOrExpression:
|
|
|
|
|
// andExpression
|
|
|
|
|
// |exclusiveOrExpression BitwiseXOR andExpression;
|
|
|
|
|
expressionName: Identifier (Dot Identifier)*;
|
|
|
|
|
fieldAccess
|
|
|
|
|
: primary Dot Identifier
|
|
|
|
|
| Super Dot Identifier
|
|
|
|
|
| typeName Dot Super Dot Identifier
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
classInstanceCreationExpression: New classOrInterfaceType ParenthesesLeft argumentsOpt ParanthesesRight classBody
|
|
|
|
|
| primary New identifier ParenthesesLeft argumentsOpt ParanthesesRight classBody;
|
|
|
|
|
|
|
|
|
|
methodInvocation: methodName arguments
|
|
|
|
|
| primary Dot Identifier arguments
|
|
|
|
|
| Super Dot Identifier arguments
|
|
|
|
|
| typeName Dot Super Dot Identifier arguments;
|
|
|
|
|
methodName
|
|
|
|
|
: Identifier (Dot Identifier)*;
|
|
|
|
|
|
|
|
|
|
//arguments: ParenthesesLeft argumentList? ParanthesesRight;
|
|
|
|
|
|
|
|
|
|
argumentList: expression (Comma expression)*;
|
2025-09-27 13:28:28 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|