CS 340, Fall 2014 Dec 11 th /13 th Final Exam Note: in all questions, the special symbol ɛ (epsilon) is used to indicate the empty string.

Similar documents
CS 340, Fall 2016 Sep 29th Exam 1 Note: in all questions, the special symbol ɛ (epsilon) is used to indicate the empty string.

CS 430 Spring Mike Lam, Professor. Parsing

Definition of Regular Expression

Fig.25: the Role of LEX

Topic 2: Lexing and Flexing

CS 432 Fall Mike Lam, Professor a (bc)* Regular Expressions and Finite Automata

Finite Automata. Lecture 4 Sections Robb T. Koether. Hampden-Sydney College. Wed, Jan 21, 2015

CSCE 531, Spring 2017, Midterm Exam Answer Key

CMPSC 470: Compiler Construction

Compilers Spring 2013 PRACTICE Midterm Exam

CS321 Languages and Compiler Design I. Winter 2012 Lecture 5

Deterministic. Finite Automata. And Regular Languages. Fall 2018 Costas Busch - RPI 1

CS412/413. Introduction to Compilers Tim Teitelbaum. Lecture 4: Lexical Analyzers 28 Jan 08

In the last lecture, we discussed how valid tokens may be specified by regular expressions.

ECE 468/573 Midterm 1 September 28, 2012

ASTs, Regex, Parsing, and Pretty Printing

Lexical Analysis: Constructing a Scanner from Regular Expressions

Dr. D.M. Akbar Hussain

ΕΠΛ323 - Θεωρία και Πρακτική Μεταγλωττιστών

CSE 401 Midterm Exam 11/5/10 Sample Solution

Lexical Analysis. Amitabha Sanyal. ( as) Department of Computer Science and Engineering, Indian Institute of Technology, Bombay

LR Parsing, Part 2. Constructing Parse Tables. Need to Automatically Construct LR Parse Tables: Action and GOTO Table

CSCI 3130: Formal Languages and Automata Theory Lecture 12 The Chinese University of Hong Kong, Fall 2011

CMSC 331 First Midterm Exam

this grammar generates the following language: Because this symbol will also be used in a later step, it receives the

Midterm I Solutions CS164, Spring 2006

Lexical analysis, scanners. Construction of a scanner

Operator Precedence. Java CUP. E E + T T T * P P P id id id. Does a+b*c mean (a+b)*c or

CS143 Handout 07 Summer 2011 June 24 th, 2011 Written Set 1: Lexical Analysis

Context-Free Grammars

Java CUP. Java CUP Specifications. User Code Additions. Package and Import Specifications

Sample Midterm Solutions COMS W4115 Programming Languages and Translators Monday, October 12, 2009

COMP 423 lecture 11 Jan. 28, 2008

CSc 453. Compilers and Systems Software. 4 : Lexical Analysis II. Department of Computer Science University of Arizona

TO REGULAR EXPRESSIONS

Languages. L((a (b)(c))*) = { ε,a,bc,aa,abc,bca,... } εw = wε = w. εabba = abbaε = abba. (a (b)(c)) *

Principles of Programming Languages

CS 321 Programming Languages and Compilers. Bottom Up Parsing

ΕΠΛ323 - Θεωρία και Πρακτική Μεταγλωττιστών. Lecture 3b Lexical Analysis Elias Athanasopoulos

Reducing a DFA to a Minimal DFA

Implementing Automata. CSc 453. Compilers and Systems Software. 4 : Lexical Analysis II. Department of Computer Science University of Arizona

Homework. Context Free Languages III. Languages. Plan for today. Context Free Languages. CFLs and Regular Languages. Homework #5 (due 10/22)

CS 241. Fall 2017 Midterm Review Solutions. October 24, Bits and Bytes 1. 3 MIPS Assembler 6. 4 Regular Languages 7.

12 <= rm <digit> 2 <= rm <no> 2 <= rm <no> <digit> <= rm <no> <= rm <number>

acronyms possibly used in this test: CFG :acontext free grammar CFSM :acharacteristic finite state machine DFA :adeterministic finite automata

LING/C SC/PSYC 438/538. Lecture 21 Sandiway Fong

CS 241 Week 4 Tutorial Solutions

Should be done. Do Soon. Structure of a Typical Compiler. Plan for Today. Lab hours and Office hours. Quiz 1 is due tonight, was posted Tuesday night

