Search CTRL + K

Context-Free Grammar

上下文无关语法(context-free grammar) 是一种 形式语法,其推导规则仅作用于 非终结符,也就是产生式的左手端只有一个 非终结符,不受任何上下文影响。


In formal language theory, a context-free grammar (CFG) is a formal grammar whose production rules can be applied to a nonterminal symbol regardless of its context. In particular, in a context-free grammar, each production rule is of the form


with A a single nonterminal symbol, and α a string of terminals and/or nonterminals ( α can be empty). Regardless of which symbols surround it, the single nonterminal A on the left hand side can always be replaced by α on the right hand side.[1]

  1. ↩︎