diff --git a/src/main/java/org/sablecc/sablecc/parser/Parser.java b/src/main/java/org/sablecc/sablecc/parser/Parser.java index 941b84c3139e9b7ab236ea8e8860ae754a997b85..2b34a7db99cba9bc03912478c12e6ed29ea5fee2 100644 --- a/src/main/java/org/sablecc/sablecc/parser/Parser.java +++ b/src/main/java/org/sablecc/sablecc/parser/Parser.java @@ -5562,13 +5562,10 @@ public class Parser implements IParser { listNode3.add(tpkgidNode1); } - if(listNode2 != null) - { - if (listNode3.isEmpty() && listNode2 instanceof LinkedList<?>) { - listNode3 = listNode2; - } else { - listNode3.addAll(listNode2); - } + if (listNode3.isEmpty() && listNode2 instanceof LinkedList<?>) { + listNode3 = listNode2; + } else { + listNode3.addAll(listNode2); } } nodeList.add(listNode3); @@ -5705,13 +5702,10 @@ public class Parser implements IParser { listNode3.add(tidNode1); } - if(listNode2 != null) - { - if (listNode3.isEmpty() && listNode2 instanceof LinkedList<?>) { - listNode3 = listNode2; - } else { - listNode3.addAll(listNode2); - } + if (listNode3.isEmpty() && listNode2 instanceof LinkedList<?>) { + listNode3 = listNode2; + } else { + listNode3.addAll(listNode2); } } nodeList.add(listNode3); @@ -6146,13 +6140,10 @@ public class Parser implements IParser { listNode4.add(pconcatNode2); } - if(listNode3 != null) - { - if (listNode4.isEmpty() && listNode3 instanceof LinkedList<?>) { - listNode4 = listNode3; - } else { - listNode4.addAll(listNode3); - } + if (listNode4.isEmpty() && listNode3 instanceof LinkedList<?>) { + listNode4 = listNode3; + } else { + listNode4.addAll(listNode3); } } @@ -6719,13 +6710,10 @@ public class Parser implements IParser { listNode3.add(paltNode1); } - if(listNode2 != null) - { - if (listNode3.isEmpty() && listNode2 instanceof LinkedList<?>) { - listNode3 = listNode2; - } else { - listNode3.addAll(listNode2); - } + if (listNode3.isEmpty() && listNode2 instanceof LinkedList<?>) { + listNode3 = listNode2; + } else { + listNode3.addAll(listNode2); } } nodeList.add(listNode3); @@ -7224,13 +7212,10 @@ public class Parser implements IParser { listNode3.add(plisttermNode1); } - if(listNode2 != null) - { - if (listNode3.isEmpty() && listNode2 instanceof LinkedList<?>) { - listNode3 = listNode2; - } else { - listNode3.addAll(listNode2); - } + if (listNode3.isEmpty() && listNode2 instanceof LinkedList<?>) { + listNode3 = listNode2; + } else { + listNode3.addAll(listNode2); } } nodeList.add(listNode3); @@ -7508,13 +7493,10 @@ public class Parser implements IParser { listNode3.add(ptermNode1); } - if(listNode2 != null) - { - if (listNode3.isEmpty() && listNode2 instanceof LinkedList<?>) { - listNode3 = listNode2; - } else { - listNode3.addAll(listNode2); - } + if (listNode3.isEmpty() && listNode2 instanceof LinkedList<?>) { + listNode3 = listNode2; + } else { + listNode3.addAll(listNode2); } } nodeList.add(listNode3); @@ -7885,13 +7867,10 @@ public class Parser implements IParser { listNode3.add(pastaltNode1); } - if(listNode2 != null) - { - if (listNode3.isEmpty() && listNode2 instanceof LinkedList<?>) { - listNode3 = listNode2; - } else { - listNode3.addAll(listNode2); - } + if (listNode3.isEmpty() && listNode2 instanceof LinkedList<?>) { + listNode3 = listNode2; + } else { + listNode3.addAll(listNode2); } } nodeList.add(listNode3); @@ -8033,8 +8012,6 @@ public class Parser implements IParser tpkgidNode2 = (TPkgId)nodeArrayList2.get(0); if (listNode1 instanceof LinkedList<?>) { listNode3 = listNode1; - } else if (listNode1 == null) { - listNode3 = new LinkedList<>(); } else { listNode3 = new LinkedList<>(listNode1); } @@ -8086,8 +8063,6 @@ public class Parser implements IParser phelperdefNode2 = (PHelperDef)nodeArrayList2.get(0); if (listNode1 instanceof LinkedList<?>) { listNode3 = listNode1; - } else if (listNode1 == null) { - listNode3 = new LinkedList<>(); } else { listNode3 = new LinkedList<>(listNode1); } @@ -8139,8 +8114,6 @@ public class Parser implements IParser tidNode2 = (TId)nodeArrayList2.get(0); if (listNode1 instanceof LinkedList<?>) { listNode3 = listNode1; - } else if (listNode1 == null) { - listNode3 = new LinkedList<>(); } else { listNode3 = new LinkedList<>(listNode1); } @@ -8192,8 +8165,6 @@ public class Parser implements IParser ptokendefNode2 = (PTokenDef)nodeArrayList2.get(0); if (listNode1 instanceof LinkedList<?>) { listNode3 = listNode1; - } else if (listNode1 == null) { - listNode3 = new LinkedList<>(); } else { listNode3 = new LinkedList<>(listNode1); } @@ -8245,8 +8216,6 @@ public class Parser implements IParser pstatelisttailNode2 = (PStateListTail)nodeArrayList2.get(0); if (listNode1 instanceof LinkedList<?>) { listNode3 = listNode1; - } else if (listNode1 == null) { - listNode3 = new LinkedList<>(); } else { listNode3 = new LinkedList<>(listNode1); } @@ -8298,8 +8267,6 @@ public class Parser implements IParser pconcatNode2 = (PConcat)nodeArrayList2.get(0); if (listNode1 instanceof LinkedList<?>) { listNode3 = listNode1; - } else if (listNode1 == null) { - listNode3 = new LinkedList<>(); } else { listNode3 = new LinkedList<>(listNode1); } @@ -8351,8 +8318,6 @@ public class Parser implements IParser punexpNode2 = (PUnExp)nodeArrayList2.get(0); if (listNode1 instanceof LinkedList<?>) { listNode3 = listNode1; - } else if (listNode1 == null) { - listNode3 = new LinkedList<>(); } else { listNode3 = new LinkedList<>(listNode1); } @@ -8404,8 +8369,6 @@ public class Parser implements IParser pprodNode2 = (PProd)nodeArrayList2.get(0); if (listNode1 instanceof LinkedList<?>) { listNode3 = listNode1; - } else if (listNode1 == null) { - listNode3 = new LinkedList<>(); } else { listNode3 = new LinkedList<>(listNode1); } @@ -8457,8 +8420,6 @@ public class Parser implements IParser pelemNode2 = (PElem)nodeArrayList2.get(0); if (listNode1 instanceof LinkedList<?>) { listNode3 = listNode1; - } else if (listNode1 == null) { - listNode3 = new LinkedList<>(); } else { listNode3 = new LinkedList<>(listNode1); } @@ -8510,8 +8471,6 @@ public class Parser implements IParser paltNode2 = (PAlt)nodeArrayList2.get(0); if (listNode1 instanceof LinkedList<?>) { listNode3 = listNode1; - } else if (listNode1 == null) { - listNode3 = new LinkedList<>(); } else { listNode3 = new LinkedList<>(listNode1); } @@ -8563,8 +8522,6 @@ public class Parser implements IParser ptermNode2 = (PTerm)nodeArrayList2.get(0); if (listNode1 instanceof LinkedList<?>) { listNode3 = listNode1; - } else if (listNode1 == null) { - listNode3 = new LinkedList<>(); } else { listNode3 = new LinkedList<>(listNode1); } @@ -8616,8 +8573,6 @@ public class Parser implements IParser plisttermNode2 = (PListTerm)nodeArrayList2.get(0); if (listNode1 instanceof LinkedList<?>) { listNode3 = listNode1; - } else if (listNode1 == null) { - listNode3 = new LinkedList<>(); } else { listNode3 = new LinkedList<>(listNode1); } @@ -8669,8 +8624,6 @@ public class Parser implements IParser ptermNode2 = (PTerm)nodeArrayList2.get(0); if (listNode1 instanceof LinkedList<?>) { listNode3 = listNode1; - } else if (listNode1 == null) { - listNode3 = new LinkedList<>(); } else { listNode3 = new LinkedList<>(listNode1); } @@ -8722,8 +8675,6 @@ public class Parser implements IParser pastprodNode2 = (PAstProd)nodeArrayList2.get(0); if (listNode1 instanceof LinkedList<?>) { listNode3 = listNode1; - } else if (listNode1 == null) { - listNode3 = new LinkedList<>(); } else { listNode3 = new LinkedList<>(listNode1); } @@ -8775,8 +8726,6 @@ public class Parser implements IParser pastaltNode2 = (PAstAlt)nodeArrayList2.get(0); if (listNode1 instanceof LinkedList<?>) { listNode3 = listNode1; - } else if (listNode1 == null) { - listNode3 = new LinkedList<>(); } else { listNode3 = new LinkedList<>(listNode1); } diff --git a/src/main/resources/org/sablecc/sablecc/parser.txt b/src/main/resources/org/sablecc/sablecc/parser.txt index d3f4b0c27200b2923077df0123dfa31aa952c499..5fc8e9973fdd3a3518443ce15cc5823f0611a38c 100644 --- a/src/main/resources/org/sablecc/sablecc/parser.txt +++ b/src/main/resources/org/sablecc/sablecc/parser.txt @@ -387,8 +387,6 @@ $ Macro:ParserTypedLinkedListInitAddAll if ($1$ instanceof LinkedList<?>) { $0$ = $1$; - } else if ($1$ == null) { - $0$ = new LinkedList<>(); } else { $0$ = new LinkedList<>($1$); } @@ -404,13 +402,10 @@ Macro:ParserTypedLinkedListAdd $ Macro:ParserTypedLinkedListAddAll - if($1$ != null) - { - if ($0$.isEmpty() && $1$ instanceof LinkedList<?>) { - $0$ = $1$; - } else { - $0$.addAll($1$); - } + if ($0$.isEmpty() && $1$ instanceof LinkedList<?>) { + $0$ = $1$; + } else { + $0$.addAll($1$); } $