[antlr-interest] Re: how to praser a '\' in antlr

David Wigg wiggjd at sbu.ac.uk
Fri Nov 22 03:13:51 PST 2002


I use the following for whitespace which seems to work. I am 
using ANTLR 2.7.1 to generate a parser in C++.

// Whitespace -- ignored
Whitespace	
	:	(	( ' ' |'\t' | '\f' )
		// handle newlines
	|	(	"\r\n"  // MS
		|	'\r'    // Mac
		|	'\n'    // Unix
		)	{ newline(); }
		// handle continuation lines
	|	(	"\\\r\n"  // MS
		|	"\\\r"    // Mac
		|	"\\\n"    // Unix
		)	{ deferredNewline(); }
	)	
	{ _ttype = ANTLR_USE_NAMESPACE(antlr)Token::SKIP; }
	;

David Wigg
Researcher
South Bank University
London, UK.



 

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



More information about the antlr-interest mailing list