fix regression; LR rules weren't working

This commit is contained in:
Terence Parr 2012-02-23 11:37:50 -08:00
parent d30b36ca01
commit 5a13ddc517
1 changed files with 7 additions and 3 deletions

View File

@ -29,8 +29,7 @@
package org.antlr.v4.tool.ast;
import org.antlr.runtime.CommonToken;
import org.antlr.runtime.Token;
import org.antlr.runtime.*;
import org.antlr.runtime.tree.Tree;
public class RuleRefAST extends GrammarASTWithOptions implements RuleElementAST {
@ -46,7 +45,12 @@ public class RuleRefAST extends GrammarASTWithOptions implements RuleElementAST
@Override
public Tree dupNode() {
RuleRefAST r = new RuleRefAST(this);
r.token = new CommonToken(r.token);
// In LR transform, we alter original token stream to make e -> e[n]
// Since we will be altering the dup, we need dup to have the
// original token. We can set this tree (the original) to have
// a new token.
r.token = this.token;
this.token = new CommonToken(r.token);
return r;
}