Scanner Termination. Multi Character Lookahead. to its physical end. Most parsers require an end of file token. Lex and Jlex automatically create an

Context-Free Grammars

Lexical Analysis and Lexical Analyzer Generators

CS201 Discussion 10 DRAWTREE + TRIES

10/12/17. Motivating Example. Lexical and Syntax Analysis (2) Recursive-Descent Parsing. Recursive-Descent Parsing. Recursive-Descent Parsing

Eliminating left recursion grammar transformation. The transformed expression grammar

Assignment 4. Due 09/18/17

UNIVERSITY OF EDINBURGH COLLEGE OF SCIENCE AND ENGINEERING SCHOOL OF INFORMATICS INFORMATICS 1 COMPUTATION & LOGIC INSTRUCTIONS TO CANDIDATES

Problem Set 2 Fall 16 Due: Wednesday, September 21th, in class, before class begins.

Theory of Computation CSE 105

CMPT 379 Compilers. Lexical Analysis

Some Thoughts on Grad School. Undergraduate Compilers Review and Intro to MJC. Structure of a Typical Compiler. Lexing and Parsing

Regular Expression Matching with Multi-Strings and Intervals. Philip Bille Mikkel Thorup

Tries. Yufei Tao KAIST. April 9, Y. Tao, April 9, 2013 Tries

Quiz2 45mins. Personal Number: Problem 1. (20pts) Here is an Table of Perl Regular Ex

Regular Expressions and Automata using Miranda

LEX5: Regexps to NFA. Lexical Analysis. CMPT 379: Compilers Instructor: Anoop Sarkar. anoopsarkar.github.io/compilers-class

Scanner Termination. Multi Character Lookahead

Suffix trees, suffix arrays, BWT

Example: Source Code. Lexical Analysis. The Lexical Structure. Tokens. What do we really care here? A Sample Toy Program:

Top-down vs Bottom-up. Bottom up parsing. Sentential form. Handles. Handles in expression example

Applied Databases. Sebastian Maneth. Lecture 13 Online Pattern Matching on Strings. University of Edinburgh - February 29th, 2016

stack of states and grammar symbols Stack-Bottom marker C. Kessler, IDA, Linköpings universitet. 1. <list> -> <list>, <element> 2.

CS 236 Language and Computation. Alphabet. Definition. I.2.1. Formal Languages (10.1)

Fall 2018 Midterm 1 October 11, ˆ You may not ask questions about the exam except for language clarifications.

Compiler Construction D7011E

Validation of XML Document Updates based on XML Schema in XML Databases * Sang-Kyun Kim 1, Myungcheol Lee 2 and Kyu-Chul Lee 1

Compilation

Welch Allyn CardioPerfect Workstation Installation Guide

Fall Compiler Principles Lecture 1: Lexical Analysis. Roman Manevich Ben-Gurion University

2014 Haskell January Test Regular Expressions and Finite Automata

Information Retrieval and Organisation

Suffix Tries. Slides adapted from the course by Ben Langmead

CS481: Bioinformatics Algorithms

Lab 1 - Counter. Create a project. Add files to the project. Compile design files. Run simulation. Debug results

Fall Compiler Principles Lecture 1: Lexical Analysis. Roman Manevich Ben-Gurion University of the Negev

Recognition of Tokens

LINX MATRIX SWITCHERS FIRMWARE UPDATE INSTRUCTIONS FIRMWARE VERSION

Discussion 1 Recap. COP4600 Discussion 2 OS concepts, System call, and Assignment 1. Questions. Questions. Outline. Outline 10/24/2010

If you are at the university, either physically or via the VPN, you can download the chapters of this book as PDFs.

box Boxes and Arrows 3 true 7.59 'X' An object is drawn as a box that contains its data members, for example:

From Dependencies to Evaluation Strategies

CIS 1068 Program Design and Abstraction Spring2015 Midterm Exam 1. Name SOLUTION

Mid-term exam. Scores. Fall term 2012 KAIST EE209 Programming Structures for EE. Thursday Oct 25, Student's name: Student ID:

Physics 208: Electricity and Magnetism Exam 1, Secs Feb IMPORTANT. Read these directions carefully:

NOTES. Figure 1 illustrates typical hardware component connections required when using the JCM ICB Asset Ticket Generator software application.

Lists in Lisp and Scheme

Lecture T4: Pattern Matching

Registering as an HPE Reseller

