簡體   English   中英

CFG for a^nb^3m c d^mef^2n 與 m, n > 0

[英]CFG for a^n b^3m c d^m e f^2n with m, n > 0

我想找到這個 a^nb^3m c d^mef^2n 的 CFG,m, n > 0

到目前為止我所擁有的

S -> A B C
A -> a A ff
B -> bbb B d
C -> c e

這有道理嗎?

我認為這是語法:

; this rule generates "a" first and "ff" last
S = a A ff

; allow more "a" first and "ff" last
A = S

; between "a^n" and "f^2n" there will be "b^3m c d^m" followed by "e"
A = B e

; this rule generates "bbb" first and "d" last
B = bbb C d

; allow more "bbb" first and "d" last
C = B

; this rules generates "c" between "b^3m" and "d^m"
C = c

到目前為止,您的語法允許c出現在違反規則的d之后。

以下應該工作

S = a S ff | a bbb B d e ff
B = bbb B d | c

第一條規則保證,對於開頭的每個a ,最后都有兩個f 它至少強制執行一個a 后半部分強制執行順序de ff...

第二條規則強制bd的正確數量,並且單個cb s 和c s 之間

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM