[antlr-interest] action syntax

Akhilesh Mritunjai mritun at gmail.com
Wed Nov 23 13:28:49 PST 2005


On Wed, 23 Nov 2005 23:29:12 +0530, Terence Parr <parrt at cs.usfca.edu>  
wrote:
>> Its my favorite pet-peeve with ANTLR. Labels are extremely limited in  
>> how they can be used.
>
> Mine too. ;)  Fixed in v3. ;)


You mean I can do something like:

rule:
(
    a:branch0
  | a:branch1
  | a:branch2
)
{
   doSomething(a);
}

Its obvious that branch0/1/2 are mutually exclusive, but ANTLR does't  
allow same label for them, so I need to write

rule:
   a:branch0 { doSomething(a); }
| b:branch1 { doSomething(b); }
| c:branch2 { doSomething(c); }

Which doesn't look nice when I have 20 branches.

- Akhilesh


More information about the antlr-interest mailing list