问题
How to convert a Context Free Grammar to a DFA? This is easy if we have transitions like A->a B. But when we have the transitions as A->a B c. Then how should we represent it as a DFA
回答1:
First, you should convert your language to CNF (Chomskey Normal Form). Then steps for conversion are as such:
Convert it to left/right grammar is called a regular grammar.
Convert the Regular Grammar into Finite Automata The transitions for automata are obtained as follows For every production A -> aB make δ(A, a) = B that is make an are labeled ‘a’ from A to B. For every production A -> a make δ(A, a) = final state. For every production A -> ϵ, make δ(A, ϵ) = A and A will be final state.
来源:https://stackoverflow.com/questions/22741321/automata-theory-conversion-of-a-context-free-grammar-to-a-dfa