# 11. a b c d e. 12. a b c d e. 13. a b c d e. 14. a b c d e. 15. a b c d e

Size: px
Start display at page:

Download "11. a b c d e. 12. a b c d e. 13. a b c d e. 14. a b c d e. 15. a b c d e"

Transcription

1 CS-3160 Concepts of Programming Languages Spring 2015 EXAM #1 (Chapters 1-6) Name: SCORES MC: /75 PROB #1: /15 PROB #2: /10 TOTAL: /100 Multiple Choice Responses Each multiple choice question in the separate packet is worth 3 points. There is no partial credit in this section. Choose the BEST answer of those given. Please indicate your answer by DARKENING the response that you have chosen in the space provided below. Make your selection obvious. Don t forget to mark your answers on this sheet. Only answers indicated below will be graded. 1. a b c d e 6. a b c d e 11. a b c d e 16. a b c d e 21. a b c d e 2. a b c d e 7. a b c d e 12. a b c d e 17. a b c d e 22. a b c d e 3. a b c d e 8. a b c d e 13. a b c d e 18. a b c d e 23. a b c d e 4. a b c d e 9. a b c d e 14. a b c d e 19. a b c d e 24. a b c d e 5. a b c d e 10. a b c d e 15. a b c d e 20. a b c d e 25. a b c d e

2 Problem #1 (15 pts) Consider the following grammar: S ( A S ^ A ) A ( B B ( * / ) A ) B ( C C ( + - ) B ) C one of {0,1,2,3,4,5,6,7,8,9} The operator semantics are the usual ones and are given in the table below. Circle the appropriate precedence (1 is highest) and associativity. operator name example Precedence Associativity + addition = L R - subtraction 6-2 = L R * multiplication 6 * 2 = L R / division 6 / 2 = L R ^ exponentiation 6 ^ 2 = L R Draw the parse tree, starting from S, for the following expression: 8 / 2 * 2 ^ ^ 4 / 4-2 What is the value of this expression? 2

3 Problem #2 (10 pts) A grammar consists of three binary operators and single-digit integer literals. The precedence and associativity are shown in the following table. operator Precedence Associativity # 1 2 L \$ 3 R Develop a set of productions (BNF or EBNF) that reflects this grammar. 3

4 Carefully record your response on the cover sheet of the exam. #1 The name used to describe having multiple ways to accomplish the same task is (a) redundancy. (b) operator overloading. (c) functional transparency. (d) feature multiplicity. (e) orthogonality. #2 When there are few restrictions one how primitive constructs can be combined, the language is said to be (a) orthogonal. (b) flexible. (c) tightly bound. (d) simple. (e) loosely constrained. #3 Which of the following are the three primary categories of languages, per the author? (a) declarative, functional, and logical. (b) imperative, object-oriented, functional. (c) imperative, declarative, and substantive. (d) imperative, functional, and logical. (e) function-oriented, data-oriented, object-oriented. #4 A general observation that is true more often than not regarding language design decisions is that (a) only decisions that improve all evaluation criteria should be adopted. (b) improvement in one area often requires sacrafice in another. (c) optimal decisions can be achieved only by carefully ranking evaluation criteria. (d) decisions must reflect the practical realities faced by language implementers. (e) no clear decisions can be made until all potential uses of the language are evaluated. #5 When two or more identifiers access the same memory cell, this is known as (a) aliasing. (b) dereferencing. (c) deferred access. (d) cross referencing. (e) inferred access.

5 #6 The smallest parts of a language, such as operators, special words, numeric values, are called (a) lexemes. (b) productions. (c) sentences. (d) tokens. (e) phrases. #7 Categories of lexemes are called (a) productions. (b) tokens. (c) phrases. (d) sentences. (e) lexemes. #8 The 'syntax' of a programming language is (a) the collection of key words and the rules for how they may be used. (b) the meaning of its expressions, statements, and program units. (c) the rules for how the language's statements may be combined to create a program. (d) the rules that govern the overloading of operators. (e) the form of its expressions, statements, and program units. #9 The 'semantics' of a programming language is (a) the form of its expressions, statements, and program units. (b) the collection of key words and the rules for how they may be used. (c) the rules that govern the overloading of operators. (d) the meaning of its expressions, statements, and program units. (e) the rules for how the language's statements may be combined to create a program. #10 The language described by a grammar (a) is dictated by whether a left-most or a right-most derivation is specified. (b) is 'context-free' if and only if it can be recognized by a finite automaton. (c) is independent of the manner (order) in which rules are applied. (d) is not context-free if it allows recursion. (e) must be finite to have any practical utility (infinitely long programs are a theoretical curiosity). 2

