JavaCC question - why does this happen?

"Leonardo Hyppolito" <megadeth@terra.com.br>
3 Sep 2002 00:31:11 -0400

          From comp.compilers

Related articles
JavaCC question - why does this happen? megadeth@terra.com.br (Leonardo Hyppolito) (2002-09-03)
Re: JavaCC question - why does this happen? vbdis@aol.com (VBDis) (2002-09-08)
| List of all articles for this month |

From: "Leonardo Hyppolito" <megadeth@terra.com.br>
Newsgroups: comp.compilers
Date: 3 Sep 2002 00:31:11 -0400
Organization: http://groups.google.com/
Keywords: parse, question
Posted-Date: 03 Sep 2002 00:31:11 EDT

Hi friends,


I'm a newbie, trying to learn how JavaCC works.


I built a .jj files that looks like:


----------------
SKIP :
{
    " "
| "\t"
| "\n"
| "\r"
}


TOKEN :
{
      < letter: ["a" - "z", "A" - "Z"] >
| < letterLow: ["a" - "z"] >
| < dig: ["0" - "9"] >
| < resWord: ("<") ("/")? (<letter>)+ ( ("-") (<letter>)+ )? (">") >
| < id: ("_") (<letterLow>) (<letterLow> | <dig>)* >
| < num: (<dig>) (<dig>)* ( (",") (<dig>) )? >
| < lit: ("'") (<letter> | <dig>)* ("'") >
}


void Input() :
{}
{
  ( <resWord> | <id> | <num> | <lit> ) Input()
  | <EOF> {return;}
}


------------


When I try to parse the file:


----
<prg>
<STORE>
</STORE>
_leo _leo23
9
32323
23343434,9
'asdasdasd'
'asdas98349834'
-----


it stops on line 5 (physical line 6), where I have a "9" and says:


Return: Input
ParseException: Found "9" at line 5, column 3.
Expected one of:
        <EOF>
        <resWord> ...
        <id> ...
        <num> ...
        <lit> ...


---------------


As my TOKEN definition for <num> is:


< num: (<dig>) (<dig>)* ( (",") (<dig>) )? >


IT SHOULD accept my number "9" as a <num> token, right??


But it doesn't accept!!!


What am I missing here ???


I appreciate any help.
Thanks in advance!


Leonardo


Brazil


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.