20100930

20100930 - The general structure of a program is that it...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
============================ CS 441 Fall 2009 -- JWJ Pre-class notes - do not distribute Tuesday, October 5, 2009 ============================ Scope: ------ Putting a few things together or "I can write a parser." Outline: ------- The objective is to analyze a small programming language and design and partially implement a parser for the language. ----------------------------- Consider a (portion of) language IF for branching instructions: 10: if (x+1 > y) then 20 else 30; 20: if (3*x-z > 3.1) then 20 else 50; 30: if (3-y+1 == 25*z-11) then 50 else action2; 40: if (x+1 > y) then action3 else 30; 50: if (z+1 < y) then 60 else 30; 60: if (x*2+11 != y) then 50 else exit;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: The general structure of a program is that it consists of a number of labeled lines, each starting with a label followed by and if-then-else statement. The first part after 'if' is a relation expression (comparison of two expressions). The actions are either 'jumps' marked by labels, action# (where # is a number), or exit. Your task is to write a program that verifies if the input is a valid program in the IF language. Formalize the above task as a compiler-related project. Design a process (and develop particular steps) that lead to the solution. Step 1: Step 2: Step 3: Step 4:...
View Full Document

This document was uploaded on 12/14/2010.

Ask a homework question - tutors are online