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

Re: [antlr-interest] controlling the parsing of grammar..

Expand Messages
  • Ruslan Zasukhin
    ... Well, Sinan, I have read this ... and ... it seems I do not even to use default AST trees. I am writing SQL grammar for Valentina database and for now I am
    Message 1 of 5 , Sep 20, 2001
    • 0 Attachment
      on 9/20/01 7:26, Sinan Karasu at allahsiz@... wrote:

      > Anytime I taught anyone how to use antlr, my words were always "write
      > your tree-walker first". Well not exactly , but not too far off. Once
      > you write a tree-walker, everything becomes vastly simpler. The
      > tinybasic example does what you are asking for already. take a look at
      > it, and don't be afraid of treewalkers.

      Well, Sinan,

      I have read this ... and ... it seems I do not even to use default AST
      trees.

      I am writing SQL grammar for Valentina database and for now I am studying
      ANTLR and its code it generate.

      I am not glad to see what it produce on default AST trees, especially when
      compare to grammars I see in mySQL and PostgreSQL.

      Today later I probably will show example of generate by ANTLR ASTs,
      and what I expect in ideal case...


      --
      Best regards,
      Ruslan Zasukhin

      -------------------------
      Paradigma.

      e-mail: ruslan@...
      web : http://www.paradigmasoft.com

      To subscribe to the Valentina mail list
      send a letter to valentina-on@...
    • Sinan
      ... Ruslan, I totally agree with your assesment. When I wrote tinybasic ( which was a 4 day project , done as a proof of concept) , I agonized about submitting
      Message 2 of 5 , Sep 20, 2001
      • 0 Attachment
        Ruslan Zasukhin wrote:
        >
        > on 9/20/01 7:26, Sinan Karasu at allahsiz@... wrote:
        >
        > > Anytime I taught anyone how to use antlr, my words were always "write
        > > your tree-walker first". Well not exactly , but not too far off. Once
        > > you write a tree-walker, everything becomes vastly simpler. The
        > > tinybasic example does what you are asking for already. take a look at
        > > it, and don't be afraid of treewalkers.
        >
        > Well, Sinan,
        >
        > I have read this ... and ... it seems I do not even to use default AST
        > trees.
        >
        > I am writing SQL grammar for Valentina database and for now I am studying
        > ANTLR and its code it generate.
        >
        > I am not glad to see what it produce on default AST trees, especially when
        > compare to grammars I see in mySQL and PostgreSQL.
        >
        > Today later I probably will show example of generate by ANTLR ASTs,
        > and what I expect in ideal case...
        >

        Ruslan,

        I totally agree with your assesment. When I wrote tinybasic ( which was
        a 4 day project ,
        done as a proof of concept) , I agonized about submitting it . It is a
        hack.

        The way I see it, is that one needs three classes of AST's.

        1) Scope
        2) Data Type AST
        3) Code Type AST

        I am looking forward to your submission. And when you do it, I will
        re-write the
        whole thing using your ideas and re-submit.

        This time I am going to write a much simpler one. One that can be used
        as a starting point
        for an interpreter.

        Thanx

        Sinan
      • Munir Shareiff
        Hi guys... The other time I was asking on how to control the parsing of the if then else thing... and Sinan suggested to use dummy rules for the part I should
        Message 3 of 5 , Sep 26, 2001
        • 0 Attachment
          Hi guys...

          The other time I was asking on how to control the
          parsing of the if then else thing... and Sinan
          suggested to use dummy rules for the part I should
          skip.. He also suggested that I should use a tree
          walker...

          I have tried a tree walker but i do not really
          understand it... however i managed to get the thing
          working using dummy rules....

          here are the grammar rules...

          if_stmt
          {int cond1, cond2;}
          : IF cond1=condition_expr
          stmt_list[cond1]

          ( ELSE { if ((cond1 == false)
          cond2 = true;
          else
          cond2 = false;
          }
          stmt_list[cond2] )?
          END IF
          ;

          stmt_list[int n]
          :
          {is_true(n)}?
          (statement)*
          | (dummy_statement)*
          ;

          Note - condition_expr will return true or false. and
          stmt_list will execute dummy_statement(same grammar as
          statement without the actions) if the parameter passed
          is false.


          okay.. my question now is... how do we execute the
          same statements a couple of times.... say in a while
          loop???

          while_stmt
          {int cond1;}
          : WHILE
          cond1=condition_expr
          stmt_list[cond1]
          END WHILE
          ;

          this grammar will only execute the stmt_list once.. i
          am stuck here... for now... any suggestions???

          by the way.. can anybody point me to some good
          examples and some good (easy to understand)
          documents... as i am a beginner... just started
          working on ANTLR about a week ago...

          thanx... and regards...
          Munir


          __________________________________________________
          Do You Yahoo!?
          Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger. http://im.yahoo.com
        Your message has been successfully submitted and would be delivered to recipients shortly.