[antlr-interest] what is a problem with following grammer

Matthew Ford Matthew.Ford at forward.com.au
Fri May 24 05:08:32 PDT 2002


 link    :
                 LINKSTART
 IMG
 LINEND

expands to

"<i18n:link" (WS (ATTR)*)?     ">"
 "<i18n:img" (WS (ATTR)*)?   "/>"
 "</i18n:link>"

you passed

<i18n:link  page="/aggregationServlet/app/aggregation/user/toViewAccount">
     <i18n:bean pageProperty="buttonCancelImage" border="0"
altProperty="buttonCancelText" />
</i18n:link>

There is no <i18n:img  so  link: complains

----- Original Message -----
From: "sachin_sawant10" <sachin_sawant10 at yahoo.com>
To: <antlr-interest at yahoogroups.com>
Sent: Friday, May 24, 2002 9:44 PM
Subject: [antlr-interest] what is a problem with following grammer


> My grammer file is as follows,
>
> ---------------------------------------------------------------------
> class JSPParser extends Parser;
>
> file:   (statement)+
> ;
>
> statement: (   WORD
>              | STRING
>      | link
>       )
> ;
>
> link    :
>                 LINKSTART
> IMG
> LINEND
>
> ;
>
>
>
> class JSPLexer extends Lexer;
> options {
> caseSensitive=false;
> k=7;
> filter=SCARF;
> charVocabulary='\3'..'\177';
> }
>
> LINKSTART
> : "<i18n:link"
> (WS (ATTR)*)?
> ">"
>
> ;
>
> IMG
>         :      "<i18n:img"
> (WS (ATTR)*)?
> "/>"
> ;
>
> LINKEND
> : "</i18n:link>"
> ;
>
>
>
> protected
> ATTR
> options {
> ignore=WS;
> }
> : w:WORD '='
> ( s:STRING
> | v:WORD
> )
> ;
>
> /** Match until next whitespace; can be file, int, etc... */
> protected
> WORD: (
> options {
> generateAmbigWarnings=false;
> }
> : 'a'..'z' | '0'..'9' | '/' | '.' | '#' | '_'
> )+
> ;
>
> protected
> STRING
> : '"' (~'"')* '"'
> | '\'' (~'\'')* '\''
> ;
>
>
> protected
> WS : ( ' '
> | '\t'
> | '\f'
> | ( "\r\n"  // DOS
> | '\r'    // Macintosh
> | '\n'    // Unix (the right way)
> )
> { newline(); }
> )
>
> ;
>
> protected
> SCARF
> : WS // track line numbers while you scarf
> | .
> ;
>
> --------------------------------------------------------------------
>
> When I run the parser.file() on the following data
>
> <i18n:link
> page="/aggregationServlet/app/aggregation/user/toViewAccount">
>      <i18n:bean pageProperty="buttonCancelImage" border="0"
> altProperty="buttonCancelText" />
> </i18n:link>
>
>
> I get "line 3: expecting IMG, found '</i18n:link>'" error.
>
> Could anybody help me to solve this issue?
>
> Thanks
>
> Sachin
>
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list