Dr. Mohamed Ben Othman 1 Project phase 3 1)Rewrite the code of the project in the slides, run it: 1)change it so the input should be from file with extension.exp.

Slides:



Advertisements
Similar presentations
1 COMP 144 Programming Language Concepts Felix Hernandez-Campos Lecture 2: Compilation and Interpretation COMP 144 Programming Language Concepts Spring.
Advertisements

CS 338 Project: Phase 4. Grammar Start  stmt eof Stmt  id = expr | if (expr) then stmt | while (expr) do stmt | begin CS end CS  stmt ; CS |   ote:
Prefix, Postfix, Infix Notation
Computer Science 2 Data Structures V section 2 Recitation 1.
CS 206 Introduction to Computer Science II 03 / 04 / 2009 Instructor: Michael Eckmann.
Arithmetic Expressions
CS 206 Introduction to Computer Science II 03 / 06 / 2009 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 10 / 17 / 2008 Instructor: Michael Eckmann.
CS150 Introduction to Computer Science 1
Reverse Polish Expressions Some general observations about what they are and how they relate to infix expressions. These 9 slides provide details about.
CS 206 Introduction to Computer Science II 03 / 16 / 2009 Instructor: Michael Eckmann.
Topic 15 Implementing and Using Stacks
CS 206 Introduction to Computer Science II 10 / 28 / 2009 Instructor: Michael Eckmann.
Lesson 1-3: Mult/Div Real #s
Week7 Stack Data Structures & Algorithms. Introduction to Stacks and Queues Widely used data structures Ordered List of element Easy to implement Easy.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
Introduction Polynomials, or expressions that contain variables, numbers, or combinations of variables and numbers, can be added and subtracted like real.
CSC 338: Compiler design and implementation
Addition, Subtraction, Multiplication, and Division of Integers
Unit 3 Lesson 2: Rational Expressions
Objective - To subtract integers. To subtract an integer is to add its opposite. a - b =a + -b = (-5) =8 + 5 = = 4 Rewrite the.
Subtracting Integers Algebraically. How to Subtract Integers Algebraically 1.Rewrite the problem  Keep the first number the same  Change the problem.
Compilers: Overview/1 1 Compiler Structures Objective – –what are the main features (structures) in a compiler? , Semester 1,
Intermediate Code Representations
This will all add up in the end. Assignment operator =Simple Assignment operator Arithmetic Operators +Additive operator – Subtraction operator * Multiplication.
Aim: How to write in Scientific Notation DO NOW: 1. WHAT DOES 10 5 MEAN? 2. WHAT IS THE VALUE OF USING YOUR CALCULATOR, CALCULATE 4.5 X 10 6.
1 Compilation and Interpretation (Sections ) Compilation and Interpretation (Sections ) CSCI 431 Programming Languages Fall 2003 A modification.
Copyright © Curt Hill Stacks An Useful Abstract Data Type.
POWERS and ORDER of OPERATIONS PRE265 Parentheses (includes brackets) Exponents & Roots Multiplication & Division (left to right) Addition & Subtraction.
Dr. Mohamed Ramadan Saady 314ALL CH1.1 Chapter 1: Introduction to Compiling.
Prefix, Postfix, Infix Notation. Infix Notation  To add A, B, we write A+B  To multiply A, B, we write A*B  The operators ('+' and '*') go in between.
Stacks A stack is a linear data structure that can be accessed only at one of its ends for storing and retrieving data LIFO (Last In First Out) structure.
1 Project 5: Leap Years. 222 Leap Years Write a program that reads an integer value from the user representing a year and determines if the year is a.
Same Signs Different Signs 1) =+7 Objective- To solve problems involving operations with integers. Combining.
Do Now: Simplify and write in standard form x 2 - x 2 + 4x – 1 -6x 2. 2 – 7x – x 3.
Solving Two-Step Equations
Integers Rules of Operation.
Integer Rules Memorize the Rules.
Pre-Algebra Review Quiz tomorrow!.
Infix to postfix conversion
Addition/ Subtraction
Negative Numbers.
Stacks Chapter 4.
106 Data Structure Homework 1
8-4 Properties of Logarithms
Solving Two-Step Equations
Solving Two-Step Equations
1 Step Equation Practice + - x ÷
Solving Two-Step Equations
Unit 2 Programming.
More About Stacks: Stack Applications
PROGRAMMING Program Development.
G7 programing language Teacher / Shamsa Hassan Alhassouni.
Function Notation “f of x” Input = x Output = f(x) = y.
More Maths Programming Guides.
Stacks – Calculator Application
Solving Two-Step Equations!!!!
Infix to Postfix Conversion
Solving Two-Step Equations
Solving 2-Step Variable Equations
Solving Two-Step Equations
CO4301 – Advanced Games Development Week 3 Parsing Continued
Solving Two-Step Equations
Solving Simple Two-Step Equations
Solving Two-Step Equations
Solving Two-Step Equations
More About Stacks: Stack Applications
Compiler Structures 1. Overview Objective
Section 12-3 Exponents & Multiplication
COMPUTING.
Presentation transcript:

Dr. Mohamed Ben Othman 1 Project phase 3 1)Rewrite the code of the project in the slides, run it: 1)change it so the input should be from file with extension.exp 2)The output should be to a file with the same name and extension.obj 3)The errors should be in a file with the same name and extension.err 2) Add more error information

Dr. Mohamed Ben Othman 2 3- As you can see the output of the program is the postfix notation of the infix expression given as input. Change the code so the output will be in the intermediate code instead of postfix format.

Dr. Mohamed Ben Othman – 5; Compiler Input (Infix) Output (Postfix) Push 1 Push 2 Pop r1 Pop r2 Add r2, r1 Push r2 Push 5 Pop r1 Pop r2 Sub r2, r1 Push r2 Output (Intermediate code)

Dr. Mohamed Ben Othman 4 The Operations in intermediate language are: Add: addition Sub: subtraction Rdiv: real division Div: integer division Mod: division reminder Mult: multiplication 5- change the grammar by adding the semantic actions. 6- change the program to provide the intermediate code as output.

Dr. Mohamed Ben Othman 5 Hint: manipulation of files in C char InputFileName[80], OutputFileName[80], ErrorFileName [80]; strcpy(InputFileName,"file"); strcat(InputFileName,".exp"); input = fopen(InputFileName,"r"); fprintf(output, “%d %s …”, …); fscanf(input, “%d …”, …); t = fgetc(input);