How to make a grammatic case insensitive?

7 views
Skip to first unread message

byron

unread,
Apr 11, 2011, 3:02:17 AM4/11/11
to lepl
Hi, I was trying to parse a grammatic of SQL and I want it to be case
insensitive (like the actual SQL), except in the explicit strings
(literal strings). So I wasn't read anything about it in any of the
support pages and neither in this list.

Obviously I can pre-analyze the input but that will be less efficient
and I don't like it.

PD: I like the lepl, it think it's a great framework, very useful.

Thank for all,
Byron Morales

andrew cooke

unread,
Apr 18, 2011, 12:59:06 PM4/18/11
to le...@googlegroups.com

Hi,

First, I'm really sorry about the delay here.  Your message seems to be a week old.  I just received a notification of message pending from Google, but perhaps I missed one a week ago.

There's nothing built-in (that I remember!), but you can do it by hand by defining a regexp like:

  select = Regexp('[Ss][Ee][Ll][Ee][Cc][Tt]')

Obviously that's tedious, but you can automate it by writing your own matcher (really, more of a matcher factory):

  def NoCase(text):
      return Regexp(''.join('[{0}{1}]'.format(c.lower(), c.upper()) for c in text)

(I'm just typing this blind, so it may not compile, but I hope you get the idea).

Cheers,
Andrew
Reply all
Reply to author
Forward
0 new messages