[antlr-interest] C++ beginner questions

Peggy Fieland madcapmaggie at yahoo.com
Fri Sep 30 09:08:19 PDT 2005


C++ Lexer its $getText. For example:

IDENT: (ID_START_LETTER) (ID_LETTER)*
{
 std::string s = $getText;
       $setText( LowerCase(s) ); }
resolving ambiguities:  syntactic or semantic
predicates

in lexer:

IDENT:
  (BOOLEAN!) => BOOLEAN  { $setType(BOOLEAN); }
...


ML_COMMENT
	:	'/' '*'
	
options {
				generateAmbigWarnings=false;
			}
		:
			{ LA(2)!='/' }? '*'
		|	'\r' '\n'		{newline();}
		|	'\r'			{newline();}
		|	'\n'			{newline();}
		|	~('*'|'\n'|'\r')
		)*
		'*' '/'
		{ _ttype = ANTLR_USE_NAMESPACE(antlr)Token::SKIP; }
	

...

in parser similarly.  More gory details upon request.

Peggy





More information about the antlr-interest mailing list