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

RE: Another ANTLR bug

Expand Messages
  • Michael Schmitt
    Hi Monty, ... I am getting #([OpenRange], #[OpGreaterOrEqual], constant ) - and a segmentation fault in the TreeParser. The problem seems to be that there is
    Message 1 of 2 , Apr 11, 2000
    • 0 Attachment
      Hi Monty,

      > If you write
      >
      > openRange :
      > ... something
      > | ( EqualsSign! { ## = #( [OpEqual] ); }
      > | GreaterThanOrEqualsSign! { ## = #( [OpGreaterOrEqual] ); } )
      > constant
      > { ## = #( [OpenRange], ## ); } ;
      >
      > OpEqual and constant are placed on the same level. Strange,
      > isn't it? It
      > is even more strange that if you write a "correct" TreeParser that
      > parses a wrong input (tokens on same level), it crashes with a null
      > pointer exception when using C++ as the target language.

      > This is what I would expect to see
      >
      > #[OpEqual]
      > or
      > #[OpenRange, #[OpGreaterOrEqual, constant]]
      >
      > You are saying you are getting something different?

      I am getting #([OpenRange], #[OpGreaterOrEqual], constant ) - and a
      segmentation fault in the TreeParser. The problem seems to be that there
      is no token in front of the operator. Hence at the time when the
      operator becomes the new root node, the current AST is the nullAST.
      Seems like something is wrong in the C++ code generator.

      You can't imagine how long it took me to find the following workaround
      (a few other approaches didn't work either)

      openRange :

      constant
      ...
      | ( o1:EqualsSign^ { #o1 -> setType( OpEqual ); #o1
      -> setText( "" ); }
      | o6:GreaterThanOrEqualsSign^ { #o6 -> setType( OpGreaterOrEqual
      ); #o6 -> setText( "" ); } )
      constant
      { ## = #( [OpenRange], ## ); }

      Well, my SDL grammar is rather big; 450 Rules for the parser, a few less
      for the TreeParser. So, probably, it is no wonder that I found a large
      number of bugs in ANTLR; thank god for all of them there are
      workarounds. However, I really hope that there will be bug fix release
      soon. Of course, I could fix a few things on my own but there are
      persons outside my institute that want to use the grammar as well and
      need a reliable, official ANTLR version.

      Michael

      --
      ======================================================================
      Michael Schmitt phone: +49 451 500 3725
      Institute for Telematics secretary: +49 451 500 3721
      Medical University of Luebeck fax: +49 451 500 3722
      Ratzeburger Allee 160 eMail: schmitt@...-luebeck.de
      D-23538 Luebeck, Germany WWW: http://www.itm.mu-luebeck.de
      ======================================================================
    Your message has been successfully submitted and would be delivered to recipients shortly.