lex & yacc questions

Ken Nelson ssdken at watson.Claremont.EDU
Tue Aug 21 03:39:10 AEST 1990


> PROBLEM 3 ------------------------------------ :-(

> I asked this before but did'nt get a response.  I'm trying to write a 
> grammer for a context, case-insensitive grammer (Unify RDBMS command
> language).  I know that you can specify lower or upper case letters
> by defining letters in the lex rules section.  In my example
> I am using letters  [A-Za-z'_'] to match upper or lower case characters
> and possibly the underscore.  My question is this, how can you get
> lex to match a reserved word you have declared, whether it's upper case
> or not.  For example, Unify has the reserved command word "application".
> I wish to scan for this word using lex and return to yyparse() whether
> the reserved word "application" is found as "application", "APPLICATION",
> "Application", "APPlication", etc.  What do you specify in lex to do
> this.  I tried using "APPLICATION" in the rules section (e.g. 
> "APPLICATION" { return(APP); } where APP is a #define).  However, this
> only works if the token found is already capitalized.

Try this:


[Aa][Pp][Pp][Ll][Ii][Cc][Aa][Tt][Ii][Oo][Nn] 	{ return _APPLICATION; }


this will match no matter what combination of case is used.


   Hope this helps.



				Ken Nelson
				Principal Engineer
				Software Systems Design
				3627 Padua Av.
				Claremont, CA 91711
				(714) 624-3402



More information about the Comp.lang.c mailing list