It's been 4 years since i have taken a compiler class. I am now trying to create a parser, and I am using javacc for creating the grammar. I will try to demonstrate my problem in the following simple scenario: Let's suppose I need a grammar to read any number of numbers and/or letters, but also to be able and recognize "(" set of characters ")". I have tried something like:
| "(" Foo() ")"
The problem here is that it refuses to recognize exactly what I need since I get a warning that 0 and A will be treated as NUM and WORD respectively. What is the best way to tackle this? Also can someone please give me an example of a recursive rule? Is that even possible? By recursive I refer to the rule calling itself, something like:
Foo() ( Foo() )*