« Return to Thread: [JavaCC] How to use loop in grammars?

[JavaCC] How to use loop in grammars?

by AlexanderPD :: Rate this Message:

Reply to Author | View in Thread

Hi, i need to "convert" my grammar in JavaCC.. but javaCC doesn't accept loops in regular expression :(

i tried to write this:

TOKEN :
{
  < AUTOMA : "Automa" >
|   < DUEPUNTI : ":" >
| < AP2SL : < AUTOMA > <DUEPUNTI > <NOME>"\n{"<STATI>","<COPPIA>"\n"<TABTR>"." >
  | < NOME : ["A"-"Z"](["a"-"z","0"-"9"])+ >
  | < COPPIA: <STATI>","< COPPIA >"\n"<TABTR>":" | "}\n{" <LISTAALFABETO> "}\n}" <LISTASIMBOLIPILA >"}\n" >
  | < LISTASIMBOLIPILA : "$,"(<SPILA>",")+ >
  | < LISTAALFABETO : <ALFABETO>"," < LISTAALFABETO > | <ALFABETO> >
  | < TABTR : "{"<TRANSIZIONI>"}\n">
  | < TRANSIZIONI :"("(<SPILA>|"$")","(<ALFABETO>|"#")")->("<STATI>","<APILA>");"< TRANSIZIONI > | "("(<SPILA>|"$")","(<ALFABETO>|"#")")->("<STATI>","<APILA>")" >
  | < STATI : ["1"-"9"](["0"-"9"])* >
  | < ALFABETO : ["a"-"z"] >
  | < SPILA : ["A"-"Z"] >
  | < APILA : (<SPILA>)* >
}

and i get 3 looping errors :(
How to solve this? I need to write a method for each looping state?

Thank you, i'm getting mad on this :D

 « Return to Thread: [JavaCC] How to use loop in grammars?