6 #11 A language recognizer performs what task? (a) Determines the order in which the productions can be applied to produce a particular sentence. (b) Creates a hierarchical description of the grammatical structure of a sentence. (c) Produces lower level instructions that implement the semantics of a sentence. (d) Answers the question of whether a particular sentence is a member of a particular language. (e) Reduces a sentence into a stream of tokens. #12 A parser performs what task? (a) Produces lower level instructions that implement the semantics of a sentence. (b) Answers the question of whether a particular sentence is a member of a particular language. (c) Creates a hierarchical description of the grammatical structure of a sentence. (d) Determines the order in which the productions can be applied to produce a particular sentence. (e) Reduces a sentence into a stream of tokens. #13 A lexer performs what task? (a) Produces lower level instructions that implement the semantics of a sentence. (b) Answers the question of whether a particular sentence is a member of a particular language. (c) Reduces a sentence into a stream of tokens. (d) Creates a hierarchical description of the grammatical structure of a sentence. (e) Determines the order in which the productions can be applied to produce a particular sentence. #14 A context free grammar imposes precedence of operators by placing (a) lower precendence non-terminals to the left of lower precedence non-terminals. (b) lower precedence operators closer to the Start symbol in the production chain. (c) lower precedence operators lower in the parse tree. (d) higher precendence non-terminals to the left of lower precedence non-terminals. (e) higher precedence operators closer to the Start symbol in the production chain. #15 The term "static" generally implies (a) that a variable is accessible even after the function that allocated it terminates. (b) that a variable is global in scope. (c) that all attributes, except the value, are known and fixed prior to runtime. (d) that a variable is available to functions in other program units. (e) that the associated attribute is known prior to runtime and does not change once the program has started running. 3

7 #16 Which of the following is NOT true: Compared to dynamicly scoped languages, statically scoped languages (a) execute faster. (b) are more prevalent. (c) are easier to read. (d) are more reliable. (e) require fewer parameters to be passed to functions. #17 The referencing environment of a statement is (a) the collection of all variables that are visible in that statement. (b) the collection of all functions that can be referred to by the statement. (c) the function in which the statement resides. (d) the file in which the statement resides. (e) the collection of all variable either read or written to within that statement. #18 In most languages, variables that are local to functions have what kind of storage binding? (a) Implicit heap-dynamic. (b) Stack-dynamic. (c) Elaborated. (d) Static. (e) Explicit heap-dynamic. #19 The scope of a variable is (a) the range of statements in which the variable is visible. (b) fixed throughout the execution of the program. (c) determined by the type of the variable. (d) the range of values that the variable can assume. (e) directly associated with the lifetime of the variable. #20 What distinguishes static (lexical) scoping from dynamic scoping? (a) In static scoping variables in the calling method are visible to the called method. (b) Static scoping can be determined prior to execution while dynamic scoping can only be determined at run time. (c) Dynamically scoped variables only exist for the lifetime of the program unit in which they are declared. (d) Statically scoped variables exist for the entire execution of the program. (e) In dynamic scoping all variables are visible to any method in the same class. 4

