Package gw.internal.gosu.parser
Class GosuParser
- java.lang.Object
-
- gw.internal.gosu.parser.ParserBase
-
- gw.internal.gosu.parser.GosuParser
-
- All Implemented Interfaces:
IGosuParser
,IParserPart
public final class GosuParser extends ParserBase implements IGosuParser
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface gw.lang.parser.IGosuParser
IGosuParser.ParseType, IGosuParser.Settings
-
-
Field Summary
Fields Modifier and Type Field Description static ErrorType
notfound
static IType
PENDING_BOUNDING_TYPE
-
Fields inherited from class gw.internal.gosu.parser.ParserBase
_bDontOptimizeStatementLists, _offsetShift
-
Fields inherited from interface gw.lang.parser.IGosuParser
BIGD_ZERO, DOUBLE_DIGITS, NaN, ONE, ZERO
-
-
Method Summary
-
Methods inherited from class gw.internal.gosu.parser.ParserBase
addBlockToBlockStack, captureAllSymbols, captureSymbol, copyBlockStackTo, eatBlock, eatBlock, eatOptionalSemiColon, eatTypeLiteral, findAndWrapLocation, findMathOpMethod, getCurrentEnclosingGosuClass, getCurrentlyInferringFunctionTypeVars, getLineNumShift, getOffsetShift, getOwner, getParsingAnonymousClass, getUncapturedSymbol, getValidator, isDontOptimizeStatementLists, isEvalClass, isParsingBlock, match, match, match, match, match, matchDeclarationKeyword, parseAnnotation, parseDotPathWord, peekInferringFunctionTypeVariableTypes, popInferringFunctionTypeVariableTypes, possiblyWrapWithCoercion, possiblyWrapWithImplicitCoercion, pushCurrentBlock, pushInferringFunctionTypeVars, resolveNamespace, resolveNamespaceSymbol, resolveRuntimeType, resolveSymbol, resolveType, resolveType, resolveTypeForArithmeticExpression, setBlocks, setDontOptimizeStatementLists, setIgnoreWarnings, setLineNumShift, setLocationForImplicitTypeAs, setOffsetShift, setOwner, setSnapshotSymbols, setSubTree, shouldSnapshotSymbols, verifyComparable, verifyComparable, verifyComparable, verifyModifiersForFeature, verifyNonVoidExpression, verifyParsedElement, verifyParsedElement, verifyTypesComparable, verifyTypesComparable
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface gw.lang.parser.IGosuParser
isParsingBlock, setIgnoreWarnings, setSnapshotSymbols
-
Methods inherited from interface gw.lang.parser.IParserPart
getLineNumShift, getOffsetShift, getOwner, isDontOptimizeStatementLists, setDontOptimizeStatementLists, setLineNumShift
-
-
-
-
Method Detail
-
setValidator
public void setValidator(IGosuValidator validator)
- Specified by:
setValidator
in interfaceIParserPart
- Overrides:
setValidator
in classParserBase
-
getScriptPart
public IScriptPartId getScriptPart()
- Specified by:
getScriptPart
in interfaceIGosuParser
-
getScriptPartIdStack
public Stack<IScriptPartId> getScriptPartIdStack()
-
pushScriptPart
public void pushScriptPart(IScriptPartId partId)
-
getInferenceMap
public TypeVarToTypeMap getInferenceMap()
-
pushInferenceMap
public void pushInferenceMap(TypeVarToTypeMap inferenceMap)
-
setScript
public void setScript(CharSequence source)
- Specified by:
setScript
in interfaceIGosuParser
-
setScript
public void setScript(ISource src)
- Specified by:
setScript
in interfaceIGosuParser
-
setScript
public void setScript(SourceCodeReader reader)
- Specified by:
setScript
in interfaceIGosuParser
-
resetScript
public void resetScript()
-
getScript
protected String getScript()
- Specified by:
getScript
in classParserBase
-
getSymbolTable
public ISymbolTable getSymbolTable()
- Specified by:
getSymbolTable
in interfaceIGosuParser
-
setSymbolTable
public void setSymbolTable(ISymbolTable symTable)
- Specified by:
setSymbolTable
in interfaceIGosuParser
-
getTypeUsesMap
public ITypeUsesMap getTypeUsesMap()
- Specified by:
getTypeUsesMap
in interfaceIGosuParser
-
setTypeUsesMap
public void setTypeUsesMap(ITypeUsesMap typeUsesMap)
- Specified by:
setTypeUsesMap
in interfaceIGosuParser
-
getNamespace
public String getNamespace()
-
getVisibilityConstraint
public IScriptabilityModifier getVisibilityConstraint()
-
getTokenizerInstructor
public ITokenizerInstructor getTokenizerInstructor()
- Specified by:
getTokenizerInstructor
in interfaceIGosuParser
-
setTokenizerInstructor
public void setTokenizerInstructor(ITokenizerInstructor tokenizerInstructor)
- Specified by:
setTokenizerInstructor
in interfaceIGosuParser
-
peekParsingFunction
public FunctionType peekParsingFunction()
-
iterateParsingFunctions
public Iterator<FunctionType> iterateParsingFunctions()
-
isParsingFunction
public boolean isParsingFunction()
- Specified by:
isParsingFunction
in interfaceIGosuParser
-
peekParsingFieldInitializer
public VarStatement peekParsingFieldInitializer()
-
isParsingFieldInitializer
public boolean isParsingFieldInitializer()
-
parseStatements
public Statement parseStatements(IScriptPartId partId) throws ParseResultsException
- Specified by:
parseStatements
in interfaceIGosuParser
- Throws:
ParseResultsException
-
parseProgram
public IProgram parseProgram(IScriptPartId partId) throws ParseResultsException
- Specified by:
parseProgram
in interfaceIGosuParser
- Throws:
ParseResultsException
-
parseProgram
public IProgram parseProgram(IScriptPartId partId, IType expectedExpressionType) throws ParseResultsException
- Specified by:
parseProgram
in interfaceIGosuParser
- Throws:
ParseResultsException
-
parseProgram
public IProgram parseProgram(IScriptPartId partId, IType expectedExpressionType, IFileContext ctx, boolean assignRuntime) throws ParseResultsException
- Specified by:
parseProgram
in interfaceIGosuParser
- Throws:
ParseResultsException
-
parseProgram
public IProgram parseProgram(IScriptPartId partId, IType expectedExpressionType, IFileContext ctx, boolean assignRuntime, boolean bDoNotThrowParseResultsException) throws ParseResultsException
- Specified by:
parseProgram
in interfaceIGosuParser
- Throws:
ParseResultsException
-
parseProgram
public IProgram parseProgram(IScriptPartId partId, boolean isolatedScope, IType expectedExpressionType) throws ParseResultsException
- Specified by:
parseProgram
in interfaceIGosuParser
- Throws:
ParseResultsException
-
parseProgram
public IProgram parseProgram(IScriptPartId partId, boolean isolatedScope, boolean reallyIsolatedScope, IType expectedExpressionType, IFileContext ctx, boolean assignRuntime) throws ParseResultsException
- Specified by:
parseProgram
in interfaceIGosuParser
- Throws:
ParseResultsException
-
parseProgram
public IProgram parseProgram(IScriptPartId partId, boolean isolatedScope, boolean reallyIsolatedScope, IType expectedExpressionType, IFileContext ctx, boolean assignRuntime, boolean bDoNotThrowParseResultsException) throws ParseResultsException
- Specified by:
parseProgram
in interfaceIGosuParser
- Throws:
ParseResultsException
-
parseProgram
public IProgram parseProgram(IScriptPartId partId, boolean isolatedScope, boolean reallyIsolatedScope, IType expectedExpressionType, IFileContext ctx, boolean assignRuntime, boolean bDoNotThrowParseResultsException, IType superType) throws ParseResultsException
- Specified by:
parseProgram
in interfaceIGosuParser
- Throws:
ParseResultsException
-
setGenerateRootExpressionAccessForProgram
public void setGenerateRootExpressionAccessForProgram(boolean bGenRootExprAccess)
- Specified by:
setGenerateRootExpressionAccessForProgram
in interfaceIGosuParser
-
isGenerateRootExpressionAccessForProgram
public boolean isGenerateRootExpressionAccessForProgram()
-
parseExp
public Expression parseExp(IScriptPartId partId) throws ParseResultsException
- Specified by:
parseExp
in interfaceIGosuParser
- Throws:
ParseResultsException
-
parseExp
public Expression parseExp(IScriptPartId partId, IType expectedExpressionType) throws ParseResultsException
- Specified by:
parseExp
in interfaceIGosuParser
- Throws:
ParseResultsException
-
parseExp
public Expression parseExp(IScriptPartId partId, IType expectedExpressionType, IFileContext context, boolean assignRuntime) throws ParseResultsException
- Specified by:
parseExp
in interfaceIGosuParser
- Throws:
ParseResultsException
-
parseExpOrProgram
public IExpression parseExpOrProgram(IScriptPartId partId) throws ParseResultsException
- Specified by:
parseExpOrProgram
in interfaceIGosuParser
- Throws:
ParseResultsException
-
parseExpOrProgram
public IExpression parseExpOrProgram(IScriptPartId partId, boolean isolatedScope, boolean assignRuntime) throws ParseResultsException
- Specified by:
parseExpOrProgram
in interfaceIGosuParser
- Throws:
ParseResultsException
-
parseExpOrProgram
public IExpression parseExpOrProgram(IScriptPartId partId, IType typeExpected, boolean isolatedScope, boolean assignRuntime) throws ParseResultsException
- Throws:
ParseResultsException
-
parseTypeLiteral
public TypeLiteral parseTypeLiteral(IScriptPartId partId) throws ParseResultsException
- Specified by:
parseTypeLiteral
in interfaceIGosuParser
- Throws:
ParseResultsException
-
isParsed
public boolean isParsed()
- Specified by:
isParsed
in interfaceIGosuParser
-
setParsed
protected void setParsed(boolean bParsed)
-
getTokenizer
public final SourceCodeTokenizer getTokenizer()
- Specified by:
getTokenizer
in interfaceIGosuParser
-
getLocations
public List<IParseTree> getLocations()
- Specified by:
getLocations
in interfaceIGosuParser
-
peekLocation
public ParseTree peekLocation()
-
hasWarnings
public boolean hasWarnings()
- Specified by:
hasWarnings
in interfaceIGosuParser
-
isThrowParseResultsExceptionForWarnings
public boolean isThrowParseResultsExceptionForWarnings()
- Specified by:
isThrowParseResultsExceptionForWarnings
in interfaceIGosuParser
-
setThrowParseExceptionForWarnings
public void setThrowParseExceptionForWarnings(boolean bThrowParseExceptionForWarnings)
- Specified by:
setThrowParseExceptionForWarnings
in interfaceIGosuParser
-
setContextInferenceManager
public void setContextInferenceManager(ContextInferenceManager ctxInferenceMgr)
-
pushInferredContextTypes
public void pushInferredContextTypes(ContextType ctxType)
-
popInferredContextTypes
public void popInferredContextTypes()
-
getContextType
public ContextType getContextType()
-
isCaptureSymbolsForEval
public boolean isCaptureSymbolsForEval()
- Specified by:
isCaptureSymbolsForEval
in interfaceIGosuParser
-
setCaptureSymbolsForEval
public void setCaptureSymbolsForEval(boolean bCaputreSymbolsForEval)
- Specified by:
setCaptureSymbolsForEval
in interfaceIGosuParser
-
isParsingStaticFeature
public boolean isParsingStaticFeature()
-
pushParsingStaticMember
public void pushParsingStaticMember(Boolean bParsingStaticFeature)
-
popParsingStaticMember
public void popParsingStaticMember()
-
isParsingAbstractConstructor
public boolean isParsingAbstractConstructor()
-
pushParsingAbstractConstructor
public void pushParsingAbstractConstructor(Boolean bParsingAbstractConstructor)
-
popParsingAbstractConstructor
public void popParsingAbstractConstructor()
-
parseTypeLiteral
public boolean parseTypeLiteral()
- Specified by:
parseTypeLiteral
in interfaceIGosuParser
-
parseTypeLiteral
public boolean parseTypeLiteral(Token token)
-
parseUsesStatementList
public UsesStatementList parseUsesStatementList(boolean bResolveUsesTypes)
- Specified by:
parseUsesStatementList
in interfaceIGosuParser
-
doParametersReifyToSameBytecodeType
public boolean doParametersReifyToSameBytecodeType(IDynamicFunctionSymbol dfs, IDynamicFunctionSymbol dfsExisting)
-
parseParameterDeclarationList
public ArrayList<ISymbol> parseParameterDeclarationList(IParsedElement element, boolean bStatic, List<IType> inferredArgumentTypes)
- Specified by:
parseParameterDeclarationList
in interfaceIGosuParser
-
parseParameterDeclarationList
public ArrayList<ISymbol> parseParameterDeclarationList(IParsedElement element, boolean bStatic, List<IType> inferredArgumentTypes, boolean bProperty, boolean bGetter, boolean bEmpty, boolean bVarDynamicArg)
-
pushExpression
protected void pushExpression(Expression e)
- Overrides:
pushExpression
in classParserBase
-
popExpression
public Expression popExpression()
- Specified by:
popExpression
in interfaceIGosuParser
- Overrides:
popExpression
in classParserBase
-
setTokenizer
public void setTokenizer(ISourceCodeTokenizer tokenizer)
- Specified by:
setTokenizer
in interfaceIGosuParser
-
peekExpression
protected Expression peekExpression()
- Overrides:
peekExpression
in classParserBase
-
peekParsedElement
protected ParsedElement peekParsedElement()
-
pushStatement
protected void pushStatement(Statement stmt)
- Overrides:
pushStatement
in classParserBase
-
popStatement
protected Statement popStatement()
- Overrides:
popStatement
in classParserBase
-
peekStatement
protected Statement peekStatement()
- Overrides:
peekStatement
in classParserBase
-
pushDynamicFunctionSymbol
protected void pushDynamicFunctionSymbol(DynamicFunctionSymbol stmt)
-
popDynamicFunctionSymbol
protected DynamicFunctionSymbol popDynamicFunctionSymbol()
-
peekDynamicFunctionSymbol
protected DynamicFunctionSymbol peekDynamicFunctionSymbol()
-
clearDfsStack
protected void clearDfsStack()
-
putDfsDeclsInTable
public void putDfsDeclsInTable(ISymbolTable table)
- Specified by:
putDfsDeclsInTable
in interfaceIGosuParser
-
putDfsDeclInSetByName
public void putDfsDeclInSetByName(IDynamicFunctionSymbol dfs)
- Specified by:
putDfsDeclInSetByName
in interfaceIGosuParser
-
nextIndexOfErrantDuplicateDynamicSymbol
public int nextIndexOfErrantDuplicateDynamicSymbol(IDynamicSymbol ds, Collection<? extends ISymbol> symbols, boolean bCheckContains)
-
setDfsDeclInSetByName
public void setDfsDeclInSetByName(Map<String,List<IFunctionSymbol>> dfsDecl)
- Specified by:
setDfsDeclInSetByName
in interfaceIGosuParser
-
newDfsDeclInSetByName
protected void newDfsDeclInSetByName()
-
getDfsDecls
public Map<String,List<IFunctionSymbol>> getDfsDecls()
- Specified by:
getDfsDecls
in interfaceIGosuParser
-
getFunctionTypesForName
protected List<IFunctionType> getFunctionTypesForName(String strFunctionName)
-
resolveTypeLiteral
protected TypeLiteral resolveTypeLiteral(String[] T)
-
resolveTypeLiteral
protected TypeLiteral resolveTypeLiteral(String[] T, boolean bRelative, boolean bInterface)
-
getDfsDeclsForFunction
protected List<IFunctionSymbol> getDfsDeclsForFunction(String strFunctionName)
-
resolveTypeLiteral
public TypeLiteral resolveTypeLiteral(String strTypeName)
Resolves the type literal given by strTypeName. If parentType is non null then strTypeName is assumed relative to the given parent.- Specified by:
resolveTypeLiteral
in interfaceIGosuParser
- Parameters:
strTypeName
-
-
resolveTypeLiteral
public TypeLiteral resolveTypeLiteral(String strTypeName, boolean bRelative, boolean bInterface)
-
getTypeVariables
public HashMap<String,ITypeVariableDefinition> getTypeVariables()
- Specified by:
getTypeVariables
in interfaceIGosuParser
-
setTypeVariables
protected void setTypeVariables(HashMap<String,ITypeVariableDefinition> map)
-
parseClass
public IGosuClassInternal parseClass(String strQualifiedClassName, ISourceFileHandle sourceFile, boolean bThrowOnWarnings, boolean bFullyCompile) throws ParseResultsException
- Specified by:
parseClass
in interfaceIGosuParser
- Throws:
ParseResultsException
-
getFunctionType
public IFunctionType getFunctionType(IType classBean, String functionName, Expression[] eArgs, List<IFunctionType> listAllMatchingMethods, GosuParser parser, boolean bMatchParamTypes) throws ParseException
- Throws:
ParseException
-
getConstructorType
public IConstructorType getConstructorType(IType classBean, Expression[] eArgs, List<IConstructorType> listAllMatchingMethods, ParserBase parserState) throws ParseException
Get the type of the method specified in the member path.- Parameters:
classBean
- The declaring class of the constructor.parserState
- The parserState that may be involved in the process of parsing a constructor. Can be null.- Returns:
- A Gosu type for the constructor.
- Throws:
ParseException
-
setWarnOnCaseIssue
public void setWarnOnCaseIssue(boolean warnOnCaseIssue)
- Specified by:
setWarnOnCaseIssue
in interfaceIGosuParser
-
setEditorParser
public void setEditorParser(boolean bStudioEditorParser)
- Specified by:
setEditorParser
in interfaceIGosuParser
-
isEditorParser
public boolean isEditorParser()
- Specified by:
isEditorParser
in interfaceIGosuParser
-
getState
public IParserState getState()
- Specified by:
getState
in interfaceIGosuParser
-
isParsingAnnotation
public boolean isParsingAnnotation()
-
setParsingAnnotation
public void setParsingAnnotation(boolean parsingAnnotation)
-
isAllowingWildcards
public boolean isAllowingWildcards()
-
setAllowWildcards
public void setAllowWildcards(boolean allowWildcards)
-
isIgnoreTypeDeprecation
public boolean isIgnoreTypeDeprecation()
-
pushIgnoreTypeDeprecation
public void pushIgnoreTypeDeprecation()
-
popIgnoreTypeDeprecation
public void popIgnoreTypeDeprecation()
-
setLocationsFromProgramClassParser
public void setLocationsFromProgramClassParser(List<ParseTree> savedLocations)
-
pushTypeVariableTypesToInfer
protected void pushTypeVariableTypesToInfer(IInvocableType functionType)
-
-