Monday, April 9, 2018
|
|
- Earl Gregory
- 5 years ago
- Views:
Transcription
1 Monday, April 9, 208 Topics for today Grammars and Languages (Chapter 7) Finite State Machines Semantic actions Code generation Overview Finite State Machines (see 7.2) If a language is regular (Type 3) we can answer the question Is string X in the language? by means of an appropriate Finite State Machine (FSM). For every regular language there is an FSM that can recognize strings in the language. (The reverse is also true for every FSM, we can represent the language it recognizes by means of a regular expression). Visually an FSM might be a graph with the states as nodes and transitions as arcs. One of the states is identified as the start state. The machine is input driven, the combination of current state and input determines what the next state is 2. Only strings that are in the language will cause the FSM to end up in one of the "final" states. In our graphs, the start state is labeled with, final states are labeled with +. In Warford s diagrams he has an arrow pointing to the start state and the final states have a double circle. FSM Example : recognizer for label letter or digit letter colon As a transition table we might have something like the following where the entries tell us the next state given the current state (row) and input (column). This is the case for a deterministic FSM. In a nondeterministic FSM there may be multiple transitions from a particular state for a given input. 2 Algorithms exist that will minimize the number of states in an FSM. This is useful if the FSM is to be implemented in hardware. Comp 62 Notes Page of April 9, 208
2 Input Current State Letter Digit Colon Other 2 Error error error error If we start in state then any string that takes us to state 3 is a label. If input is not a label then the FSM will crash in some error state. The following general algorithm will determine if the input is in the language defined by a transition table. current_state = Start while ( current_state!= error && more_input ) { get(input) current_state = transition_table[current_state][typeof(input)] } if (ismember(finish_states, current_state) output( Yes ) else output( No ) FSM Example 2: recognizer for train On a certain railroad, all trains begin with one or more locomotives followed by zero or more wagons followed by a caboose. Using W for wagons, L for locomotives, and C for cabooses, the following regular expression defines valid trains. The following FSM recognizes valid trains. LL*W*C L 3 W L 2 C W C + 4 Comp 62 Notes Page 2 of April 9, 208
3 As a table Input Current State L W C Other 2 error error error error 3 error 3 4 error Semantic actions Semantic actions are actions associated with particular transitions from one state to another. They are useful for performing such operations as forming input characters into a string or creating a variable containing the value of an input number. Example We can attach semantic actions to our label checker that build up the string as it is read characterbycharacter then, when we read the colon, enters the string into the symbol table. Here are the actions Action When done Details A On reading the first character String S = character B On reading a subsequent noncolon character Append character to S C On reading a colon Enter S into symbol table Here is the modified FSM with transitions labeled input/action Letter/B or digit/b letter /A colon/c Comp 62 Notes Page 3 of April 9, 208
4 FSM Example 3: recognizer for real numbers Assume that in a real number we must have at least one digit before the decimal point or at least one digit after the decimal point. A number can begin with an optional sign character. Thus, Valid Invalid Regular expression: [sign] (digit digit*.digit* digit*.digit digit* ) [x] = none or one x Here is a FSM that recognizes real numbers defined in this way. 2 digit digit digit digit dec. pt sign dec. pt dec. pt 4 digit We can attach semantic actions to our real number parser to create a variable containing the value of the number. There will be an action performed before input is read and another action performed after input has finished and actions associated with statetostate transitions. The actions will use global variables. Here are the actions: Comp 62 Notes Page 4 of April 9, 208
5 Action When done Details Initially dec_places = 0, sign =, N = 0 A On reading a decimal point dec_places = 0 B On reading a sign character if (input = '') sign = C On reading a digit N = N * 0 + input; dec_places++ At the end N *= sign, N = N / (0 dec_places ) So our augmented FSM with transitions now depicting input/action is 2 digit/c digit/c digit/c digit/c dec. pt/a sign/b dec. pt/a dec. pt/a 4 digit/c Here is a trace of what happens when input is the 7character string Input Sign N Dec_places <initially> <end> Comp 62 Notes Page 5 of April 9, 208
6 Code generation (see section 7.4) A compiler, having verified that the input string is legal in the particular programming language, will generate appropriate assembly language. Warford s example in section 7.4 is not very general; we describe and solve a more general problem: Translate an arithmetic expression into Pep/9 assembly language Like a compiler, we can produce the assembly code in two phases: () Analysis: verify input and build an appropriate data structure. (2) Synthesis: generate code from the data structure Example simple assignment statements such as X = A + ( B + C ) * ( D + E ) Analysis: A binary tree representing the expression is constructed using semantic actions as the expression is read symbol by symbol. If input were the expression above we get this tree that correctly represents the priorities of the arithmetic operations. = X + A * + + B C D E Synthesis: We traverse the tree in a systematic way to generate assembly code. For example, from the tree above, the sequence of Pep/9 assembly language begins subsp 2,i ldwa B,d stwa 0,s subsp 2,i ldwa C,d etc We will lead up to the Analysis and Synthesis algorithms involved by first looking at three simpler ones. Comp 62 Notes Page 6 of April 9, 208
7 Algorithm. Evaluation of a postfix expression Algorithm 2. Conversion of an infix expression to postfix form Algorithm 3. Evaluation of an infix expression (algorithms and 2 combined). Then we can look at the Analysis algorithm Algorithm 4: Building a tree from an infix expression And finally at the Synthesis algorithm Algorithm 5: Generating assembly code We know that the language of arithmetic expressions is not Type 3 so a simple finite state machine will not be sufficient to process it. Our algorithm will use stacks. Algorithm will use a stack of operands (numbers) Algorithm 2 will use a stack of operators Algorithm 3, because it combines Algorithms and 2 will use two stacks one of operands and one of operators. We will keep our algorithm as simple as possible by limiting our identifiers to single letter and constants to single digits. Reading We are looking at an alternative to Warford s section 7.4 Comp 62 Notes Page 7 of April 9, 208
8 Review Questions. (a) draw a FSM that accepts unary numbers that are multiples of 3. (b) how many states are there in a FSM that accepts unary numbers that are multiples of k? 2. (a) draw a FSM that accepts unsigned binary integers that are multiples of 4. (b) how many states are there in a FSM that accepts unsigned binary numbers that are multiples of 2 k? 3. The Wikipedia entry for Regular Expression claims that the following regular expression (0 ((0*0)*))* represents the language of positive binary numbers that are multiples of 3. Draw the corresponding FSM and test the claim. 4. For each of the following regular expressions, draw a FSM that recognizes the same language. (a) a (b c)* d (b) a (bc)* d 5. Derive a regular expression for the language recognized by the following FSM A D E G A,C + F B C I H C Comp 62 Notes Page 8 of April 9, 208
9 6. Consider the real number recognizer. For each of the following invalid inputs identify as appropriate the state where the FSM crashes or the nonfinal state it is in when the input ends. (a) (b) 624 (c).2 (d) The notes show the first few instructions generated from the tree representing X = A + ( B + C ) * ( D + E ) What are likely to be the final three instructions? 8. Suppose we remove the parentheses from our example assignment resulting in X = A + B + C * D + E Draw a tree that represents this revised statement Comp 62 Notes Page 9 of April 9, 208
10 Review Answers. (a) + + (b) k+ 2. (a) (b) k (a) C A D + B Comp 62 Notes Page 0 of April 9, 208
11 (b) A D + B C 5. (AD) (BC) E* F (G (HI) )* 6. (a) 5 (b) 2 (c) 3 (d) 5 7. ldwa 0,s stwa X,d addsp 2,i 8. = X + A + B + * E C D Comp 62 Notes Page of April 9, 208
Wednesday, November 8, 2017
Wednesday, November 8, 207 Topics for today Grammars and Languages (hapter 7) Finite State Machines Semantic actions ode generation - Overview Finite State Machines (see 7.2) If a language is regular (Type
More informationMonday, April 14, 2014
Monday, April 14, 2014 Topics for today Grammars and Languages (Chapter 7) Finite State Machines Semantic actions Code generation - Overview Analysis Algorithm 1: evaluation of postfix Algorithm 2: infix
More informationMonday, November 9, 2015
Monday, November 9, 2015 Topics for today Grammars and Languages (Chapter 7) Finite State Machines Semantic actions Code generation - Overview nalysis lgorithm 1: evaluation of postfix lgorithm 2: infix
More informationMonday, April 15, We will lead up to the Analysis and Synthesis algorithms involved by first looking at three simpler ones.
Monday, pril 15, 2013 Topics for today Code generation nalysis lgorithm 1: evaluation of postfix lgorithm 2: infix to postfix lgorithm 3: evaluation of infix lgorithm 4: infix to tree Synthesis lgorithm
More informationMonday, November 13, 2017
Monday, November 13, 2017 Topics for today ode generation nalysis lgorithm 1: evaluation of postfix lgorithm 2: infix to postfix lgorithm 3: evaluation of infix lgorithm 4: infix to tree nalysis We are
More informationMonday, March 6, We have seen how to translate void functions. What about functions that return a value such as
Monday, March 6, 2017 Topics for today C functions and Pep/9 subroutines Translating functions (c) Non-void functions (d) Recursive functions Reverse Engineering: Pep/9 to C C Functions and Pep/9 Subroutines
More informationWednesday, September 27, 2017
Wednesday, September 27, 2017 Topics for today Chapter 6: Mapping High-level to assembly-level The Pep/9 run-time stack (6.1) Stack-relative addressing (,s) SP manipulation Stack as scratch space Global
More informationSTACKS. A stack is defined in terms of its behavior. The common operations associated with a stack are as follows:
STACKS A stack is a linear data structure for collection of items, with the restriction that items can be added one at a time and can only be removed in the reverse order in which they were added. The
More informationWednesday, November 15, 2017
Wednesday, November 15, 2017 Topics for today Code generation Synthesis Algorithm 5: tree to code Optimizations Code generation Algorithm 5: generating assembly code Visiting all the nodes in a linked
More informationMonday, March 27, 2017
Monday, March 27, 2017 Topics for today Indexed branching Implementation of switch statement Reusable subroutines Indexed branching It turns out that arrays are useful in translating other language constructs,
More informationFormal Languages and Automata Theory, SS Project (due Week 14)
Formal Languages and Automata Theory, SS 2018. Project (due Week 14) 1 Preliminaries The objective is to implement an algorithm for the evaluation of an arithmetic expression. As input, we have a string
More informationMonday, March 9, 2015
Monday, March 9, 2015 Topics for today C functions and Pep/8 subroutines Passing parameters by reference Globals Locals More reverse engineering: Pep/8 to C Representation of Booleans C Functions and Pep/8
More informationCSE 401 Midterm Exam 11/5/10
Name There are 5 questions worth a total of 100 points. Please budget your time so you get to all of the questions. Keep your answers brief and to the point. The exam is closed books, closed notes, closed
More informationWednesday, February 15, 2017
Wednesday, February 15, 2017 Topics for today Before and after assembly: Macros, Linkers Overview of Chapter 6 Branching Unconditional Status bits and branching If statements While statements The V and
More informationThis book is licensed under a Creative Commons Attribution 3.0 License
6. Syntax Learning objectives: syntax and semantics syntax diagrams and EBNF describe context-free grammars terminal and nonterminal symbols productions definition of EBNF by itself parse tree grammars
More informationExamples of attributes: values of evaluated subtrees, type information, source file coordinates,
1 2 3 Attributes can be added to the grammar symbols, and program fragments can be added as semantic actions to the grammar, to form a syntax-directed translation scheme. Some attributes may be set by
More informationWednesday, September 13, Chapter 4
Wednesday, September 13, 2017 Topics for today Introduction to Computer Systems Static overview Operation Cycle Introduction to Pep/9 Features of the system Operational cycle Program trace Categories of
More informationAn Interactive Desk Calculator. Project P2 of. Common Lisp: An Interactive Approach. Stuart C. Shapiro. Department of Computer Science
An Interactive Desk Calculator Project P2 of Common Lisp: An Interactive Approach Stuart C. Shapiro Department of Computer Science State University of New York at Bualo January 25, 1996 The goal of this
More informationWednesday, February 28, 2018
Wednesday, February 28, 2018 Topics for today C functions and Pep/9 subroutines Introduction Location of subprograms in a program Translating functions (a) Void functions (b) Void functions with parameters
More informationWednesday, September 20, 2017
Wednesday, September 20, 2017 Topics for today More high-level to Pep/9 translations Compilers and Assemblers How assemblers work Symbol tables ILC Pass 1 algorithm, Error checking Pass 2 Immediate mode
More informationMonday, October 17, 2016
Monday, October 17, 2016 Topics for today C functions and Pep/8 subroutines Passing parameters by reference Globals Locals Reverse Engineering II Representation of Booleans C Functions and Pep/8 Subroutines
More informationCOMP-421 Compiler Design. Presented by Dr Ioanna Dionysiou
COMP-421 Compiler Design Presented by Dr Ioanna Dionysiou Administrative! Any questions about the syllabus?! Course Material available at www.cs.unic.ac.cy/ioanna! Next time reading assignment [ALSU07]
More informationCode No: R Set No. 1
Code No: R05010106 Set No. 1 1. (a) Draw a Flowchart for the following The average score for 3 tests has to be greater than 80 for a candidate to qualify for the interview. Representing the conditional
More informationInfix to Postfix Conversion
Infix to Postfix Conversion Infix to Postfix Conversion Stacks are widely used in the design and implementation of compilers. For example, they are used to convert arithmetic expressions from infix notation
More informationTheory and Compiling COMP360
Theory and Compiling COMP360 It has been said that man is a rational animal. All my life I have been searching for evidence which could support this. Bertrand Russell Reading Read sections 2.1 3.2 in the
More informationStacks (Section 2) By: Pramod Parajuli, Department of Computer Science, St. Xavier s College, Nepal.
(Section 2) Linked list implementation of stack Typical Application of stacks Evaluation of expressions (infix, postfix, prefix) References and further details By: Pramod Parajuli, Department of Computer
More informationWednesday, March 14, 2018
Wednesday, March 14, 2018 Topics for today Arrays and Indexed Addressing Arrays as parameters of functions Multi-dimensional arrays Option A: Space-minimal solution Option B: Iliffe vectors Array bound
More informationA Simple Syntax-Directed Translator
Chapter 2 A Simple Syntax-Directed Translator 1-1 Introduction The analysis phase of a compiler breaks up a source program into constituent pieces and produces an internal representation for it, called
More informationStating the obvious, people and computers do not speak the same language.
3.4 SYSTEM SOFTWARE 3.4.3 TRANSLATION SOFTWARE INTRODUCTION Stating the obvious, people and computers do not speak the same language. People have to write programs in order to instruct a computer what
More informationCSE P 501 Exam 8/5/04
Name There are 7 questions worth a total of 65 points. Please budget your time so you get to all of the questions. Keep your answers brief and to the point. You may refer to the following references: Course
More informationStructure of a Compiler: Scanner reads a source, character by character, extracting lexemes that are then represented by tokens.
CS 441 Fall 2018 Notes Compiler - software that translates a program written in a source file into a program stored in a target file, reporting errors when found. Source Target program written in a High
More information1. Lexical Analysis Phase
1. Lexical Analysis Phase The purpose of the lexical analyzer is to read the source program, one character at time, and to translate it into a sequence of primitive units called tokens. Keywords, identifiers,
More informationBritish Informatics Olympiad Final 30 March 1 April, 2007 Sponsored by Lionhead Studios. Parsing
British Informatics Olympiad Final 30 March 1 April, 2007 Sponsored by Lionhead Studios Parsing This question is quite long do not worry if you do not get to the end Backus-Naur form One of the first tasks
More informationMidterm 2 Solutions Many acceptable answers; one was the following: (defparameter g1
Midterm 2 Solutions 1. [20 points] Consider the language that consist of possibly empty lists of the identifier x enclosed by parentheses and separated by commas. The language includes { () (x) (x,x) (x,x,x)
More informationCSC 221: Computer Organization, Spring 2009
1 of 7 4/17/2009 10:52 AM Overview Schedule Resources Assignments Home CSC 221: Computer Organization, Spring 2009 Practice Exam 2 Solutions The exam will be open-book, so that you don't have to memorize
More informationCS Lecture 2. The Front End. Lecture 2 Lexical Analysis
CS 1622 Lecture 2 Lexical Analysis CS 1622 Lecture 2 1 Lecture 2 Review of last lecture and finish up overview The first compiler phase: lexical analysis Reading: Chapter 2 in text (by 1/18) CS 1622 Lecture
More information4. Inputting data or messages to a function is called passing data to the function.
Test Bank for A First Book of ANSI C 4th Edition by Bronson Link full download test bank: http://testbankcollection.com/download/test-bank-for-a-first-book-of-ansi-c-4th-edition -by-bronson/ Link full
More informationMonday, November 7, Structures and dynamic memory
Monday, November 7, 2016 Topics for today Structures Structures and dynamic memory Grammars and Languages (Chapter 7) String generation Parsing Regular languages Structures We have seen one composite data
More informationKEY. A 1. The action of a grammar when a derivation can be found for a sentence. Y 2. program written in a High Level Language
1 KEY CS 441G Fall 2018 Exam 1 Matching: match the best term from the following list to its definition by writing the LETTER of the term in the blank to the left of the definition. (1 point each) A Accepts
More informationPrefix/Infix/Postfix Notation
Prefix/Infix/Postfix Notation One commonly writes arithmetic expressions, such as 3 + 4 * (5-2) in infix notation which means that the operator is placed in between the two operands. In this example, the
More informationMonday, March 13, 2017
Monday, March 13, 2017 Topics for today Arrays and Indexed Addressing Global arrays Local arrays Buffer exploit attacks Arrays and indexed addressing (section 6.4) So far we have looked at scalars (int,
More informationLecture Chapter 6 Recursion as a Problem Solving Technique
Lecture Chapter 6 Recursion as a Problem Solving Technique Backtracking 1. Select, i.e., guess, a path of steps that could possibly lead to a solution 2. If the path leads to a dead end then retrace steps
More informationCD Assignment I. 1. Explain the various phases of the compiler with a simple example.
CD Assignment I 1. Explain the various phases of the compiler with a simple example. The compilation process is a sequence of various phases. Each phase takes input from the previous, and passes the output
More informationRecursion as a Problem-Solving Technique. Chapter 5
Recursion as a Problem-Solving Technique Chapter 5 Overview Ass2: TimeSpan Ass3: Maze "Quiz Ch02 + Ch05" - due before Wednesday class Not all in-class quizzes will be announced ahead of time Week-5: Sample
More informationWednesday, April 16, 2014
Wednesday, pril 16, 2014 Topics for today Homework #5 solutions Code generation nalysis lgorithm 4: infix to tree Synthesis lgorithm 5: tree to code Optimization HW #5 solutions 1. lda 0,i ; for sum of
More informationCS 206 Introduction to Computer Science II
CS 206 Introduction to Computer Science II 03 / 31 / 2017 Instructor: Michael Eckmann Today s Topics Questions? Comments? finish RadixSort implementation some applications of stack Priority Queues Michael
More informationWednesday, February 7, 2018
Wednesday, February 7, 2018 Topics for today The Pep/9 memory Four example programs The loader The assembly language level (Chapter 5) Symbolic Instructions Assembler directives Immediate mode and equate
More informationStructure of a compiler. More detailed overview of compiler front end. Today we ll take a quick look at typical parts of a compiler.
More detailed overview of compiler front end Structure of a compiler Today we ll take a quick look at typical parts of a compiler. This is to give a feeling for the overall structure. source program lexical
More informationProblem with Scanning an Infix Expression
Operator Notation Consider the infix expression (X Y) + (W U), with parentheses added to make the evaluation order perfectly obvious. This is an arithmetic expression written in standard form, called infix
More informationCIS 1.5 Course Objectives. a. Understand the concept of a program (i.e., a computer following a series of instructions)
By the end of this course, students should CIS 1.5 Course Objectives a. Understand the concept of a program (i.e., a computer following a series of instructions) b. Understand the concept of a variable
More informationAbout the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Compiler Design
i About the Tutorial A compiler translates the codes written in one language to some other language without changing the meaning of the program. It is also expected that a compiler should make the target
More informationLexical Scanning COMP360
Lexical Scanning COMP360 Captain, we re being scanned. Spock Reading Read sections 2.1 3.2 in the textbook Regular Expression and FSA Assignment A new assignment has been posted on Blackboard It is due
More informationCS 314 Principles of Programming Languages. Lecture 3
CS 314 Principles of Programming Languages Lecture 3 Zheng Zhang Department of Computer Science Rutgers University Wednesday 14 th September, 2016 Zheng Zhang 1 CS@Rutgers University Class Information
More informationOperators and Expressions:
Operators and Expressions: Operators and expression using numeric and relational operators, mixed operands, type conversion, logical operators, bit operations, assignment operator, operator precedence
More informationLec-5-HW-1, TM basics
Lec-5-HW-1, TM basics (Problem 0)-------------------- Design a Turing Machine (TM), T_sub, that does unary decrement by one. Assume a legal, initial tape consists of a contiguous set of cells, each containing
More information9/21/17. Outline. Expression Evaluation and Control Flow. Arithmetic Expressions. Operators. Operators. Notation & Placement
Outline Expression Evaluation and Control Flow In Text: Chapter 6 Notation Operator evaluation order Operand evaluation order Overloaded operators Type conversions Short-circuit evaluation of conditions
More informationCompiler Code Generation COMP360
Compiler Code Generation COMP360 Students who acquire large debts putting themselves through school are unlikely to think about changing society. When you trap people in a system of debt, they can t afford
More informationMore on Syntax. Agenda for the Day. Administrative Stuff. More on Syntax In-Class Exercise Using parse trees
More on Syntax Judy Stafford Comp 80 Meeting February, 00 Agenda for the Day Administrative Stuff Moodle Classlist at without waiting list More on Syntax InClass Exercise Using parse trees Last time Syntax
More informationMonday, February 16, 2015
Monday, February 16, 2015 Topics for today How assemblers work Symbol tables ILC Pass 1 algorithm, Error checking Pass 2 Immediate mode and equate Assembler variants: Disassembler, Cross assembler Macros
More informationMidterm Solutions COMS W4115 Programming Languages and Translators Wednesday, March 25, :10-5:25pm, 309 Havemeyer
Department of Computer cience Columbia University Midterm olutions COM W4115 Programming Languages and Translators Wednesday, March 25, 2009 4:10-5:25pm, 309 Havemeyer Closed book, no aids. ach question
More informationECS 120 Lesson 7 Regular Expressions, Pt. 1
ECS 120 Lesson 7 Regular Expressions, Pt. 1 Oliver Kreylos Friday, April 13th, 2001 1 Outline Thus far, we have been discussing one way to specify a (regular) language: Giving a machine that reads a word
More informationComputer Programming CS F111
Computer Programming CS F111 BITS Pilani Dubai Campus NAND KUMAR Basics of C Programming BITS Pilani Dubai Campus Write a program that 1. Asks 5 marks from the user, find the average of the marks and print
More informationUniversity of California at Berkeley College of Engineering Department of Electrical Engineering and Computer Sciences. Spring 2010 May 10, 2010
University of California at Berkeley College of Engineering Department of Electrical Engineering and Computer Sciences EECS150 J. Wawrzynek Spring 2010 May 10, 2010 Final Exam Name: ID number: This is
More informationCOMP-421 Compiler Design. Presented by Dr Ioanna Dionysiou
COMP-421 Compiler Design Presented by Dr Ioanna Dionysiou Administrative! [ALSU03] Chapter 3 - Lexical Analysis Sections 3.1-3.4, 3.6-3.7! Reading for next time [ALSU03] Chapter 3 Copyright (c) 2010 Ioanna
More informationThere are many other applications like constructing the expression tree from the postorder expression. I leave you with an idea as how to do it.
Programming, Data Structures and Algorithms Prof. Hema Murthy Department of Computer Science and Engineering Indian Institute of Technology, Madras Lecture 49 Module 09 Other applications: expression tree
More informationWednesday, February 4, Chapter 4
Wednesday, February 4, 2015 Topics for today Introduction to Computer Systems Static overview Operation Cycle Introduction to Pep/8 Features of the system Operational cycle Program trace Categories of
More informationLinear Data Structure
Linear Data Structure Definition A data structure is said to be linear if its elements form a sequence or a linear list. Examples: Array Linked List Stacks Queues Operations on linear Data Structures Traversal
More informationStacks. Chapter 5. Copyright 2012 by Pearson Education, Inc. All rights reserved
Stacks Chapter 5 Copyright 2012 by Pearson Education, Inc. All rights reserved Contents Specifications of the ADT Stack Using a Stack to Process Algebraic Expressions A Problem Solved: Checking for Balanced
More informationWe use L i to stand for LL L (i times). It is logical to define L 0 to be { }. The union of languages L and M is given by
The term languages to mean any set of string formed from some specific alphaet. The notation of concatenation can also e applied to languages. If L and M are languages, then L.M is the language consisting
More informationExpression Evaluation and Control Flow. Outline
Expression Evaluation and Control Flow In Text: Chapter 6 Outline Notation Operator Evaluation Order Operand Evaluation Order Overloaded operators Type conversions Short-circuit evaluation of conditions
More informationASTS, GRAMMARS, PARSING, TREE TRAVERSALS. Lecture 14 CS2110 Fall 2018
1 ASTS, GRAMMARS, PARSING, TREE TRAVERSALS Lecture 14 CS2110 Fall 2018 Announcements 2 Today: The last day to request prelim regrades Assignment A4 due next Thursday night. Please work on it early and
More informationsyntax tree - * * * * * *
Announcements Today: The last day to request prelim regrades Assignment A4 due next Thursday night. Please work on it early and steadily. Watch the two videos on recursion on trees before working on A4!
More informationCS164: Midterm I. Fall 2003
CS164: Midterm I Fall 2003 Please read all instructions (including these) carefully. Write your name, login, and circle the time of your section. Read each question carefully and think about what s being
More informationComputer Components. Software{ User Programs. Operating System. Hardware
Computer Components Software{ User Programs Operating System Hardware What are Programs? Programs provide instructions for computers Similar to giving directions to a person who is trying to get from point
More informationFaculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology
Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology exam Compiler Construction in4303 April 9, 2010 14.00-15.30 This exam (6 pages) consists of 52 True/False
More informationLECTURE 17. Expressions and Assignment
LECTURE 17 Expressions and Assignment EXPRESSION SYNTAX An expression consists of An atomic object, e.g. number or variable. An operator (or function) applied to a collection of operands (or arguments)
More informationCSE 582 Autumn 2002 Exam 11/26/02
Name There are 8 questions worth a total of 100 points. Please budget your time so you get to all of the questions. Keep your answers brief and to the point. You may refer to the following reference materials:
More informationADTS, GRAMMARS, PARSING, TREE TRAVERSALS
3//15 1 AD: Abstract Data ype 2 Just like a type: Bunch of values together with operations on them. Used often in discussing data structures Important: he definition says ntthing about the implementation,
More informationADTS, GRAMMARS, PARSING, TREE TRAVERSALS
1 Pointers to material ADS, GRAMMARS, PARSING, R RAVRSALS Lecture 13 CS110 all 016 Parse trees: text, section 3.36 Definition of Java Language, sometimes useful: docs.oracle.com/javase/specs/jls/se8/html/index.html
More informationSOFTWARE DEVELOPMENT 1. Operators 2018W A. Ferscha (Institute of Pervasive Computing, JKU Linz)
SOFTWARE DEVELOPMENT 1 Operators 2018W (Institute of Pervasive Computing, JKU Linz) OPERATORS Operators are required to form expressions. Depending on the number of operands they take, they are called:
More informationCSE P 501 Compilers. Parsing & Context-Free Grammars Hal Perkins Winter /15/ Hal Perkins & UW CSE C-1
CSE P 501 Compilers Parsing & Context-Free Grammars Hal Perkins Winter 2008 1/15/2008 2002-08 Hal Perkins & UW CSE C-1 Agenda for Today Parsing overview Context free grammars Ambiguous grammars Reading:
More informationRevision Statement while return growth rate asymptotic notation complexity Compare algorithms Linear search Binary search Preconditions: sorted,
[1] Big-O Analysis AVERAGE(n) 1. sum 0 2. i 0. while i < n 4. number input_number(). sum sum + number 6. i i + 1 7. mean sum / n 8. return mean Revision Statement no. of times executed 1 1 2 1 n+1 4 n
More informationDraw a diagram of an empty circular queue and describe it to the reader.
1020_1030_testquestions.text Wed Sep 10 10:40:46 2014 1 1983/84 COSC1020/30 Tests >>> The following was given to students. >>> Students can have a good idea of test questions by examining and trying the
More informationLexical Analysis. COMP 524, Spring 2014 Bryan Ward
Lexical Analysis COMP 524, Spring 2014 Bryan Ward Based in part on slides and notes by J. Erickson, S. Krishnan, B. Brandenburg, S. Olivier, A. Block and others The Big Picture Character Stream Scanner
More informationCS 441G Fall 2018 Exam 1 Matching: LETTER
CS 441G Fall 2018 Exam 1 Matching: match the best term from the following list to its definition by writing the LETTER of the term in the blank to the left of the definition. All 31 definitions are given
More informationCompiling Regular Expressions COMP360
Compiling Regular Expressions COMP360 Logic is the beginning of wisdom, not the end. Leonard Nimoy Compiler s Purpose The compiler converts the program source code into a form that can be executed by the
More informationOperators & Expressions
Operators & Expressions Operator An operator is a symbol used to indicate a specific operation on variables in a program. Example : symbol + is an add operator that adds two data items called operands.
More informationLe L c e t c ur u e e 2 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Variables Operators
Course Name: Advanced Java Lecture 2 Topics to be covered Variables Operators Variables -Introduction A variables can be considered as a name given to the location in memory where values are stored. One
More informationStacks. Chapter 5. Copyright 2012 by Pearson Education, Inc. All rights reserved
Stacks Chapter 5 Contents Specifications of the ADT Stack Using a Stack to Process Algebraic Expressions A Problem Solved: Checking for Balanced Delimiters in an Infix Algebraic Expression A Problem Solved:
More informationWednesday, February 19, 2014
Wednesda, Februar 19, 2014 Topics for toda Solutions to HW #2 Topics for Eam #1 Chapter 6: Mapping High-level to assembl-level The Pep/8 run-time stack Stack-relative addressing (,s) SP manipulation Stack
More informationCDA 3103 Computer Organization Homework #7 Solution Set
CDA 3103 Computer Organization Homework #7 Solution Set 1 Problems 1. Write a MARIE assembly program for the following algorithm where the subroutine takes two numbers and returns their product. Your assembly
More informationADTS, GRAMMARS, PARSING, TREE TRAVERSALS. Regrades 10/6/15. Prelim 1. Prelim 1. Expression trees. Pointers to material
1 Prelim 1 2 Max: 99 Mean: 71.2 Median: 73 Std Dev: 1.6 ADS, GRAMMARS, PARSING, R RAVRSALS Lecture 12 CS2110 Spring 2015 3 Prelim 1 Score Grade % 90-99 A 82-89 A-/A 26% 70-82 B/B 62-69 B-/B 50% 50-59 C-/C
More informationSupplemental Materials: Grammars, Parsing, and Expressions. Topics. Grammars 10/11/2017. CS2: Data Structures and Algorithms Colorado State University
Supplemental Materials: Grammars, Parsing, and Expressions CS2: Data Structures and Algorithms Colorado State University Original slides by Chris Wilcox, Updated by Russ Wakefield and Wim Bohm Topics Grammars
More informationCSCI312 Principles of Programming Languages!
CSCI312 Principles of Programming Languages!! Chapter 3 Regular Expression and Lexer Xu Liu Recap! Copyright 2006 The McGraw-Hill Companies, Inc. Clite: Lexical Syntax! Input: a stream of characters from
More informationAdvanced Computer Networks. Rab Nawaz Jadoon DCS. Assistant Professor COMSATS University, Lahore Pakistan. Department of Computer Science
Advanced Computer Networks Department of Computer Science DCS COMSATS Institute of Information Technology Rab Nawaz Jadoon Assistant Professor COMSATS University, Lahore Pakistan Advanced Computer Networks
More informationWednesday, September 6, 2017
Wednesday, September 6, 2017 Topics for today Arithmetic operations and status bits Logical operators Introduction to bigger bases Encoding characters Coding in general Status bits We saw last time that
More informationPushdown Automata. A PDA is an FA together with a stack.
Pushdown Automata A PDA is an FA together with a stack. Stacks A stack stores information on the last-in firstout principle. Items are added on top by pushing; items are removed from the top by popping.
More informationDeclaration and Memory
Declaration and Memory With the declaration int width; the compiler will set aside a 4-byte (32-bit) block of memory (see right) The compiler has a symbol table, which will have an entry such as Identifier
More informationInput part 3: Implementing Interaction Techniques
Input part 3: Implementing Interaction Techniques Recap: Interaction techniques A method for carrying out a specific interactive task Example: enter a number in a range could use (simulated) slider (simulated)
More informationAnnouncements! P1 part 1 due next Tuesday P1 part 2 due next Friday
Announcements! P1 part 1 due next Tuesday P1 part 2 due next Friday 1 Finite-state machines CS 536 Last time! A compiler is a recognizer of language S (Source) a translator from S to T (Target) a program
More information