Grammar almost complete!
This commit is contained in:
@@ -187,7 +187,7 @@ BooleanLiteral: 'true' | 'false' ;
|
|||||||
NullLiteral: 'null';
|
NullLiteral: 'null';
|
||||||
|
|
||||||
//SEPRATORS -------------------------------------------------------------------------------------------------------------------------
|
//SEPRATORS -------------------------------------------------------------------------------------------------------------------------
|
||||||
ParanthesesLeft: '(';
|
ParenthesesLeft: '(';
|
||||||
ParanthesesRight: ')';
|
ParanthesesRight: ')';
|
||||||
CurlyBracketLeft: '{';
|
CurlyBracketLeft: '{';
|
||||||
CurlyBracketRight: '}';
|
CurlyBracketRight: '}';
|
||||||
|
|||||||
105
ExprSyntactic.g4
105
ExprSyntactic.g4
@@ -79,10 +79,10 @@ primary: (expression)
|
|||||||
| basicType bracketsOpt Dot Class
|
| basicType bracketsOpt Dot Class
|
||||||
| Void Dot Class;
|
| Void Dot Class;
|
||||||
|
|
||||||
identifierSuffix: SquareBracketLeft(SquareBracketRight bracketsOpt Dot Class Division expression SquareBracketRight)
|
identifierSuffix: SquareBracketLeft SquareBracketRight bracketsOpt Dot Class //Case []...'.'class
|
||||||
| arguments
|
|SquareBracketLeft expression SquareBracketRight //arr[5]
|
||||||
|Dot ParanthesesLeft Class Divisor This Divisor Super arguments Divisor New innerCreator ParanthesesRight;
|
|arguments
|
||||||
// confused about this need to ask prof
|
|Dot (Class | This | Super arguments New innerCreator);
|
||||||
|
|
||||||
prefixOp: Increment
|
prefixOp: Increment
|
||||||
| Decrement
|
| Decrement
|
||||||
@@ -93,14 +93,14 @@ prefixOp: Increment
|
|||||||
|
|
||||||
postfixOp: Increment | Decrement;
|
postfixOp: Increment | Decrement;
|
||||||
|
|
||||||
selector: '.' identifier [arguments]
|
selector: Dot identifier (arguments)?
|
||||||
| '.' This
|
| Dot This
|
||||||
| '.' Super superSuffix
|
| Dot Super superSuffix
|
||||||
| '.' New innerCreator
|
| Dot New innerCreator
|
||||||
| [expression];
|
| SquareBracketLeft expression SquareBracketRight;
|
||||||
|
|
||||||
superSuffix: arguments
|
superSuffix: arguments
|
||||||
| '.' identifier [arguments];
|
| Dot identifier (arguments)?;
|
||||||
|
|
||||||
basicType: Byte
|
basicType: Byte
|
||||||
| Short
|
| Short
|
||||||
@@ -110,15 +110,92 @@ basicType: Byte
|
|||||||
| Float
|
| Float
|
||||||
| Double
|
| Double
|
||||||
| Boolean;
|
| Boolean;
|
||||||
|
//TODO: REVIEW ANYTHING BEFORE THIS POINT FOR POTENTIAL CONFUSSION ON TERMINAL SYMBOLS AND GRAMMAR
|
||||||
argumentsOpt: (arguments)?;
|
argumentsOpt: (arguments)?;
|
||||||
|
|
||||||
arguments: '(' (expression (',' expression)*)? ')';
|
arguments: ParenthesesLeft (expression (',' expression)*)? ParenthesesRight;
|
||||||
|
|
||||||
bracketsOpt: ('[' ']')*; //ask prof.
|
bracketsOpt: (SquareBracketLeft SquareBracketRight)*;
|
||||||
|
|
||||||
creator: qualifiedIdentifier ( arrayCreatorRest | classCreatorRest);
|
creator: qualifiedIdentifier ( arrayCreatorRest | classCreatorRest);
|
||||||
|
|
||||||
innerCreator: identifier classCreatorRest;
|
innerCreator: identifier classCreatorRest;
|
||||||
|
|
||||||
arrayCreatorRest: '[' ( ']' bracketsOpt arrayInitializer | expression ']' {[expression]};
|
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
|
||||||
|
|(identifier Colon)?;
|
||||||
|
|
||||||
|
localVariableDeclarationStatement: (Final)? type variableDeclarators;
|
||||||
|
|
||||||
|
statement: block
|
||||||
|
| If parExpression statement (Else statement)?
|
||||||
|
| For ParenthesesLeft forInitOp Semicolon (expression)? Semicolon forUpdateOpt ParenthesesRight statement
|
||||||
|
| While parExpression statement
|
||||||
|
| Do statement While parExpression Semicolon
|
||||||
|
| Try block (catches | (catches)? Finally block)
|
||||||
|
| Switch parExpression CurlyBracketLeft switchBlockStatementsGroups? CurlyBracketRight
|
||||||
|
| Synchronized parExpression block
|
||||||
|
| Return (expression)? Semicolon
|
||||||
|
| Throw expression Semicolon
|
||||||
|
| Break (identifier)? Semicolon
|
||||||
|
| Continue (identifier)? Semicolon
|
||||||
|
| Semicolon
|
||||||
|
| expressionStatement
|
||||||
|
| identifier Colon statement;
|
||||||
|
|
||||||
|
catches: catchClause (catchClause)*;
|
||||||
|
|
||||||
|
catchClause: Catch ParenthesesLeft formalParameter ParanthesesRight block;
|
||||||
|
|
||||||
|
switchBlockStatementGroups: (switchBlockStatementGroups)*;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
variableDeclarators: variableDeclarators (Comma variableDeclarator)*;
|
||||||
|
|
||||||
|
variableDeclaratorsRest: variableDeclaratorsRest (Comma variableDeclarator)*;
|
||||||
|
|
||||||
|
constantDeclaratorRest: constantDeclaratorRest (Comma constantDeclarator)*;
|
||||||
|
|
||||||
|
variableDeclarator: identifier variableDeclaratorsRest;
|
||||||
|
|
||||||
|
constantDeclarator: identifier constantDeclaratorRest;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user