Midterm 2 Sample solution

Distributed Systems Principles and Paradigms

COS 333: Advanced Programming Techniques

Transcription:

CS 340, Fll 2014 Dec 11 th /13 th Finl Exm Nme: Note: in ll questions, the specil symol ɛ (epsilon) is used to indicte the empty string. Question 1. [5 points] Consider the following regulr expression; ( c)* For ech of the strings elow, circle it if it is in the lnguge generted y the regulr expression, nd cross it out if it is not in the lnguge generted y the regulr expression. c c c c c Question 2. [5 points] Specify regulr expression tht genertes the lnguge over the lphet {,, c} of ll strings not contining the sustring c. Exmples of strings in the lnguge: c c c Exmples of strings not in the lnguge: c c cc c c

Question 3. [5 points] Consider the following nondeterministic finite utomton (NFA): q2 q1 c q0 q4 q5 q3 For ech of the strings elow, circle it if it is in the lnguge ccepted y the NFA, nd cross it out if it isn t. c c cc cc c c c c Question 4. [10 points] Specify deterministic finite utomton (DFA) tht genertes the lnguge over the lphet {,, c} of ll strings not contining the sustring c. (See Question 2 for lists of exmple strings in the lnguge nd not in the lnguge.) In your DFA, e sure to indicte strt stte nd one or more finl sttes, nd mke sure ech trnsition specifies direction nd single input symol consumed.

Question 5. [5 points] Consider the following context-free grmmr (CFG), where P is the strt symol: P pp P qp P r For ech of the strings on the right, circle the string if is in the lnguge generted y the CFG, nd cross it out if it isn t. p q r ppr qqr prr pqrr pqqp pqqpr qq Question 6. [10 points] Specify context-free grmmr (CFG) which genertes the lnguge of ll ALists. An AList hs the following properties: It is sequence of terminl symols chosen from ( ), It egins with ( nd ends with ) It contins (etween the prentheses) comm-seprted list of 0 or more AListMemers An AListMemer is either the terminl symol or n AList. Exmples of strings in the lnguge Exmples of strings not in the lnguge: () () (, ) ((, (, (), )), ) ɛ, () ( (, )) Be sure to indicte which nonterminl symol in your grmmr is the strt symol.

Question 7. [10 points] Consider the following context-free grmmr with strt symol A, nonterminl symols A E F V N nd terminl symols ( ) λ. 1 2 A E E A E F V N F ( λ V. E ) V N 1 2 Assume tht you re writing recursive descent prser for this grmmr. Assume you hve lexer supporting peek(), next(), nd expect() opertions. (You cn ssume tht the lexer opertions re stteful, i.e., you don t hve to ssume tht you re using functionl lnguge.) Use pseudo-code to show how the following prse functions would e implemented. You don t hve to uild the prse tree, ut do show ll lexer opertions nd clls to prse functions. Hint: for prsee, think out how to use the lexer to decide whether tokens mtching n occurrence of the F, V, or N nonterminl is out to egin. () prsee() { () prsea() {

Progrmming Questions First things first: the following we pge specifies which resources you my use during the exm, nd links to the permitted resources: http://ycpcs.githu.io/cs340-fll2014/ssign/finl.html Strt y downloding the exm zipfile using the commnd wget zipfileurl where zipfileurl is the URL of the exm zipfile. Import the zipfile s n Eclipse project. You should see project clled cs340-finl. You will e editing the file src/cs340 finl/core.clj. There re four functions to implement: doule-it, doule-them, count-ll-nested, nd vec->tower. Mke sure you meet ll of the requirements of ech function: e.g., if the function is required to e til recursive, mke sure your function is til recursive. Some generl hints: (empty? s) tests whether sequence s is empty (first s) gets the first element in sequence s (second s) gets the second element in sequence s (lst s) gets the lst element in sequence s (rest s) gets sequence with ll ut the first element of sequence s [] is n empty vector (conj v elt) cretes vector which results from ppending elt onto the vector v (conj v elt1 elt2) returns vector which results from ppending elt1 nd elt2 onto the vector v (suvec v i j) returns vector with of the elements of vector v from index i (inclusive) to index j (exclusive) You cn run the commnd lein test in terminl window to run unit tests. When you re done, sumit your code using the lue up rrow icon (Sumit project) in Eclipse, or run the commnd mke sumit. Type your Mrmoset usernme nd pssword when prompted. Hve fun!