{a m b n c i | m> n + i}
我一直试图弄清楚这两个小时。这是我到目前为止所做的。
//To start with as many a's as you want:
S => a | aA | aS
//To ensure an a gets added each time a b or c does so there is always at least 1 more a than b's plus c's.
A => aBb | aaBbCc | aCc
B => aBb | lambda
C => ???
我知道这远远不够正确,这就是我要求帮助/提示的原因。
感谢。
答案 0 :(得分:1)
你的语法不正确。
阅读Tips for creating “Context Free Grammar”并将其答案链接起来,语言的语法为
S --> aSc | B // for every `c` there must be a `a`
B --> aBb | A // for every `b` there must be a `a`
A --> aA | a // generate extra `a`
答案 1 :(得分:0)
从内到外构建:
这不是最小的 - 你可以用5个规则和2个非终端来做。