S属性和L属性语法是什么意思?
我正在读一本编译器书,当它说“S 属性语法也是 L 属性语法”时,我有点困惑。无法理解。有人可以说清楚吗(一个例子应该很好)。谢谢。
I'm reading a compiler book and kinda confused when it says "a S-attribute grammar is also a L-attribute grammar". Couldn't understand. Can someone make it clear (an example should be great). Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
L 属性语法
S 属性语法
在L-属性语法中,属性评估可以通过从左到右的遍历来执行。由于在 S 属性语法中属性不是继承的,因此它不会阻止您这样做。因此,您可以说 S 属性语法符合 L 语法的特征。
L-attributed grammar
S-attributed grammar
In L-attributed grammars attribute evaluation can be performed in left-to-right traversal. Since in S-attributed grammars attributes are not inherited, it does not prevent you from doing just that. As such, you can say an S-attributed grammar conforms to that characteristic of an L-grammar.
简单的S属性语法是一种具有严格综合类型语法的语法,意味着在整个解析树中仅具有值属性,
而L属性语法可以同时具有综合语法和继承语法,其中一些规则例如具有传递继承总是从左到右。
我想这会对你有所帮助。
Simply S-attributed Grammar is the Grammar who has strictly Synthesized type of grammar means Only having Value attribute throughout the parse tree
where as L-Attributed grammar can have both synthesized as well as Inherited grammar with some of the rules like one having the transfer of inheritance from always left to right.
I think it will help you out.