Solved

JavaCC: ParseException in bundled examples after very slight modification

Posted on 2004-08-11
7
1,234 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

760 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

22 Experts available now in Live!

Get 1:1 Help Now