Is there an algorithm or tool to convert regular grammar to regular expression?
相关问题
- How do shader compilers work?
- Improve converting string to readable urls
- C++ Builder - Difference between Lib and Res
- Regex to match charset
- Regex subsequence matching
相关文章
- Optimization techniques for backtracking regex imp
- Regex to check for new line
- Allow only 2 decimal points entry to a textbox usi
- Comparing speed of non-matching regexp
- Regular expression to get URL in string swift with
- 请问如何删除之前和之后的非字母中文单字
- Lazy (ungreedy) matching multiple groups using reg
- How to force Delphi compiler to display all hints
The algorithm is pretty straightforward if you can compute an automaton from your regular expression. Once you have your automaton. For instance for
(aa*b|c)
, an automaton would be (arrows go to the right):Then just "enumerate" your transitions as rules. Below, consider that 0, 1, and 2 are nonterminal symbols, and of course a, b and c are the tokens.
or, if you don't want empty right-hand sides.
And of course, the route in the other direction provides one means to convert a regular grammar into an automaton, hence a rational expression.
Answer from dalibocai:
My goal is to convert regular grammer to DFA. Finally, I found an excellent tool : JFLAP.