Package gw.lang.parser
Interface IGosuParser
-
- All Superinterfaces:
IParserPart
public interface IGosuParser extends IParserPart
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classIGosuParser.ParseTypestatic classIGosuParser.Settings
-
Field Summary
Fields Modifier and Type Field Description static BigDecimalBIGD_ZEROstatic Double[]DOUBLE_DIGITSstatic DoubleNaNstatic DoubleONEstatic DoubleZERO
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Map<String,List<IFunctionSymbol>>getDfsDecls()List<IParseTree>getLocations()IScriptPartIdgetScriptPart()The context associated with the parser's script.IParserStategetState()ISymbolTablegetSymbolTable()Returns the parser's symbol table.ISourceCodeTokenizergetTokenizer()ITokenizerInstructorgetTokenizerInstructor()The TokenizerInstructor to use for this parser.ITypeUsesMapgetTypeUsesMap()Get the type uses map.Map<String,ITypeVariableDefinition>getTypeVariables()booleanhasWarnings()booleanisCaptureSymbolsForEval()booleanisEditorParser()booleanisParsed()booleanisParsingBlock()booleanisParsingFunction()booleanisThrowParseResultsExceptionForWarnings()IGosuClassparseClass(String strQualifiedClassName, ISourceFileHandle sourceFile, boolean bThrowOnWarnings, boolean bFullyCompile)For use by code editors etc.IExpressionparseExp(IScriptPartId partId)Parses a Gosu expression.IExpressionparseExp(IScriptPartId partId, IType expectedExpressionType)Parses a Gosu expression.IExpressionparseExp(IScriptPartId partId, IType expectedExpressionType, IFileContext context, boolean assignRuntime)Parses a Gosu expression.IExpressionparseExpOrProgram(IScriptPartId partId)Parses a Gosu expression.IExpressionparseExpOrProgram(IScriptPartId partId, boolean isolatedScope, boolean assignRuntime)Parses a Gosu expression.ArrayList<ISymbol>parseParameterDeclarationList(IParsedElement pe, boolean bStatic, List<IType> inferredArgumentTypes)IProgramparseProgram(IScriptPartId partId)IProgramparseProgram(IScriptPartId partId, boolean isolatedScope, boolean reallyIsolatedScope, IType expectedExpressionType, IFileContext ctx, boolean assignRuntime)IProgramparseProgram(IScriptPartId partId, boolean isolatedScope, boolean reallyIsolatedScope, IType expectedExpressionType, IFileContext ctx, boolean assignRuntime, boolean bDoNotThrowParseResultsException)IProgramparseProgram(IScriptPartId partId, boolean isolatedScope, boolean reallyIsolatedScope, IType expectedExpressionType, IFileContext ctx, boolean assignRuntime, boolean bDoNotThrowParseResultsException, IType superType)IProgramparseProgram(IScriptPartId partId, boolean isolatedScope, IType expectedExpressionType)IProgramparseProgram(IScriptPartId partId, IType expectedExpressionType)IProgramparseProgram(IScriptPartId partId, IType expectedExpressionType, IFileContext ctx, boolean assignRuntime)IProgramparseProgram(IScriptPartId partId, IType expectedExpressionType, IFileContext ctx, boolean assignRuntime, boolean bDoNotThrowParseResultsException)IStatementparseStatements(IScriptPartId partId)Parses a set of Gosu statements.booleanparseTypeLiteral()Consumes a type literal from the current tokenizer, if one exists.ITypeLiteralExpressionparseTypeLiteral(IScriptPartId partId)Parses a type literal expression.IUsesStatementListparseUsesStatementList(boolean resolveTypes)IExpressionpopExpression()voidputDfsDeclInSetByName(IDynamicFunctionSymbol specialFunction)voidputDfsDeclsInTable(ISymbolTable table)ITypeLiteralExpressionresolveTypeLiteral(String strName)voidsetCaptureSymbolsForEval(boolean bCaputreSymbolsForEval)voidsetDfsDeclInSetByName(Map<String,List<IFunctionSymbol>> dfsDecl)voidsetEditorParser(boolean bEditorParser)voidsetGenerateRootExpressionAccessForProgram(boolean bGenRootExprAccess)voidsetIgnoreWarnings(Set<ResourceKey> ignoreWarnings)voidsetScript(ISource reader)Set the script or expression to parse and execute.voidsetScript(SourceCodeReader reader)Set the script or expression to parse and execute.voidsetScript(CharSequence strRule)Set the script or expression to parse and execute.voidsetSnapshotSymbols()voidsetSymbolTable(ISymbolTable symTable)Sets the parser's symbol table.voidsetThrowParseExceptionForWarnings(boolean bThrowParseExceptionForWarnings)voidsetTokenizer(ISourceCodeTokenizer tokenizer)voidsetTokenizerInstructor(ITokenizerInstructor instructor)voidsetTypeUsesMap(ITypeUsesMap typeUsesMap)Set the type uses map.voidsetWarnOnCaseIssue(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)
-
-