I am trying to write a parser grammar and currently have the following productions for an LL Grammar (in Antlr) and I am trying to parse one or more (numbers or strings) that is separated by a "#" that is right associative. How do I modify the the productions so that it can parse one or more strings separated by "#" instead of just one at the moment?
A ::= B
| Number
| String
B ::= C "->" A
C ::= Number
| String
Examples of languages for this grammar:
ABC # 123
123 # ABC
ABC # DEF # 123
ABC # DEF # (123 # 456)
ABC # (DEF # 123) # 456
I tried using the EBNF form
A ::= B
| Number
| String
| "(" A ")"
B ::= C ("#" A)?
C ::= Number
| String
But that causes my Grammar to be ambiguous. How would I fix this ambiguity?