Solved

JavaCC: ParseException in bundled examples after very slight modification

Posted on 2004-08-11
7
1,239 Views
Last Modified: 2012-08-13
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.
0
Comment
Question by:angelamaria
  • 3
  • 2
  • 2
7 Comments
 
LVL 1

Author Comment

by:angelamaria
ID: 11781765
Anyone?
0
 
LVL 11

Expert Comment

by:cjjclifford
ID: 11784722
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...
0
 
LVL 1

Expert Comment

by:SlimHealer
ID: 11785787
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.  
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

by:angelamaria
ID: 11789528
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?
0
 
LVL 11

Assisted Solution

by:cjjclifford
cjjclifford earned 50 total points
ID: 11791089
Hi,

I don't use Windows, so I can't say what Notepad is likely to do - however, Java "shouldn't" have any problems with the normal CRLF differences between *nix and Windows. I know "wordpad" occasionally saves text files in RTF, perhaps "notepad" does the same nowadays... If there is a "Save As" option, select this, there might be a choice of formats...

Perhaps "cat" the file in a command console (or use "more") - this might give an indication of what the file contents are...
0
 
LVL 1

Accepted Solution

by:
SlimHealer earned 50 total points
ID: 11795111
You asked:

"I don't start a new file or anything, so shouldn't it be saving in the same format?"

The answer is "Yes, it probably should, but it sure looks like it doesn't".

Here's my best guess as to what is going on -- the confusion probably comes from the .jj extension on the sample files you are editting.  Since the .jj extension is not mapped to any particular data format, Notepad does it's best to recognize it, see's text, and loads up the data OK.  However, when it goes to write Sample1.jj back out when you save, it looks at the .jj extension, fails to recognize it, and writes the data back out in it's favorite format, which is likely not raw ASCII text.


Do you have any luck editting these samples with a different word processor, and explicitly saving in a text format?

0
 
LVL 1

Author Comment

by:angelamaria
ID: 11802604
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!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
allswap challenge 6 75
Responding to Java JComponent extended classes's resize event 4 50
compre toata in where clue oracle 4 55
backtracking recursion  code 19 53
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This video teaches viewers about errors in exception handling.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now