我試圖將給定的BNF列表轉換爲EBNF,即時通訊完全無能爲力。誰能幫忙?BNF到EBNF轉換
的BNF是:
<Sentence> :== <NounPhrase><VerbPhrase>
<NounPhrase> :== <Noun>
<NounPhrase> :== <Article><Noun>
<NounPhrase> :== <Article><AdjectiveList><Noun>
<NounPhrase> :== <AdjectiveList><Noun>
<AdjectiveList> :== <Adjective>
<AdjectiveList> :== <Adjective><AdjectiveList>
<VerbPhrase> :== <Verb>
<VerbPhrase> :== <Verb><Adverb>
<Noun> :== frog | grass | goblin
<Article> :== a | the | that
<Adjective> :== purple | green | tiny
<Verb> :== grows | dreams | eats
<Adverb> :== quickly | slowly | badly
擴展BNF語法使用以下約定:
- 上標?在符號之後意味着它是可選的並且可以出現一次或者根本不出現。
- 符號後面的上標+表示它必須至少出現一次,但可以多次出現。
- 符號後面的上標*表示完全不會出現,一次或多次出現。
- 成對的括號可以用於將符號分組在一起:?,+,*運營商。
- 尖括號通常從非終端符號中刪除,而不同的字體用於區分終端和非終端。
這是我到目前爲止,但我不知道它是正確的。
Sentence :== (<NounPhrase><VerbPhrase>) +
NounPhrase :== <Noun> + (<Article>< AdjectiveList>)?
AdjectiveList :== <Adjective> *
VerbPhrase :== <Verb> + <Adverb>?
Noun :== (frog | grass | goblin)*
Article :== (a | the | that)*
Adjective :== (purple | green | tiny)*
Verb :== (grows | dreams | eats)*
Adverb :== (quickly | slowly | badly)*
您是否搜索過嗎? [如何將BNF轉換爲EBNF]缺少哪些信息(http://stackoverflow.com/questions/14922242/how-to-convert-bnf-to-ebnf)? – 2014-11-07 02:51:45
抱歉,我忘記發佈其他部分,現在已經修復。我已經得到了這些轉換規則的幫助。 – 2014-11-07 03:05:15
描述的EBNF約定不是EBNF-EBNF是ISO標準([ISO 14977:1996](http://www.iso.ch/cate/d26153.html),可免費獲得)。你仍然沒有回答我的問題,即「另一個問題缺少什麼信息?」,其編輯「你對你的任務或者BNF沒有了解嗎?」和「你試過什麼?」。 – 2014-11-07 03:13:31