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_bDontOptimizeStatementListsprotected 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 voidaddBlockToBlockStack(BlockExpression block)protected voidcaptureAllSymbols(ICompilableTypeInternal anonClass, ICompilableTypeInternal enclosingClass, List<ICapturedSymbol> capturedSymbols)protected ISymbolcaptureSymbol(ICompilableTypeInternal anonClass, String strName, ParsedElement e)protected voidcopyBlockStackTo(ParserBase otherParser)TokeneatBlock(char cBegin, char cEnd, boolean bOperator)TokeneatBlock(char cBegin, char cEnd, boolean bOperator, boolean bStopAtDeclarationKeyword)protected voideatOptionalSemiColon(boolean bEat)voideatTypeLiteral()ParseTreefindAndWrapLocation(Expression oldExpr, ParsedElement newExpr)static IMethodInfofindMathOpMethod(IType lhsType, int op, IType rhsType)protected ICompilableTypeInternalgetCurrentEnclosingGosuClass()List<IType>getCurrentlyInferringFunctionTypeVars()intgetLineNumShift()intgetOffsetShift()GosuParsergetOwner()protected IGosuClassInternalgetParsingAnonymousClass()protected abstract StringgetScript()protected ISymbolgetUncapturedSymbol(ICompilableType gsClass, String strName)IGosuValidatorgetValidator()booleanisDontOptimizeStatementLists()protected booleanisEvalClass()booleanisParsingBlock()protected booleanmatch(Token T, int iType)Possibly matches the specified token type.protected booleanmatch(Token T, Keyword token)protected booleanmatch(Token T, String token)Possibly matches the specified string token value.booleanmatch(Token T, String token, int iType)Possibly matches the specified token or name (in token).booleanmatch(Token T, String token, int iType, boolean bPeek)Possibly matches the specified token or name (in token).static booleanmatchDeclarationKeyword(String[] ret, boolean bPeek, SourceCodeTokenizer tokenizer)protected voidparseAnnotation(List<IGosuAnnotation> annotations)StringparseDotPathWord(String t)Parse a dot separated path as a single logical tokenprotected ExpressionpeekExpression()protected List<IType>peekInferringFunctionTypeVariableTypes()protected StatementpeekStatement()protected ExpressionpopExpression()protected List<IType>popInferringFunctionTypeVariableTypes()protected StatementpopStatement()protected ExpressionpossiblyWrapWithCoercion(Expression expressionToCoerce, IType typeToCoerceTo, boolean bImplicit)protected ExpressionpossiblyWrapWithImplicitCoercion(Expression expressionToCoerce, IType typeToCoerceTo)voidpushCurrentBlock(BlockExpression block)protected voidpushExpression(Expression e)protected voidpushInferringFunctionTypeVars(List<IType> typeVariableTypes)protected voidpushStatement(Statement stmt)protected INamespaceTyperesolveNamespace(String strName)protected ISymbolresolveNamespaceSymbol(ParsedElement e, String strName)static ITyperesolveRuntimeType(ArithmeticExpression expr, IType lhsType, int op, IType rhsType)protected ISymbolresolveSymbol(ParsedElement e, String strName, boolean ignoreFunctionSymbols)protected ITyperesolveType(ParsedElement parsedElement, IType lhsType, int op, IType rhsType)static ITyperesolveType(IType lhsType, int op, IType rhsType)protected ITyperesolveTypeForArithmeticExpression(ParsedElement parsedElement, IType lhsType, String op, IType rhsType)voidsetBlocks(Stack<BlockExpression> blocks)voidsetDontOptimizeStatementLists(boolean dontOptimizeStatementLists)voidsetIgnoreWarnings(Set<ResourceKey> msgKeys)voidsetLineNumShift(int lineNumShift)protected voidsetLocationForImplicitTypeAs(Expression expressionToCoerce, TypeAsExpression tas)protected voidsetOffsetShift(int offsetShift)protected voidsetOwner(GosuParser owner)voidsetSnapshotSymbols()voidsetSubTree(List<IParseTree> subTree)voidsetValidator(IGosuValidator validator)booleanshouldSnapshotSymbols()protected voidverifyComparable(IType lhsType, Expression rhs)protected voidverifyComparable(IType lhsType, Expression rhs, boolean bBiDirectional, boolean bErrorIfCoercion)protected voidverifyComparable(IType lhsType, Expression rhs, boolean bBiDirectional, boolean bErrorIfCoercion, IParserState state)protected voidverifyModifiersForFeature(IParsedElement pe, ModifierInfo modInfo)voidverifyNonVoidExpression(Expression eas)protected voidverifyParsedElement(IParsedElement element)protected voidverifyParsedElement(IParsedElement element, boolean bThrowOnWarnings)protected ITypeverifyTypesComparable(ParsedElement element, IType lhsType, IType rhsType, boolean bBiDirectional, boolean bErrorIfCoercion)protected ITypeverifyTypesComparable(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:
getOwnerin 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:
setDontOptimizeStatementListsin interfaceIParserPart
-
isDontOptimizeStatementLists
public boolean isDontOptimizeStatementLists()
- Specified by:
isDontOptimizeStatementListsin 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:
setValidatorin interfaceIParserPart
-
getValidator
public IGosuValidator getValidator()
-
setOffsetShift
protected void setOffsetShift(int offsetShift)
-
setLineNumShift
public void setLineNumShift(int lineNumShift)
- Specified by:
setLineNumShiftin interfaceIParserPart
-
getLineNumShift
public int getLineNumShift()
- Specified by:
getLineNumShiftin interfaceIParserPart
-
getOffsetShift
public int getOffsetShift()
- Specified by:
getOffsetShiftin 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()
-
-