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
-
Nested Class Summary
Nested classes/interfaces inherited from interface gw.lang.parser.IGosuParser
IGosuParser.ParseType, IGosuParser.Settings -
Field Summary
FieldsFields inherited from class gw.internal.gosu.parser.ParserBase
_bDontOptimizeStatementLists, _offsetShiftFields inherited from interface gw.lang.parser.IGosuParser
BIGD_ZERO, DOUBLE_DIGITS, NaN, ONE, ZERO -
Method Summary
Modifier and TypeMethodDescriptionprotected voidbooleandoParametersReifyToSameBytecodeType(IDynamicFunctionSymbol dfs, IDynamicFunctionSymbol dfsExisting) static ITypegetConstructorType(IType classBean, Expression[] eArgs, List<IConstructorType> listAllMatchingMethods, ParserBase parserState) Get the type of the method specified in the member path.protected List<IFunctionSymbol> getDfsDeclsForFunction(String strFunctionName) getFunctionType(IType classBean, String functionName, Expression[] eArgs, List<IFunctionType> listAllMatchingMethods, GosuParser parser, boolean bMatchParamTypes) protected List<IFunctionType> getFunctionTypesForName(String strFunctionName) protected StringThe context associated with the parser's script.getState()Returns the parser's symbol table.final SourceCodeTokenizerThe TokenizerInstructor to use for this parser.Get the type uses map.booleanbooleanbooleanbooleanbooleanbooleanbooleanisParsed()booleanbooleanbooleanbooleanbooleanbooleanprotected voidintnextIndexOfErrantDuplicateDynamicSymbol(IDynamicSymbol ds, Collection<? extends ISymbol> symbols, boolean bCheckContains) parseClass(String strQualifiedClassName, ISourceFileHandle sourceFile, boolean bThrowOnWarnings, boolean bFullyCompile) For use by code editors etc.parseExp(IScriptPartId partId) Parses a Gosu expression.parseExp(IScriptPartId partId, IType expectedExpressionType) Parses a Gosu expression.parseExp(IScriptPartId partId, IType expectedExpressionType, IFileContext context, boolean assignRuntime) Parses a Gosu expression.parseExpOrProgram(IScriptPartId partId) Parses a Gosu expression.parseExpOrProgram(IScriptPartId partId, boolean isolatedScope, boolean assignRuntime) Parses a Gosu expression.parseExpOrProgram(IScriptPartId partId, IType typeExpected, boolean isolatedScope, boolean assignRuntime) parseParameterDeclarationList(IParsedElement element, boolean bStatic, List<IType> inferredArgumentTypes) parseParameterDeclarationList(IParsedElement element, boolean bStatic, List<IType> inferredArgumentTypes, boolean bProperty, boolean bGetter, boolean bEmpty, boolean bVarDynamicArg) parseProgram(IScriptPartId partId) parseProgram(IScriptPartId partId, boolean isolatedScope, boolean reallyIsolatedScope, IType expectedExpressionType, IFileContext ctx, boolean assignRuntime) parseProgram(IScriptPartId partId, boolean isolatedScope, boolean reallyIsolatedScope, IType expectedExpressionType, IFileContext ctx, boolean assignRuntime, boolean bDoNotThrowParseResultsException) parseProgram(IScriptPartId partId, boolean isolatedScope, boolean reallyIsolatedScope, IType expectedExpressionType, IFileContext ctx, boolean assignRuntime, boolean bDoNotThrowParseResultsException, IType superType) parseProgram(IScriptPartId partId, boolean isolatedScope, IType expectedExpressionType) parseProgram(IScriptPartId partId, IType expectedExpressionType) parseProgram(IScriptPartId partId, IType expectedExpressionType, IFileContext ctx, boolean assignRuntime) parseProgram(IScriptPartId partId, IType expectedExpressionType, IFileContext ctx, boolean assignRuntime, boolean bDoNotThrowParseResultsException) parseStatements(IScriptPartId partId) Parses a set of Gosu statements.booleanConsumes a type literal from the current tokenizer, if one exists.booleanparseTypeLiteral(Token token) parseTypeLiteral(IScriptPartId partId) Parses a type literal expression.parseUsesStatementList(boolean bResolveUsesTypes) protected DynamicFunctionSymbolprotected Expressionprotected ParsedElementprotected Statementprotected DynamicFunctionSymbolvoidvoidvoidvoidprotected Statementprotected voidprotected voidvoidvoidpushInferenceMap(TypeVarToTypeMap inferenceMap) voidpushInferredContextTypes(ContextType ctxType) voidpushParsingAbstractConstructor(Boolean bParsingAbstractConstructor) voidpushParsingStaticMember(Boolean bParsingStaticFeature) voidpushScriptPart(IScriptPartId partId) protected voidpushStatement(Statement stmt) protected voidpushTypeVariableTypesToInfer(IInvocableType functionType) voidvoidputDfsDeclsInTable(ISymbolTable table) voidresolveTypeLiteral(String strTypeName) Resolves the type literal given by strTypeName.protected TypeLiteralresolveTypeLiteral(String[] T) protected TypeLiteralresolveTypeLiteral(String[] T, boolean bRelative, boolean bInterface) resolveTypeLiteral(String strTypeName, boolean bRelative, boolean bInterface) voidsetAllowWildcards(boolean allowWildcards) voidsetCaptureSymbolsForEval(boolean bCaputreSymbolsForEval) voidsetContextInferenceManager(ContextInferenceManager ctxInferenceMgr) voidsetDfsDeclInSetByName(Map<String, List<IFunctionSymbol>> dfsDecl) voidsetEditorParser(boolean bStudioEditorParser) voidsetGenerateRootExpressionAccessForProgram(boolean bGenRootExprAccess) voidsetLocationsFromProgramClassParser(List<ParseTree> savedLocations) protected voidsetParsed(boolean bParsed) voidsetParsingAnnotation(boolean parsingAnnotation) voidSet the script or expression to parse and execute.voidsetScript(SourceCodeReader reader) Set the script or expression to parse and execute.voidsetScript(CharSequence source) Set the script or expression to parse and execute.voidsetSymbolTable(ISymbolTable symTable) Sets the parser's symbol table.voidsetThrowParseExceptionForWarnings(boolean bThrowParseExceptionForWarnings) voidsetTokenizer(ISourceCodeTokenizer tokenizer) voidsetTokenizerInstructor(ITokenizerInstructor tokenizerInstructor) voidsetTypeUsesMap(ITypeUsesMap typeUsesMap) Set the type uses map.protected voidvoidsetValidator(IGosuValidator validator) voidsetWarnOnCaseIssue(boolean warnOnCaseIssue) toString()booleantypeVarExists(Map<String, ITypeVariableDefinition> typeVarMap, TypeVariableDefinition typeVarDef) 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, verifyTypesComparableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface gw.lang.parser.IGosuParser
isParsingBlock, setIgnoreWarnings, setSnapshotSymbolsMethods inherited from interface gw.lang.parser.IParserPart
getLineNumShift, getOffsetShift, getOwner, isDontOptimizeStatementLists, setDontOptimizeStatementLists, setLineNumShift
-
Field Details
-
PENDING_BOUNDING_TYPE
-
notfound
-
-
Method Details
-
setValidator
- Specified by:
setValidatorin interfaceIParserPart- Overrides:
setValidatorin classParserBase
-
getScriptPart
Description copied from interface:IGosuParserThe context associated with the parser's script. E.g., a file name, a library, a rule, etc.- Specified by:
getScriptPartin interfaceIGosuParser
-
getScriptPartIdStack
-
pushScriptPart
-
getInferenceMap
-
pushInferenceMap
-
setScript
Description copied from interface:IGosuParserSet the script or expression to parse and execute.- Specified by:
setScriptin interfaceIGosuParser- Parameters:
source- The rule (Gosu) source to parse/execute.
-
setScript
Description copied from interface:IGosuParserSet the script or expression to parse and execute.- Specified by:
setScriptin interfaceIGosuParser- Parameters:
src- A reader for the rule (Gosu) source to parse/execute.
-
setScript
Description copied from interface:IGosuParserSet the script or expression to parse and execute.- Specified by:
setScriptin interfaceIGosuParser- Parameters:
reader- A reader for the rule (Gosu) source to parse/execute.
-
resetScript
public void resetScript() -
getScript
- Specified by:
getScriptin classParserBase
-
getSymbolTable
Description copied from interface:IGosuParserReturns the parser's symbol table.- Specified by:
getSymbolTablein interfaceIGosuParser
-
setSymbolTable
Description copied from interface:IGosuParserSets the parser's symbol table.- Specified by:
setSymbolTablein interfaceIGosuParser- Parameters:
symTable- The symbol table the parser will use when parsing and executing rules.
-
getTypeUsesMap
Description copied from interface:IGosuParserGet the type uses map.- Specified by:
getTypeUsesMapin interfaceIGosuParser
-
setTypeUsesMap
Description copied from interface:IGosuParserSet the type uses map.- Specified by:
setTypeUsesMapin interfaceIGosuParser
-
getNamespace
-
getVisibilityConstraint
-
getTokenizerInstructor
Description copied from interface:IGosuParserThe TokenizerInstructor to use for this parser. Optional.- Specified by:
getTokenizerInstructorin interfaceIGosuParser
-
setTokenizerInstructor
- Specified by:
setTokenizerInstructorin interfaceIGosuParser
-
peekParsingFunction
-
iterateParsingFunctions
-
isParsingFunction
public boolean isParsingFunction()- Specified by:
isParsingFunctionin interfaceIGosuParser
-
peekParsingFieldInitializer
-
isParsingFieldInitializer
public boolean isParsingFieldInitializer() -
parseStatements
Description copied from interface:IGosuParserParses a set of Gosu statements. To execute all of the Statements at once call Statement.execute().- Specified by:
parseStatementsin interfaceIGosuParser- Returns:
- The parsed Statement[s].
- Throws:
ParseResultsException- if any of the statements do not parse according to the Gosu grammar.
-
parseProgram
- Specified by:
parseProgramin interfaceIGosuParser- Throws:
ParseResultsException
-
parseProgram
public IProgram parseProgram(IScriptPartId partId, IType expectedExpressionType) throws ParseResultsException - Specified by:
parseProgramin interfaceIGosuParser- Throws:
ParseResultsException
-
parseProgram
public IProgram parseProgram(IScriptPartId partId, IType expectedExpressionType, IFileContext ctx, boolean assignRuntime) throws ParseResultsException - Specified by:
parseProgramin interfaceIGosuParser- Throws:
ParseResultsException
-
parseProgram
public IProgram parseProgram(IScriptPartId partId, IType expectedExpressionType, IFileContext ctx, boolean assignRuntime, boolean bDoNotThrowParseResultsException) throws ParseResultsException - Specified by:
parseProgramin interfaceIGosuParser- Throws:
ParseResultsException
-
parseProgram
public IProgram parseProgram(IScriptPartId partId, boolean isolatedScope, IType expectedExpressionType) throws ParseResultsException - Specified by:
parseProgramin interfaceIGosuParser- Throws:
ParseResultsException
-
parseProgram
public IProgram parseProgram(IScriptPartId partId, boolean isolatedScope, boolean reallyIsolatedScope, IType expectedExpressionType, IFileContext ctx, boolean assignRuntime) throws ParseResultsException - Specified by:
parseProgramin 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:
parseProgramin 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:
parseProgramin interfaceIGosuParser- Throws:
ParseResultsException
-
setGenerateRootExpressionAccessForProgram
public void setGenerateRootExpressionAccessForProgram(boolean bGenRootExprAccess) - Specified by:
setGenerateRootExpressionAccessForProgramin interfaceIGosuParser
-
isGenerateRootExpressionAccessForProgram
public boolean isGenerateRootExpressionAccessForProgram() -
parseExp
Description copied from interface:IGosuParserParses a Gosu expression. To evaluate the Expression simply call Expression.evaluate().- Specified by:
parseExpin interfaceIGosuParser- Returns:
- The parsed Expression.
- Throws:
ParseResultsException- if the expression does not parse according to the Gosu grammar.
-
parseExp
public Expression parseExp(IScriptPartId partId, IType expectedExpressionType) throws ParseResultsException Description copied from interface:IGosuParserParses a Gosu expression. To evaluate the Expression simply call Expression.evaluate().- Specified by:
parseExpin interfaceIGosuParser- Returns:
- The parsed Expression.
- Throws:
ParseResultsException- if the expression does not parse according to the Gosu grammar.
-
parseExp
public Expression parseExp(IScriptPartId partId, IType expectedExpressionType, IFileContext context, boolean assignRuntime) throws ParseResultsException Description copied from interface:IGosuParserParses a Gosu expression. To evaluate the Expression simply call Expression.evaluate().- Specified by:
parseExpin interfaceIGosuParser- Returns:
- The parsed Expression.
- Throws:
ParseResultsException- if the expression does not parse according to the Gosu grammar.
-
parseExpOrProgram
Description copied from interface:IGosuParserParses a Gosu expression. If that fails, attempts to parse a Gosu program (which is also an expression, but which has a different grammar.- Specified by:
parseExpOrProgramin interfaceIGosuParser- Parameters:
partId- Script part id- Returns:
- either a pure expression or Program, depending on the source
- Throws:
ParseResultsException- if neither an expression nor a program parses according to the Gosu grammar. We try to make a best guess as to which IParseResultsException to throw, so that the errors are as close as possible to the true cause of the IParseResultsException
-
parseExpOrProgram
public IExpression parseExpOrProgram(IScriptPartId partId, boolean isolatedScope, boolean assignRuntime) throws ParseResultsException Description copied from interface:IGosuParserParses a Gosu expression. If that fails, attempts to parse a Gosu program (which is also an expression, but which has a different grammar.- Specified by:
parseExpOrProgramin interfaceIGosuParser- Parameters:
partId- Script part idisolatedScope- if false, the program will modify the symbol table at the current scope- Returns:
- either a pure expression or Program, depending on the source
- Throws:
ParseResultsException- if neither an expression nor a program parses according to the Gosu grammar. We try to make a best guess as to which IParseResultsException to throw, so that the errors are as close as possible to the true cause of the IParseResultsException
-
parseExpOrProgram
public IExpression parseExpOrProgram(IScriptPartId partId, IType typeExpected, boolean isolatedScope, boolean assignRuntime) throws ParseResultsException - Throws:
ParseResultsException
-
parseTypeLiteral
Description copied from interface:IGosuParserParses a type literal expression. The source must obviously satisfy the type literal syntax.- Specified by:
parseTypeLiteralin interfaceIGosuParser- Throws:
ParseResultsException
-
isParsed
public boolean isParsed()- Specified by:
isParsedin interfaceIGosuParser- Returns:
- Whether or not the referenced Gosu source has been parsed.
-
setParsed
protected void setParsed(boolean bParsed) -
getTokenizer
- Specified by:
getTokenizerin interfaceIGosuParser
-
getLocations
- Specified by:
getLocationsin interfaceIGosuParser- Returns:
- All the locations corresponding to parsed elements.
-
peekLocation
-
hasWarnings
public boolean hasWarnings()- Specified by:
hasWarningsin interfaceIGosuParser- Returns:
- Did the most recent parse have warnings
-
isThrowParseResultsExceptionForWarnings
public boolean isThrowParseResultsExceptionForWarnings()- Specified by:
isThrowParseResultsExceptionForWarningsin interfaceIGosuParser
-
setThrowParseExceptionForWarnings
public void setThrowParseExceptionForWarnings(boolean bThrowParseExceptionForWarnings) - Specified by:
setThrowParseExceptionForWarningsin interfaceIGosuParser
-
setContextInferenceManager
-
pushInferredContextTypes
-
popInferredContextTypes
public void popInferredContextTypes() -
getContextType
-
isCaptureSymbolsForEval
public boolean isCaptureSymbolsForEval()- Specified by:
isCaptureSymbolsForEvalin interfaceIGosuParser
-
setCaptureSymbolsForEval
public void setCaptureSymbolsForEval(boolean bCaputreSymbolsForEval) - Specified by:
setCaptureSymbolsForEvalin interfaceIGosuParser
-
findImpl
-
isParsingStaticFeature
public boolean isParsingStaticFeature() -
pushParsingStaticMember
-
popParsingStaticMember
public void popParsingStaticMember() -
isParsingAbstractConstructor
public boolean isParsingAbstractConstructor() -
pushParsingAbstractConstructor
-
popParsingAbstractConstructor
public void popParsingAbstractConstructor() -
parseTypeLiteral
public boolean parseTypeLiteral()Description copied from interface:IGosuParserConsumes a type literal from the current tokenizer, if one exists.- Specified by:
parseTypeLiteralin interfaceIGosuParser- Returns:
- true if a type literal was found, false otherwise
-
parseTypeLiteral
-
parseUsesStatementList
- Specified by:
parseUsesStatementListin interfaceIGosuParser
-
doParametersReifyToSameBytecodeType
public boolean doParametersReifyToSameBytecodeType(IDynamicFunctionSymbol dfs, IDynamicFunctionSymbol dfsExisting) -
parseParameterDeclarationList
public ArrayList<ISymbol> parseParameterDeclarationList(IParsedElement element, boolean bStatic, List<IType> inferredArgumentTypes) - Specified by:
parseParameterDeclarationListin interfaceIGosuParser
-
parseParameterDeclarationList
public ArrayList<ISymbol> parseParameterDeclarationList(IParsedElement element, boolean bStatic, List<IType> inferredArgumentTypes, boolean bProperty, boolean bGetter, boolean bEmpty, boolean bVarDynamicArg) -
typeVarExists
public boolean typeVarExists(Map<String, ITypeVariableDefinition> typeVarMap, TypeVariableDefinition typeVarDef) -
pushExpression
- Overrides:
pushExpressionin classParserBase
-
popExpression
- Specified by:
popExpressionin interfaceIGosuParser- Overrides:
popExpressionin classParserBase
-
setTokenizer
- Specified by:
setTokenizerin interfaceIGosuParser
-
peekExpression
- Overrides:
peekExpressionin classParserBase
-
peekParsedElement
-
pushStatement
- Overrides:
pushStatementin classParserBase
-
popStatement
- Overrides:
popStatementin classParserBase
-
peekStatement
- Overrides:
peekStatementin classParserBase
-
pushDynamicFunctionSymbol
-
popDynamicFunctionSymbol
-
peekDynamicFunctionSymbol
-
clearDfsStack
protected void clearDfsStack() -
putDfsDeclsInTable
- Specified by:
putDfsDeclsInTablein interfaceIGosuParser
-
putDfsDeclInSetByName
- Specified by:
putDfsDeclInSetByNamein interfaceIGosuParser
-
nextIndexOfErrantDuplicateDynamicSymbol
public int nextIndexOfErrantDuplicateDynamicSymbol(IDynamicSymbol ds, Collection<? extends ISymbol> symbols, boolean bCheckContains) -
setDfsDeclInSetByName
- Specified by:
setDfsDeclInSetByNamein interfaceIGosuParser
-
newDfsDeclInSetByName
protected void newDfsDeclInSetByName() -
getDfsDecls
- Specified by:
getDfsDeclsin interfaceIGosuParser
-
getFunctionTypesForName
-
resolveTypeLiteral
-
resolveTypeLiteral
-
getDfsDeclsForFunction
-
resolveTypeLiteral
Resolves the type literal given by strTypeName. If parentType is non null then strTypeName is assumed relative to the given parent.- Specified by:
resolveTypeLiteralin interfaceIGosuParser- Parameters:
strTypeName-
-
resolveTypeLiteral
-
getTypeVariables
- Specified by:
getTypeVariablesin interfaceIGosuParser
-
setTypeVariables
-
parseClass
public IGosuClassInternal parseClass(String strQualifiedClassName, ISourceFileHandle sourceFile, boolean bThrowOnWarnings, boolean bFullyCompile) throws ParseResultsException Description copied from interface:IGosuParserFor use by code editors etc.- Specified by:
parseClassin 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:
setWarnOnCaseIssuein interfaceIGosuParser
-
setEditorParser
public void setEditorParser(boolean bStudioEditorParser) - Specified by:
setEditorParserin interfaceIGosuParser
-
isEditorParser
public boolean isEditorParser()- Specified by:
isEditorParserin interfaceIGosuParser
-
getState
- Specified by:
getStatein 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
-
pushTypeVariableTypesToInfer
-
toString
-