Solved

JavaCC: ParseException in bundled examples after very slight modification

Posted on 2004-08-11
7
1,249 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
recursion example 16 126
java.io.BufferedReader   readLine()  //returns the entire file ? 4 73
servlet example 17 30
iterator/ListIterator approach 17 26
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
The viewer will learn how to implement Singleton Design Pattern in Java.

770 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