Class SuitableGenusOrError

java.lang.Object
org.ek9lang.compiler.common.RuleSupport
org.ek9lang.compiler.common.SuitableGenusOrError
All Implemented Interfaces:
Function<org.antlr.v4.runtime.ParserRuleContext, Optional<ISymbol>>

public final class SuitableGenusOrError extends RuleSupport implements Function<org.antlr.v4.runtime.ParserRuleContext, Optional<ISymbol>>
Checks for a type is resolved and is suitable genus and category. THE genus check for a resolved type: the phase 2 extension, application and registration checks use it, and so does phase 3's check of the type a 'register' statement constructs (validOrError(ParserRuleContext, ISymbol)).
  • Constructor Details

    • SuitableGenusOrError

      public SuitableGenusOrError(SymbolsAndScopes symbolsAndScopes, ErrorListener errorListener, SymbolGenus genus, boolean allowTemplates, boolean issueErrorIfNotResolved)
      Checks that the typedef/identifierReference passed in (when resolved) is suitable genus.
    • SuitableGenusOrError

      public SuitableGenusOrError(SymbolsAndScopes symbolsAndScopes, ErrorListener errorListener, List<SymbolGenus> genus, boolean allowTemplates, boolean issueErrorIfNotResolved)
      Checks that the typedef/identifierReference passed in (when resolved) is suitable genus. Accepts multiple allowed genus. i.e. FUNCTION and FUNCTION_TRAIT.
  • Method Details

    • apply

      public Optional<ISymbol> apply(org.antlr.v4.runtime.ParserRuleContext ctx)
      Specified by:
      apply in interface Function<org.antlr.v4.runtime.ParserRuleContext, Optional<ISymbol>>
    • validOrError

      public boolean validOrError(org.antlr.v4.runtime.ParserRuleContext ctx, ISymbol symbol)
      Checks a symbol that is already in hand (for example the type a call constructs), reporting at ctx.
      Returns:
      true when the symbol is resolved and of a supported genus and category.