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

Unexpected token error

Expand Messages
  • Jerry Dy
    Hi, I get an unexpected error for simple grammar below. Can someone explain to me why? Thanks! -Jerry options { language= Cpp ; } class PageParser extends
    Message 1 of 2 , Mar 8, 2004
    • 0 Attachment
      Hi, I get an unexpected error for simple grammar below. Can someone
      explain to me why? Thanks!

      -Jerry

      options { language="Cpp"; }
      class PageParser extends Parser;
      options { buildAST = true; }
      page: element
      ;
      element: attr+
      ;
      attr: ID
      ;

      class PageLexer extends Lexer;
      ID: 'a'
      ;

      ANTLR Parser Generator Version 2.7.3 (20040224-91) 1989-2003
      jGuru.com
      soac.g:6:10: rule classDef trapped:
      soac.g:6:10: unexpected token: attr
      error: aborting grammar 'PageParser' due to errors
      Exiting due to errors.
      *** Error code 1
      clearmake: Error: Build script failed for "PageLexer.cpp"
    • Terence Parr
      You need (attr)+ not attr+ :) Ter ... -- Professor Comp. Sci., University of San Francisco Creator, ANTLR Parser Generator, http://www.antlr.org Cofounder,
      Message 2 of 2 , Mar 8, 2004
      • 0 Attachment
        You need (attr)+ not attr+ :)

        Ter

        On Mar 8, 2004, at 11:19 AM, Jerry Dy wrote:

        > Hi, I get an unexpected error for simple grammar below. Can someone
        > explain to me why? Thanks!
        >
        > -Jerry
        >
        > options { language="Cpp"; }
        > class PageParser extends Parser;
        > options { buildAST = true; }
        > page: element
        > ;
        > element: attr+
        > ;
        > attr: ID
        > ;
        >
        > class PageLexer extends Lexer;
        > ID: 'a'
        > ;
        >
        > ANTLR Parser Generator Version 2.7.3 (20040224-91) 1989-2003
        > jGuru.com
        > soac.g:6:10: rule classDef trapped:
        > soac.g:6:10: unexpected token: attr
        > error: aborting grammar 'PageParser' due to errors
        > Exiting due to errors.
        > *** Error code 1
        > clearmake: Error: Build script failed for "PageLexer.cpp"
        >
        >
        >
        >
        >
        > Yahoo! Groups Links
        >
        >
        >
        >
        >
        >
        --
        Professor Comp. Sci., University of San Francisco
        Creator, ANTLR Parser Generator, http://www.antlr.org
        Cofounder, http://www.jguru.com
        Cofounder, http://www.knowspam.net enjoy email again!
        Cofounder, http://www.peerscope.com pure link sharing
      Your message has been successfully submitted and would be delivered to recipients shortly.