编译器设计中的语法问题 [英] grammer issue in compiler design

查看:77
本文介绍了编译器设计中的语法问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我有一些我不完全了解的内容时,我正在研究语法家族.

如何知道/猜测/证明/语法属于任何家庭?

例如:

I was looking through grammar families when I had something I don''t fully understand .

how to know/guess/prove/ a grammar belongs to any family ?

for example :

S -> A
A -> B | B a A
B -> b C
C -> C b | C x | epsilon



是LR(0)吗?是SLR(1)吗?
为什么?
以及你怎么知道的??

感谢



is it LR(0) ? is it SLR(1) ?
why?
and how u got that!?

thanks

推荐答案

以下语法(在EBNF中给出)接受相同的语言:

S = b {b | x} {a b {b | x}}.

但是,并没有真正回答您的问题.这是LL(1).

您可以阅读有关该主题的任何体面的教科书,并检查LR(0)和SLR(1)的定义.
在给定的作品中
-一个显然是左递归
-一个显然是右递归

玩得开心!

安迪
The following grammar (given in EBNF) accepts the same language:

S = b { b | x } { a b { b | x } } .

Not really answering your question, though. This one is LL(1).

You might take any decent textbook on that topic and check the definitions for LR(0) and SLR(1).
Of the given productions
- one is obviously left-recursive
- one is obviously right-recursive

Have fun!

Andi


这篇关于编译器设计中的语法问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