[antlr-interest] Re: A question about extracting comments

Fan Yang yhhf_dy at yahoo.com
Fri Oct 11 11:37:59 PDT 2002


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/ 



More information about the antlr-interest mailing list