I got quite confused about my compiler class this semester. The textbook we used is the famous "Dragoon Book" - Compilers, Principles, Techniques and Tools, by Alfred V. Aho, Monica S. Lam, Ravi Sethi and Jeffrey D. Ullman. Now I have figured everything out regarding syntax analysis. So I decide to write the algorithms in my way.
How to eliminate left recursion
Replace the rule
by and
How to eliminate common prefixes
Replace the rule
by
and
Top-down parsing
To rule
First(X):
1. 2. If , then
3. If , then
Follow(X):
1. $ is contained in Follow(X)2. If , then
3. If or and , then Follow(A) Follow(B)
No comments:
Post a Comment