Package gw.lang.parser
Interface IGosuParser
- All Superinterfaces:
IParserPart
- All Known Implementing Classes:
GosuParser
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enum
static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final BigDecimal
static final Double[]
static final Double
static final Double
static final Double
-
Method Summary
Modifier and TypeMethodDescriptionThe context associated with the parser's script.getState()
Returns the parser's symbol table.The TokenizerInstructor to use for this parser.Get the type uses map.boolean
boolean
boolean
boolean
isParsed()
boolean
boolean
boolean
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.parseParameterDeclarationList
(IParsedElement pe, boolean bStatic, List<IType> inferredArgumentTypes) 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.boolean
Consumes a type literal from the current tokenizer, if one exists.parseTypeLiteral
(IScriptPartId partId) Parses a type literal expression.parseUsesStatementList
(boolean resolveTypes) void
putDfsDeclInSetByName
(IDynamicFunctionSymbol specialFunction) void
putDfsDeclsInTable
(ISymbolTable table) resolveTypeLiteral
(String strName) void
setCaptureSymbolsForEval
(boolean bCaputreSymbolsForEval) void
setDfsDeclInSetByName
(Map<String, List<IFunctionSymbol>> dfsDecl) void
setEditorParser
(boolean bEditorParser) void
setGenerateRootExpressionAccessForProgram
(boolean bGenRootExprAccess) void
setIgnoreWarnings
(Set<ResourceKey> ignoreWarnings) void
Set the script or expression to parse and execute.void
setScript
(SourceCodeReader reader) Set the script or expression to parse and execute.void
setScript
(CharSequence strRule) Set the script or expression to parse and execute.void
void
setSymbolTable
(ISymbolTable symTable) Sets the parser's symbol table.void
setThrowParseExceptionForWarnings
(boolean bThrowParseExceptionForWarnings) void
setTokenizer
(ISourceCodeTokenizer tokenizer) void
setTokenizerInstructor
(ITokenizerInstructor instructor) void
setTypeUsesMap
(ITypeUsesMap typeUsesMap) Set the type uses map.void
setWarnOnCaseIssue
(boolean warnOnCaseIssue) Methods inherited from interface gw.lang.parser.IParserPart
getLineNumShift, getOffsetShift, getOwner, isDontOptimizeStatementLists, setDontOptimizeStatementLists, setLineNumShift, setValidator
-
Field Details
-
NaN
-
ZERO
-
ONE
-
DOUBLE_DIGITS
-
BIGD_ZERO
-
-
Method Details
-
getScriptPart
IScriptPartId getScriptPart()The context associated with the parser's script. E.g., a file name, a library, a rule, etc. -
setScript
Set the script or expression to parse and execute.- Parameters:
strRule
- The rule (Gosu) source to parse/execute.
-
setScript
Set the script or expression to parse and execute.- Parameters:
reader
- A reader for the rule (Gosu) source to parse/execute.
-
setScript
Set the script or expression to parse and execute.- Parameters:
reader
- A reader for the rule (Gosu) source to parse/execute.
-
getSymbolTable
ISymbolTable getSymbolTable()Returns the parser's symbol table. -
setSymbolTable
Sets the parser's symbol table.- Parameters:
symTable
- The symbol table the parser will use when parsing and executing rules.
-
getTypeUsesMap
ITypeUsesMap getTypeUsesMap()Get the type uses map. -
setTypeUsesMap
Set the type uses map. -
parseStatements
Parses a set of Gosu statements. To execute all of the Statements at once call Statement.execute().- Returns:
- The parsed Statement[s].
- Throws:
ParseResultsException
- if any of the statements do not parse according to the Gosu grammar.
-
parseProgram
- Throws:
ParseResultsException
-
parseProgram
IProgram parseProgram(IScriptPartId partId, IType expectedExpressionType) throws ParseResultsException - Throws:
ParseResultsException
-
parseProgram
IProgram parseProgram(IScriptPartId partId, IType expectedExpressionType, IFileContext ctx, boolean assignRuntime) throws ParseResultsException - Throws:
ParseResultsException
-
parseProgram
IProgram parseProgram(IScriptPartId partId, IType expectedExpressionType, IFileContext ctx, boolean assignRuntime, boolean bDoNotThrowParseResultsException) throws ParseResultsException - Throws:
ParseResultsException
-
parseProgram
IProgram parseProgram(IScriptPartId partId, boolean isolatedScope, boolean reallyIsolatedScope, IType expectedExpressionType, IFileContext ctx, boolean assignRuntime) throws ParseResultsException - Throws:
ParseResultsException
-
parseProgram
IProgram parseProgram(IScriptPartId partId, boolean isolatedScope, boolean reallyIsolatedScope, IType expectedExpressionType, IFileContext ctx, boolean assignRuntime, boolean bDoNotThrowParseResultsException) throws ParseResultsException - Throws:
ParseResultsException
-
parseProgram
IProgram parseProgram(IScriptPartId partId, boolean isolatedScope, boolean reallyIsolatedScope, IType expectedExpressionType, IFileContext ctx, boolean assignRuntime, boolean bDoNotThrowParseResultsException, IType superType) throws ParseResultsException - Throws:
ParseResultsException
-
parseClass
IGosuClass parseClass(String strQualifiedClassName, ISourceFileHandle sourceFile, boolean bThrowOnWarnings, boolean bFullyCompile) throws ParseResultsException For use by code editors etc.- Throws:
ParseResultsException
-
parseExp
Parses a Gosu expression. To evaluate the Expression simply call Expression.evaluate().- Returns:
- The parsed Expression.
- Throws:
ParseResultsException
- if the expression does not parse according to the Gosu grammar.
-
parseExp
IExpression parseExp(IScriptPartId partId, IType expectedExpressionType) throws ParseResultsException Parses a Gosu expression. To evaluate the Expression simply call Expression.evaluate().- Returns:
- The parsed Expression.
- Throws:
ParseResultsException
- if the expression does not parse according to the Gosu grammar.
-
parseExp
IExpression parseExp(IScriptPartId partId, IType expectedExpressionType, IFileContext context, boolean assignRuntime) throws ParseResultsException Parses a Gosu expression. To evaluate the Expression simply call Expression.evaluate().- Returns:
- The parsed Expression.
- Throws:
ParseResultsException
- if the expression does not parse according to the Gosu grammar.
-
parseExpOrProgram
Parses a Gosu expression. If that fails, attempts to parse a Gosu program (which is also an expression, but which has a different grammar.- 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
IExpression parseExpOrProgram(IScriptPartId partId, boolean isolatedScope, boolean assignRuntime) throws ParseResultsException Parses a Gosu expression. If that fails, attempts to parse a Gosu program (which is also an expression, but which has a different grammar.- 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
-
parseTypeLiteral
Parses a type literal expression. The source must obviously satisfy the type literal syntax.- Throws:
ParseResultsException
-
parseTypeLiteral
boolean parseTypeLiteral()Consumes a type literal from the current tokenizer, if one exists.- Returns:
- true if a type literal was found, false otherwise
-
isParsed
boolean isParsed()- Returns:
- Whether or not the referenced Gosu source has been parsed.
-
hasWarnings
boolean hasWarnings()- Returns:
- Did the most recent parse have warnings
-
getLocations
List<IParseTree> getLocations()- Returns:
- All the locations corresponding to parsed elements.
-
getTokenizerInstructor
ITokenizerInstructor getTokenizerInstructor()The TokenizerInstructor to use for this parser. Optional. -
setTokenizerInstructor
-
getTypeVariables
Map<String,ITypeVariableDefinition> getTypeVariables() -
isThrowParseResultsExceptionForWarnings
boolean isThrowParseResultsExceptionForWarnings() -
setThrowParseExceptionForWarnings
void setThrowParseExceptionForWarnings(boolean bThrowParseExceptionForWarnings) -
setWarnOnCaseIssue
void setWarnOnCaseIssue(boolean warnOnCaseIssue) -
setEditorParser
void setEditorParser(boolean bEditorParser) -
isEditorParser
boolean isEditorParser() -
putDfsDeclsInTable
-
getTokenizer
ISourceCodeTokenizer getTokenizer() -
parseParameterDeclarationList
ArrayList<ISymbol> parseParameterDeclarationList(IParsedElement pe, boolean bStatic, List<IType> inferredArgumentTypes) -
putDfsDeclInSetByName
-
resolveTypeLiteral
-
getDfsDecls
Map<String,List<IFunctionSymbol>> getDfsDecls() -
getState
IParserState getState() -
isCaptureSymbolsForEval
boolean isCaptureSymbolsForEval() -
setCaptureSymbolsForEval
void setCaptureSymbolsForEval(boolean bCaputreSymbolsForEval) -
setDfsDeclInSetByName
-
isParsingFunction
boolean isParsingFunction() -
isParsingBlock
boolean isParsingBlock() -
parseProgram
IProgram parseProgram(IScriptPartId partId, boolean isolatedScope, IType expectedExpressionType) throws ParseResultsException - Throws:
ParseResultsException
-
setGenerateRootExpressionAccessForProgram
void setGenerateRootExpressionAccessForProgram(boolean bGenRootExprAccess) -
setSnapshotSymbols
void setSnapshotSymbols() -
parseUsesStatementList
-
popExpression
IExpression popExpression() -
setTokenizer
-
setIgnoreWarnings
-