CISC 471 First Exam Review Game Questions. Overview 1 Draw the standard phases of a compiler for compiling a high level language to machine code, showing.

Slides:



Advertisements
Similar presentations
1 Week 9 Questions / Concerns Hand back Test#2 What’s due: Final Project due next Thursday June 5. Final Project check-off on Friday June 6 in class. Next.
Advertisements

A question from last class: construct the predictive parsing table for this grammar: S->i E t S e S | i E t S | a E -> B.
Lesson 8 CDT301 – Compiler Theory, Spring 2011 Teacher: Linus Källberg.
Bottom up Parsing Bottom up parsing trys to transform the input string into the start symbol. Moves through a sequence of sentential forms (sequence of.
Translator Architecture Code Generator ParserTokenizer string of characters (source code) string of tokens abstract program string of integers (object.
Mooly Sagiv and Roman Manevich School of Computer Science
Recap Mooly Sagiv. Outline Subjects Studied Questions & Answers.
Chapter 4 Lexical and Syntax Analysis Sections 1-4.
CS Summer 2005 Top-down and Bottom-up Parsing - a whirlwind tour June 20, 2005 Slide acknowledgment: Radu Rugina, CS 412.
Context-Free Grammars Lecture 7
Parsing III (Eliminating left recursion, recursive descent parsing)
1 COMP 144 Programming Language Concepts Felix Hernandez-Campos Lecture 5: Syntax Analysis COMP 144 Programming Language Concepts Spring 2002 Felix Hernandez-Campos.
ISBN Chapter 4 Lexical and Syntax Analysis The Parsing Problem Recursive-Descent Parsing.
Syntax Analysis Mooly Sagiv html:// Textbook:Modern Compiler Design Chapter 2.2 (Partial) Hashlama 11:00-14:00.
1 Chapter 3 Context-Free Grammars and Parsing. 2 Parsing: Syntax Analysis decides which part of the incoming token stream should be grouped together.
(2.1) Grammars  Definitions  Grammars  Backus-Naur Form  Derivation – terminology – trees  Grammars and ambiguity  Simple example  Grammar hierarchies.
CSC3315 (Spring 2009)1 CSC 3315 Lexical and Syntax Analysis Hamid Harroud School of Science and Engineering, Akhawayn University
Abstract Syntax Trees Lecture 14 Wed, Mar 3, 2004.
1 Introduction to Parsing Lecture 5. 2 Outline Regular languages revisited Parser overview Context-free grammars (CFG’s) Derivations.
BİL 744 Derleyici Gerçekleştirimi (Compiler Design)1 Syntax Analyzer Syntax Analyzer creates the syntactic structure of the given source program. This.
10/13/2015IT 3271 Tow kinds of predictive parsers: Bottom-Up: The syntax tree is built up from the leaves Example: LR(1) parser Top-Down The syntax tree.
CS 461 – Oct. 7 Applications of CFLs: Compiling Scanning vs. parsing Expression grammars –Associativity –Precedence Programming language (handout)
Joey Paquet, Lecture 12 Review. Joey Paquet, Course Review Compiler architecture –Lexical analysis, syntactic analysis, semantic.
1 Syntax In Text: Chapter 3. 2 Chapter 3: Syntax and Semantics Outline Syntax: Recognizer vs. generator BNF EBNF.
1 Lecture 5: Syntax Analysis (Section 2.2) CSCI 431 Programming Languages Fall 2002 A modification of slides developed by Felix Hernandez-Campos at UNC.
Parsing Lecture 5 Fri, Jan 28, Syntax Analysis The syntax of a language is described by a context-free grammar. Each grammar rule has the form A.
Parsing Introduction Syntactic Analysis I. Parsing Introduction 2 The Role of the Parser The Syntactic Analyzer, or Parser, is the heart of the front.
Bernd Fischer RW713: Compiler and Software Language Engineering.
CPS 506 Comparative Programming Languages Syntax Specification.
CS412/413 Introduction to Compilers and Translators Spring ’99 Lecture 3: Introduction to Syntactic Analysis.
INTRODUCTION TO COMPILERS(cond….) Prepared By: Mayank Varshney(04CS3019)
Compiler Introduction 1 Kavita Patel. Outlines 2  1.1 What Do Compilers Do?  1.2 The Structure of a Compiler  1.3 Compilation Process  1.4 Phases.
Syntax Analyzer (Parser)
CSC312 Automata Theory Lecture # 26 Chapter # 12 by Cohen Context Free Grammars.
1 Introduction to Parsing. 2 Outline l Regular languages revisited l Parser overview Context-free grammars (CFG ’ s) l Derivations.
Chap. 7, Syntax-Directed Compilation J. H. Wang Nov. 24, 2015.
COMP 3438 – Part II-Lecture 5 Syntax Analysis II Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ.
Parser: CFG, BNF Backus-Naur Form is notational variant of Context Free Grammar. Invented to specify syntax of ALGOL in late 1950’s Uses ::= to indicate.
1 Topic #4: Syntactic Analysis (Parsing) CSC 338 – Compiler Design and implementation Dr. Mohamed Ben Othman ( )
COMP 3438 – Part II-Lecture 6 Syntax Analysis III Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ.
Mid-Terms Exam Scope and Introduction. Format Grades: 100 points -> 20% in the final grade Multiple Choice Questions –8 questions, 7 points each Short.
Syntax Analysis By Noor Dhia Syntax analysis:- Syntax analysis or parsing is the most important phase of a compiler. The syntax analyzer considers.
Chapter 3 – Describing Syntax CSCE 343. Syntax vs. Semantics Syntax: The form or structure of the expressions, statements, and program units. Semantics:
Chapter 3 – Describing Syntax
Chapter 4 - Parsing CSCE 343.
CS 326 Programming Languages, Concepts and Implementation
Programming Languages Translator
CS510 Compiler Lecture 4.
Lexical and Syntax Analysis
Parsing and Parser Parsing methods: top-down & bottom-up
Introduction to Parsing (adapted from CS 164 at Berkeley)
Textbook:Modern Compiler Design
Table-driven parsing Parsing performed by a finite state machine.
Chapter 4 Syntax Analysis.
Syntax Analysis Chapter 4.
Abstract Syntax Trees Lecture 14 Mon, Feb 28, 2005.
PROGRAMMING LANGUAGES
Bison: Parser Generator
CSE 3302 Programming Languages
Compiler Design 4. Language Grammars
Lexical and Syntax Analysis
Introduction CI612 Compiler Design CI612 Compiler Design.
CPSC 388 – Compiler Design and Construction
ENERGY 211 / CME 211 Lecture 15 October 22, 2008.
R.Rajkumar Asst.Professor CSE
Lecture 4: Lexical Analysis & Chomsky Hierarchy
Lec00-outline May 18, 2019 Compiler Design CS416 Compiler Design.
Review for the Midterm. Overview (Chapter 1):
COP 4620 / 5625 Programming Language Translation / Compiler Writing Fall 2003 Lecture 2, 09/04/2003 Prof. Roy Levow.
Parsing CSCI 432 Computer Science Theory
Presentation transcript:

CISC 471 First Exam Review Game Questions

Overview 1 Draw the standard phases of a compiler for compiling a high level language to machine code, showing the input and output forms for each phase.

Overview 2 State 2 advantages of using an interpreter instead of a compiler for implementing a language. State 2 advantages of using a compiler instead of an interpreter for implementing a language.

Overview 3 What are the roles of a: – Preprocessor – Assembler – Linker ?

Lexical Analysis 1 Demonstrate that you understand the difference between a token and a lexeme, through an example. Give an example of a language feature that makes scanning nontrivial.

Lexical Analysis 2 Give a regular expression that represents exactly the set of decimal numbers that contain at least one digit representing the whole number part, no sign, and if there is a decimal point, then at least one digit to the right of the decimal point. Also, 0. is illegal.

Lexical Analysis 3 Show the partitioning of the input string below given the following flex spec rule set: a*b bba+c aaba b | c Input: abaabbaabaaaabbbccaabbaaba

CFG 1 Show an equivalent Context free grammar for the regular expression: S -> (A | B)* BA|C A -> DA | w B -> w | x C -> CD | D D -> y

CFG 2 Show that E -> E + E | w is an ambiguous grammar. How would you rewrite the grammar to remove the ambiguity if + is left associative?

CFG 3 Show a leftmost derivation for the string (a,a) with the grammar: S-> (L) | a L-> L,S | S Explain the difference between an abstract syntax tree and a concrete syntax tree and justify why most compilers use abstract syntax trees.

Parsing 1 Explain and show an example of two properties of grammars that cause problems for topdown parsers, and require rewrites or special rules in the yacc file. Name the two different ways that are used to build top-down parsers.

Parsing 2 Write the recursive descent routine for the following nonterminal: D -> D, id | id | ε

Parsing 3 Explain the actions of an LR bottom up parser for: Shift Reduce Explain how the parser determines the state to put back on top of the stack after a Reduce.

Semantic Analysis 1 Give 3 different examples of errors that are caught by semantic analysis and cannot be caught by the first two phases. Explain the difference between inherited and synthesized attributes.

Semantic Analysis 2 Show the attributed tree for -101 with the rules:

Semantic Analysis 3 Why is it a nice property to have an attribute grammar that has only synthesized attributes? Why is a circular attribute grammar a bad property?