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

3035Re: [antlr-interest] Re: [2.7.1a2] java.tree.g omission

Expand Messages
  • Alexander Lenski
    Jan 1, 2001
    • 0 Attachment
      Use semantic predicates or try this:
      newExpression
      : #( "new" type
      ( newArrayDeclarator (arrayInitializer)?
      | elist
      ( objBlock
      { unit.addAnonymousClass(); }
      | // This is elist without objBlock
      )
      )
      )
      ;
      // Alexander Lenski

      ----- Original Message -----
      From: <chris@...>
      To: <antlr-interest@egroups.com>
      Sent: Sunday, December 31, 2000 7:14 PM
      Subject: [antlr-interest] Re: [2.7.1a2] java.tree.g omission


      > This is great! I am in the process of writing a Tree Walker that
      > needs to know when it encounters a new Anonymous type being born.
      > Unfortunately a can't seem to figure out how to tell the difference
      > between a plain elist and an elist with an objBlock. I tried
      >
      > newExpression
      > : #( "new" type
      > ( newArrayDeclarator (arrayInitializer)?
      > | elist (objBlock) { unit.addAnonymousClass(); }
      > | elist
      > )
      > )
      > ;
      >
      > But ANTLR says that's ambiguous. I figure there's probably a way in
      > the code block to tell whether there is actually an objBlock, but I
      > don't know ANTLR well enough (yet). Can anyone fill in the missing
      > pieces for me?
      >
      > newExpression
      > : #( "new" type
      > ( newArrayDeclarator (arrayInitializer)?
      > | elist (objBlock)?
      > {
      > if(?????) {
      > unit.addAnonymousClass();
      > }
      > }
      > )
      > )
      > ;
      >
      > I'm expecting something like that, but I have know idea what to
      > replace the ?????'s with. Thanks.
      > (*Chris*)
      >
      > --- In antlr-interest@egroups.com, james@e... wrote:
      > > The example Java tree walker seems to have an omission. The rule:
      > >
      > > --------------------------------------------------------------------
      > ----
      > > newExpression
      > > : #( "new" type
      > > ( newArrayDeclarator (arrayInitializer)?
      > > | elist
      > > )
      > > )
      > >
      > > ;
      > > --------------------------------------------------------------------
      > ----
      > >
      > > should be:
      > >
      > > --------------------------------------------------------------------
      > ----
      > > newExpression
      > > : #( "new" type
      > > ( newArrayDeclarator (arrayInitializer)?
      > > | elist (objBlock)?
      > > )
      > > )
      > >
      > > ;
      > > --------------------------------------------------------------------
      > ----
      > >
      > > in order to support anonymous classes.
      > > --
      > > Jerry James
      >
      >
      >
      >
      >
      >
    • Show all 4 messages in this topic