[antlr-interest] [] in commentary
Monty Zukowski
monty at codetransform.com
Thu Aug 5 07:25:36 PDT 2004
See the documentation about the charVocabulary option.
http://www.antlr.org/doc/options.html#_bb14
Monty
ANTLR & Java Consultant -- http://www.codetransform.com
ANSI C/GCC transformation toolkit --
http://www.codetransform.com/gcc.html
Embrace the Decay -- http://www.codetransform.com/EmbraceDecay.html
On Aug 5, 2004, at 1:30 AM, Klaus Dalinghaus 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;
> // a paraphrase used for error messages
> paraphrase = "an identifier";
> }
> ('a'..'z'|'A'..'Z'|'_'|'0'..'9'|'.'|'-')*
> : ('a'..'z'|'A'..'Z'|'_'|'0'..'9'|'.'|'-')+
> ;
>
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
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