8 #21 Primitive data types (a) are direct reflections of the underlying hardware representations. (b) do not include character types since these may be defined in terms of ASCII integer values. (c) are all based on Boolean types, which directly reflect hardware capabilities. (d) are those data types that are not defined in terms of other data types. (e) are limited to integer and floating point numeric types. #22 An enumeration type is generally (a) not supported by modern languages because of the lessened readabily that usually results. (b) a range of integers starting with zero. (c) a set of named constants. (d) not used except when working with explicit array limits. (e) defined by the compiler based on the usage of integer literals. #23 A type who variables may store different data types at different times is known as a (a) union. (b) structure. (c) class. (d) array. (e) record. #24 What does "lost memory" refer to? (a) A block of allocated memory that is no longer accessible to a user program. (b) A pointer that refers to a heap-dynamic variable that has been deallocated. (c) A pointer that has been set to nil (or NULL). (d) Memory that can no longer be written to because it has been damaged. (e) A pointer that points to memory containing data of a different type than the pointer was declared as. #25 Decimal data types are intended to (a) eliminate cumulative roundoff error in financial calculations. (b) store string representations of decimal values. (c) store decimal values, including fractional values, exactly over some range. (d) enable fast hardware processing of financial data. (e) store arbitrary precision decimal values. 5

### Programming Languages Third Edition. Chapter 7 Basic Semantics

Programming Languages Third Edition Chapter 7 Basic Semantics Objectives Understand attributes, binding, and semantic functions Understand declarations, blocks, and scope Learn how to construct a symbol

### CS 3360 Design and Implementation of Programming Languages. Exam 1

1 Spring 2016 (Monday, March 21) Name: CS 3360 Design and Implementation of Programming Languages Exam 1 This test has 18 questions and pages numbered 1 through 6. Reminders This test is closed-notes and

### Programming Languages, Summary CSC419; Odelia Schwartz

Programming Languages, Summary CSC419; Odelia Schwartz Chapter 1 Topics Reasons for Studying Concepts of Programming Languages Programming Domains Language Evaluation Criteria Influences on Language Design

### CS 415 Midterm Exam Spring SOLUTION

CS 415 Midterm Exam Spring 2005 - SOLUTION Name Email Address Student ID # Pledge: This exam is closed note, closed book. Questions will be graded on quality of answer. Please supply the best answer you

### St. MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad

St. MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad-00 014 Subject: PPL Class : CSE III 1 P a g e DEPARTMENT COMPUTER SCIENCE AND ENGINEERING S No QUESTION Blooms Course taxonomy level Outcomes UNIT-I

### COSE312: Compilers. Lecture 1 Overview of Compilers

COSE312: Compilers Lecture 1 Overview of Compilers Hakjoo Oh 2017 Spring Hakjoo Oh COSE312 2017 Spring, Lecture 1 March 7, 2017 1 / 15 What is Compiler? Software systems that translate a program written

### The PCAT Programming Language Reference Manual

The PCAT Programming Language Reference Manual Andrew Tolmach and Jingke Li Dept. of Computer Science Portland State University September 27, 1995 (revised October 15, 2002) 1 Introduction The PCAT language

SE352b Software Engineering Design Tools W3: Programming Paradigms Feb. 3, 2005 SE352b, ECE,UWO, Hamada Ghenniwa SE352b: Roadmap CASE Tools: Introduction System Programming Tools Programming Paradigms

### MIDTERM EXAM (Solutions)

MIDTERM EXAM (Solutions) Total Score: 100, Max. Score: 83, Min. Score: 26, Avg. Score: 57.3 1. (10 pts.) List all major categories of programming languages, outline their definitive characteristics and

### The SPL Programming Language Reference Manual

The SPL Programming Language Reference Manual Leonidas Fegaras University of Texas at Arlington Arlington, TX 76019 fegaras@cse.uta.edu February 27, 2018 1 Introduction The SPL language is a Small Programming

### A simple syntax-directed

Syntax-directed is a grammaroriented compiling technique Programming languages: Syntax: what its programs look like? Semantic: what its programs mean? 1 A simple syntax-directed Lexical Syntax Character

### 2. Reachability in garbage collection is just an approximation of garbage.

symbol tables were on the first exam of this particular year's exam. We did not discuss register allocation in this This exam has questions from previous CISC 471/672. particular year. Not all questions

### CS 415 Midterm Exam Spring 2002

CS 415 Midterm Exam Spring 2002 Name KEY Email Address Student ID # Pledge: This exam is closed note, closed book. Good Luck! Score Fortran Algol 60 Compilation Names, Bindings, Scope Functional Programming

