5.1.1 Context-Free Grammars

一个上下文无关文法(context-free grammar)由一组产生式(productions)组成。每个产生式,左端(left-hand side)是一个被称为非终结符的抽象记号,右端(right-hand side)是

一个上下文无关文法(context-free grammar)由一组产生式(productions)组成。每个产生式有一个抽象符号称为非终结符号(nonterminal)作为它的左部(left-hand side),以及包含零个或多个非终结符号和终结符号(terminal)的一个序列作为它的右部(right-hand side)。对于每个文法而言,终结符号都取自一个指定的符号表。

一个链式产生式是一个有一个非终结符号和零个或多个终结符号在右部的产生式。

从一个只包含一个独特的非终结符号(目标符号,goal symbol)的句子开始,一个给定的上下文无关文法定义了一种语言(language),即终结符号序列的集合(甚至是无限的集合)。这些序列可以通过反复地把生成式序列中的非终结符号替换成以该非终结符号为左部的生成式的右部来生成。

A context-free grammar consists of a number of productions. Each production has an abstract symbol called a nonterminal as its left-hand side, and a sequence of zero or more nonterminal and terminal symbols as its right-hand side. For each grammar, the terminal symbols are drawn from a specified alphabet.

A chain production is a production that has exactly one nonterminal symbol on its right-hand side along with zero or more terminal symbols.

Starting from a sentence consisting of a single distinguished nonterminal, called thegoal symbol, a given context-free grammar specifies a language, namely, the (perhaps infinite) set of possible sequences of terminal symbols that can result from repeatedly replacing any nonterminal in the sequence with a right-hand side of a production for which the nonterminal is the left-hand side.上下文无关文法

Last updated