Presentation is loading. Please wait.

Presentation is loading. Please wait.

COP 4620 / 5625 Programming Language Translation / Compiler Writing Fall 2003 Lecture 6, 10/02/2003 Prof. Roy Levow.

Similar presentations


Presentation on theme: "COP 4620 / 5625 Programming Language Translation / Compiler Writing Fall 2003 Lecture 6, 10/02/2003 Prof. Roy Levow."— Presentation transcript:

1 COP 4620 / 5625 Programming Language Translation / Compiler Writing Fall 2003 Lecture 6, 10/02/2003 Prof. Roy Levow

2 LL(1) Project Grammar Basic Grammar LL(1) Grammar for LLgenLL(1) Grammar LLgen grammar analysisanalysis

3 LLgen %token identifies tokens %start identifies start symbol –May have more than one for sub-parsers Can add –function parameter lists to non-terminals –C code for actions

4 LLgen Example

5 LLgen Auxiliary code fig. 2.77

6 LLgen Auxiliary code fig. 2.77-b

7 LLgen Error Handling Code Class > 0 –Class of token inserted Class = 0 –Token LLsymb deleted Class = -1 –Stack empty but input remains

8 LLgen Error Handling Code.2

9 Generating a Parse Tree

10 Generating a Parse Tree.2

11 Expression Reorganization Because expression grammar is left recursive, and thus not LL(1) Grammar was reorganized to be right recursive But this gives wrong semantics Modify parse tree to get right semantics


Download ppt "COP 4620 / 5625 Programming Language Translation / Compiler Writing Fall 2003 Lecture 6, 10/02/2003 Prof. Roy Levow."

Similar presentations


Ads by Google