Merge pull request #376 from parrt/master

fix null pointer bug with rule "a : a;"
This commit is contained in:
Terence Parr 2013-12-19 16:37:43 -08:00
commit 2618aa335a
1 changed files with 15 additions and 11 deletions

View File

@ -88,19 +88,23 @@ public class LeftRecursiveRule extends Rule {
List<Triple<Integer,AltAST,String>> labels = new ArrayList<Triple<Integer,AltAST,String>>();
List<Triple<Integer,AltAST,String>> normalAltLabels = super.getAltLabels();
if ( normalAltLabels!=null ) labels.addAll(normalAltLabels);
for (LeftRecursiveRuleAltInfo altInfo : recPrimaryAlts) {
if (altInfo.altLabel != null) {
labels.add(new Triple<Integer, AltAST, String>(altInfo.altNum,
altInfo.originalAltAST,
altInfo.altLabel));
if ( recPrimaryAlts!=null ) {
for (LeftRecursiveRuleAltInfo altInfo : recPrimaryAlts) {
if (altInfo.altLabel != null) {
labels.add(new Triple<Integer, AltAST, String>(altInfo.altNum,
altInfo.originalAltAST,
altInfo.altLabel));
}
}
}
for (int i = 0; i < recOpAlts.size(); i++) {
LeftRecursiveRuleAltInfo altInfo = recOpAlts.getElement(i);
if ( altInfo.altLabel!=null ) {
labels.add(new Triple<Integer,AltAST,String>(altInfo.altNum,
altInfo.originalAltAST,
altInfo.altLabel));
if ( recOpAlts!=null ) {
for (int i = 0; i < recOpAlts.size(); i++) {
LeftRecursiveRuleAltInfo altInfo = recOpAlts.getElement(i);
if ( altInfo.altLabel!=null ) {
labels.add(new Triple<Integer,AltAST,String>(altInfo.altNum,
altInfo.originalAltAST,
altInfo.altLabel));
}
}
}
if ( labels.isEmpty() ) return null;