Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6889945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:13:12+00:00 2026-05-27T06:13:12+00:00

I read in a tutorial that when you do something like that : SimpleNode

  • 0

I read in a tutorial that when you do something like that :

SimpleNode Program() #Program : {} 
{
    (Class_decl())* <EOF>

    { return jjtThis; }
}

it should create a Programm class which inherits from SimpleNode (once you compile with jjtree), but in my case it doesn’t create such as class. Do I have to create it myself or am I missing something ?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:13:13+00:00Added an answer on May 27, 2026 at 6:13 am

    Are you first using jjtree on your grammar (before javacc)? It works fine with me:

    file: Test.jjt

    options {
      MULTI=true;
      NODE_PREFIX="";
    }
    
    PARSER_BEGIN(Test)
    public class Test {
      public static void main(String[] args) throws Exception {
        Test parser = new Test(new java.io.StringReader("class A; class B;"));
        SimpleNode root = parser.Program();
        root.dump("");
      }
    }
    PARSER_END(Test)
    
    TOKEN :
    {
         < CLASS : "class" >
      |  < SCOL  : ";" >
      |  < ID    : (["a"-"z","A"-"Z"])+ >
    }
    
    SKIP :
    {
      " " | "\t" | "\r" | "\n"
    }
    
    SimpleNode Program() #Program : 
    {} 
    {
      (Class_decl())* <EOF> {return jjtThis;}
    }
    
    void Class_decl() #ClassDecl :
    {}
    {    
      <CLASS> <ID> <SCOL>
    }
    

    And then the commands:

    jjtree Test.jjt
    javacc Test.jj
    

    which generates the following Java source files:

    ClassDecl.java
    JJTTestState.java
    Node.java
    Program.java
    SimpleNode.java
    TestTreeConstants.java
    

    And both ClassDecl and Program extend SimpleNode:

    /* Generated By:JJTree: Do not edit this line. Program.java Version 4.3 */
    /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=false,TRACK_TOKENS=false,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
    public
    class Program extends SimpleNode {
      ...
    }
    
    /* Generated By:JJTree: Do not edit this line. ClassDecl.java Version 4.3 */
    /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=false,TRACK_TOKENS=false,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
    public
    class ClassDecl extends SimpleNode {
      ...
    }
    

    Compiling all source files and running the Test class:

    javac -cp . *.java
    java -cp . Test
    

    which will print:

    Program
     ClassDecl
     ClassDecl
    

    (i.e. Program is the root with two ClassDecl children)

    Tested with Java Compiler Compiler Version 5.0.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've made some unit tests (in test class). The tutorial I've read said that
I've read the learning webgl tutorial, but it does not explain everything. Something like
Is there any book or links that I can read some tutorial about the
OK I have a mySQL Database that looks something like this ID - an
I read in MIPS tutorial, that only reginsters $s0-$s7 are preserved across procedure calls.
Okay, let's say you have something like this: <span class=image style=background-image: url('http://www.example.com/images/image1.png')></span> Every CSS
I am new in hibernate,after read the hibernate api and tutorial,it seems that the
Almost all of the examples in the jQuery tutorials that I've read, usually use
I'm trying to read some OpenGL tutorials on the net. the problem is that
I read the tutorial which advises me to run at util-linux package ./configure I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.