简体   繁体   English

将上下文无关语法转换为LL1语法

[英]Convert The Context Free Grammar to LL1 Grammar

I want to write a program to gives grammar as input and change it to LL1. 我想编写一个程序以将语法作为输入并将其更改为LL1。
my problem is converting to LL1 I don't have any algorithm to convert. 我的问题是转换为LL1,我没有任何算法可以转换。 I earn grammar from some input text by a simple text analyzer but how I can change it to LL1 ? 我可以通过简单的文本分析器从一些输入文本中获得语法,但是如何将其更改为LL1呢? is there any algorithm that is clear to implement. 是否有明确的算法可以实现。

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. 巨著:Aho,Sethi和Ullman撰写的《编译器,原理,技术和工具》一书(标题为“语法分析”)解释了消除左递归的过程,以及消除左递归语法的另一过程。

The resulting grammar is suitable for LL parsing. 生成的语法适用于LL解析。

I suggest you read that chapter in the book and see if you can convert it into code. 我建议您阅读本书中的这一章,看看是否可以将其转换为代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM