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 {
if ( a == EMPTY && b == EMPTY ) return EMPTY; // $ + $ = $
if ( a == EMPTY ) { // $ + x = [$,x]
int[] payloads = {EMPTY_FULL_CTX_INVOKING_STATE, b.invokingState};
PredictionContext[] parents = {null, b.parent};
int[] payloads = {b.invokingState, EMPTY_FULL_CTX_INVOKING_STATE};
PredictionContext[] parents = {b.parent, null};
PredictionContext joined =
new ArrayPredictionContext(parents, payloads);
return joined;
}
if ( b == EMPTY ) { // x + $ = [$,x] ($ is always first if present)
int[] payloads = {EMPTY_FULL_CTX_INVOKING_STATE, a.invokingState};
PredictionContext[] parents = {null, a.parent};
int[] payloads = {a.invokingState, EMPTY_FULL_CTX_INVOKING_STATE};
PredictionContext[] parents = {a.parent, null};
PredictionContext joined =
new ArrayPredictionContext(parents, payloads);
return joined;