Fix PredictionContext.mergeRoot placing states in the wrong order

This commit is contained in:
Sam Harwell 2012-10-08 10:26:07 -05:00
parent e14e7663b5
commit 9cea095d81
1 changed files with 4 additions and 4 deletions

View File

@ -234,15 +234,15 @@ public abstract class PredictionContext implements Iterable<SingletonPredictionC
else { else {
if ( a == EMPTY && b == EMPTY ) return EMPTY; // $ + $ = $ if ( a == EMPTY && b == EMPTY ) return EMPTY; // $ + $ = $
if ( a == EMPTY ) { // $ + x = [$,x] if ( a == EMPTY ) { // $ + x = [$,x]
int[] payloads = {EMPTY_FULL_CTX_INVOKING_STATE, b.invokingState}; int[] payloads = {b.invokingState, EMPTY_FULL_CTX_INVOKING_STATE};
PredictionContext[] parents = {null, b.parent}; PredictionContext[] parents = {b.parent, null};
PredictionContext joined = PredictionContext joined =
new ArrayPredictionContext(parents, payloads); new ArrayPredictionContext(parents, payloads);
return joined; return joined;
} }
if ( b == EMPTY ) { // x + $ = [$,x] ($ is always first if present) if ( b == EMPTY ) { // x + $ = [$,x] ($ is always first if present)
int[] payloads = {EMPTY_FULL_CTX_INVOKING_STATE, a.invokingState}; int[] payloads = {a.invokingState, EMPTY_FULL_CTX_INVOKING_STATE};
PredictionContext[] parents = {null, a.parent}; PredictionContext[] parents = {a.parent, null};
PredictionContext joined = PredictionContext joined =
new ArrayPredictionContext(parents, payloads); new ArrayPredictionContext(parents, payloads);
return joined; return joined;