When working with Prolog DCG for parsing, it is useful to have an auxiliary BNF grammar.
For instance:
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
like 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].
However, Prolog DCG may also have arguments as
in this example Numberfor singularorplural
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].
Is there a standard or accepted extension for BNF that includes arguments for non-terminals?
If so, I need a link to it.
I suspect that ATNs (Augmented Transition Networks) are in a ball park and may be the only standard answer, but I hope for something that is linear text and not some form of vertex / edge.
source
share