Regular Expression Difference [af]? lex

I do not know how to do this and I have not found any good resources on the internet for how to accomplish this operation. [] I'm trying to take an annotated EBNF production rule, which is the difference between two regular expressions, and turn it into a grammar specification rule (na | f?) Lex [.] The problem is I don't see a way to do this normally [.] { 3} is there a way to do this using Klein algebra, for example a way you can use an empty alternation match in a context-free grammar [?]

-1


source to share


1 answer


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

The specified difference A\B

between regexes is equivalent to complement intersection A&~B

:: a set of strings matched by A, stripped of any strings that match B. Neither flex nor alex support such semantics in their expression languages ​​regex.



An expression of this form still denotes a regular language and therefore has an equivalent automaton for which there is a regular expression based only on the alternation operators and Kleene. This equivalent expression is not easy to find and depends on the specific internals of A and B. That is, we cannot just plug A and B into some general regex formula so that the result means many differences. The original A and B will not show up in the given delta regex.

+1


source







All Articles