4

I am AI student and we work with JavaCC. I am new with it. I was trying simple example and I had some errors.

1) I downloaded JavaCC 0.6 from it's website

2) I extracted it in disc C

3) I wrote this code in a file with extension ".jj"

PARSE_BEGIN(Test)

import java.io.*;
class Test
{
    public static void main(string [] args)
    {
        new Test(new InputStreamReader(System.in));
    start();
    }
}
PARSE_END(Test);
Token:
{
    <number: (["0"-"9"])+("." (["0"-"9"])+)?(("e"|"E")(["0"-"9"])+)?>|
    <plus: "+">    
}

void start():
{ }
{
    <number>(<plus><number>)*
}

4) I saved it and put it in javacc/bin folder

5) I wrote this line in command

..."my Path"..javacc Test.jj

6) I had this error

Could not find or load main class javacc

Is there something I have to install before these steps? thx in advance

user207421
  • 305,947
  • 44
  • 307
  • 483
user2970269
  • 43
  • 1
  • 4
  • What is in the javacc/bin folder besides you .jj file and the lib subdirectory? Also when you say "my Path"..javacc, what is the full path that you are using? – Theodore Norvell Nov 09 '13 at 22:46
  • The tag `compiler` should be applied to questions concerning the programming of compilers or for questions about the detailed inner workings of compilers. Don't use `compiler` for questions about options and settings for a particular compiler, use the name of the compiler you are interested in instead. – user207421 Nov 14 '13 at 00:47

2 Answers2

1

Use version 5 at https://java.net/projects/javacc/downloads . Version 6.0 is missing the scripts to run JavaCC. If you really want to use version 6.0 you can find the appropriate scripts in version 5, just copy them to version 6's bin directory and away you go.


Update (2020): Since version 6 is now harder to find, I have put a copy at www.engr.mun.ca/~theo/JavaCC/javacc-6.1.0.zip

Theodore Norvell
  • 15,366
  • 6
  • 31
  • 45
0

I selected the step you missed in bold below.

The download should have placed into your file system either a ZIP or GZIP file containing the JavaCC software. You should go to the directory where the archive was installed and unzip it's contents. That completes your installation.

Once you have completed installation, add the bin directory within the JavaCC installation to your path. The javacc, jjtree, and jjdoc invocation scripts/executables reside in this directory.

You need to modify PATH system variable in windows (wild guess on used OS). For example as described in

http://www.computerhope.com/issues/ch000549.htm

http://www.java.com/en/download/help/path.xml

...

arkonautom
  • 958
  • 18
  • 29
  • Please read attached links, there are screenshot guides. You need to modify OS variable so that OS knows where to find a program (javacc) when you ask OS to execute "javacc". Add semicolon (;) and location of bin folder from installation to PATH. – arkonautom Nov 09 '13 at 11:26
  • i do that but it dose not work, is it true when i want to compile it use this javacc Test.jj – user2970269 Nov 09 '13 at 11:41
  • If you have a "C:\javacc-6.0\bin" directory your Path variable should end with ";C:\javacc-6.0\bin". Close and open new cmd after you save edit to the variable. – arkonautom Nov 09 '13 at 11:45