Class LL1Analyzer

java.lang.Object
org.antlr.v4.runtime.atn.LL1Analyzer

public class LL1Analyzer extends Object
  • Field Details

    • HIT_PRED

      public static final int HIT_PRED
      Special value added to the lookahead sets to indicate that we hit a predicate during analysis if seeThruPreds==false.
      See Also:
    • atn

      public final ATN atn
  • Constructor Details

    • LL1Analyzer

      public LL1Analyzer(ATN atn)
  • Method Details

    • getDecisionLookahead

      public IntervalSet[] getDecisionLookahead(ATNState s)
      Calculates the SLL(1) expected lookahead set for each outgoing transition of an ATNState. The returned array has one element for each outgoing transition in s. If the closure from transition i leads to a semantic predicate before matching a symbol, the element at index i of the result will be null.
      Parameters:
      s - the ATN state
      Returns:
      the expected symbols for each outgoing transition of s.
    • LOOK

      public IntervalSet LOOK(ATNState s, RuleContext ctx)
      Compute set of tokens that can follow s in the ATN in the specified ctx.

      If ctx is null and the end of the rule containing s is reached, Token.EPSILON is added to the result set. If ctx is not null and the end of the outermost rule is reached, Token.EOF is added to the result set.

      Parameters:
      s - the ATN state
      ctx - the complete parser context, or null if the context should be ignored
      Returns:
      The set of tokens that can follow s in the ATN in the specified ctx.
    • LOOK

      public IntervalSet LOOK(ATNState s, ATNState stopState, RuleContext ctx)
      Compute set of tokens that can follow s in the ATN in the specified ctx.

      If ctx is null and the end of the rule containing s is reached, Token.EPSILON is added to the result set. If ctx is not null and the end of the outermost rule is reached, Token.EOF is added to the result set.

      Parameters:
      s - the ATN state
      stopState - the ATN state to stop at. This can be a BlockEndState to detect epsilon paths through a closure.
      ctx - the complete parser context, or null if the context should be ignored
      Returns:
      The set of tokens that can follow s in the ATN in the specified ctx.
    • _LOOK

      protected void _LOOK(ATNState s, ATNState stopState, PredictionContext ctx, IntervalSet look, Set<ATNConfig> lookBusy, BitSet calledRuleStack, boolean seeThruPreds, boolean addEOF)
      Compute set of tokens that can follow s in the ATN in the specified ctx.

      If ctx is null and stopState or the end of the rule containing s is reached, Token.EPSILON is added to the result set. If ctx is not null and addEOF is true and stopState or the end of the outermost rule is reached, Token.EOF is added to the result set.

      Parameters:
      s - the ATN state.
      stopState - the ATN state to stop at. This can be a BlockEndState to detect epsilon paths through a closure.
      ctx - The outer context, or null if the outer context should not be used.
      look - The result lookahead set.
      lookBusy - A set used for preventing epsilon closures in the ATN from causing a stack overflow. Outside code should pass new HashSet<ATNConfig> for this argument.
      calledRuleStack - A set used for preventing left recursion in the ATN from causing a stack overflow. Outside code should pass new BitSet() for this argument.
      seeThruPreds - true to true semantic predicates as implicitly true and "see through them", otherwise false to treat semantic predicates as opaque and add HIT_PRED to the result if one is encountered.
      addEOF - Add Token.EOF to the result if the end of the outermost context is reached. This parameter has no effect if ctx is null.