Case-insensitive parser

Jan 27, 2012 at 7:30 PM
Edited Jan 27, 2012 at 7:31 PM

Hi,

I've been writing an meta# parser for the SQL like language. Is it even possible to define a grammar for such case-insensitive  language? Any ideas on how to accept a sequence that matches some input (of character), without regard to case?

Thanks,

Gremlin2

Coordinator
Jan 30, 2012 at 4:08 PM

Hello,

I would love to hear more about what you are working on but basically you can define a rule that accepts upper or lower case letters for identifiers, for example:

Identifier = CaseInsensitiveLetter (CaseInsensitiveLetter | Number)+;

CaseInsensitiveLetter = 'A'..'Z' | 'a'..'z';

Jan 30, 2012 at 6:23 PM

Hello,

Thanks for the quick reply, but what i really want is to define а keyword that accept "insert" or "INSERT" or any other permutation of case.

Coordinator
Jan 31, 2012 at 1:48 AM

Off the top of my head I think you would have to do something like this:

A = 'a' | 'A';
B = 'b' | 'B';
C = 'c' | 'C';
...
Z = 'z' | 'Z';

[Keyword]
Insert = [I N S E R T];

Jan 31, 2012 at 6:20 AM

Hello,

Thank you. I'll check it.