Package org.ek9lang.compiler.phase5
Class PreIRListener
java.lang.Object
org.ek9lang.antlr.EK9BaseListener
org.ek9lang.compiler.common.AbstractEK9PhaseListener
org.ek9lang.compiler.common.ScopeStackConsistencyListener
org.ek9lang.compiler.phase5.PreIRListener
- All Implemented Interfaces:
org.antlr.v4.runtime.tree.ParseTreeListener
,EK9Listener
Designed to do additional logic checks once everything has been resolved.
Initially focused on ensuring that uninitialised variables are initialised before being used.
But may extend to other forms of checks. For example booleans set to literals and never altered and used in an 'if'.
This is designed to try and catch as much as possible before creating an Intermediate Representation and doing
further checks.
-
Field Summary
Fields inherited from class org.ek9lang.compiler.common.AbstractEK9PhaseListener
symbolsAndScopes
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Enter a parse tree produced byEK9Parser.assignmentStatement()
.void
On entry of a dynamic function need to record any return symbol, because we won't parse the text as it is inferred.void
Enter a parse tree produced byEK9Parser.guardExpression()
.void
Enter a parse tree produced byEK9Parser.identifier()
.void
Enter a parse tree produced byEK9Parser.variableOnlyDeclaration()
.void
Exit a parse tree produced byEK9Parser.dynamicFunctionDeclaration()
.void
Exit a parse tree produced byEK9Parser.forStatementExpression()
.void
Exit a parse tree produced byEK9Parser.functionDeclaration()
.void
Exit a parse tree produced byEK9Parser.identifierReference()
.void
Exit a parse tree produced byEK9Parser.ifStatement()
.void
Exit a parse tree produced byEK9Parser.methodDeclaration()
.void
Exit a parse tree produced byEK9Parser.operatorDeclaration()
.void
Exit a parse tree produced byEK9Parser.serviceOperationDeclaration()
.void
Exit a parse tree produced byEK9Parser.switchStatementExpression()
.void
Exit a parse tree produced byEK9Parser.tryStatementExpression()
.void
Exit a parse tree produced byEK9Parser.whileStatementExpression()
.Methods inherited from class org.ek9lang.compiler.common.ScopeStackConsistencyListener
enterApplicationDeclaration, enterBlock, enterCatchStatementExpression, enterClassDeclaration, enterComponentDeclaration, enterDynamicClassDeclaration, enterDynamicVariableCapture, enterFinallyStatementExpression, enterForStatementExpression, enterFunctionDeclaration, enterIfStatement, enterInstructionBlock, enterMethodDeclaration, enterOperatorDeclaration, enterPackageBlock, enterRecordDeclaration, enterReturningParam, enterServiceDeclaration, enterServiceOperationDeclaration, enterSingleStatementBlock, enterSwitchStatementExpression, enterTextBodyDeclaration, enterTextDeclaration, enterTraitDeclaration, enterTryStatementExpression, enterTypeDeclaration, enterWhileStatementExpression
Methods inherited from class org.ek9lang.compiler.common.AbstractEK9PhaseListener
exitApplicationDeclaration, exitBlock, exitCatchStatementExpression, exitClassDeclaration, exitComponentDeclaration, exitDynamicClassDeclaration, exitDynamicVariableCapture, exitFinallyStatementExpression, exitInstructionBlock, exitModuleDeclaration, exitPackageBlock, exitRecordDeclaration, exitReturningParam, exitServiceDeclaration, exitSingleStatementBlock, exitTextBodyDeclaration, exitTextDeclaration, exitTraitDeclaration, exitTypeDeclaration, getErrorListener, getParsedModule, isScopeStackEmpty, pullBlockTerminationUp, pullIfElseTerminationUp, pullSwitchCaseDefaultUp, pullTryCatchFinallyUp
Methods inherited from class org.ek9lang.antlr.EK9BaseListener
enterAccessModifier, enterAggregateParts, enterAggregateProperty, enterAllowingOnly, enterApplicationBlock, enterArgumentParam, enterAspectDeclaration, enterAssertStatement, enterAssignmentExpression, enterBinaryLit, enterBinaryLiteral, enterBlockStatement, enterBooleanLit, enterBooleanLiteral, enterCall, enterCaseExpression, enterCaseStatement, enterCharacterLit, enterCharacterLiteral, enterClassBlock, enterColourLit, enterColourLiteral, enterCompilationUnit, enterComponentBlock, enterConstantBlock, enterConstantDeclaration, enterConstantInitialiser, enterConstrainDeclaration, enterConstrainType, enterDateLit, enterDateLiteral, enterDateTimeLit, enterDateTimeLiteral, enterDeclareArgumentParam, enterDecorationDimensionLiteral, enterDecorationResolutionLiteral, enterDefaultOperator, enterDict, enterDimensionLit, enterDirective, enterDirectivePart, enterDottedName, enterDurationLit, enterDurationLiteral, enterDynamicFunctionBody, enterElseOnlyBlock, enterEnumerationDeclaration, enterEveryRule, enterExpression, enterExpressionParam, enterExtendDeclaration, enterExtendPreamble, enterFloatingPointLit, enterFloatingPointLiteral, enterForLoop, enterForRange, enterFunctionBlock, enterHttpAccess, enterHttpVerb, enterIdentifierReference, enterIfControlBlock, enterInitValuePair, enterIntegerLit, enterIntegerLiteral, enterList, enterMillisecondLit, enterMillisecondLiteral, enterModuleBlock, enterModuleDeclaration, enterMoneyLit, enterMoneyLiteral, enterObjectAccess, enterObjectAccessExpression, enterObjectAccessStart, enterObjectAccessType, enterOperationCall, enterOperationDetails, enterOperator, enterParameterisedArgs, enterParameterisedDetail, enterParameterisedParams, enterParameterisedType, enterParamExpression, enterPathLit, enterPathLiteral, enterPipelinePart, enterPreFlowAndControl, enterPreFlowStatement, enterPrimary, enterPrimaryReference, enterProgramBlock, enterRange, enterRecordBlock, enterReferencesBlock, enterRegExLit, enterRegisterStatement, enterRegularExpressionLiteral, enterResolutionLit, enterServiceBlock, enterSheBang, enterStatement, enterStreamCat, enterStreamExpression, enterStreamExpressionTermination, enterStreamFor, enterStreamPart, enterStreamSource, enterStreamStatement, enterStreamStatementTermination, enterStringLit, enterStringLiteral, enterStringPart, enterTextBlock, enterThrowStatement, enterTimeLit, enterTimeLiteral, enterTraitBlock, enterTraitPreamble, enterTraitReference, enterTraitsList, enterTypeBlock, enterTypeDef, enterVariableDeclaration, enterVersionNumberLit, enterVersionNumberLiteral, enterWebVariableCorrelation, exitAccessModifier, exitAggregateParts, exitAggregateProperty, exitAllowingOnly, exitApplicationBlock, exitArgumentParam, exitAspectDeclaration, exitAssertStatement, exitAssignmentExpression, exitAssignmentStatement, exitBinaryLit, exitBinaryLiteral, exitBlockStatement, exitBooleanLit, exitBooleanLiteral, exitCall, exitCaseExpression, exitCaseStatement, exitCharacterLit, exitCharacterLiteral, exitClassBlock, exitColourLit, exitColourLiteral, exitCompilationUnit, exitComponentBlock, exitConstantBlock, exitConstantDeclaration, exitConstantInitialiser, exitConstrainDeclaration, exitConstrainType, exitDateLit, exitDateLiteral, exitDateTimeLit, exitDateTimeLiteral, exitDeclareArgumentParam, exitDecorationDimensionLiteral, exitDecorationResolutionLiteral, exitDefaultOperator, exitDict, exitDimensionLit, exitDirective, exitDirectivePart, exitDottedName, exitDurationLit, exitDurationLiteral, exitDynamicFunctionBody, exitElseOnlyBlock, exitEnumerationDeclaration, exitEveryRule, exitExpression, exitExpressionParam, exitExtendDeclaration, exitExtendPreamble, exitFloatingPointLit, exitFloatingPointLiteral, exitForLoop, exitForRange, exitFunctionBlock, exitGuardExpression, exitHttpAccess, exitHttpVerb, exitIdentifier, exitIfControlBlock, exitInitValuePair, exitIntegerLit, exitIntegerLiteral, exitList, exitMillisecondLit, exitMillisecondLiteral, exitModuleBlock, exitMoneyLit, exitMoneyLiteral, exitObjectAccess, exitObjectAccessExpression, exitObjectAccessStart, exitObjectAccessType, exitOperationCall, exitOperationDetails, exitOperator, exitParameterisedArgs, exitParameterisedDetail, exitParameterisedParams, exitParameterisedType, exitParamExpression, exitPathLit, exitPathLiteral, exitPipelinePart, exitPreFlowAndControl, exitPreFlowStatement, exitPrimary, exitPrimaryReference, exitProgramBlock, exitRange, exitRecordBlock, exitReferencesBlock, exitRegExLit, exitRegisterStatement, exitRegularExpressionLiteral, exitResolutionLit, exitServiceBlock, exitSheBang, exitStatement, exitStreamCat, exitStreamExpression, exitStreamExpressionTermination, exitStreamFor, exitStreamPart, exitStreamSource, exitStreamStatement, exitStreamStatementTermination, exitStringLit, exitStringLiteral, exitStringPart, exitTextBlock, exitThrowStatement, exitTimeLit, exitTimeLiteral, exitTraitBlock, exitTraitPreamble, exitTraitReference, exitTraitsList, exitTypeBlock, exitTypeDef, exitVariableDeclaration, exitVariableOnlyDeclaration, exitVersionNumberLit, exitVersionNumberLiteral, exitWebVariableCorrelation, visitErrorNode, visitTerminal
-
Constructor Details
-
PreIRListener
PreIRListener(ParsedModule parsedModule)
-
-
Method Details
-
enterVariableOnlyDeclaration
Description copied from class:EK9BaseListener
Enter a parse tree produced byEK9Parser.variableOnlyDeclaration()
.The default implementation does nothing.
- Specified by:
enterVariableOnlyDeclaration
in interfaceEK9Listener
- Overrides:
enterVariableOnlyDeclaration
in classEK9BaseListener
- Parameters:
ctx
- the parse tree
-
enterAssignmentStatement
Description copied from class:EK9BaseListener
Enter a parse tree produced byEK9Parser.assignmentStatement()
.The default implementation does nothing.
- Specified by:
enterAssignmentStatement
in interfaceEK9Listener
- Overrides:
enterAssignmentStatement
in classEK9BaseListener
- Parameters:
ctx
- the parse tree
-
enterGuardExpression
Description copied from class:EK9BaseListener
Enter a parse tree produced byEK9Parser.guardExpression()
.The default implementation does nothing.
- Specified by:
enterGuardExpression
in interfaceEK9Listener
- Overrides:
enterGuardExpression
in classEK9BaseListener
- Parameters:
ctx
- the parse tree
-
enterIdentifier
Description copied from class:EK9BaseListener
Enter a parse tree produced byEK9Parser.identifier()
.The default implementation does nothing.
- Specified by:
enterIdentifier
in interfaceEK9Listener
- Overrides:
enterIdentifier
in classEK9BaseListener
- Parameters:
ctx
- the parse tree
-
exitIdentifierReference
Description copied from class:EK9BaseListener
Exit a parse tree produced byEK9Parser.identifierReference()
.The default implementation does nothing.
- Specified by:
exitIdentifierReference
in interfaceEK9Listener
- Overrides:
exitIdentifierReference
in classEK9BaseListener
- Parameters:
ctx
- the parse tree
-
exitIfStatement
Description copied from class:EK9BaseListener
Exit a parse tree produced byEK9Parser.ifStatement()
.The default implementation does nothing.
- Specified by:
exitIfStatement
in interfaceEK9Listener
- Overrides:
exitIfStatement
in classAbstractEK9PhaseListener
- Parameters:
ctx
- the parse tree
-
exitSwitchStatementExpression
Description copied from class:EK9BaseListener
Exit a parse tree produced byEK9Parser.switchStatementExpression()
.The default implementation does nothing.
- Specified by:
exitSwitchStatementExpression
in interfaceEK9Listener
- Overrides:
exitSwitchStatementExpression
in classAbstractEK9PhaseListener
- Parameters:
ctx
- the parse tree
-
exitTryStatementExpression
Description copied from class:EK9BaseListener
Exit a parse tree produced byEK9Parser.tryStatementExpression()
.The default implementation does nothing.
- Specified by:
exitTryStatementExpression
in interfaceEK9Listener
- Overrides:
exitTryStatementExpression
in classAbstractEK9PhaseListener
- Parameters:
ctx
- the parse tree
-
exitForStatementExpression
Description copied from class:EK9BaseListener
Exit a parse tree produced byEK9Parser.forStatementExpression()
.The default implementation does nothing.
- Specified by:
exitForStatementExpression
in interfaceEK9Listener
- Overrides:
exitForStatementExpression
in classAbstractEK9PhaseListener
- Parameters:
ctx
- the parse tree
-
exitWhileStatementExpression
Description copied from class:EK9BaseListener
Exit a parse tree produced byEK9Parser.whileStatementExpression()
.The default implementation does nothing.
- Specified by:
exitWhileStatementExpression
in interfaceEK9Listener
- Overrides:
exitWhileStatementExpression
in classAbstractEK9PhaseListener
- Parameters:
ctx
- the parse tree
-
enterDynamicFunctionDeclaration
On entry of a dynamic function need to record any return symbol, because we won't parse the text as it is inferred. The on exit handler still needs to do the same return processing to see if the rtn has been initialised. But again cannot depend on source structure because the return is inferred and also the error has to appear on the dynamic function declaration because there will be not '<-' to report the error on. Downside of having dynamic function infer arguments and returns, but worth it for the terseness.- Specified by:
enterDynamicFunctionDeclaration
in interfaceEK9Listener
- Overrides:
enterDynamicFunctionDeclaration
in classScopeStackConsistencyListener
- Parameters:
ctx
- the parse tree
-
exitDynamicFunctionDeclaration
Description copied from class:EK9BaseListener
Exit a parse tree produced byEK9Parser.dynamicFunctionDeclaration()
.The default implementation does nothing.
- Specified by:
exitDynamicFunctionDeclaration
in interfaceEK9Listener
- Overrides:
exitDynamicFunctionDeclaration
in classAbstractEK9PhaseListener
- Parameters:
ctx
- the parse tree
-
exitFunctionDeclaration
Description copied from class:EK9BaseListener
Exit a parse tree produced byEK9Parser.functionDeclaration()
.The default implementation does nothing.
- Specified by:
exitFunctionDeclaration
in interfaceEK9Listener
- Overrides:
exitFunctionDeclaration
in classAbstractEK9PhaseListener
- Parameters:
ctx
- the parse tree
-
exitMethodDeclaration
Description copied from class:EK9BaseListener
Exit a parse tree produced byEK9Parser.methodDeclaration()
.The default implementation does nothing.
- Specified by:
exitMethodDeclaration
in interfaceEK9Listener
- Overrides:
exitMethodDeclaration
in classAbstractEK9PhaseListener
- Parameters:
ctx
- the parse tree
-
exitOperatorDeclaration
Description copied from class:EK9BaseListener
Exit a parse tree produced byEK9Parser.operatorDeclaration()
.The default implementation does nothing.
- Specified by:
exitOperatorDeclaration
in interfaceEK9Listener
- Overrides:
exitOperatorDeclaration
in classAbstractEK9PhaseListener
- Parameters:
ctx
- the parse tree
-
exitServiceOperationDeclaration
Description copied from class:EK9BaseListener
Exit a parse tree produced byEK9Parser.serviceOperationDeclaration()
.The default implementation does nothing.
- Specified by:
exitServiceOperationDeclaration
in interfaceEK9Listener
- Overrides:
exitServiceOperationDeclaration
in classAbstractEK9PhaseListener
- Parameters:
ctx
- the parse tree
-