Regular vs Context Free Grammars

后端 未结 8 1393
我寻月下人不归
我寻月下人不归 2020-11-30 16:44

I\'m studying for my computing languages test, and there\'s one idea I\'m having problems wrapping my head around.

I understood that regular grammars<

8条回答
  •  醉梦人生
    2020-11-30 17:45

    The difference between regular and context free grammar: (N, Σ, P, S) : terminals, nonterminals, productions, starting state Terminal symbols

    ● elementary symbols of the language defined by a formal grammar

    ● abc

    Nonterminal symbols (or syntactic variables)

    ● replaced by groups of terminal symbols according to the production rules

    ● ABC

    regular grammar: right or left regular grammar right regular grammar, all rules obey the forms

    1. B → a where B is a nonterminal in N and a is a terminal in Σ
    2. B → aC where B and C are in N and a is in Σ
    3. B → ε where B is in N and ε denotes the empty string, i.e. the string of length 0

    left regular grammar, all rules obey the forms

    1. A → a where A is a nonterminal in N and a is a terminal in Σ
    2. A → Ba where A and B are in N and a is in Σ
    3. A → ε where A is in N and ε is the empty string

    context free grammar (CFG)

    ○ formal grammar in which every production rule is of the form V → w

    ○ V is a single nonterminal symbol

    ○ w is a string of terminals and/or nonterminals (w can be empty)

提交回复
热议问题