Link to home
Start Free TrialLog in
Avatar of angelamaria
angelamaria

asked on

JavaCC: ParseException in bundled examples after very slight modification

I'm really rather stumped right now as to what the problem is. I downloaded JavaCC and tried running the examples included in the downloaded file. I started with the simple examples, Simple1.jj -- in order to read it, I fixed the file up to show new lines properly in Notetab (I just hit Enter when the newline character came up).

And then I tried running javacc on it, and this came up:

Java Compiler Compiler Version 3.2 (Parser Generator)
(type "javacc" with no arguments for help)
Reading from file Simple1.jj . . .
org.javacc.parser.ParseException: Encountered "\\u00ef" at line 1, column 1.
Was expecting one of:
   "options" ...
   "PARSER_BEGIN" ...
Detected 1 errors and 0 warnings.

There. That's it. I deleted the comments before the options line, made the options line the first line in the file, but the same thing keeps coming up.

Any help would be greatly appreciated, I can't even start learning JavaCC because of this error.
Avatar of angelamaria
angelamaria

ASKER

Anyone?
Hi,

It sounds like there are some unexpected characters being put in the ".jj" file by the editor (character "\\u00ef") - try the file without editing with Notetab...

sorry I can't provide any more help...
I can confirm that cjjclifford is on the right track.  Make sure that when you edit Simple1.jj, you save the resulting file as pure text and not some other format.

To confirm that this was the problem, I downloaded the JavaCC and ran the Simple1.jj through it without any problem.  

I then editted the Simple1.jj with my least favorite word processor (MS Word) and saved it into unicode rather than text.  When I ran this editted version of the file through javacc, I got:

Java Compiler Compiler Version 3.2 (Parser Generator)
(type "javacc" with no arguments for help)
Reading from file /private/Network/Servers/harris/Volumes/heim/mtm/Desktop/Simple1.jj . . .
org.javacc.parser.ParseException: Encountered "\\u02db\\u02c7" at line 1, column 1.
Was expecting one of:
    "options" ...
    "PARSER_BEGIN" ...
   
Detected 1 errors and 0 warnings.


Which is suspiciously close to the problem that you report.  
I tried running one that I didn't edit with Notepad (sorry, I meant Notepad, not Notetab, though I also use the latter, hee) and it did run.

I'm now confused though. I realize that Linux and Windows treat newlines differently (something like /n and /r/n) but since I use Notepad, it's supposed to save as plain text, right? Plus, I'm sure it's not saving as Unicode, as I only open .jj files using Notepad, edit it to change the newlines (so that it's readable to me) and then save it. I don't start a new file or anything, so shouldn't it be saving in the same format?
SOLUTION
Avatar of cjjclifford
cjjclifford

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I tried making a new file and typing out the whole thing, and the funny thing is... it works. -_-; So I guess what you said it true, heh. Something weird with Notepad, that's true.

Thanks!