Exam question ( 9 March 2009)

6 views
Skip to first unread message

Hamid E

unread,
Mar 16, 2011, 6:23:27 PM3/16/11
to proglang-course-2011
We discussed about this question ( " question 4 : 9 March 2009" ) in
study session, but I think we made a serious mistake. (since we only
talked about conflict in our grammar )


http://www.cse.chalmers.se/edu/course/TIN321/exams/exam-plt-2009-2.pdf

Is your grammar in Question 1 LL(1)? If not, explain why. (3p)

Oxana Sachenkova

unread,
Mar 17, 2011, 2:37:14 AM3/17/11
to proglang-c...@googlegroups.com
Yes, this grammar is LL, there are now first/first, first/follow
conflicts and no left recursion. Right?

2011/3/16 Hamid E <hamid...@gmail.com>:

--
Sincerely yours,
Sachenkova Oxana.

Aarne Ranta

unread,
Mar 17, 2011, 2:54:15 AM3/17/11
to proglang-c...@googlegroups.com
Hello,

Since conjunction and disjunction are left-associative, your grammar should have left-recursive rules for them, e.g.

  Exp1 ::= Exp1 "&&" Exp2

Then it cannot be an LL grammar (see lecture 4).

The dangling else conflict is another reason for this: a grammar that is not LR(1) cannot be LL(1); the book says more about the relations between these classes. (Notice that an LR conflict always means that the grammar is, strictly speaking, not LR.)

Regards

  Aarne.

Oxana Sachenkova

unread,
Mar 17, 2011, 3:32:55 AM3/17/11
to proglang-c...@googlegroups.com
Thank you, Aarne!
Then we was right on the study session, guys.
Just forgot about left recursion.

2011/3/17 Aarne Ranta <aa...@chalmers.se>:

Reply all
Reply to author
Forward
0 new messages