[af]?lex正则表达式的区别 [英] [af]?lex regular expression difference

查看:92
本文介绍了[af]?lex正则表达式的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道如何执行此操作,而且我没有在线上找到有关如何执行此操作的好资源[.]我正在尝试采用带注释的EBNF生产规则,该规则是两个正则表达式之间的区别并把它变成一个(na | f?)lex语法规范规则[.]问题是我看不到通常能做到这一点的方法[.] {3},有一种方法可以像克莱恩代数一样使用克莱恩代数来做到这一点.您可以在上下文无关的语法中使用带交替符的空匹配[?]

I don't know how to do this, and I've found no good resources online for how to perform this operation[.] I'm trying to take an annotated EBNF production rule which is a difference between two regular expressions and turn it into a(n a| f?)lex grammar specification rule[.] The problem is that I see no way to do this normally[.]{3} is there a way to do this using Kleene algebra, like the way you can use an empty match with alternation in a context-free grammar[?]

推荐答案

EBNF生产规则是什么样的(您可以在EBNF中写出来吗?)

What does the EBNF production rule look like (and can you write that in EBNF?)

正则表达式之间的集合差异A\B等于与补码的交集:A&~B:与A匹配的字符串集,没有与B匹配的任何字符串.flex和alex都不在其正则表达式中支持此类语义表达语言.

The set difference A\B between regular expressions is equivalent to intersection with a complement: A&~B: the set of strings matched by A, devoid of any strings matched by B. Neither flex nor alex support such semantics in their regular expression languages.

这种形式的表达式仍表示正则语言,因此具有等效的自动机,为此,仅基于交替和Kleene运算符才存在正则表达式.这种等效表达式不容易找到,并且取决于A和B的特定内部.也就是说,我们不能仅将A和B插入一些通用的正则表达式中,以使结果表示集合差异.原始A和B将不会出现在设置差异正则表达式中.

An expression of this form still denotes a regular language, and therefore has an equivalent automaton, for which a regular expression exists based only on the alternation and Kleene operators. This equivalent expression not easy to find, and it depends on the specific internals of A and B. That is to say, we can't just plug A and B into some general regex formula such that the result denotes the set difference. The original A and B will not appear in the set difference regex.

这篇关于[af]?lex正则表达式的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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