[antlr-interest] RewriteEmptyStreamException
Jamie Penney
jpen054 at ec.auckland.ac.nz
Wed Feb 13 19:38:31 PST 2008
To answer my own question, it seems like I had an alternative in the
'type' rule that didn't have a rewrite rule associated with it. I
thought ANTLR was supposed to automatically create an AST if you didn't
specify a rewrite rule? For whoever is interested, this was the rule:
type
: (namespace_or_type_name -> ^(TYPE $namespace_or_type_name) //
JP Added -> ^(TYPE $namespace_or_type_name)
| simple_type
| OBJECT
| STRING
| VOID s1=STAR -> ^(VOID $s1)
) (s2=STAR -> ^(TYPE $type OP_POINTER[$s2])
| INTERR -> ^(TYPE $type OP_NULLABLE[$INTERR])
| (rank_specifier)=> rank_specifier -> ^(TYPE $type
rank_specifier)
)*
;
Because the second group (starting with s2=STAR) is optional, if it
wasn't triggered there was no rewrite rule triggered.
Jamie Penney wrote:
> Forgot to mention that I am using the antlr-2008-01-23.10 build. I
> tried the lastest build after Terrance announced it, but it was giving
> me Template missing exceptions after I recompiled to add some stuff I
> needed to the CSharp target.
>
> Jamie
>
> Jamie Penney wrote:
>> Hi All,
>> I am getting the following exception when executing a rewrite rule:
>>
>> Antlr.Runtime.Tree.RewriteEmptyStreamException: rule type
>> at Antlr.Runtime.Tree.RewriteRuleElementStream`1._Next()
>> at
>> Antlr.Runtime.Tree.RewriteRuleSubtreeStream.FetchObject(ProcessHandler
>> ph)
>> at Antlr.Runtime.Tree.RewriteRuleSubtreeStream.NextTree()
>> at Kerriv.CSharpML.CSharp3ParserSyntax.using_namespace_directive()
>> in ....
>>
>>
>> This is cause by the code generated from the following rule:
>> using_namespace_directive
>> : USING type SEMICOLON -> ^(USING type SEMICOLON)
>> ;
>>
>> Any ideas as to where I should start with this? The documentation and
>> Google haven't given me any clues.
>>
>> Thanks,
>> Jamie Penney
>
More information about the antlr-interest
mailing list