[antlr-interest] What multiple alternative?
John B. Brodie
jbb at acm.org
Sat Jan 7 06:46:45 PST 2012
Greetings!
On 01/07/2012 03:30 AM, James Ladd wrote:
> array_constant
> : '#' array
> ;
>
> array
> : '(' array_element* ')'
> ;
>
> array_element
> : WHITESPACE
> | NUMBER
> | symbol
> | STRING
> | CHARACTER_CONSTANT
> | array
> ;
>
> symbol_constant
> : '#' symbol
> ;
>
> symbol
> : IDENTIFIER
> | BINARY_SELECTOR
> | (KEYWORD)+
> ;
>
>
you have two nested repetitions but no way to know when the inner ends
and the outer resumes.
e.g. zero or more array_elements each of which may contain 1 or more
KEYWORDS (via symbol).
consider the input: #(a:b:c:d:)
now is this a single array_element containing a single symbol having 4
KEYWORDs?
or is this 4 array_elements each containing a single symbol having 1
KEYWORD?
or is this 2 array_elements each containing a single symbol having 2
KEYWORDs?
or is this 2 array_elements each containing 2 symbols each having 1 KEYWORD?
or is this 3 array_elements...... you get the idea i hope
More information about the antlr-interest
mailing list