Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Case-insensitive matching in Marpa

Related to my earlier question about case-insensitive keyword matching using regular expressions.

Is it possible to match strings case-insensitively in Marpa? If so, how?

Suppose I have the grammar

:start ::= script
identifier ~ [\w]+
script ::= 'script' identifier code
code ::= command*
command ::= 'run' | 'walk' | 'stop'

How can I make it match any of script, Script, SCRIPT or any other combination of lower and uppercase letters?

like image 644
onitake Avatar asked Jul 08 '13 15:07

onitake


1 Answers

There isn't a straightforward way to specify case-insensitivity. Of course, you can string together character classes: [sS] [cC] [rR] [iI] [pP] [tT], but that's pretty awkward.

Sorry. Case-insensitive strings would be a good feature to add.

UPDATE: As of 2.076000, the latest indexed release, Marpa::R2 now has an :ic modifier for both strings and character classes, making them case-insensitve. In the docs, see https://metacpan.org/pod/Marpa::R2::Scanless::DSL#Single-quoted-strings and https://metacpan.org/pod/Marpa::R2::Scanless::DSL#Character-classes .

like image 120
Jeffrey Kegler Avatar answered Nov 02 '22 16:11

Jeffrey Kegler