Solved

JavaCC: ParseException in bundled examples after very slight modification

Posted on 2004-08-11
7
1,271 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
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 practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

840 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