### Chapter 3: Describing Syntax and Semantics. Introduction Formal methods of describing syntax (BNF)

Chapter 3: Describing Syntax and Semantics Introduction Formal methods of describing syntax (BNF) We can analyze syntax of a computer program on two levels: 1. Lexical level 2. Syntactic level Lexical

### SEMANTIC ANALYSIS TYPES AND DECLARATIONS

SEMANTIC ANALYSIS CS 403: Type Checking Stefan D. Bruda Winter 2015 Parsing only verifies that the program consists of tokens arranged in a syntactically valid combination now we move to check whether

### PL Revision overview

PL Revision overview Course topics Parsing G = (S, P, NT, T); (E)BNF; recursive descent predictive parser (RDPP) Lexical analysis; Syntax and semantic errors; type checking Programming language structure

### CS 330 Lecture 18. Symbol table. C scope rules. Declarations. Chapter 5 Louden Outline

CS 0 Lecture 8 Chapter 5 Louden Outline The symbol table Static scoping vs dynamic scoping Symbol table Dictionary associates names to attributes In general: hash tables, tree and lists (assignment ) can

### CPSC 3740 Programming Languages University of Lethbridge. Data Types

Data Types A data type defines a collection of data values and a set of predefined operations on those values Some languages allow user to define additional types Useful for error detection through type

### Chapter 5. Names, Bindings, and Scopes

Chapter 5 Names, Bindings, and Scopes Chapter 5 Topics Introduction Names Variables The Concept of Binding Scope Scope and Lifetime Referencing Environments Named Constants 1-2 Introduction Imperative

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

### CS 430 Spring Mike Lam, Professor. Data Types and Type Checking

CS 430 Spring 2015 Mike Lam, Professor Data Types and Type Checking Type Systems Type system Rules about valid types, type compatibility, and how data values can be used Benefits of a robust type system

### CPS 506 Comparative Programming Languages. Syntax Specification

CPS 506 Comparative Programming Languages Syntax Specification Compiling Process Steps Program Lexical Analysis Convert characters into a stream of tokens Lexical Analysis Syntactic Analysis Send tokens

### DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Year & Semester : I Year / II Semester Section : CSE - I Subject Code : CS7203 Subject Name : PRINCIPLES OF PROGRAMMING LANGUAGES Degree & Branch : M.E C.S.E.

### Briefly describe the purpose of the lexical and syntax analysis phases in a compiler.

Name: Midterm Exam PID: This is a closed-book exam; you may not use any tools besides a pen. You have 75 minutes to answer all questions. There are a total of 75 points available. Please write legibly;

### CS 4201 Compilers 2014/2015 Handout: Lab 1

CS 4201 Compilers 2014/2015 Handout: Lab 1 Lab Content: - What is compiler? - What is compilation? - Features of compiler - Compiler structure - Phases of compiler - Programs related to compilers - Some

### Heap, Variables, References, and Garbage. CS152. Chris Pollett. Oct. 13, 2008.

Heap, Variables, References, and Garbage. CS152. Chris Pollett. Oct. 13, 2008. Outline. Dynamic Allocation. Variables and Constants. Aliases and Problems. Garbage. Introduction. On Wednesday, we were talking

### The Structure of a Syntax-Directed Compiler

Source Program (Character Stream) Scanner Tokens Parser Abstract Syntax Tree Type Checker (AST) Decorated AST Translator Intermediate Representation Symbol Tables Optimizer (IR) IR Code Generator Target

### Structure of Programming Languages Lecture 3

Structure of Programming Languages Lecture 3 CSCI 6636 4536 Spring 2017 CSCI 6636 4536 Lecture 3... 1/25 Spring 2017 1 / 25 Outline 1 Finite Languages Deterministic Finite State Machines Lexical Analysis

### CS 411 Midterm Feb 2008

CS 411 Midterm Feb 2008 Exam number: P1: / 9 P4: / 10 P2: / 4 P5: / 9 Student Name: P3: / 7 P6: / 8 P7: / 8 SUBTOTALS: / 20 / 35 Student ID number: TOTAL: / 55 READ THIS CAREFULLY BEFORE PROCEEDING DO

