dcsimg
JavaCC grammar troubles...
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Mingus_Snapsnop
Posted On:   Tuesday, May 14, 2002 10:14 AM

PoornaChandra Raju posted this question Oct 2, 2001: I am using JavaCC utility to generate a parser. I have three tokens defined say TokenA: "A", TokenB: "B" and TokenC: "C". I have to write a statement in my grammar such that, the above said tokens can appear in the any of the following ways; 1) All the tokens are optional Example : ABC or AB or Ac or A or nothing 2)The tokens can appear in any order Example: ABC or CBA or ACB or ..... 3) A token can appear only once Example: AAB ---> is wrong, becaue "A" appears twice. I have solved this problem using Jav   More>>
PoornaChandra Raju posted this question Oct 2, 2001:

I am using JavaCC utility to generate a parser.

I have three tokens defined say TokenA: "A", TokenB: "B" and TokenC: "C".

I have to write a statement in my grammar such that,

the above said tokens can appear in the any of the following ways;


1) All the tokens are optional

Example : ABC or AB or Ac or A or nothing


2)The tokens can appear in any order

Example: ABC or CBA or ACB or .....


3) A token can appear only once

Example: AAB ---> is wrong, becaue "A" appears twice.


I have solved this problem using Java code in my grammar, but is it possible to solve it using a JavaCC production?

   <<Less
About | Sitemap | Contact