I am trying to figure out how to build CFG (context free grammar) based on this regular expression. For example, a (ab) * (a | b) I think there is an algorithm that can be followed, but it is really confusing. here is what i got so far:
S->aAB; A->aAb|empty; B->a|b;
Does this look right? Any help would be appreciated.
Another way to build context-free grammar for a given regular expression:
X -> t Y
F -> epsilon
X -> t
X -> t F
, FSA ( , , ):
:
S -> a A1 A1 -> a A2 A2 -> b B3 B3 -> a A2 B3 -> a A4 B3 -> b B5 A1 -> a A4 A1 -> b B5 A4 -> epsilon B5 -> epsilon epsilon ->
, , :
A1 -> a A1 -> b B3 -> a B3 -> b
, , , , , , , , .
CFG , a, (ab)* (a|b).
a
(ab)*
(a|b)
(a|b) B -> a | b .
B -> a | b
(ab)* ab, abab, ababab .. , A -> abA | empty .
ab
abab
ababab
A -> abA | empty
, :
S -> aAB A -> abA | empty B -> a | b
: A -> aAb | empty ab, aabb, aaabbb .., .
A -> aAb | empty
aabb
aaabbb
Source: https://habr.com/ru/post/1539125/More articles:How does the POSIX tee command work? - shellHow to join the Urdu alphabet in C # - c #Associating a Laravel Form Form with Relationships - laravelTypeahead.js соответствует только началу слова - jqueryThread Safety and MEF Catalog - multithreadingNSCollectionView resizes items like iTunes - cocoaСбой сборки. Не удалось найти тип "System.Globalization.SortVersion" - monoDocumenting a Python function with a docstring that is read in raw form and provides good sphinx output - pythonSetting Elasticsearch _score based on the field value in relation to another field value of the corresponding document - popularityWhat does a function attribute mean? - c ++All Articles