Loading ...
Sorry, an error occurred while loading the content.
 

Tree structure

Expand Messages
  • ManimuthuLakshmi Pitchaikani
    Hi, I want the tree structure as follows: Nice ... My code is as follows: opt_pri! :#(PRI priVal) { #opt_pri = #([NICE, nice ], #priVal); } ; priVal! : INT {
    Message 1 of 8 , Sep 30, 2004
      Hi,
       
      I want the tree structure as follows:
       
      Nice 
           |
           |--15
       
      My code is as follows:

      opt_pri! :#(PRI priVal)

      {

      #opt_pri = #([NICE,

      "nice"], #priVal);

      }

      ;

      priVal! : INT

      {

      #priVal = #[INT,

      "-15"];

      }

      ;

       
      Am getting the following error:

      java.lang.Error: Unresolved compilation problem:

      priVal cannot be resolved

      How i can resolve this error? Is there is any other way?

      Thanks.

      Best regards,

      Lakshmi

       

       

       


      Do you Yahoo!?
      Yahoo! Mail - Helps protect you from nasty viruses.
    • Monty Zukowski
      Have a look at the generated code. is there a variable declaration missing or something? Nothing is obviously wrong from what I see. Monty ANTLR & Java
      Message 2 of 8 , Sep 30, 2004
        Have a look at the generated code. is there a variable declaration
        missing or something? Nothing is obviously wrong from what I see.

        Monty

        ANTLR & Java Consultant -- http://www.codetransform.com
        ANSI C/GCC transformation toolkit --
        http://www.codetransform.com/gcc.html
        Embrace the Decay -- http://www.codetransform.com/EmbraceDecay.html

        On Sep 30, 2004, at 9:52 AM, ManimuthuLakshmi Pitchaikani wrote:

        > Hi,
        >  
        > I want the tree structure as follows:
        >  
        > Nice 
        >      |
        >      |--15
        >  
        > My code is as follows:
        >
        > opt_pri! :#(PRI priVal)
        >
        > {
        >
        > #opt_pri = #([NICE, "nice"], #priVal);
        >
        >
        > }
        >
        > ;
        >
        > priVal! : INT
        >
        > {
        >
        > #priVal = #[INT,"-15"];
        >
        >
        > }
        >
        > ;
        >  
        > Am getting the following error:
        >
        > java.lang.Error: Unresolved compilation problem:
        >
        > priVal cannot be resolved
        >
        > How i can resolve this error? Is there is any other way?
        >
        > Thanks.
        >
        > Best regards,
        >
        > Lakshmi
        >
        >  
        >
        >  
        >  
        >
        > Do you Yahoo!?
        > Yahoo! Mail - Helps protect you from nasty viruses.
        >
        > Yahoo! Groups Links
        >
        > • To visit your group on the web, go to:
        > http://groups.yahoo.com/group/antlr-interest/
        >  
        > • To unsubscribe from this group, send an email to:
        > antlr-interest-unsubscribe@yahoogroups.com
        >  
        > • Your use of Yahoo! Groups is subject to the Yahoo! Terms of
        > Service.
        >
        >
      • Bryan Ewbank
        ... I have problems sometimes when I don t use # everywhere, so you might try changing from this #( [NICE, nice ], #priVal) to this #( #[NICE, nice ],
        Message 3 of 8 , Sep 30, 2004
          > What's wrong with this:
          >
          > opt_pri! :#(PRI priVal)
          > { #opt_pri = #([NICE, "nice"], #priVal);

          I have problems sometimes when I don't use "#" everywhere, so
          you might try changing from this
          #( [NICE, "nice"], #priVal)
          to this
          #( #[NICE, "nice"], #priVal)
        • ManimuthuLakshmi Pitchaikani
          Hi, I tried in the same way as Bryan suggested. Now am getting two errors: 1. priVal cannot be resolved 2. The method create() in the Type ASTFactory is not
          Message 4 of 8 , Sep 30, 2004
            Hi,
             
            I tried in the same way as Bryan suggested.
             
            Now am getting two errors:
             
            1. priVal cannot be resolved
            2. The method create() in the Type ASTFactory is not applicable for the arguments(AST,String)
             
            Is the priVal rule needs the change?
             
            Thanks.
             
            Best Regards,
            Lakshmi


            Bryan Ewbank <ewbank@...> wrote:
            > What's wrong with this:
            >
            > opt_pri! :#(PRI priVal)
            > { #opt_pri = #([NICE, "nice"], #priVal);

            I have problems sometimes when I don't use "#" everywhere, so
            you might try changing from this
            #( [NICE, "nice"], #priVal)
            to this
            #( #[NICE, "nice"], #priVal)




            Yahoo! Groups Links

            <*> To visit your group on the web, go to:
            http://groups.yahoo.com/group/antlr-interest/

            <*> To unsubscribe from this group, send an email to:
            antlr-interest-unsubscribe@yahoogroups.com

            <*> Your use of Yahoo! Groups is subject to:
            http://docs.yahoo.com/info/terms/



            Do you Yahoo!?
            New and Improved Yahoo! Mail - Send 10MB messages!

          • ManimuthuLakshmi Pitchaikani
            In .java file, priVal_AST = (AST)astFactory.make( (new ASTArray(1)).add(astFactory.create(tmp12_AST, -15 ))); The errors is on the create(tmp12_AST, -15 ).
            Message 5 of 8 , Sep 30, 2004
              In .java file,
               
              priVal_AST = (AST)astFactory.make( (new ASTArray(1)).add(astFactory.create(tmp12_AST,"-15")));
               
              The errors is on the create(tmp12_AST,"-15").  The errror "The method create() in the ASTFactory is not applicable for the arguments(AST,String)" occurs.
               
              Because of this error, the following error occurs for priVal as it is not being recognised:

              opt_pri_AST = (AST)astFactory.make( (

              new ASTArray(2)).add(astFactory.create(NICE,"nice")).add(priVal));
              Here it is not able to recognise priVal and the error "priVal cannot be resolved" occurs.
              Also i observed that '!' mark doesn't matter.  
               
              Rule on priVal needs any change?
               
              Current code:
               

              opt_pri! :#(PRI priVal)

              {

              #opt_pri = #(#[NICE,

              "nice"], #priVal);

              }

              ;

              priVal! : INT

              {

              #priVal = #([INT,

              "-15"]);

              }

              ;



              Bryan Ewbank <Bryan.Ewbank@...> wrote:
              One other problem I've had is that "!" disables construction of the subtrees.  Try removing the "!" after the rule name.  This is just a guess, but it follows the pattern of what I've been seeing in my code.
               
              I'm using ANTLR to generate C++, by the way; I don't think it'd be different for java, but just in case....
              -----Original Message-----
              From: ManimuthuLakshmi Pitchaikani [mailto:antlr_lakshmi@...]
              Sent: Thursday, September 30, 2004 14:52
              To: Bryan.Ewbank@...
              Subject: Fwd: RE: [antlr-interest] Tree structure



              Note: forwarded message attached.


              Do you Yahoo!?
              vote.yahoo.com - Register online to vote today!


              Do you Yahoo!?
              New and Improved Yahoo! Mail - 100MB free storage!

            • Anakreon
              ... This is a problem I have faced many times. The workaround for this is: int intType = INT; #priVal = #([intType, -15 ]); If this behaver is a feature of
              Message 6 of 8 , Sep 30, 2004
                > priVal! : INT
                >
                > {
                >
                > #priVal = #([INT,"-15"]);
                This is a problem I have faced many times.
                The workaround for this is:
                int intType = INT;
                #priVal = #([intType, "-15"]);

                If this behaver is a feature of Antlr, I wish it's removed.
                Anakreon
              • Bryan Ewbank
                I think the problem here is that the tree is not constructed (because of the ! following priVal). Therefore, INT is not recognized as special in the
                Message 7 of 8 , Oct 1, 2004
                  I think the problem here is that the tree is not constructed (because of the
                  "!" following priVal). Therefore, INT is
                  not recognized as "special" in the context of tree-building directives #(
                  ... ). Try removing the "!" after "priVal",
                  as well as prefixing "[INT ...]" with another "#", and it should work.

                  It is throwing away some information (the original priVal node is lost), but
                  this way it correctly builds the tree
                  components you need.

                  > -----Original Message-----
                  > From: Anakreon [mailto:anakreonmejdi@...]
                  > Sent: Thursday, September 30, 2004 16:48
                  > To: antlr-interest@yahoogroups.com
                  > Subject: Re: [antlr-interest] Tree structure
                  >
                  >
                  >
                  > > priVal! : INT
                  > >
                  > > {
                  > >
                  > > #priVal = #([INT,"-15"]);
                  > This is a problem I have faced many times.
                  > The workaround for this is:
                  > int intType = INT;
                  > #priVal = #([intType, "-15"]);
                  >
                  > If this behaver is a feature of Antlr, I wish it's removed.
                  > Anakreon
                  >
                  >
                  >
                  > Yahoo! Groups Links
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                • Colm McHugh
                  Hi antlr-interest, [Language=C++ only, didn t try with Java] This is in the realm of triviality, but I noticed today that antlr produces what looks like to me
                  Message 8 of 8 , Oct 1, 2004
                    Hi antlr-interest,

                    [Language=C++ only, didn't try with Java]

                    This is in the realm of triviality, but I noticed
                    today that antlr produces what looks like to me an
                    obscure error message if a variable in an action
                    begins with an '_' (underscore) char:

                    // offending snippet from test.g:

                    mexpr returns [int _rr = 0]
                    {int tmp = 0;}
                    : _rr=atom (STAR tmp=atom { _rr*=tmp; )*
                    ;

                    $ antlr test.g
                    ANTLR Parser Generator Version 2.7.4 1989-2004
                    jGuru.com
                    TokenStreamException: unexpected char: '_'

                    Anyways, had me baffled for a few minutes so just
                    thought I'd share!




                    __________________________________
                    Do you Yahoo!?
                    Yahoo! Mail Address AutoComplete - You start. We finish.
                    http://promotions.yahoo.com/new_mail
                  Your message has been successfully submitted and would be delivered to recipients shortly.