### CMSC 331 Final Exam Section 0201 December 18, 2000

CMSC 331 Final Exam Section 0201 December 18, 2000 Name: Student ID#: You will have two hours to complete this closed book exam. We reserve the right to assign partial credit, and to deduct points for

### Chapter 5 Names, Binding, Type Checking and Scopes

Chapter 5 Names, Binding, Type Checking and Scopes Names - We discuss all user-defined names here - Design issues for names: -Maximum length? - Are connector characters allowed? - Are names case sensitive?

### Index. object lifetimes, and ownership, use after change by an alias errors, use after drop errors, BTreeMap, 309

A Arithmetic operation floating-point arithmetic, 11 12 integer numbers, 9 11 Arrays, 97 copying, 59 60 creation, 48 elements, 48 empty arrays and vectors, 57 58 executable program, 49 expressions, 48

### UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division. P. N. Hilfinger

UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division CS 164 Spring 2010 P. N. Hilfinger CS 164: Final Examination (revised) Name: Login: You have

### CS Exam #1-100 points Spring 2011

CS 4700 - Exam #1-100 points Spring 2011 Fill in the blanks (1 point each) 1. syntactic sugar is a term coined for additions to the syntax of a computer language that do not affect its expressiveness but

### Compiler Theory. (Semantic Analysis and Run-Time Environments)

Compiler Theory (Semantic Analysis and Run-Time Environments) 005 Semantic Actions A compiler must do more than recognise whether a sentence belongs to the language of a grammar it must do something useful

### FORM 2 (Please put your name and form # on the scantron!!!!)

CS 161 Exam 2: FORM 2 (Please put your name and form # on the scantron!!!!) True (A)/False(B) (2 pts each): 1. Recursive algorithms tend to be less efficient than iterative algorithms. 2. A recursive function

### R13 SET Discuss how producer-consumer problem and Dining philosopher s problem are solved using concurrency in ADA.

R13 SET - 1 III B. Tech I Semester Regular Examinations, November - 2015 1 a) What constitutes a programming environment? [3M] b) What mixed-mode assignments are allowed in C and Java? [4M] c) What is

### CS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square)

CS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square) Introduction This semester, through a project split into 3 phases, we are going

### 0. Overview of this standard Design entities and configurations... 5

Contents 0. Overview of this standard... 1 0.1 Intent and scope of this standard... 1 0.2 Structure and terminology of this standard... 1 0.2.1 Syntactic description... 2 0.2.2 Semantic description...

### CS 415 Midterm Exam Fall 2003

CS 415 Midterm Exam Fall 2003 Name KEY Email Address Student ID # Pledge: This exam is closed note, closed book. Questions will be graded on quality of answer. Please supply the best answer you can to

### CS415 Compilers. Lexical Analysis

CS415 Compilers Lexical Analysis These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University Lecture 7 1 Announcements First project and second homework

### 1 Lexical Considerations

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2013 Handout Decaf Language Thursday, Feb 7 The project for the course is to write a compiler

### Homework & Announcements

Homework & nnouncements New schedule on line. Reading: Chapter 18 Homework: Exercises at end Due: 11/1 Copyright c 2002 2017 UMaine School of Computing and Information S 1 / 25 COS 140: Foundations of

### CSE 307: Principles of Programming Languages

1 / 57 CSE 307: Principles of Programming Languages Course Review R. Sekar Course Topics Introduction and History Syntax Values and types Names, Scopes and Bindings Variables and Constants Expressions

### CS1622. Semantic Analysis. The Compiler So Far. Lecture 15 Semantic Analysis. How to build symbol tables How to use them to find

CS1622 Lecture 15 Semantic Analysis CS 1622 Lecture 15 1 Semantic Analysis How to build symbol tables How to use them to find multiply-declared and undeclared variables. How to perform type checking CS

### G Programming Languages - Fall 2012

G22.2110-003 Programming Languages - Fall 2012 Lecture 2 Thomas Wies New York University Review Last week Programming Languages Overview Syntax and Semantics Grammars and Regular Expressions High-level

### CS3360 Design and Implementation of Programming Languages Final Exam May 16, pm to 12:45pm (2 hour and 40 minutes) NAME:

