语法规则之间的差异

时间:2017-03-26 03:54:28

标签: grammar computation-theory

假设有两个语法规则

规则1B-> aB |的cB

规则2 B - > Ba | BC

我对这两者的区别感到有些困惑。规则1的表达式是(a + c)*?那么规则2的表达式是什么?

1 个答案:

答案 0 :(得分:1)

这两种语法都产生空语言,因为没有非递归规则,因此不能导出只包含终端的句子。

如果添加了作品void Update () { currentBodyRotation = body.GetComponent<Transform> ().rotation.eulerAngles.y; yaw += Input.GetAxis ("Mouse X") * mouseSensitivity; yawMin = currentBodyRotation - 90f; yawMax = currentBodyRotation + 90f; yaw = Mathf.Clamp (yaw, yawMin, yawMax); pitch -= Input.GetAxis ("Mouse Y") * mouseSensitivity; pitch = Mathf.Clamp (pitch, pitchMinMax.x, pitchMinMax.y); currentRotation = Vector3.SmoothDamp (currentRotation, new Vector3 (pitch, yaw), ref rotationSmoothVelocity, rotationSmoothTime); transform.rotation = Quaternion.Euler (currentRotation); } ,则两个语法都会生成相同的语言,相当于正则表达式B→ε。但是,解析产生的解析树会有很大不同。