예제 #1
0
 private Expr buildLookaheadWithAmountCondition(
     String symbol,
     GExpansion expansion,
     int amount,
     NodeList<FormalParameter> params,
     NodeList<Expr> args) {
   String matchMethodName = "match" + symbol + "_lookahead" + incrementCount(symbol);
   NodeList<Stmt> stmts =
       buildLookaheadWithAmountCondition(
           Collections.singletonList(expansion.location()), 0, amount, params, args);
   stmts = stmts.append(returnStmt().withExpr(FAILED_LOOKAHEAD));
   createMatchMethod(symbol, matchMethodName, expansion, stmts, emptyList());
   return binaryExpr(
       matchMethodCall(matchMethodName, literalExpr(0), emptyList()),
       BinaryOp.NotEqual,
       FAILED_LOOKAHEAD);
 }
예제 #2
0
 private List<String> firstTerminalsOf(GExpansion expansion) {
   GContinuations c = new GContinuations(expansion.location(), productions, false);
   c.next();
   return c.terminals();
 }