20101111

20101111 - ============================ CS 441 Fall 2010 --...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ============================ CS 441 Fall 2010 -- JWJ Pre-class notes - do not distribute Thursday, November 11, 2010 ============================ Topics Constructing compilers with Yacc and Lex Concepts/Definitions This class has the format of practicum. We are working in the lab dissecting the calculator code from one of our textbook. We will review the basic elements of Bison and will see how the calculator can be modified to generate code for a P-stack machine. This modification is essential to your programming assignment that will be explained today. http://www.epaperpress.com/lexandyacc/index.html The general structure of a Yacc spec is ... definitions ... %% ... rules <<< The rules correspond to the syntax-directed translation. %% ... subroutines ... From the calc3.y ... (Tom Niemann) The language supported by calc3 is a calculator extended with basic control statements (while, if-then-else). The language does require declarations and does not support functions or blocks. Example program: n=12; p=1; i=1; while (i <= n) { p = p * i; print p; i = i + 1; }; and the AST corresponding to the while-loop is while | |-------------------------| | | [<=] [;] | | |-----| |-------------------| | | | | id(I) id(N) [;] [=] | | |-----------| |-------| | | | | [=] print id(I) [+] | | | |--------|...
View Full Document

This document was uploaded on 12/14/2010.

Page1 / 5

20101111 - ============================ CS 441 Fall 2010 --...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online