Marpa中不区分大小写的匹配 [英] Case-insensitive matching in Marpa

查看:85
本文介绍了Marpa中不区分大小写的匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我先前的问题有关使用正则表达式的不区分大小写的关键字匹配有关。

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

是否有可能在 Marpa
如果是这样,怎么办?

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

假设我有语法

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

我如何使其与任何脚本匹配脚本 SCRIPT 还是任何其他大小写字母组合?

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

推荐答案

没有一种简单的方法可以指定不区分大小写。当然,您可以将字符类串在一起:[sS] [cC] [rR] [iI] [pP] [tT],但这很尴尬。

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.

更新:自2.076000以来,最新的索引版本Marpa :: R2现在都为两个都具有:ic修饰符字符串和字符类,使它们不区分大小写。在文档中,请参见 https://metacpan.org / pod / Marpa :: R2 :: Scanless :: DSL#单引号字符串 https://metacpan.org/pod/Marpa::R2::Scanless::DSL#Character-classes

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 .

这篇关于Marpa中不区分大小写的匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