diff --git a/src/main/java/org/sablecc/sablecc/GenerateAlternativeCodeForParser.java b/src/main/java/org/sablecc/sablecc/GenerateAlternativeCodeForParser.java index d350a2c5887c4dbc7304cf7b3f21a6fb62dbb775..ee69c03467621bbd03f391e310962535b925e412 100644 --- a/src/main/java/org/sablecc/sablecc/GenerateAlternativeCodeForParser.java +++ b/src/main/java/org/sablecc/sablecc/GenerateAlternativeCodeForParser.java @@ -80,7 +80,7 @@ public class GenerateAlternativeCodeForParser extends DepthFirstAdapter { if("null".equals(typeName)) { - throw new IllegalArgumentException("Null values have no variable name"); + return "null"; } else if(typeName.startsWith("L")) { @@ -156,15 +156,7 @@ public class GenerateAlternativeCodeForParser extends DepthFirstAdapter position = CG.getTermNumbers().get(term); - if("null".equals(type_name)) - { - macros.apply(file, "ParserNewBodyListAddNull", null); - } - else - { - macros.apply(file, "ParserNewBodyListAdd", new String[] {getVariableName(type_name, position)}); - } - + macros.apply(file, "ParserNewBodyListAdd", new String[] {getVariableName(type_name, position)}); } if (popCount > 0) { // The nodeArrayList variables are numbered starting at 1, so the first popped variable has the number popCount and not popCount-1. @@ -344,14 +336,7 @@ public class GenerateAlternativeCodeForParser extends DepthFirstAdapter type_name = lookupInternalTypeName(term); position = CG.getTermNumbers().get(term); - if(type_name.equals("null")) - { - macros.apply(file, "ParserNewBodyParam", new String[] {isNotTheFirstParam+"null"}); - } - else - { - macros.apply(file, "ParserNewBodyParam", new String[] {isNotTheFirstParam + getVariableName(type_name, position)}); - } + macros.apply(file, "ParserNewBodyParam", new String[] {isNotTheFirstParam + getVariableName(type_name, position)}); isNotTheFirstParam = ", "; } diff --git a/src/main/resources/org/sablecc/sablecc/parser.txt b/src/main/resources/org/sablecc/sablecc/parser.txt index 82811fe1b5b2987846edbb15724dd62db49832a2..ea838eadbbcd32735cd976f7ba7142d24beb6169 100644 --- a/src/main/resources/org/sablecc/sablecc/parser.txt +++ b/src/main/resources/org/sablecc/sablecc/parser.txt @@ -386,11 +386,6 @@ Macro:ParserNewBodyListAdd $ -Macro:ParserNewBodyListAddNull - nodeList.add(null); - -$ - Macro:ParserNewCheck checkResult(nodeList.get(0), nodeArrayList1, nodeArrayList$0$);