I'm trying to produce a LALR grammar for a very simple language composed of assignments. For example:
foo = "bar"
bar = 42
The language should also handle list of values, for example:
foo = 1, 2, 3
But I also want to handle list on multiple lines:
foo = 1, 2
3, 4
Trailing comma (for singletons and language flexibility):
foo = 1,
foo = 1, 2,
And obviously, both at the same time:
foo = 1,
2,
3,
I'm able to write a grammar with trailing comma or multi-line list, but not for both at the same time.
My grammar look like this:
content : content '\n'
: content assignment
| <empty>
assignment : NAME '=' value
| NAME '=' list
value : TEXT
| NUMBER
list : ???
Note: I need the '\n' in the grammar to forbid this kind of code:
foo
=
"bar"
Thanks by advance,
Antoine.