[antlr-interest] [] in commentary

Peggy Fieland madcapmaggie at yahoo.com
Thu Aug 5 07:23:26 PDT 2004


Yes, you need to tell antlr which characters are
allowed in your grammar -- otherwise it just assumes
that only the ones you've got specifically are valid.
You want something like:
    charVocabulary='\3'..'\377';
in your lexer options section.

Peggy

--- kdaling71 <kdaling at uos.de> wrote:

> Hi all,
> 
> I am using the following lines to get comments in my
> grammar:
> 
> SL_COMMENT :
>     "//"
>     (~'\n')* '\n'
>     { _ttype = Token.SKIP; newline(); }
>     ;
> 
> When I now put a comment with squared brackets in my
> file like
> 
> // This is [a] comment
> 
> I get an error message:
> 
> expecting '\n' found [
> 
> Comments with other symbols like () oder {} are
> allowed.
> Does anybody has an idea what the problem is?
> 
> Thanks
> 
> 
> Klaus Dalinghaus
> 
>
---------------------------------------------------------------
> Institute of Cognitive Science, University of
> Osnabrück
> Kolpingstraße 7, 49069 Osnabrück
> Tel.: +49-(0)-541-969-4797   Fax.:
> +49-(0)-541-969-6229
> http://www.cogsci.uni-osnabrueck.de/~kdaling
> 
> 
> 
> 
> 
> 
> 
> Here is my complete grammar
> 
> class FPParseParser extends Parser;
> 
> // options for the parser
> options {
>     buildAST = true;    // uses CommonAST by default
>     defaultErrorHandler = false;
> }
> 
> 
> fuzzyProgram
>     :    ( prefixStatement ) ? ( operatorDefinition
> ) * ( clauseBlock ) +
>     ;
> 
> prefixStatement
>     :    PREFIX^ IDENTIFIER SEMI!
>     ;
> 
> operatorDefinition
>     :    OPERATOR^ IDENTIFIER EQUALS! IDENTIFIER
> LEFTBRACKET! (
> operatorArgumentList ) ? RIGHTBRACKET! SEMI!
>     ;
> 
> operatorArgumentList
>     :    IDENTIFIER ( COMMA^ IDENTIFIER ) *
>     ;
> 
> clauseBlock
>     :    clause SEMI^
>     ;
> 
> clause
>     :    conclusion LEFTARROW^ premiseOp
>     ;
> 
> premiseOp
>     :    simplePremise
>     |    multiPremise
>     |   
>     ;
> 
> simplePremise
>     :    premiseList PIPE^ operator
>     ;
> 
> multiPremise
>     :     LEFTCURLY^ premise RIGHTCURLY! PIPE!
> operator
>     ;
> 
> premiseList
>     :    premise ( COMMA^ premise )*
>     ;
> 
> conclusion
>     :    IDENTIFIER
>     ;
> 
> premise
>     :    IDENTIFIER
>     ;
> 
> operator
>     :    IDENTIFIER
>     ;
> 
> class FPParseLexer extends Lexer;
> 
> 
> options{
>     defaultErrorHandler = false;
> }
> 
> tokens{
>     PREFIX = "prefix";
>     OPERATOR = "operator";
> }
> 
> WS    :    (' '
>     |    '\t'
>     |    '\n'
>     |    '\r')
>         { _ttype = Token.SKIP; }
>     ;
> 
> SL_COMMENT :
>     "//"
>     (~'\n')* '\n'
>     { _ttype = Token.SKIP; newline(); }
>     ;
> 
> 
> EQUALS:            '=';
> 
> LEFTARROW:        "<-";
> 
> LEFTCURLY:        '{';
> 
> RIGHTCURLY:        '}';
> 
> LEFTBRACKET:    '(';
> 
> RIGHTBRACKET:    ')';
> 
> SEMI:            ';';
> 
> COMMA:            ',';
> 
> PIPE:            "|";
> 
> IDENTIFIER
> options {
>     testLiterals = true;
>     paraphrase = "an identifier";
> }
>     :    ('a'..'z'|'A'..'Z'|'_'|'0'..'9'|'.'|'-')+
>     ;
> 
> 
> 
> 
> 
> 
> 
>  
> Yahoo! Groups Links
> 
> 
>     antlr-interest-unsubscribe at yahoogroups.com
> 
>  
> 
> 



		
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail 


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

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



More information about the antlr-interest mailing list