Java Tree Builder and JavaCC - Help!!

"Lisa Browne" <lisa031@gofree.indigo.ie>
20 Aug 2001 01:52:05 -0400

          From comp.compilers

Related articles
Java Tree Builder and JavaCC - Help!! lisa031@gofree.indigo.ie (Lisa Browne) (2001-08-20)
| List of all articles for this month |
From: "Lisa Browne" <lisa031@gofree.indigo.ie>
Newsgroups: comp.compilers
Date: 20 Aug 2001 01:52:05 -0400
Organization: Indigo
Keywords: C++, Java, parse
Posted-Date: 20 Aug 2001 01:52:05 EDT

I'm trying to use the C++ grammar from JavaCC with JTB (Java Tree
Builder) and I'm getting a number of errors when I try to run
jtb.out.jj through JavaCC. The errors are all of the same type and
are shown in greater detail below, but I'm hoping that someone has
already used this grammar and perhaps come up with a fix. This is for
a non-commercial application and any or all assistance would be cited.


I'm using JavaCC2.0 and JTB122, I'm assuming that they are compatible.


Many thanks
Lucy




FUNCTION_DEFINITION( ) AS IT APPEARS IN cplusplus.jj


void function_definition() :
{
      Scope sc = null;
      boolean isTypedef;
}
{


        LOOKAHEAD(3) isTypedef = declaration_specifiers()
                sc = function_declarator(isTypedef) func_decl_def(sc)
      |
        sc = function_declarator(false) func_decl_def(sc)
}




FUNCTION_DEFINITION ( ) AS IT APPEARS IN jtb.out.jj
note the lines isTypedef=n2=declaration_specifiers()
                                                    sc=n3=function_declarator(isTypedef)
the error is that a "(" is expected before the second "=".


function_definition function_definition() :
{
      NodeChoice n0;
      NodeSequence n1;
      declaration_specifiers n2;
      function_declarator n3;
      func_decl_def n4;
      NodeSequence n5;
      function_declarator n6;
      func_decl_def n7;


      {
            Scope sc = null;
            boolean isTypedef;
      }
}
{
      (
            LOOKAHEAD(3)
            { n1 = new NodeSequence(4); }
            isTypedef=n2=declaration_specifiers()
            { n1.addNode(n2); }
            sc=n3=function_declarator(isTypedef)
            { n1.addNode(n3); }
            n4=func_decl_def(sc)
            { n1.addNode(n4); }
            { n0 = new NodeChoice(n1, 0); }
      |
            { n5 = new NodeSequence(2); }
            {sc=n6=function_declarator(false);}
            { n5.addNode(n6); }
            n7=func_decl_def(sc)
            { n5.addNode(n7); }
            { n0 = new NodeChoice(n5, 1); }
      )


      { return new function_definition(n0); }
}


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.