fix bug in code gen for * loops

[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9082]
This commit is contained in:
parrt 2011-09-25 14:43:37 -08:00
parent e3d6db0478
commit cd2c4e622d
3 changed files with 8 additions and 5 deletions

View File

@ -130,9 +130,12 @@ treeSpec returns [MatchTree treeMatch]
subrule returns [List<? extends SrcOp> omos]
: ^(astBlockSuffix block[null,null,$astBlockSuffix.start]) {$omos = $block.omos;}
| ^(OPTIONAL block[null,$OPTIONAL,null]) {$omos = $block.omos;}
| ( ^(op=CLOSURE b=block[null,$CLOSURE,null])
| ^(op=POSITIVE_CLOSURE b=block[null,$POSITIVE_CLOSURE,null])
| ^(OPTIONAL b=block[null,$OPTIONAL,null])
{
$omos = $block.omos;
}
| ( ^(op=CLOSURE b=block[null,null,null])
| ^(op=POSITIVE_CLOSURE b=block[null,null,null])
)
{
List<CodeBlockForAlt> alts = new ArrayList<CodeBlockForAlt>();

View File

@ -124,7 +124,7 @@ rule:
-> (RULE a int i (throws a.b.c) (BLOCK (ALT A)))
block:
"( ^(A B) | ^(b C) )" -> (BLOCK (ALT ("^(" A B)) (ALT ("^(" b C)))
"( ^(A B) | ^(b C) )" -> (BLOCK (ALT ("^(" A DOWN B UP)) (ALT ("^(" b DOWN C UP)))
ebnf:
"(A|B)" -> (BLOCK (ALT A) (ALT B))

View File

@ -113,7 +113,7 @@ public class TestASTStructure extends org.antlr.v4.gunit.gUnitBase {
// gunit test on line 127
RuleReturnScope rstruct = (RuleReturnScope)execParser("block", "( ^(A B) | ^(b C) )", 127);
Object actual = ((Tree)rstruct.getTree()).toStringTree();
Object expecting = "(BLOCK (ALT (^( A B)) (ALT (^( b C)))";
Object expecting = "(BLOCK (ALT (^( A DOWN B UP)) (ALT (^( b DOWN C UP)))";
assertEquals("testing rule block", expecting, actual);
} @Test public void test_ebnf1() throws Exception {
// gunit test on line 130