Solved

JavaCC: ParseException in bundled examples after very slight modification

Posted on 2004-08-11
7
1,324 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

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…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

691 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