是否有带有非终结符号参数的 BNF?

Is there a BNF with arguments for non-terminal symbols?

在使用 Prolog DCG 解析输入时,最好有语法的伴随 BNF。

例如:

BNF

<Sentence> ::= <Noun_phrase> <Verb_phrase>
<Noun_phrase> ::= <Determiner> <Noun>
<Verb_phrase> ::= <Verb> <Phrase>
<Determiner> ::= a
<Determiner> ::= the
<Noun> ::= cat
<Noun> ::= mouse
<Verb> ::= scares
<Verb> ::= hates

作为 Prolog DCG

sentence --> noun_phrase, verb_phrase.
verb_phrase --> verb, noun_phrase.
noun_phrase --> determiner, noun.
determiner --> [a].
determiner --> [the].
noun --> [cat].
noun --> [mouse].
verb --> [scares].
verb --> [hates].

但是 Prolog DCG 也可以有参数
在这个例子中 Number 代表 singularplural

sentence(Number) --> noun_phrase(Number), verb_phrase(Number).
verb_phrase(Number) --> verb(Number), noun_phrase(Number).
noun_phrase(Number) --> determiner(Number), noun(Number).
determiner(singular) --> [a].
determiner(singular) --> [the].
determiner(plural) --> [the].
noun(singular) --> [cat].
noun(plural) --> [cats].
noun(singular) --> [mouse].
noun(plural) --> [mice].
verb(singular) --> [scares].
verb(plural) --> [scare].
verb(singular) --> [hates].
verb(plural) --> [hate].

是否有包含非终结符参数的标准或公认的 BNF 扩展?

如果是这样,我需要一个 link。

我怀疑 ATN(增强转换网络)在球场上并且可能是唯一的标准答案,但我希望得到的是线性文本而不是某种形式的 vertex/edge 图表。

我认为 feature structures 的概念正是您要找的;您在示例中显示的参数共享是更通用的特征结构统一方法的特例。

我不知道具体针对 BNF 的特征结构扩展,但是有合理接受的符号可以将它们添加到其他语法形式中。 NLTK(一个 Python 自然语言处理库)的文档有 an example here 他们使用的符号。以下是他们的一些规则,大致对应于您示例中的前几个作品:

S -> NP[CASE=nom, AGR=?a] VP[AGR=?a]
VP[AGR=?a] -> TV[OBJCASE=?c, AGR=?a] NP[CASE=?c]
NP[CASE=?c, AGR=?a] -> Det[CASE=?c, AGR=?a] N[CASE=?c, AGR=?a]

?x是他们对逻辑变量的表示法。 NLTK 手册的整章包含对特征结构的一般描述,并包括一些参考文献。