CS3360 Design and Implementation of Programming Languages Final Exam May 16, 2013 10pm to 12:45pm (2 hour and 40 minutes) NAME: GRADE = / 140 1. Choice of Programming Languages / 25 2. Programming languages:

### Time : 1 Hour Max Marks : 30

Total No. of Questions : 6 P4890 B.E/ Insem.- 74 B.E ( Computer Engg) PRINCIPLES OF MODERN COMPILER DESIGN (2012 Pattern) (Semester I) Time : 1 Hour Max Marks : 30 Q.1 a) Explain need of symbol table with

### 1. true / false By a compiler we mean a program that translates to code that will run natively on some machine.

1. true / false By a compiler we mean a program that translates to code that will run natively on some machine. 2. true / false ML can be compiled. 3. true / false FORTRAN can reasonably be considered

### INSTITUTE OF AERONAUTICAL ENGINEERING

INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad -500 043 INFORMATION TECHNOLOGY TUTORIAL QUESTION BANK Name : PRINCIPLES OF PROGRAMMING LANGUAGES Code : A40511 Class : II B. Tech

### CS5363 Final Review. cs5363 1

CS5363 Final Review cs5363 1 Programming language implementation Programming languages Tools for describing data and algorithms Instructing machines what to do Communicate between computers and programmers

### Compiling Techniques

Lecture 2: The view from 35000 feet 19 September 2017 Table of contents 1 2 Passes Representations 3 Instruction Selection Register Allocation Instruction Scheduling 4 of a compiler Source Compiler Machine

### Midterm 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)

### Introduction Primitive Data Types Character String Types User-Defined Ordinal Types Array Types. Record Types. Pointer and Reference Types

Chapter 6 Topics WEEK E FOUR Data Types Introduction Primitive Data Types Character String Types User-Defined Ordinal Types Array Types Associative Arrays Record Types Union Types Pointer and Reference

### 1. The output of lexical analyser is a) A set of RE b) Syntax Tree c) Set of Tokens d) String Character

1. The output of lexical analyser is a) A set of RE b) Syntax Tree c) Set of Tokens d) String Character 2. The symbol table implementation is based on the property of locality of reference is a) Linear

### Concepts of Programming Languages

Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana State University Spring 2014 Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014

### MIDTERM EXAMINATION - CS130 - Spring 2005

MIDTERM EAMINATION - CS130 - Spring 2005 Your full name: Your UCSD ID number: This exam is closed book and closed notes Total number of points in this exam: 231 + 25 extra credit This exam counts for 25%

### Typescript on LLVM Language Reference Manual

Typescript on LLVM Language Reference Manual Ratheet Pandya UNI: rp2707 COMS 4115 H01 (CVN) 1. Introduction 2. Lexical Conventions 2.1 Tokens 2.2 Comments 2.3 Identifiers 2.4 Reserved Keywords 2.5 String

### Lecture 7: Type Systems and Symbol Tables. CS 540 George Mason University

Lecture 7: Type Systems and Symbol Tables CS 540 George Mason University Static Analysis Compilers examine code to find semantic problems. Easy: undeclared variables, tag matching Difficult: preventing

### Types. What is a type?

Types What is a type? Type checking Type conversion Aggregates: strings, arrays, structures Enumeration types Subtypes Types, CS314 Fall 01 BGRyder 1 What is a type? A set of values and the valid operations

### EI326 ENGINEERING PRACTICE & TECHNICAL INNOVATION (III-G) Kenny Q. Zhu Dept. of Computer Science Shanghai Jiao Tong University

EI326 ENGINEERING PRACTICE & TECHNICAL INNOVATION (III-G) Kenny Q. Zhu Dept. of Computer Science Shanghai Jiao Tong University KENNY ZHU Research Interests: Programming Languages Data processing Coordination

### Lexical Analysis. Introduction

Lexical Analysis Introduction Copyright 2015, Pedro C. Diniz, all rights reserved. Students enrolled in the Compilers class at the University of Southern California have explicit permission to make copies

### Types II. Hwansoo Han

