Skip to content

Instantly share code, notes, and snippets.

@arielqw
Last active August 29, 2015 14:12
Show Gist options
  • Save arielqw/5db28a7c135e91c24914 to your computer and use it in GitHub Desktop.
Save arielqw/5db28a7c135e91c24914 to your computer and use it in GitHub Desktop.
If you have:
MyThings ::= { thing [X] ,}
[ meaning MyThings can be an empty list or a list of one or more Thing separated by comma ]
Then you can write the following grammer :
MyThings ::= { ThingsList:things } {: RESULT = new MyThings(things); :}
| { } {: RESULT = new MyThings( new ThingsList() ); :}
;
ThingsList ::= ThingsList : things , Thing : e {: things.append(thing); RESULT = things; :}
| Thing : thing {: ThingsList things = new ThingsList(); things.append(thing); RESULT = things ; :}
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment