[antlr-interest] Multiple Occurrence Read Out

Bart Kiers bkiers at gmail.com
Fri May 6 08:40:38 PDT 2011


Only at the end. You need to place the code-block *inside* the parenthesis
like this:

keysAndValues
  :  ('"' key '"' value
       {
         // Some code to read the key(s) and value(s) out.
         System.out.println("key=" + $key.text + ", value=" + $value.text);
       }
     )*
  ;


Regards,

Bart.


On Fri, May 6, 2011 at 5:19 PM, Philip Mötteli <philip.moetteli at tele2.ch>wrote:

> Hi,
>
>
> I have a parser rule, that parses a kind of a property list:
>
>        keysAndValues   :       ('"' key '"' value)*
>                                                {       // Some code to read
> the key(s) and value(s) out.
>                                                        // Is this part
> called for every occurrence of "*" or only once at the end?
>                                                }
>                                        ;
>
>
> I would like to add every key and its property to a dictionary in my
> program. How can I read those values out?
>
>
> Thanks
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>


More information about the antlr-interest mailing list