
4.12 a. Can an LL(1) grammar be ambigous? Why or Why not?
b. Can an ambigous grammar be LL(1)? Why or Why not? c. Must an unambigous grammar be LL(1)? Why or Why not? [Solution] Defination of an ambiguous grammar: A grammar that generates a string with two distinct parse trees. (Page 116) Defination of an LL(1) grammar: A grammar is an LL(1) grammar if the associatied LL(1) parsing table has at most one priduction in each table entry.
a. An LL(1) grammar can not be ambiguous, since the defination implies that an unambiguous parse can
be constructed using the LL(1) parsing table
b. An ambiguous grammar can not be LL(1) grammar, but can be convert to be ambiguous by using
disambiguating rule.
c. An unambiguous grammar may be not an LL(1) grammar, since some ambiuous grammar can be
parsed using LL(K) table, where K>1. 4.13
Left recursive grammars can not be LL(1):
Consider a grammar with a production A → A β with symbol t in its first set. IF A is on the top of the stack and the current look-ahead token is t, A will be popped off the stack and then β will be pushed onto the stack followed by A. A will again be the top of the stack and the look-ahead token will still be t, so it will repeat again, and again, infinitely, or until you get a stack overflow.
Note: The first set for the recursive production will have a non-empty intersection with the first set for the terminating production, which will lead to a conflict when creating the LL(1) table.
编译原理与实践 第五章 答案_计算机软件及应用_IT/计算机_专业资料。The ... 编译原理与实践 第三章... 编译原理与实践 第四章... 编译原理与实践 第...
编译原理与实践 第二章 答案_IT/计算机_专业资料。Louden著 冯博琴译 《编译原理及实践》--习题答案,英文版答案The exercises of Chapter Two 2.1 Write ...
编译原理与实践 第六 七章 答案_理学_高等教育_教育专区。The Exercises of ... 编译原理与实践 第三章... 编译原理与实践 第四章... 编译原理与实践 第...
《编译原理实践及应用》... 71页 1下载券 编译原理 第四章 语法分... ...消去文法G[S]的左递归 答案: S T T’ (T)
编译原理与实践 第三章 答案_理学_高等教育_教育专区。The exercises of Chapter... 编译原理与实践 第四章... 编译原理与实践 第五章... 编译原理与实践 第...
编译原理及实践部分课后习题答案_IT/计算机_专业资料。编译原理及实践部分课后... 课后部分习题答案 55页 免费 第一章至第四章部分课后... 26页 免费 编译...
作业题: 2.1(a,c,d), 2.8(a,c,d), 2.12, 3.3, 3.4, 4.8, 4.12 5.8(a,b,c), 5.12, 6.7, 6.8, 6.13 7.4, 7.15 第二章...
第四章(3) LR分析方法 本节要求 ? 主要内容: LR分析方法及其相关概念, 语法分析器的自动生成,各种语法分析中 的错误处理 ? 重点掌握:LR分析方法与分析过程,活...
光学教程第2章_参考答案 8页 免费 编译原理及实践-第1章 概... 暂无评价...第2 章参考答案: 1:解答:略! 2.解答:字母表:是元素的有穷非空集合∑ ...
编译原理及实践教程(黄贤英 王柯柯 编著) 习题答案_工学_高等教育_教育专区...解答:略! 第 4 章习题解答: 1,2,3,4 解答 ,,,略! 解答: 5. 解答: ...
热门文档