Exemplo n.º 1
0
 /**
  * Build what amounts to an epsilon transition with a semantic predicate action. The pred is a
  * pointer into the AST of the SEMPRED token.
  */
 public Handle sempred(PredAST pred) {
   // System.out.println("sempred: "+ pred);
   ATNState left = newState(pred);
   ATNState right = newState(pred);
   boolean isCtxDependent = UseDefAnalyzer.actionIsContextDependent(pred);
   PredicateTransition p =
       new PredicateTransition(right, currentRule.index, g.sempreds.get(pred), isCtxDependent);
   left.addTransition(p);
   pred.atnState = left;
   return new Handle(left, right);
 }
Exemplo n.º 2
0
  /**
   * Build what amounts to an epsilon transition with a semantic predicate action. The {@code pred}
   * is a pointer into the AST of the {@link ANTLRParser#SEMPRED} token.
   */
  @Override
  public Handle sempred(PredAST pred) {
    // System.out.println("sempred: "+ pred);
    ATNState left = newState(pred);
    ATNState right = newState(pred);

    AbstractPredicateTransition p;
    if (pred.getOptionString(LeftRecursiveRuleTransformer.PRECEDENCE_OPTION_NAME) != null) {
      int precedence =
          Integer.parseInt(
              pred.getOptionString(LeftRecursiveRuleTransformer.PRECEDENCE_OPTION_NAME));
      p = new PrecedencePredicateTransition(right, precedence);
    } else {
      boolean isCtxDependent = UseDefAnalyzer.actionIsContextDependent(pred);
      p = new PredicateTransition(right, currentRule.index, g.sempreds.get(pred), isCtxDependent);
    }

    left.addTransition(p);
    pred.atnState = left;
    return new Handle(left, right);
  }