Types II Hwansoo Han Arrays Most common and important composite data types Homogeneous elements, unlike records Fortran77 requires element type be scalar Elements can be any type (Fortran90, etc.) A mapping

### Extending SystemVerilog Data Types to Nets

Extending SystemVerilog Data Types to Nets SystemVerilog extended Verilog by adding powerful new data types and operators that can be used to declare and manipulate parameters and variables. Extensions

### PRINCIPLES OF COMPILER DESIGN UNIT I INTRODUCTION TO COMPILERS

Objective PRINCIPLES OF COMPILER DESIGN UNIT I INTRODUCTION TO COMPILERS Explain what is meant by compiler. Explain how the compiler works. Describe various analysis of the source program. Describe the

### Programming Languages

Programming Languages Tevfik Koşar Lecture - VIII February 9 th, 2006 1 Roadmap Allocation techniques Static Allocation Stack-based Allocation Heap-based Allocation Scope Rules Static Scopes Dynamic Scopes

### Lexical Considerations

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2010 Handout Decaf Language Tuesday, Feb 2 The project for the course is to write a compiler

### Computer Science Department Carlos III University of Madrid Leganés (Spain) David Griol Barres

Computer Science Department Carlos III University of Madrid Leganés (Spain) David Griol Barres dgriol@inf.uc3m.es Introduction He am a driver might be syntactically correct but semantically wrong. Semantic

### MIDTERM EXAMINATION - CS130 - Spring 2003

MIDTERM EXAMINATION - CS130 - Spring 2003 Your full name: Your UCSD ID number: This exam is closed book and closed notes Total number of points in this exam: 120 + 10 extra credit This exam counts for

### Chapter 5 Names, Bindings, Type Checking, and Scopes

Chapter 5 Names, Bindings, Type Checking, and Scopes 長庚大學資訊工程學系 陳仁暉 助理教授 Tel: (03) 211-8800 Ext: 5990 E-mail: jhchen@mail.cgu.edu.tw URL: http://www.csie.cgu.edu.tw/jhchen All rights reserved. No part

### Faculty 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

### Question Marks 1 /11 2 /4 3 /13 4 /5 5 /11 6 /14 7 /32 8 /6 9 /11 10 /10 Total /117

CSC 326, Midterm November 3, 2005 Name: Student ID: Signature: You have 75 minutes to write the 10 questions on this examination. A total of 117 marks is available. Justify all of your answers You may

### Semantic Analysis and Type Checking

Semantic Analysis and Type Checking The compilation process is driven by the syntactic structure of the program as discovered by the parser Semantic routines: interpret meaning of the program based on

### KEY. 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

### Course Text. Course Description. Course Objectives. StraighterLine Introduction to Programming in C++

Introduction to Programming in C++ Course Text Programming in C++, Zyante, Fall 2013 edition. Course book provided along with the course. Course Description This course introduces programming in C++ and

### afewadminnotes CSC324 Formal Language Theory Dealing with Ambiguity: Precedence Example Office Hours: (in BA 4237) Monday 3 4pm Wednesdays 1 2pm

afewadminnotes CSC324 Formal Language Theory Afsaneh Fazly 1 Office Hours: (in BA 4237) Monday 3 4pm Wednesdays 1 2pm January 16, 2013 There will be a lecture Friday January 18, 2013 @2pm. 1 Thanks to

### Short Notes of CS201

#includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system

### CSCI Compiler Design

CSCI 565 - Compiler Design Spring 2015 Midterm Exam March 04, 2015 at 8:00 AM in class (RTH 217) Duration: 2h 30 min. Please label all pages you turn in with your name and student number. Name: Number:

### CS 3360 Design and Implementation of Programming Languages. Exam 1

1 Spring 2017 (Thursday, March 9) Name: CS 3360 Design and Implementation of Programming Languages Exam 1 This test has 8 questions and pages numbered 1 through 7. Reminders This test is closed-notes and

### Formal Languages and Compilers Lecture I: Introduction to Compilers

Formal Languages and Compilers Lecture I: Introduction to Compilers Free University of Bozen-Bolzano Faculty of Computer Science POS Building, Room: 2.03 artale@inf.unibz.it http://www.inf.unibz.it/ artale/

