[prog] lex/yacc problem

Almut Behrens almut-behrens at gmx.net
Wed May 28 13:24:16 EST 2003


Jimen Ching wrote:
> 
> The lexer has the following patterns:
> 
> WS		[ \t\r\b]
> Digit		[0-9]
> DigitU		[0-9_]
> Letter		[a-zA-Z]
> LetterU		[a-zA-Z_]
> WordNum		[0-9a-zA-Z]
> WordNumU	[0-9a-zA-Z_]
> Number		{Digit}{DigitU}*
> Word		{LetterU}{WordNumU}*
> Binary		([-+]?{Number}{WS}*)?\'[bB]{WS}*[01xXzZ?][01xXzZ?_]*
> 
> <INITIAL>"#"		{ save_word("#"); return YYPOUND; }
> <INITIAL>{Binary}	{ copy_word(yytext); return YYNUMBER; }
> <INITIAL>{Word}		{ copy_word(yytext); return YYCHARSTR; }


do you hava a rule somewhere that handles the occurrence of whitespace, e.g.

<INITIAL>{WS}  { }

in its most simple case (i.e. to ignore whitespace)?  If not, the lexer will
pass 
the string " = " to the parser, instead of "=", as your yacc grammar
expects.

(just an idea, haven't tested it...)

Almut


-- 
+++ GMX - Mail, Messaging & more  http://www.gmx.net +++
Bitte lächeln! Fotogalerie online mit GMX ohne eigene Homepage!



More information about the Programming mailing list