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 Details

    • EMPTY_ARRAY

      private static final Object[] EMPTY_ARRAY
    • PLACEHOLDER_PARSER_STATE

      private static final IParserState PLACEHOLDER_PARSER_STATE
    • PROGRAM_NAMESPACE

      private static final INamespaceType PROGRAM_NAMESPACE
    • _snapshotSymbols

      private boolean _snapshotSymbols
    • _owner

      private GosuParser _owner
    • _blocks

    • _validator

      private IGosuValidator _validator
    • _offsetShift

      protected int _offsetShift
    • _lineNumShift

      private int _lineNumShift
    • _bDontOptimizeStatementLists

      protected boolean _bDontOptimizeStatementLists
    • _subTree

      private List<IParseTree> _subTree
    • _inferringFunctionTypes

      private Stack<List<IType>> _inferringFunctionTypes
    • NOT_SET_EXPRESSION

      private static final NotAWordExpression NOT_SET_EXPRESSION
    • _ignoreWarnings

      private Set<ResourceKey> _ignoreWarnings
  • Constructor Details

    • ParserBase

      public ParserBase()
    • ParserBase

      public ParserBase(GosuParser owner)
  • Method Details

    • getOwner

      public GosuParser getOwner()
      Specified by:
      getOwner in interface IParserPart
    • setOwner

      protected void setOwner(GosuParser owner)
    • setIgnoreWarnings

      public void setIgnoreWarnings(Set<ResourceKey> msgKeys)
    • getTokenizer

      SourceCodeTokenizer getTokenizer()
    • getSymbolTable

      ISymbolTable getSymbolTable()
    • setLocation

      void setLocation(int iOffset, int iLineNum, int iColumn)
    • setLocation

      void setLocation(int iOffset, int iLineNum, int iColumn, boolean bForceRedundancy)
    • setLocation

      void setLocation(int iOffset, int iLineNum, int iColumn, boolean bZeroLength, boolean bForceRedundancy)
    • addLocation

      private ParseTree addLocation(ParseTree location, boolean bForceRedundancy)
    • getLocationsList

      List<ParseTree> getLocationsList()
    • 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()
    • eatStatementBlock

      boolean eatStatementBlock(ParsedElement parsedElement, ResourceKey errorKey)
    • eatPossibleStatementBlock

      boolean eatPossibleStatementBlock()
    • eatPossibleEnclosedVarInStmt

      boolean eatPossibleEnclosedVarInStmt()
    • eatParenthesized

      void eatParenthesized(ParsedElement parsedElement, ResourceKey errorKey)
    • eatPossibleParametarization

      void eatPossibleParametarization()
    • eatPossibleParametarization

      void eatPossibleParametarization(boolean bMatchStart)
    • eatPossibleArrayBrackets

      void eatPossibleArrayBrackets()
    • eatPossibleArrayBrackets

      void eatPossibleArrayBrackets(boolean bMatchStart)
    • 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 found
      token - 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 found
      iType - 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 found
      token - the string object to match
      iType - 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 found
      token - the string object to match
      iType - 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
    • isWordOrValueKeyword

      final boolean isWordOrValueKeyword(Token T)
    • match

      protected final boolean match(Token T, Keyword token)
    • match

      final boolean match(Token T, Keyword keyword, boolean bPeek)
    • addError

      final void addError(ParsedElement parsedElement, ResourceKey errorMsg, Object... args)
    • addError

      final void addError(ParsedElement parsedElement, ResourceKey errorMsg)
    • verify

      final boolean verify(ParsedElement parsedElement, boolean bExpression, ResourceKey errorMesg, String arg0)
    • verify

      final boolean verify(ParsedElement parsedElement, boolean bExpression, ResourceKey errorMesg, String... args)
    • verify

      final boolean verify(ParsedElement parsedElement, boolean bExpression, ResourceKey errorMesg, Object... args)
    • verify

      final boolean verify(ParsedElement parsedElement, boolean bExpression, IParserState parserState, ResourceKey errorMesg, Object... args)
    • verify

      final boolean verify(ParsedElement parsedElement, boolean bExpression, boolean bNextTokenIfException, ResourceKey errorMesg, Object... args)
    • verify

      boolean verify(ParsedElement parsedElement, boolean bExpression, boolean bNextTokenIfException, IParserState parserState, ResourceKey errorMesg, Object... args)
    • warn

      final boolean warn(ParsedElement target, boolean bExpression, ResourceKey err, Object... args)
    • warn

      final boolean warn(ParsedElement target, boolean bExpression, IParserState state, ResourceKey err, Object... args)
    • verifyOrWarn

      final boolean verifyOrWarn(ParsedElement target, boolean bExpression, boolean bWarning, ResourceKey err, Object... args)
    • verify

      private boolean verify(ParsedElement parsedElement, boolean bExpression, boolean bNextTokenIfException, boolean bWarning, IParserState parserState, ResourceKey errorMesg, Object... args)
    • advanceToNextTokenSilently

      final void advanceToNextTokenSilently()
    • makeFullParserState

      final IFullParserState makeFullParserState()
      Returns:
      a full parser state, which includes symbol table information, a clone of the tokenizer and everything else
    • makeFullParserStateWithSymbols

      final IFullParserState makeFullParserStateWithSymbols()
      Returns:
      a full parser state, which includes symbol table information, a clone of the tokenizer and everything else
    • makeLightweightParserState

      final LightweightParserState makeLightweightParserState()
      Returns:
      a lightweight parser state, which includes *only* the offset information of the parser, and no symbol information or a tokenizer state.
    • makeLazyLightweightParserState

      final LazyLightweightParserState makeLazyLightweightParserState()
    • resolveTypeForArithmeticExpression

      protected IType resolveTypeForArithmeticExpression(ParsedElement parsedElement, IType lhsType, String op, IType rhsType)
    • resolveType

      protected IType resolveType(ParsedElement parsedElement, IType lhsType, int op, IType rhsType)
    • isNonFinalDimension

      private static boolean isNonFinalDimension(IType type)
    • resolveRuntimeType

      public static IType resolveRuntimeType(ArithmeticExpression expr, IType lhsType, int op, IType rhsType)
    • resolveType

      public static IType resolveType(IType lhsType, int op, IType rhsType)
    • handleBoxedAndPrimitiveTypes

      private static IType handleBoxedAndPrimitiveTypes(IType lhsType, IType rhsType)
    • makeBoxedTypeIfEitherOperandIsBoxed

      private static IType makeBoxedTypeIfEitherOperandIsBoxed(IType lhsType, IType rhsType, IType retType)
    • resolveIfDimensionOperand

      private static IType resolveIfDimensionOperand(ParserBase parser, ParsedElement parsedElement, IType lhsType, int op, IType rhsType)
    • assertBoxedOrBigNumber

      private static boolean assertBoxedOrBigNumber(ParserBase parser, ParsedElement parsedElement, IType rhsType, int op)
    • isFinalDimension

      static boolean isFinalDimension(ParserBase parser, IType lhsType, ParsedElement pe)
    • getAndAssignOperatorOverloader

      private static IType getAndAssignOperatorOverloader(IType lhsType, IType rhsType, int op, ParsedElement parsedElement)
    • findMathOpMethod

      public static IMethodInfo findMathOpMethod(IType lhsType, int op, IType rhsType)
    • resolveSymbol

      protected ISymbol resolveSymbol(ParsedElement e, String strName, boolean ignoreFunctionSymbols)
    • handleForwardReference

      private ISymbol handleForwardReference(ParsedElement e, ISymbol sym)
    • isOrIsEnclosedByAnonymousClass

      boolean isOrIsEnclosedByAnonymousClass(ICompilableType type)
    • resolveNamespaceSymbol

      protected ISymbol resolveNamespaceSymbol(ParsedElement e, String strName)
    • maybeAddLocalsOfEnclosingType

      private void maybeAddLocalsOfEnclosingType()
    • 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)
    • warnOnPcfVariablesHack

      private void warnOnPcfVariablesHack(ParsedElement e, ISymbol sym)
    • getScope

      private IScope getScope(ICompilableType anonClass)
    • resolveForNullEnclosingClass

      private ISymbol resolveForNullEnclosingClass(String strName)
    • getUncapturedSymbol

      protected ISymbol getUncapturedSymbol(ICompilableType gsClass, String strName)
    • getSymbolTableForClass

      private ISymbolTable getSymbolTableForClass(ICompilableType gsClass)
    • findSymbol

      private ISymbol findSymbol(String strName, boolean ignoreFunctionSymbols)
    • findSymbol

      private ISymbol findSymbol(String strName, ISymbolTable symTable, boolean ignoreFunctionSymbols)
    • 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)
    • getGosuClass

      ICompilableTypeInternal getGosuClass()
    • getClassStatement

      ClassStatement getClassStatement()
    • parseModifiers

      ModifierInfo parseModifiers()
    • parseModifiers

      ModifierInfo parseModifiers(boolean bIgnoreErrors)
    • maybeAddJavadocDeprecatedModifier

      private int maybeAddJavadocDeprecatedModifier(int iModifiers, List<IGosuAnnotation> annotations)
    • pushModifierList

      void pushModifierList(int iOffsetList, int iLineNumList, int iColumnList)
    • eatOptionalSemiColon

      protected void eatOptionalSemiColon(boolean bEat)
    • parseAnnotation

      protected void parseAnnotation(List<IGosuAnnotation> annotations)
    • parseAnnotationUseSiteTarget

      private AnnotationUseSiteTargetClause parseAnnotationUseSiteTarget()
    • maybeVerifyAnnotationArgs

      private void maybeVerifyAnnotationArgs(Expression e)
    • verifyModifiers

      void verifyModifiers(IParsedElement pe, ModifierInfo modInfo, UsageTarget targetType)
    • verifyModifiersForFeature

      protected void verifyModifiersForFeature(IParsedElement pe, ModifierInfo modInfo)
    • verifyAnnotations

      void verifyAnnotations(IParsedElement pe, ModifierInfo modInfo, UsageTarget targetType)
    • verifyNoAbstractHideOverrideStaticModifierDefined

      void verifyNoAbstractHideOverrideStaticModifierDefined(ParsedElement elem, boolean bIgnoreErrors, int modifier, Keyword kw)
    • verifyNoAbstractHideOverrideStaticModifierDefined

      void verifyNoAbstractHideOverrideStaticModifierDefined(ParsedElement elem, boolean bIgnoreErrors, int modifier, Keyword kw, boolean alreadyMatched)
    • verifyNoHideOverrideStaticModifierDefined

      void verifyNoHideOverrideStaticModifierDefined(ParsedElement elem, boolean bIgnoreErrors, int modifier, Keyword kw)
    • verifyNoAbstractHideStaticModifierDefined

      void verifyNoAbstractHideStaticModifierDefined(ParsedElement elem, boolean bIgnoreErrors, int modifier, Keyword kw, boolean alreadyMatched)
    • verifyNoAccessibilityModifierDefined

      void verifyNoAccessibilityModifierDefined(ParsedElement elem, boolean bIgnoreErrors, int modifier, Keyword kw)
    • verifyNoAbstractHideOverrideModifierDefined

      void verifyNoAbstractHideOverrideModifierDefined(ParsedElement elem, boolean bIgnoreErrors, int modifier, Keyword kw)
    • verifyNoHideOverrideModifierDefined

      void verifyNoHideOverrideModifierDefined(ParsedElement elem, boolean bIgnoreErrors, int modifier, Keyword kw)
    • verifyNoCombinedPrivateAbstract

      void verifyNoCombinedPrivateAbstract(ParsedElement elem, boolean bIgnoreErrors, int modifier)
    • verifyNoCombinedFinalPrivateModifierDefined

      void verifyNoCombinedFinalPrivateModifierDefined(ParsedElement elem, boolean bIgnoreErrors, int modifier)
    • verifyNoCombinedFinalStaticModifierDefined

      void verifyNoCombinedFinalStaticModifierDefined(ParsedElement elem, boolean bIgnoreErrors, int modifier)
    • setDontOptimizeStatementLists

      public void setDontOptimizeStatementLists(boolean dontOptimizeStatementLists)
      Specified by:
      setDontOptimizeStatementLists in interface IParserPart
    • isDontOptimizeStatementLists

      public boolean isDontOptimizeStatementLists()
      Specified by:
      isDontOptimizeStatementLists in interface IParserPart
    • 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()
    • getOuterFromScriptPartStack

      private ICompilableTypeInternal getOuterFromScriptPartStack()
    • popCurrentBlock

      void popCurrentBlock()
    • 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)
    • verifyTypeVarAreReified

      void verifyTypeVarAreReified(Expression expr, IType rhsType)
    • isTypeVarInReifiedContext

      boolean isTypeVarInReifiedContext(Expression expr, ITypeVariableType typeVarType)
    • setLocationForImplicitTypeAs

      protected void setLocationForImplicitTypeAs(Expression expressionToCoerce, TypeAsExpression tas)
    • findAndWrapLocation

      public ParseTree findAndWrapLocation(Expression oldExpr, ParsedElement newExpr)
    • popLastComment

      private DocCommentBlock popLastComment()
    • setValidator

      public void setValidator(IGosuValidator validator)
      Specified by:
      setValidator in interface IParserPart
    • getValidator

      public IGosuValidator getValidator()
    • setOffsetShift

      protected void setOffsetShift(int offsetShift)
    • setLineNumShift

      public void setLineNumShift(int lineNumShift)
      Specified by:
      setLineNumShift in interface IParserPart
    • getLineNumShift

      public int getLineNumShift()
      Specified by:
      getLineNumShift in interface IParserPart
    • getOffsetShift

      public int getOffsetShift()
      Specified by:
      getOffsetShift in interface IParserPart
    • pushInferringFunctionTypeVars

      protected void pushInferringFunctionTypeVars(List<IType> typeVariableTypes)
    • popInferringFunctionTypeVariableTypes

      protected List<IType> popInferringFunctionTypeVariableTypes()
    • peekInferringFunctionTypeVariableTypes

      protected List<IType> peekInferringFunctionTypeVariableTypes()
    • getCurrentlyInferringFunctionTypeVars

      public List<IType> getCurrentlyInferringFunctionTypeVars()
    • matchDeclarationKeyword

      public static boolean matchDeclarationKeyword(String[] ret, boolean bPeek, SourceCodeTokenizer tokenizer)
    • shouldSnapshotSymbols

      public boolean shouldSnapshotSymbols()
    • setSnapshotSymbols

      public void setSnapshotSymbols()