将上下文无关语法转换为LL1语法 [英] Convert The Context Free Grammar to LL1 Grammar

查看:232
本文介绍了将上下文无关语法转换为LL1语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个程序以将语法作为输入并将其更改为LL1.
我的问题是转换为LL1,我没有任何算法可以转换.我可以通过简单的文本分析器从某些输入文本中获得语法,但是如何将其更改为LL1呢?有没有明确的算法可以实现.

I want to write a program to gives grammar as input and change it to LL1.
my problem is converting to LL1 I don't have any algorithm to convert. I earn grammar from some input text by a simple text analyzer but how I can change it to LL1 ? is there any algorithm that is clear to implement.

推荐答案

巨龙书:Aho,Sethi和Ullman撰写的《编译器,原理,技巧和工具》有一章(标题为语法分析"),该章解释了消除左递归的过程以及留出上下文无关文法的另一个过程.

The dragon book: Compilers, Principles, Techniques and Tools by Aho, Sethi and Ullman has a chapter (titled Syntax Analysis) which explains a procedure to eliminate left recursion and another procedure to left factor a context free grammar.

生成的语法适合于LL解析.

The resulting grammar is suitable for LL parsing.

我建议您阅读本书中的这一章,看看是否可以将其转换为代码.

I suggest you read that chapter in the book and see if you can convert it into code.

这篇关于将上下文无关语法转换为LL1语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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