### Building Compilers with Phoenix

Building Compilers with Phoenix Syntax-Directed Translation Structure of a Compiler Character Stream Intermediate Representation Lexical Analyzer Machine-Independent Optimizer token stream Intermediate

### Chapter 3: CONTEXT-FREE GRAMMARS AND PARSING Part2 3.3 Parse Trees and Abstract Syntax Trees

Chapter 3: CONTEXT-FREE GRAMMARS AND PARSING Part2 3.3 Parse Trees and Abstract Syntax Trees 3.3.1 Parse trees 1. Derivation V.S. Structure Derivations do not uniquely represent the structure of the strings

### Lexical Considerations

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Fall 2005 Handout 6 Decaf Language Wednesday, September 7 The project for the course is to write a

### ! Those values must be stored somewhere! Therefore, variables must somehow be bound. ! How?

A Binding Question! Variables are bound (dynamically) to values Subprogram Activation! Those values must be stored somewhere! Therefore, variables must somehow be bound to memory locations! How? Function

### CS201 - Introduction to Programming Glossary By

CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with

### Principles of Programming Languages. Lecture Outline

Principles of Programming Languages CS 492 Lecture 1 Based on Notes by William Albritton 1 Lecture Outline Reasons for studying concepts of programming languages Programming domains Language evaluation

### COP4020 Spring 2011 Midterm Exam

COP4020 Spring 2011 Midterm Exam Name: (Please print Put the answers on these sheets. Use additional sheets when necessary or write on the back. Show how you derived your answer (this is required for full

### Absolute C++ Walter Savitch

Absolute C++ sixth edition Walter Savitch Global edition This page intentionally left blank Absolute C++, Global Edition Cover Title Page Copyright Page Preface Acknowledgments Brief Contents Contents

### Syntax Intro and Overview. Syntax

Syntax Intro and Overview CS331 Syntax Syntax defines what is grammatically valid in a programming language Set of grammatical rules E.g. in English, a sentence cannot begin with a period Must be formal

### Outline. Java Models for variables Types and type checking, type safety Interpretation vs. compilation. Reasoning about code. CSCI 2600 Spring

Java Outline Java Models for variables Types and type checking, type safety Interpretation vs. compilation Reasoning about code CSCI 2600 Spring 2017 2 Java Java is a successor to a number of languages,

### CSE 307: Principles of Programming Languages

CSE 307: Principles of Programming Languages Variables and Constants R. Sekar 1 / 22 Topics 2 / 22 Variables and Constants Variables are stored in memory, whereas constants need not be. Value of variables

### Question No: 1 ( Marks: 1 ) - Please choose one One difference LISP and PROLOG is. AI Puzzle Game All f the given

MUHAMMAD FAISAL MIT 4 th Semester Al-Barq Campus (VGJW01) Gujranwala faisalgrw123@gmail.com MEGA File Solved MCQ s For Final TERM EXAMS CS508- Modern Programming Languages Question No: 1 ( Marks: 1 ) -

### Lecture 4: Syntax Specification

The University of North Carolina at Chapel Hill Spring 2002 Lecture 4: Syntax Specification Jan 16 1 Phases of Compilation 2 1 Syntax Analysis Syntax: Webster s definition: 1 a : the way in which linguistic

### The Structure of a Syntax-Directed Compiler

Source Program (Character Stream) Scanner Tokens Parser Abstract Syntax Tree (AST) Type Checker Decorated AST Translator Intermediate Representation Symbol Tables Optimizer (IR) IR Code Generator Target

### Chapter 5 Names, Bindings, Type Checking, and Scopes

Chapter 5 Names, Bindings, Type Checking, and Scopes Names Variables The Concept of Binding Scope and Lifetime Type Checking Referencing Environments Named Constants Names Used for variables, subprograms

### Chapter 3:: Names, Scopes, and Bindings (cont.)

Chapter 3:: Names, Scopes, and Bindings (cont.) Programming Language Pragmatics Michael L. Scott Review What is a regular expression? What is a context-free grammar? What is BNF? What is a derivation?