[antlr-interest] Re: A question about extracting comments
Brian Smith
brian-l-smith at uiowa.edu
Fri Oct 11 12:45:49 PDT 2002
Fan,
I'm sorry, I didn't read your problem correctly. It indeed seems like
you will need to use a predicate. I've never used a predicate in the
lexer before so I'm not sure how it all works.
Sorry,
Brian
Fan Yang wrote:
> Hi Brian,
>
> According to your suggestion, I have modified my lexter which is
> showing below. I think I used it in a wrong because there is an error
> like:
>
> ANTLR Parser Generator Version 2.7.1 1989-2000 jGuru.com
> error: Lexer rule REM is not defined
> MyVB.g:804: no definition of rule mREM
>
> I'm sorry I ask you guys so many naive questions.
>
> Regards,
>
> fan
> /* --- Test.g Begin --- */
>
> class MyLexer extends Lexer;
> options {
> k=4;
> exportVocab=DIALECT;
> testLiterals=false;
> caseSensitiveLiterals=false;
> caseSensitive=false;
> }
>
> tokens{
> REM="rem";
> }
>
> COMMENT
> : (REM |'\'')
> (~('\n'|'\r'))* ('\n'|'\r'('\n')?)
> {std::cout<<$getText<<std::endl; $setType(ANTLR_USE_NAMESPACE
> (antlr)Token::SKIP); newline();}
> ;
>
> // Whitespace -- ignored
> WS_
> :(' '
> |'\t'
> ){ _ttype = ANTLR_USE_NAMESPACE(antlr)Token.SKIP; }
> ;
>
> /* --- Test.g End --- */
>
> --- In antlr-interest at y..., Brian Smith <brian-l-smith at u...> wrote:
>
>>tokens {
>> REM="rem";
>>}
>>
>>Fan Yang wrote:
>>
>>>Thank all of you.
>>>
>>>I don't know how to put "rem" into the lexer's tokens table:(.
>>
> Would
>
>>>you please give me some hints?
>>>
>>>BTW, I'm looking for Ter's post on the list.
>>>
>>>Have a nice weekend,
>>>
>>>Fan
>>
>
>
>
>
> 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