fix bison generation bug when nonterminal has no productions
@@ -206,16 +206,19 @@ public class KSyntax2Bison {
encode(start, bison);
bison.append(" { result = $1.nterm; } ;\n");
for (Sort sort : reachableSorts) {
+ List<Production> prodsForSort = Optional.ofNullable(prods.get(sort)).orElse(java.util.Collections.emptyList());
+ if (!prodsForSort.isEmpty()) {
encode(sort, bison);
bison.append(":\n");
String conn = "";
- for (Production prod : Optional.ofNullable(prods.get(sort)).orElse(java.util.Collections.emptyList())) {
+ for (Production prod : prodsForSort) {
bison.append(" " + conn);
processProduction(prod, module, disambModule, scanner, bison, glr);
conn = "|";
}
bison.append(";\n");
}
+ }
bison.append("\n%%\n");
bison.append("\n" +
"void yyerror (YYLTYPE *loc, void *scanner, const char *s) {\n" +
