Package gw.lang.parser
Interface IGosuParser
-
- All Superinterfaces:
IParserPart
- All Known Implementing Classes:
GosuParser
public interface IGosuParser extends IParserPart
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
IGosuParser.ParseType
static class
IGosuParser.Settings
-
Field Summary
Fields Modifier and Type Field Description static BigDecimal
BIGD_ZERO
static Double[]
DOUBLE_DIGITS
static Double
NaN
static Double
ONE
static Double
ZERO
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Map<String,List<IFunctionSymbol>>
getDfsDecls()
List<IParseTree>
getLocations()
IScriptPartId
getScriptPart()
The context associated with the parser's script.IParserState
getState()
ISymbolTable
getSymbolTable()
Returns the parser's symbol table.ISourceCodeTokenizer
getTokenizer()
ITokenizerInstructor
getTokenizerInstructor()
The TokenizerInstructor to use for this parser.ITypeUsesMap
getTypeUsesMap()
Get the type uses map.Map<String,ITypeVariableDefinition>
getTypeVariables()
boolean
hasWarnings()
boolean
isCaptureSymbolsForEval()
boolean
isEditorParser()
boolean
isParsed()
boolean
isParsingBlock()
boolean
isParsingFunction()
boolean
isThrowParseResultsExceptionForWarnings()
IGosuClass
parseClass(String strQualifiedClassName, ISourceFileHandle sourceFile, boolean bThrowOnWarnings, boolean bFullyCompile)
For use by code editors etc.IExpression
parseExp(IScriptPartId partId)
Parses a Gosu expression.IExpression
parseExp(IScriptPartId partId, IType expectedExpressionType)
Parses a Gosu expression.IExpression
parseExp(IScriptPartId partId, IType expectedExpressionType, IFileContext context, boolean assignRuntime)
Parses a Gosu expression.IExpression
parseExpOrProgram(IScriptPartId partId)
Parses a Gosu expression.IExpression
parseExpOrProgram(IScriptPartId partId, boolean isolatedScope, boolean assignRuntime)
Parses a Gosu expression.ArrayList<ISymbol>
parseParameterDeclarationList(IParsedElement pe, boolean bStatic, List<IType> inferredArgumentTypes)
IProgram
parseProgram(IScriptPartId partId)
IProgram
parseProgram(IScriptPartId partId, boolean isolatedScope, boolean reallyIsolatedScope, IType expectedExpressionType, IFileContext ctx, boolean assignRuntime)
IProgram
parseProgram(IScriptPartId partId, boolean isolatedScope, boolean reallyIsolatedScope, IType expectedExpressionType, IFileContext ctx, boolean assignRuntime, boolean bDoNotThrowParseResultsException)
IProgram
parseProgram(IScriptPartId partId, boolean isolatedScope, boolean reallyIsolatedScope, IType expectedExpressionType, IFileContext ctx, boolean assignRuntime, boolean bDoNotThrowParseResultsException, IType superType)
IProgram
parseProgram(IScriptPartId partId, boolean isolatedScope, IType expectedExpressionType)
IProgram
parseProgram(IScriptPartId partId, IType expectedExpressionType)
IProgram
parseProgram(IScriptPartId partId, IType expectedExpressionType, IFileContext ctx, boolean assignRuntime)
IProgram
parseProgram(IScriptPartId partId, IType expectedExpressionType, IFileContext ctx, boolean assignRuntime, boolean bDoNotThrowParseResultsException)
IStatement
parseStatements(IScriptPartId partId)
Parses a set of Gosu statements.boolean
parseTypeLiteral()
Consumes a type literal from the current tokenizer, if one exists.ITypeLiteralExpression
parseTypeLiteral(IScriptPartId partId)
Parses a type literal expression.IUsesStatementList
parseUsesStatementList(boolean resolveTypes)
IExpression
popExpression()
void
putDfsDeclInSetByName(IDynamicFunctionSymbol specialFunction)
void
putDfsDeclsInTable(ISymbolTable table)
ITypeLiteralExpression
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
setScript(ISource reader)
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
setSnapshotSymbols()
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 Detail
-
NaN
static final Double NaN
-
ZERO
static final Double ZERO
-
ONE
static final Double ONE
-
DOUBLE_DIGITS
static final Double[] DOUBLE_DIGITS
-
BIGD_ZERO
static final BigDecimal BIGD_ZERO
-
-
Method Detail
-
getScriptPart
IScriptPartId getScriptPart()
The context associated with the parser's script. E.g., a file name, a library, a rule, etc.
-
setScript
void setScript(CharSequence strRule)
Set the script or expression to parse and execute.- Parameters:
strRule
- The rule (Gosu) source to parse/execute.
-
setScript
void setScript(SourceCodeReader reader)
Set the script or expression to parse and execute.- Parameters:
reader
- A reader for the rule (Gosu) source to parse/execute.
-
setScript
void setScript(ISource reader)
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
void setSymbolTable(ISymbolTable symTable)
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
void setTypeUsesMap(ITypeUsesMap typeUsesMap)
Set the type uses map.
-
parseStatements
IStatement parseStatements(IScriptPartId partId) throws ParseResultsException
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
IProgram parseProgram(IScriptPartId partId) throws ParseResultsException
- 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
IExpression parseExp(IScriptPartId partId) 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) 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
IExpression parseExpOrProgram(IScriptPartId partId) 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 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
ITypeLiteralExpression parseTypeLiteral(IScriptPartId partId) throws ParseResultsException
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
void setTokenizerInstructor(ITokenizerInstructor instructor)
-
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
void putDfsDeclsInTable(ISymbolTable table)
-
getTokenizer
ISourceCodeTokenizer getTokenizer()
-
parseParameterDeclarationList
ArrayList<ISymbol> parseParameterDeclarationList(IParsedElement pe, boolean bStatic, List<IType> inferredArgumentTypes)
-
putDfsDeclInSetByName
void putDfsDeclInSetByName(IDynamicFunctionSymbol specialFunction)
-
resolveTypeLiteral
ITypeLiteralExpression resolveTypeLiteral(String strName)
-
getDfsDecls
Map<String,List<IFunctionSymbol>> getDfsDecls()
-
getState
IParserState getState()
-
isCaptureSymbolsForEval
boolean isCaptureSymbolsForEval()
-
setCaptureSymbolsForEval
void setCaptureSymbolsForEval(boolean bCaputreSymbolsForEval)
-
setDfsDeclInSetByName
void setDfsDeclInSetByName(Map<String,List<IFunctionSymbol>> dfsDecl)
-
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
IUsesStatementList parseUsesStatementList(boolean resolveTypes)
-
popExpression
IExpression popExpression()
-
setTokenizer
void setTokenizer(ISourceCodeTokenizer tokenizer)
-
setIgnoreWarnings
void setIgnoreWarnings(Set<ResourceKey> ignoreWarnings)
-
-