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

RE: [antlr-interest] single identifier as java expression

Expand Messages
  • mzukowski@bco.com
    So then if the follow set is wrong narrow the java grammar down to just what you need--expressions. If it isn t wrong then I m blowin smoke. In that case
    Message 1 of 3 , Aug 1, 1947
      RE: [antlr-interest] single identifier as java expression

      So then if the follow set is wrong narrow the java grammar down to just what you need--expressions.  If it isn't wrong then I'm blowin smoke.  In that case post the code that's throwing the exception.


      -----Original Message-----
      From: mzukowski@... [mailto:mzukowski@...]
      Sent: Friday, August 31, 2001 9:08 AM
      To: antlr-interest@yahoogroups.com
      Subject: RE: [antlr-interest] single identifier as java expression

      First figure out if the follow set is correct.  Look at the generated code for expression() and castExpression() and see if they allow EOF as LA(2).  Add this parser option:

              codeGenBitsetTestThreshold = 99999;
      That will prevent bitsets from being generated and make it easier to tell what is expected.
      > -----Original Message-----
      > From: Jonathan Bachrach [mailto:jrb@...]
      > Sent: Friday, August 31, 2001 8:38 AM
      > To: antlr-interest@yahoogroups.com
      > Subject: [antlr-interest] single identifier as java expression
      > i'm writing a java macro system (called JSE) that utilizes ANTLR for
      > it's lexer and constraint-based pattern matching.  in particular,
      > ANTLR is used to say whether a stream of tokens is admissable as a
      > particular non-terminal constraint (e.g., expression).  unfortunately,
      > i'm having trouble getting this to work with ANTLR and its
      > accompanying java grammar.  
      > i've got a very simple example of where things go wrong.  i took the
      > java example from 2.6.0/examples/java and modified it to behave as i
      > would like it to in my macro system.  i modified Main.java as follows:
      >                       // start parsing at the compilationUnit rule
      >                       // parser.compilationUnit();
      >                       parser.expression();
      > to get the top level to try to parse simply an expression.  and then
      > fed it a file called exp.java with one identifier in it (fragments).
      > the following is the error:
      >   jrb@oroboros>java Main exp.java
      >   Parsing...
      >      /home/ai/jrb/jse/antlr-2.6.0/examples/java/exp.java
      >   parser exception: line(1), unexpected token: fragments
      >   line(1), unexpected token: fragments
      >         at JavaRecognizer.castExpression(JavaRecognizer.java:4044)
      >         at
      > JavaRecognizer.multiplicativeExpression(JavaRecognizer.java:3762)
      >         at JavaRecognizer.additiveExpression(JavaRecognizer.java:3705)
      >         at JavaRecognizer.shiftExpression(JavaRecognizer.java:3638)
      >         at
      > JavaRecognizer.relationalExpression(JavaRecognizer.java:3561)
      >         at JavaRecognizer.equalityExpression(JavaRecognizer.java:3504)
      >         at JavaRecognizer.andExpression(JavaRecognizer.java:3469)
      >         at
      > JavaRecognizer.exclusiveOrExpression(JavaRecognizer.java:3434)
      >         at
      > JavaRecognizer.inclusiveOrExpression(JavaRecognizer.java:3399)
      >         at
      > JavaRecognizer.logicalAndExpression(JavaRecognizer.java:3364)
      >         at
      > JavaRecognizer.logicalOrExpression(JavaRecognizer.java:3329)
      >         at
      > JavaRecognizer.conditionalExpression(JavaRecognizer.java:3265)
      >         at
      > JavaRecognizer.assignmentExpression(JavaRecognizer.java:3087)
      >         at JavaRecognizer.expression(JavaRecognizer.java:1966)
      >         at Main.parseFile(Main.java:70)
      >         at Main.doFile(Main.java:54)
      >         at Main.main(Main.java:25)
      > now the castExpression seems to allow for a single identifier by
      > having an postfixExpression followed by an optional instanceof suffix,
      > where a postfixExpression can be a primaryExpression, which can in
      > turn be an IDENT.  perhaps this has something to do with eof handling
      > etc but i'm not sure exactly how to coax ANTLR into accepting a single
      > identifier as an expression.  btw, i tried this in the latest version
      > of ANTLR also without luck. 
      > any help would be greatly appreciated.
      > jonathan bachrach

      > Your use of Yahoo! Groups is subject to

      Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

    Your message has been successfully submitted and would be delivered to recipients shortly.