Package gw.internal.gosu.parser
Class ParserBase
- java.lang.Object
-
- gw.internal.gosu.parser.ParserBase
-
- All Implemented Interfaces:
IParserPart
- Direct Known Subclasses:
GosuClassParser
,GosuParser
public abstract class ParserBase extends Object implements IParserPart
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
_bDontOptimizeStatementLists
protected int
_offsetShift
-
Constructor Summary
Constructors Constructor Description ParserBase()
ParserBase(GosuParser owner)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addBlockToBlockStack(BlockExpression block)
protected void
captureAllSymbols(ICompilableTypeInternal anonClass, ICompilableTypeInternal enclosingClass, List<ICapturedSymbol> capturedSymbols)
protected ISymbol
captureSymbol(ICompilableTypeInternal anonClass, String strName, ParsedElement e)
protected void
copyBlockStackTo(ParserBase otherParser)
Token
eatBlock(char cBegin, char cEnd, boolean bOperator)
Token
eatBlock(char cBegin, char cEnd, boolean bOperator, boolean bStopAtDeclarationKeyword)
protected void
eatOptionalSemiColon(boolean bEat)
void
eatTypeLiteral()
ParseTree
findAndWrapLocation(Expression oldExpr, ParsedElement newExpr)
static IMethodInfo
findMathOpMethod(IType lhsType, int op, IType rhsType)
protected ICompilableTypeInternal
getCurrentEnclosingGosuClass()
List<IType>
getCurrentlyInferringFunctionTypeVars()
int
getLineNumShift()
int
getOffsetShift()
GosuParser
getOwner()
protected IGosuClassInternal
getParsingAnonymousClass()
protected abstract String
getScript()
protected ISymbol
getUncapturedSymbol(ICompilableType gsClass, String strName)
IGosuValidator
getValidator()
boolean
isDontOptimizeStatementLists()
protected boolean
isEvalClass()
boolean
isParsingBlock()
protected boolean
match(Token T, int iType)
Possibly matches the specified token type.protected boolean
match(Token T, Keyword token)
protected boolean
match(Token T, String token)
Possibly matches the specified string token value.boolean
match(Token T, String token, int iType)
Possibly matches the specified token or name (in token).boolean
match(Token T, String token, int iType, boolean bPeek)
Possibly matches the specified token or name (in token).static boolean
matchDeclarationKeyword(String[] ret, boolean bPeek, SourceCodeTokenizer tokenizer)
protected void
parseAnnotation(List<IGosuAnnotation> annotations)
String
parseDotPathWord(String t)
Parse a dot separated path as a single logical tokenprotected Expression
peekExpression()
protected List<IType>
peekInferringFunctionTypeVariableTypes()
protected Statement
peekStatement()
protected Expression
popExpression()
protected List<IType>
popInferringFunctionTypeVariableTypes()
protected Statement
popStatement()
protected Expression
possiblyWrapWithCoercion(Expression expressionToCoerce, IType typeToCoerceTo, boolean bImplicit)
protected Expression
possiblyWrapWithImplicitCoercion(Expression expressionToCoerce, IType typeToCoerceTo)
void
pushCurrentBlock(BlockExpression block)
protected void
pushExpression(Expression e)
protected void
pushInferringFunctionTypeVars(List<IType> typeVariableTypes)
protected void
pushStatement(Statement stmt)
protected INamespaceType
resolveNamespace(String strName)
protected ISymbol
resolveNamespaceSymbol(ParsedElement e, String strName)
static IType
resolveRuntimeType(ArithmeticExpression expr, IType lhsType, int op, IType rhsType)
protected ISymbol
resolveSymbol(ParsedElement e, String strName, boolean ignoreFunctionSymbols)
protected IType
resolveType(ParsedElement parsedElement, IType lhsType, int op, IType rhsType)
static IType
resolveType(IType lhsType, int op, IType rhsType)
protected IType
resolveTypeForArithmeticExpression(ParsedElement parsedElement, IType lhsType, String op, IType rhsType)
void
setBlocks(Stack<BlockExpression> blocks)
void
setDontOptimizeStatementLists(boolean dontOptimizeStatementLists)
void
setIgnoreWarnings(Set<ResourceKey> msgKeys)
void
setLineNumShift(int lineNumShift)
protected void
setLocationForImplicitTypeAs(Expression expressionToCoerce, TypeAsExpression tas)
protected void
setOffsetShift(int offsetShift)
protected void
setOwner(GosuParser owner)
void
setSnapshotSymbols()
void
setSubTree(List<IParseTree> subTree)
void
setValidator(IGosuValidator validator)
boolean
shouldSnapshotSymbols()
protected void
verifyComparable(IType lhsType, Expression rhs)
protected void
verifyComparable(IType lhsType, Expression rhs, boolean bBiDirectional, boolean bErrorIfCoercion)
protected void
verifyComparable(IType lhsType, Expression rhs, boolean bBiDirectional, boolean bErrorIfCoercion, IParserState state)
protected void
verifyModifiersForFeature(IParsedElement pe, ModifierInfo modInfo)
void
verifyNonVoidExpression(Expression eas)
protected void
verifyParsedElement(IParsedElement element)
protected void
verifyParsedElement(IParsedElement element, boolean bThrowOnWarnings)
protected IType
verifyTypesComparable(ParsedElement element, IType lhsType, IType rhsType, boolean bBiDirectional, boolean bErrorIfCoercion)
protected IType
verifyTypesComparable(ParsedElement element, IType lhsType, IType rhsType, boolean bBiDirectional, boolean bErrorIfCoercion, IParserState state)
-
-
-
Constructor Detail
-
ParserBase
public ParserBase()
-
ParserBase
public ParserBase(GosuParser owner)
-
-
Method Detail
-
getOwner
public GosuParser getOwner()
- Specified by:
getOwner
in interfaceIParserPart
-
setOwner
protected void setOwner(GosuParser owner)
-
setIgnoreWarnings
public void setIgnoreWarnings(Set<ResourceKey> msgKeys)
-
pushExpression
protected void pushExpression(Expression e)
-
verifyParsedElement
protected void verifyParsedElement(IParsedElement element) throws ParseResultsException
- Throws:
ParseResultsException
-
verifyParsedElement
protected void verifyParsedElement(IParsedElement element, boolean bThrowOnWarnings) throws ParseResultsException
- Throws:
ParseResultsException
-
getScript
protected abstract String getScript()
-
popExpression
protected Expression popExpression()
-
peekExpression
protected Expression peekExpression()
-
pushStatement
protected void pushStatement(Statement stmt)
-
popStatement
protected Statement popStatement()
-
peekStatement
protected Statement peekStatement()
-
eatBlock
public final Token eatBlock(char cBegin, char cEnd, boolean bOperator)
-
eatBlock
public final Token eatBlock(char cBegin, char cEnd, boolean bOperator, boolean bStopAtDeclarationKeyword)
-
eatTypeLiteral
public void eatTypeLiteral()
-
parseDotPathWord
public String parseDotPathWord(String t)
Parse a dot separated path as a single logical token
-
match
protected final boolean match(Token T, String token)
Possibly matches the specified string token value. If a match occurs the token will be eaten and its information put into T (if T is not null).- Parameters:
T
- the Token object to populate iff a match is foundtoken
- the string object to match- Returns:
- true if a match occurred, and false otherwise
-
match
protected final boolean match(Token T, int iType)
Possibly matches the specified token type. If a match occurs then the token will be eaten and its information put into T (if T is not null).- Parameters:
T
- the Token object to populate iff a match is foundiType
- the token "type" to match (e.g.ISourceCodeTokenizer.TT_WORD
)- Returns:
- true if a match occurred, and false otherwise
-
match
public final boolean match(Token T, String token, int iType)
Possibly matches the specified token or name (in token). If a match occurs then the token will be eaten and its information put into T (if T is not null).- Parameters:
T
- the Token object to populate iff a match is foundtoken
- the string object to matchiType
- the token "type" to match (e.g.ISourceCodeTokenizer.TT_WORD
)- Returns:
- true if a match occurred, and false otherwise
-
match
public final boolean match(Token T, String token, int iType, boolean bPeek)
Possibly matches the specified token or name (in token). If a match occurs and bPeek is false then the token will be eaten and its information put into T (if T is not null).- Parameters:
T
- the Token object to populate iff a match is foundtoken
- the string object to matchiType
- the token "type" to match (e.g.ISourceCodeTokenizer.TT_WORD
)bPeek
- if true, a matching token will not be consumed (i.e. the stream will not advance to the next token.) if false, a matching token will be removed from the front of the stream.- Returns:
- true if a match occurred, and false otherwise
-
resolveTypeForArithmeticExpression
protected IType resolveTypeForArithmeticExpression(ParsedElement parsedElement, IType lhsType, String op, IType rhsType)
-
resolveType
protected IType resolveType(ParsedElement parsedElement, IType lhsType, int op, IType rhsType)
-
resolveRuntimeType
public static IType resolveRuntimeType(ArithmeticExpression expr, IType lhsType, int op, IType rhsType)
-
findMathOpMethod
public static IMethodInfo findMathOpMethod(IType lhsType, int op, IType rhsType)
-
resolveSymbol
protected ISymbol resolveSymbol(ParsedElement e, String strName, boolean ignoreFunctionSymbols)
-
resolveNamespaceSymbol
protected ISymbol resolveNamespaceSymbol(ParsedElement e, String strName)
-
resolveNamespace
protected INamespaceType resolveNamespace(String strName)
-
captureAllSymbols
protected void captureAllSymbols(ICompilableTypeInternal anonClass, ICompilableTypeInternal enclosingClass, List<ICapturedSymbol> capturedSymbols)
-
captureSymbol
protected ISymbol captureSymbol(ICompilableTypeInternal anonClass, String strName, ParsedElement e)
-
getUncapturedSymbol
protected ISymbol getUncapturedSymbol(ICompilableType gsClass, String strName)
-
isEvalClass
protected boolean isEvalClass()
-
verifyComparable
protected void verifyComparable(IType lhsType, Expression rhs)
-
verifyComparable
protected void verifyComparable(IType lhsType, Expression rhs, boolean bBiDirectional, boolean bErrorIfCoercion)
-
verifyComparable
protected void verifyComparable(IType lhsType, Expression rhs, boolean bBiDirectional, boolean bErrorIfCoercion, IParserState state)
-
verifyTypesComparable
protected IType verifyTypesComparable(ParsedElement element, IType lhsType, IType rhsType, boolean bBiDirectional, boolean bErrorIfCoercion)
-
verifyTypesComparable
protected IType verifyTypesComparable(ParsedElement element, IType lhsType, IType rhsType, boolean bBiDirectional, boolean bErrorIfCoercion, IParserState state)
-
verifyNonVoidExpression
public void verifyNonVoidExpression(Expression eas)
-
eatOptionalSemiColon
protected void eatOptionalSemiColon(boolean bEat)
-
parseAnnotation
protected void parseAnnotation(List<IGosuAnnotation> annotations)
-
verifyModifiersForFeature
protected void verifyModifiersForFeature(IParsedElement pe, ModifierInfo modInfo)
-
setDontOptimizeStatementLists
public void setDontOptimizeStatementLists(boolean dontOptimizeStatementLists)
- Specified by:
setDontOptimizeStatementLists
in interfaceIParserPart
-
isDontOptimizeStatementLists
public boolean isDontOptimizeStatementLists()
- Specified by:
isDontOptimizeStatementLists
in interfaceIParserPart
-
setSubTree
public void setSubTree(List<IParseTree> subTree)
-
setBlocks
public void setBlocks(Stack<BlockExpression> blocks)
-
pushCurrentBlock
public void pushCurrentBlock(BlockExpression block)
-
addBlockToBlockStack
public void addBlockToBlockStack(BlockExpression block)
-
getCurrentEnclosingGosuClass
protected ICompilableTypeInternal getCurrentEnclosingGosuClass()
-
isParsingBlock
public boolean isParsingBlock()
-
copyBlockStackTo
protected void copyBlockStackTo(ParserBase otherParser)
-
getParsingAnonymousClass
protected IGosuClassInternal getParsingAnonymousClass()
-
possiblyWrapWithImplicitCoercion
protected Expression possiblyWrapWithImplicitCoercion(Expression expressionToCoerce, IType typeToCoerceTo)
-
possiblyWrapWithCoercion
protected Expression possiblyWrapWithCoercion(Expression expressionToCoerce, IType typeToCoerceTo, boolean bImplicit)
-
setLocationForImplicitTypeAs
protected void setLocationForImplicitTypeAs(Expression expressionToCoerce, TypeAsExpression tas)
-
findAndWrapLocation
public ParseTree findAndWrapLocation(Expression oldExpr, ParsedElement newExpr)
-
setValidator
public void setValidator(IGosuValidator validator)
- Specified by:
setValidator
in interfaceIParserPart
-
getValidator
public IGosuValidator getValidator()
-
setOffsetShift
protected void setOffsetShift(int offsetShift)
-
setLineNumShift
public void setLineNumShift(int lineNumShift)
- Specified by:
setLineNumShift
in interfaceIParserPart
-
getLineNumShift
public int getLineNumShift()
- Specified by:
getLineNumShift
in interfaceIParserPart
-
getOffsetShift
public int getOffsetShift()
- Specified by:
getOffsetShift
in interfaceIParserPart
-
pushInferringFunctionTypeVars
protected void pushInferringFunctionTypeVars(List<IType> typeVariableTypes)
-
peekInferringFunctionTypeVariableTypes
protected List<IType> peekInferringFunctionTypeVariableTypes()
-
matchDeclarationKeyword
public static boolean matchDeclarationKeyword(String[] ret, boolean bPeek, SourceCodeTokenizer tokenizer)
-
shouldSnapshotSymbols
public boolean shouldSnapshotSymbols()
-
setSnapshotSymbols
public void setSnapshotSymbols()
-
-