FS22k Transducer User Manual
|
|
- Cornelius Perry
- 5 years ago
- Views:
Transcription
1 FS22k Transducer User Manual Rebecca Nesson September 1, Meta-Notation Below, we use BNF notation to define the syntax of the rewriting system. In the BNF metanotation, all terminals are given in a computery font, like this. Vertical bars specify alternatives. An ellipsis following two constituents specifies zero or more occurrences of the first separated by occurrences of the second. For instance, the BNF rule: <list> ::= <string>,... would specify a comma-separated list of strings. 2 Specifying Patterns Tree variables. Patterns can be specified with tree variables: <pattern> ::= <tree-variable> = <tree-pattern> ( <pattern-children> ) <tree-variable> ::= <ident> <tree-pattern> ::= <label> <label> - <index> - <index> <label> ::= <ident> <index> ::= <ident> <ident> ::= Any sequence of alphabetic and numeric characters and hyphen. An ident can contain at most one hyphen Examples of identifiers: Exchange Chip-give Chip-1 east -chips Tree patterns are matched to input trees. If a tree pattern matches a particular input tree, then that tree is bound to the tree-variable that appears on the left-hand side of the equals sign. 1
2 Tree patterns with no <label> (such as - and -chips) match any tree. Variables starting with a <label> match any tree whose root node is labeled with the given symbol. Thus the variable - matches any tree and the variable Chip-give matches any trees whose root node is labeled with Chip. Upon matching, the tree variable becomes bound to the matched tree. That tree variable can then be used to refer to that tree in the result portion of a rule. No tree variable may occur more than once in a given pattern. The intended use for indices is to allow specification of (and later reference to) multiple variables that match trees with the same root label. Examples of patterns (omitting the details of children): x = Exchange() give = Chip-give() y = -() Pattern Children We ll now fill in the grammar for specifying the children of a node: <pattern-children> ::= ɛ <pattern>, <pattern-children> Note that because the pattern children are patterns themselves, they must also be complete patterns with bindings to tree variables. Examples of complete patterns: x = Exchange(give = -givechips, obtain = -obtainchips) Exchange = Exchange(a = chip-a, b = chip-b) y = Chip(q = quantity, c = color) The first example matches a tree with a root node labeled Exchange and two children, which can be anything. x will be bound to the whole tree while give and obtain will be bound to the left and right subtrees, respectively. The second example is similar except that the two children must each be rooted in nodes that are labeled with chip. The third example matches a tree whose root node is labeled Chip and whose children are labeled quantity and color respectively. Tree Sequences. To allow for matching against an indeterminate number of children, a variable matching a sequence of children is allowed at the end of the list of pattern children: <pattern-children> ::= <tree-variable> = can match against zero or more children. Note that it can only appear at the end of a list of pattern children, not instead of a tree. Example: and = And(chip = Chip, rest =...) This pattern matches a node with root labeled And, a leftmost child labeled Chip, and then one 2
3 or more additional children that can be labeled anything. The sequence of children comprising all but the leftmost one is bound to the tree variable rest. Note the difference between the following two patterns: c = Chip(rest =...) c = Chip() The first pattern will match against any tree with Chip at the root it need not have more than one child. The third pattern will match only against a leaf labeled Chip with no children. 3 Pattern Shorthands One can already see that specifying patterns in this notation can be quite cumbersome. First, one must always specify the children of a node, whether or not they are relevant to the rewrite. Second, it requires each tree pattern to be explicitly associated with a tree variable. To alleviate this problem, we define shorthands for specifying the most common types of patterns. Thus, the following pre-processing transformations are applied in order to generate the pattern expected by the grammar: Transformation 1: Omission of children The children may be omitted from any tree. When children are omitted from a particular tree, it is assumed that a properly labeled node with any number of children will match the pattern in question. <tree-pattern> ( <pattern-children> ) <tree-pattern> ( <pattern-children> ) <tree-pattern> <tree-pattern> (+ =...) + is used as the variable name for the..., but it is special because it cannot be used to refer to the generated... on the right-hand side of the rule. If a... is generated by Transformation 1, it can never be referred to on the right-hand side of the rule. Examples of shorthand leading to application of Transformation 1: x = exchange(c1 = chip-1(k1 =...), c2 = chip-2(k2 =...)) x = exchange(c1 = chip-1, c2 = chip-2) Note that these two rules specify quite similar patterns because when Transformation 1 is applied, to the second example it will generate: x = exchange(c1 = chip-1(+ =...), c1 = chip-2(+ =...)) The only difference between the first example and the resulting rule when Transformation 1 is 3
4 applied to the second example is that the children of the chip nodes cannot be referenced in the right-hand side of the rule generated by example 2. Transformation 2: Omission of tree variables The tree variable and accompanying equal sign can be left out of any pattern. When this occurs, it is interpreted as shorthand and a corresponding tree variable is generated for the tree pattern in question. <tree-variable> = <tree-pattern> <tree-variable> = <tree-pattern> <tree-pattern> <tree-pattern> = <tree-pattern> <tree-variable> =... <tree-variable> = * =... Examples of the application of Transformation 2: exchange(chip-1(), chip-2()) request(chip(...-1),...) request(chip(+ =...),...) In the first example, applying Transformation 2 will yield: exchange = exchange(chip-1 = chip-1(), chip-2 = chip2()) In the second example, applying Trasnformation 2 will yield: request = request(chip = chip(*-1 =...-1), * =...) Note that in the second example, the user is given distinct ways to refer to the different sequence variables present in the pattern. In the third example, we see a rule that has already undergone Transformation 1, which added the children to chip. When Transformation 2 is applied, it generates: request = request(chip = chip(+ =...), * =...) Because the + refers to a generated sequence variable, it is as if no binding were created for it. 4 Specifying Results Given a set of bindings resulting from matching an input tree to a pattern, the following notations allow the user to specify the tree that results from applying the rule. In the examples below, we assume that the following bindings are in force: Exchange Exchange(Chip(1,blue), Chip(2,green)) 4
5 -givechips -obtainchips Chip(1,blue) Chip(2,green) Generation of New Structure. The simplest way to form a result is to generate new tree structure without reference to the bindings created in the pattern match. This alone is not particularly useful, but when combined with use of references can be important. <result> ::= <ident> <ident> ( <result-children> ) Examples of new structure in results: a(b(), c()) => x(y); b(c) => c; Note that children may be omitted in results and there are no tree variables at all. In the second example, the result will be the single letter c, not the piece of the input tree that the tree variable c is bound to. In order to refer to the tree variable c, the result needs to use an explicit symbol to indicate that the value of c should be looked up. Tree References. Results can be specified with reference to tree variables that were bound by the corresponding pattern part of the rewrite rule by appending a special lookup symbol, $: <result> ::= <tree-variable>$ A tree variable reference specifies that the output should be whatever tree is bound to the referenced variable. In addition, the rule may specify that the tree variable should be looked up, and the input tree it is bound to should be rewritten again. This is specified with the special symbol : <result> ::= <tree-variable> Finally, it is possible to look up a tree using a tree variable and then apply a cut to it to remove everything but the root. The cut is specified with the special symbol \: <result> ::= <tree-variable>\ Examples of tree references in results: a(b, c) => x(c$, b$); a(b, c) => x(c, b ); a(b, c) => x(a\, b$, c$); In the first example, the result will be a new tree, rooted in x rather than a, and with the two children switched in position. Rather than just the letters c and b, the bound pieces of the input trees will appear in the result. The second example is similar except that before placing the bound pieces of the input trees into the result, they will be rewritten again themselves. This means that they will be matched to a rule (which may be a different rule) and rewritten into a new result. 5
6 Finally, in the third example, the input tree bound to a will have all its children cut off and the root node will become the first child of the new tree. Trees. Combinations of new structure and tree references can be used to build new trees within the results: <result> ::= <tree-variable>\( <result-children> ) <result-children> ::= ɛ <result>, <result-children> Note that if tree variables appear at the root of a result tree, they must be cut. They cannot be looked up without being cut. They also cannot be rewritten (though this may be changed in future implementations.) Sequence variables Sequence variables (...) are a slightly special case. When they are explicitly given a tree variable in a pattern (ex. rest =...), they should be referenced with those tree variables. When tree variables are generated for them by Transformation 2, they should be referred to not with the generated *, but with the sequence variable itself:... This makes the rules much more human readable, though it seems a bit confusing here. When sequence variables are indexed, they should be referred to by the sequence variable and index combination. When a sequence variable is generated by Transformation 1, it cannot be referenced on the right-hand side of the rule. Examples of sequence variables in rules: a(rest =...) => b(rest$); a(...) => b(...$); a(...) => b(*); NOT LEGAL! a(...-2) => b(...-2); a => b(...$); NOT LEGAL! 5 Specifying Rewrite Rules Given the languages for pattern and results, the following notation allows specification of rewrite rules: <rule> ::= <pattern> => <result> ; Examples: We ve seen examples of simple rules already. The following two rules are commonly useful, slightly odd rules that do a good job of exercising the capabilities of the system: - => -$; 6
7 -(...) => -\(... ); The first rule here matches to anything and then leaves it unchanged on the other side. This can be useful for allowing things not affected by a particular set of rules to remain unchanged. The second rule also matches to anything, leaves the root unchanged, and rewrites the children. This can be useful for traversing a tree rewriting everything that matches a particular rule. These two rules demonstrate the application of both Transformations, the rules on bindings, look ups, cuts, rewrites, and references to sequence variables. 6 Specifying Systems of Rules It is very often useful to divide up the rewriting of a tree into different phases. The rewriting system makes this possible by allowing the specification of different passes of rules. Each pass is applied in ascending numerical order. All possible rewriting is done with the given pass before proceeding to the next pass. In addition, all rewriting caused by the affixing of a to a particular symbol takes place in the same pass as the rule in which the symbol appears. Passes are specified as follows: <rule> ::= <pass> <pattern> => <result> ; <pass> ; <pass> ::= ( <natural-number> ) <natural-number> ::= any whole number greater than or equal to 0 A pass may appear on the same line as a rule at the beginning of the line, or it may appear on a line by itself. A rule belongs to the pass that appears on the same line. Note, however, that a rule may appear without a pass. If no pass appears on the same line, a rule belongs to the nearest pass appearing above it. Every rule must belong to a pass. Applying a system of rules to a tree works as follows: In the lowest numbered pass, the textually first rule whose pattern matches is applied. Its result is generated and returned as the rewritten form of the input tree. If no rules match, the pass fails and no rewritten version is generated. When the pass is complete, the next pass in ascending order is applied. Note that it is also possible to specify that a single pass be used or to specify an alternate order in which to apply passes, but the default is to apply them all in order from the lowest to the highest. 7
8 7 The Complete Grammar <rule> ::= <pass> <pattern> => <result> ; <pattern> => <result> ; <pass> ; <pass> ::= ( <natural-number> ) <pattern> ::= <tree-variable> = <tree-pattern> ( <pattern-children> ) <tree-variable> ::= <ident> <tree-pattern> ::= <label> <label> - <index> - <index> <pattern-children> ::= <tree-variable> =... <result> ::= <ident> <tree-variable>$ <tree-variable> <tree-variable>\ <ident> ( <result-children> ) <tree-variable>\( <result-children> ) <result-children> ::= ɛ <result>, <result-children> <label> ::= <ident> <index> ::= <ident> <ident> ::= Any sequence of alphabetic and numeric characters and hyphen. An ident can contain at most one hyphen <natural-number> ::= any whole number greater than or equal to 0 8
CSE 12 Abstract Syntax Trees
CSE 12 Abstract Syntax Trees Compilers and Interpreters Parse Trees and Abstract Syntax Trees (AST's) Creating and Evaluating AST's The Table ADT and Symbol Tables 16 Using Algorithms and Data Structures
More informationComputer Science 210 Data Structures Siena College Fall Topic Notes: Priority Queues and Heaps
Computer Science 0 Data Structures Siena College Fall 08 Topic Notes: Priority Queues and Heaps Heaps and Priority Queues From here, we will look at some ways that trees are used in other structures. First,
More informationCMSC 330: Organization of Programming Languages
CMSC 330: Organization of Programming Languages Context Free Grammars and Parsing 1 Recall: Architecture of Compilers, Interpreters Source Parser Static Analyzer Intermediate Representation Front End Back
More informationCMSC 330: Organization of Programming Languages. Architecture of Compilers, Interpreters
: Organization of Programming Languages Context Free Grammars 1 Architecture of Compilers, Interpreters Source Scanner Parser Static Analyzer Intermediate Representation Front End Back End Compiler / Interpreter
More informationMore Assigned Reading and Exercises on Syntax (for Exam 2)
More Assigned Reading and Exercises on Syntax (for Exam 2) 1. Read sections 2.3 (Lexical Syntax) and 2.4 (Context-Free Grammars) on pp. 33 41 of Sethi. 2. Read section 2.6 (Variants of Grammars) on pp.
More informationProgramming Languages Third Edition
Programming Languages Third Edition Chapter 12 Formal Semantics Objectives Become familiar with a sample small language for the purpose of semantic specification Understand operational semantics Understand
More informationArchitecture of Compilers, Interpreters. CMSC 330: Organization of Programming Languages. Front End Scanner and Parser. Implementing the Front End
Architecture of Compilers, Interpreters : Organization of Programming Languages ource Analyzer Optimizer Code Generator Context Free Grammars Intermediate Representation Front End Back End Compiler / Interpreter
More informationStatistics Case Study 2000 M. J. Clancy and M. C. Linn
Statistics Case Study 2000 M. J. Clancy and M. C. Linn Problem Write and test functions to compute the following statistics for a nonempty list of numeric values: The mean, or average value, is computed
More informationChapter 1. Math review. 1.1 Some sets
Chapter 1 Math review This book assumes that you understood precalculus when you took it. So you used to know how to do things like factoring polynomials, solving high school geometry problems, using trigonometric
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 informationA language is a subset of the set of all strings over some alphabet. string: a sequence of symbols alphabet: a set of symbols
The current topic:! Introduction! Object-oriented programming: Python! Functional programming: Scheme! Python GUI programming (Tkinter)! Types and values! Logic programming: Prolog! Introduction! Rules,
More informationWhere We Are. CMSC 330: Organization of Programming Languages. This Lecture. Programming Languages. Motivation for Grammars
CMSC 330: Organization of Programming Languages Context Free Grammars Where We Are Programming languages Ruby OCaml Implementing programming languages Scanner Uses regular expressions Finite automata Parser
More information2.2 Syntax Definition
42 CHAPTER 2. A SIMPLE SYNTAX-DIRECTED TRANSLATOR sequence of "three-address" instructions; a more complete example appears in Fig. 2.2. This form of intermediate code takes its name from instructions
More informationRichard Feynman, Lectures on Computation
Chapter 8 Sorting and Sequencing If you keep proving stuff that others have done, getting confidence, increasing the complexities of your solutions for the fun of it then one day you ll turn around and
More informationPrinciples of Programming Languages COMP251: Syntax and Grammars
Principles of Programming Languages COMP251: Syntax and Grammars Prof. Dekai Wu Department of Computer Science and Engineering The Hong Kong University of Science and Technology Hong Kong, China Fall 2006
More informationProgramming Lecture 3
Programming Lecture 3 Expressions (Chapter 3) Primitive types Aside: Context Free Grammars Constants, variables Identifiers Variable declarations Arithmetic expressions Operator precedence Assignment statements
More informationSigned umbers. Sign/Magnitude otation
Signed umbers So far we have discussed unsigned number representations. In particular, we have looked at the binary number system and shorthand methods in representing binary codes. With m binary digits,
More informationCMSC 330: Organization of Programming Languages
CMSC 330: Organization of Programming Languages Context Free Grammars 1 Architecture of Compilers, Interpreters Source Analyzer Optimizer Code Generator Abstract Syntax Tree Front End Back End Compiler
More informationTheoretical Part. Chapter one:- - What are the Phases of compiler? Answer:
Theoretical Part Chapter one:- - What are the Phases of compiler? Six phases Scanner Parser Semantic Analyzer Source code optimizer Code generator Target Code Optimizer Three auxiliary components Literal
More informationCMSC 330: Organization of Programming Languages. Context Free Grammars
CMSC 330: Organization of Programming Languages Context Free Grammars 1 Architecture of Compilers, Interpreters Source Analyzer Optimizer Code Generator Abstract Syntax Tree Front End Back End Compiler
More informationTree Structures. A hierarchical data structure whose point of entry is the root node
Binary Trees 1 Tree Structures A tree is A hierarchical data structure whose point of entry is the root node This structure can be partitioned into disjoint subsets These subsets are themselves trees and
More information6. Finding Efficient Compressions; Huffman and Hu-Tucker
6. Finding Efficient Compressions; Huffman and Hu-Tucker We now address the question: how do we find a code that uses the frequency information about k length patterns efficiently to shorten our message?
More informationVLOOKUP() takes three mandatory parameters and one default/optional parameter:
Excel Lesson: Table Lookup Functions Topics Covered: VLookup() [Look across] HLookup() [Look down] Lookup() [Look almost anywhere] Related Functions (a list) We will not be examining all forms of these
More informationCSCI312 Principles of Programming Languages!
CSCI312 Principles of Programming Languages! Chapter 2 Syntax! Xu Liu Review! Principles of PL syntax, naming, types, semantics Paradigms of PL design imperative, OO, functional, logic What makes a successful
More informationTree Parsing. $Revision: 1.4 $
Tree Parsing $Revision: 1.4 $ Compiler Tools Group Department of Electrical and Computer Engineering University of Colorado Boulder, CO, USA 80309-0425 i Table of Contents 1 The Tree To Be Parsed.........................
More informationShorthand for values: variables
Chapter 2 Shorthand for values: variables 2.1 Defining a variable You ve typed a lot of expressions into the computer involving pictures, but every time you need a different picture, you ve needed to find
More informationMA513: Formal Languages and Automata Theory Topic: Context-free Grammars (CFG) Lecture Number 18 Date: September 12, 2011
MA53: Formal Languages and Automata Theory Topic: Context-free Grammars (CFG) Lecture Number 8 Date: September 2, 20 xercise: Define a context-free grammar that represents (a simplification of) expressions
More informationPrinciples of Programming Languages COMP251: Syntax and Grammars
Principles of Programming Languages COMP251: Syntax and Grammars Prof. Dekai Wu Department of Computer Science and Engineering The Hong Kong University of Science and Technology Hong Kong, China Fall 2007
More informationCMSC 330: Organization of Programming Languages
CMSC 330: Organization of Programming Languages Context Free Grammars 1 Architecture of Compilers, Interpreters Source Analyzer Optimizer Code Generator Abstract Syntax Tree Front End Back End Compiler
More informationEvaluation of Predicate Calculus By Arve Meisingset, retired research scientist from Telenor Research Oslo Norway
Evaluation of Predicate Calculus By Arve Meisingset, retired research scientist from Telenor Research 31.05.2017 Oslo Norway Predicate Calculus is a calculus on the truth-values of predicates. This usage
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 informationThe syntax and semantics of Beginning Student
The syntax and semantics of Beginning Student Readings: HtDP, Intermezzo 1 (Section 8). We are covering the ideas of section 8, but not the parts of it dealing with section 6/7 material (which will come
More informationThe syntax and semantics of Beginning Student
The syntax and semantics of Beginning Student Readings: HtDP, Intermezzo 1 (Section 8). We are covering the ideas of section 8, but not the parts of it dealing with section 6/7 material (which will come
More informationOptimizing Finite Automata
Optimizing Finite Automata We can improve the DFA created by MakeDeterministic. Sometimes a DFA will have more states than necessary. For every DFA there is a unique smallest equivalent DFA (fewest states
More informationCOP 3402 Systems Software Top Down Parsing (Recursive Descent)
COP 3402 Systems Software Top Down Parsing (Recursive Descent) Top Down Parsing 1 Outline 1. Top down parsing and LL(k) parsing 2. Recursive descent parsing 3. Example of recursive descent parsing of arithmetic
More informationOutline. Parser overview Context-free grammars (CFG s) Derivations Syntax-Directed Translation
Outline Introduction to Parsing (adapted from CS 164 at Berkeley) Parser overview Context-free grammars (CFG s) Derivations Syntax-Directed ranslation he Functionality of the Parser Input: sequence of
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 informationCPSC 427a: Object-Oriented Programming
CPSC 427a: Object-Oriented Programming Michael J. Fischer Lecture 5 September 15, 2011 CPSC 427a, Lecture 5 1/35 Functions and Methods Parameters Choosing Parameter Types The Implicit Argument Simple Variables
More informationContext-Free Grammars and Languages (2015/11)
Chapter 5 Context-Free Grammars and Languages (2015/11) Adriatic Sea shore at Opatija, Croatia Outline 5.0 Introduction 5.1 Context-Free Grammars (CFG s) 5.2 Parse Trees 5.3 Applications of CFG s 5.4 Ambiguity
More informationAnnouncements. The current topic: Scheme. Review: BST functions. Review: Representing trees in Scheme. Reminder: Lab 2 is due on Monday at 10:30 am.
The current topic: Scheme! Introduction! Object-oriented programming: Python Functional programming: Scheme! Introduction! Numeric operators, REPL, quotes, functions, conditionals! Function examples, helper
More informationCMSC 330: Organization of Programming Languages. Context Free Grammars
CMSC 330: Organization of Programming Languages Context Free Grammars 1 Architecture of Compilers, Interpreters Source Analyzer Optimizer Code Generator Abstract Syntax Tree Front End Back End Compiler
More informationCaveat lector: This is the first edition of this lecture note. Please send bug reports and suggestions to
Caveat lector: This is the first edition of this lecture note. Please send bug reports and suggestions to jeffe@illinois.edu. But the Lord came down to see the city and the tower the people were building.
More informationOperators and Expressions in C & C++ Mahesh Jangid Assistant Professor Manipal University, Jaipur
Operators and Expressions in C & C++ Mahesh Jangid Assistant Professor Manipal University, Jaipur Operators and Expressions 8/24/2012 Dept of CS&E 2 Arithmetic operators Relational operators Logical operators
More information8. Relational Calculus (Part II)
8. Relational Calculus (Part II) Relational Calculus, as defined in the previous chapter, provides the theoretical foundations for the design of practical data sub-languages (DSL). In this chapter, we
More informationSolutions to Homework 10
CS/Math 240: Intro to Discrete Math 5/3/20 Instructor: Dieter van Melkebeek Solutions to Homework 0 Problem There were five different languages in Problem 4 of Homework 9. The Language D 0 Recall that
More informationData Structure. IBPS SO (IT- Officer) Exam 2017
Data Structure IBPS SO (IT- Officer) Exam 2017 Data Structure: In computer science, a data structure is a way of storing and organizing data in a computer s memory so that it can be used efficiently. Data
More informationBinary, Hexadecimal and Octal number system
Binary, Hexadecimal and Octal number system Binary, hexadecimal, and octal refer to different number systems. The one that we typically use is called decimal. These number systems refer to the number of
More informationLexical and Syntactic Analysis
3 Lexical and Syntactic Analysis Exercises 3.1 a. Identif ier letter IdentRest IdentRest letter IdentRest digit IdentRest b. where letter and digit are treated as terminals. Note that individual letters
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 informationCOP 3402 Systems Software Syntax Analysis (Parser)
COP 3402 Systems Software Syntax Analysis (Parser) Syntax Analysis 1 Outline 1. Definition of Parsing 2. Context Free Grammars 3. Ambiguous/Unambiguous Grammars Syntax Analysis 2 Lexical and Syntax Analysis
More informationFunctional abstraction. What is abstraction? Eating apples. Readings: HtDP, sections Language level: Intermediate Student With Lambda
Functional abstraction Readings: HtDP, sections 19-24. Language level: Intermediate Student With Lambda different order used in lecture section 24 material introduced much earlier sections 22, 23 not covered
More informationFunctional abstraction
Functional abstraction Readings: HtDP, sections 19-24. Language level: Intermediate Student With Lambda different order used in lecture section 24 material introduced much earlier sections 22, 23 not covered
More informationBinary Trees
Binary Trees 4-7-2005 Opening Discussion What did we talk about last class? Do you have any code to show? Do you have any questions about the assignment? What is a Tree? You are all familiar with what
More informationHomework & 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
More informationParsing. Roadmap. > Context-free grammars > Derivations and precedence > Top-down parsing > Left-recursion > Look-ahead > Table-driven parsing
Roadmap > Context-free grammars > Derivations and precedence > Top-down parsing > Left-recursion > Look-ahead > Table-driven parsing The role of the parser > performs context-free syntax analysis > guides
More informationDATA STRUCTURE AND ALGORITHM USING PYTHON
DATA STRUCTURE AND ALGORITHM USING PYTHON Advanced Data Structure and File Manipulation Peter Lo Linear Structure Queue, Stack, Linked List and Tree 2 Queue A queue is a line of people or things waiting
More informationWeek 2: Syntax Specification, Grammars
CS320 Principles of Programming Languages Week 2: Syntax Specification, Grammars Jingke Li Portland State University Fall 2017 PSU CS320 Fall 17 Week 2: Syntax Specification, Grammars 1/ 62 Words and Sentences
More informationExact String Matching Part II. Suffix Trees See Gusfield, Chapter 5
Exact String Matching Part II Suffix Trees See Gusfield, Chapter 5 Outline for Today What are suffix trees Application to exact matching Building a suffix tree in linear time, part I: Ukkonen s algorithm
More information6.001 Notes: Section 15.1
6.001 Notes: Section 15.1 Slide 15.1.1 Our goal over the next few lectures is to build an interpreter, which in a very basic sense is the ultimate in programming, since doing so will allow us to define
More informationLower Bound on Comparison-based Sorting
Lower Bound on Comparison-based Sorting Different sorting algorithms may have different time complexity, how to know whether the running time of an algorithm is best possible? We know of several sorting
More information6.001 Notes: Section 31.1
6.001 Notes: Section 31.1 Slide 31.1.1 In previous lectures we have seen a number of important themes, which relate to designing code for complex systems. One was the idea of proof by induction, meaning
More informationlecture notes September 2, How to sort?
.30 lecture notes September 2, 203 How to sort? Lecturer: Michel Goemans The task of sorting. Setup Suppose we have n objects that we need to sort according to some ordering. These could be integers or
More information15.4 Longest common subsequence
15.4 Longest common subsequence Biological applications often need to compare the DNA of two (or more) different organisms A strand of DNA consists of a string of molecules called bases, where the possible
More informationFriday Four Square! 4:15PM, Outside Gates
Binary Search Trees Friday Four Square! 4:15PM, Outside Gates Implementing Set On Monday and Wednesday, we saw how to implement the Map and Lexicon, respectively. Let's now turn our attention to the Set.
More informationEDAN65: Compilers, Lecture 04 Grammar transformations: Eliminating ambiguities, adapting to LL parsing. Görel Hedin Revised:
EDAN65: Compilers, Lecture 04 Grammar transformations: Eliminating ambiguities, adapting to LL parsing Görel Hedin Revised: 2017-09-04 This lecture Regular expressions Context-free grammar Attribute grammar
More informationHorn Formulae. CS124 Course Notes 8 Spring 2018
CS124 Course Notes 8 Spring 2018 In today s lecture we will be looking a bit more closely at the Greedy approach to designing algorithms. As we will see, sometimes it works, and sometimes even when it
More informationPython allows variables to hold string values, just like any other type (Boolean, int, float). So, the following assignment statements are valid:
1 STRINGS Objectives: How text data is internally represented as a string Accessing individual characters by a positive or negative index String slices Operations on strings: concatenation, comparison,
More informationFinite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018
Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018 Lecture 11 Ana Bove April 26th 2018 Recap: Regular Languages Decision properties of RL: Is it empty? Does it contain this word? Contains
More informationDDS Dynamic Search Trees
DDS Dynamic Search Trees 1 Data structures l A data structure models some abstract object. It implements a number of operations on this object, which usually can be classified into l creation and deletion
More informationXQuery Semantics CSE 232B. March 31, 2016
XQuery Semantics CSE 232B March 31, 2016 1 The XPath Sub-language of XQuery We consider XPath, the sublanguage of XQuery which deals with specifying paths along which the XML tree is to be navigated to
More informationSection 5.5. Left subtree The left subtree of a vertex V on a binary tree is the graph formed by the left child L of V, the descendents
Section 5.5 Binary Tree A binary tree is a rooted tree in which each vertex has at most two children and each child is designated as being a left child or a right child. Thus, in a binary tree, each vertex
More informationWe assume uniform hashing (UH):
We assume uniform hashing (UH): the probe sequence of each key is equally likely to be any of the! permutations of 0,1,, 1 UH generalizes the notion of SUH that produces not just a single number, but a
More informationContext-Free Languages & Grammars (CFLs & CFGs) Reading: Chapter 5
Context-Free Languages & Grammars (CFLs & CFGs) Reading: Chapter 5 1 Not all languages are regular So what happens to the languages which are not regular? Can we still come up with a language recognizer?
More informationReasoning About Programs Panagiotis Manolios
Reasoning About Programs Panagiotis Manolios Northeastern University March 22, 2012 Version: 58 Copyright c 2012 by Panagiotis Manolios All rights reserved. We hereby grant permission for this publication
More informationCPS 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
More informationIt can be confusing when you type something like the expressions below and get an error message. a range variable definition a vector of sine values
7_april_ranges_.mcd Understanding Ranges, Sequences, and Vectors Introduction New Mathcad users are sometimes confused by the difference between range variables and vectors. This is particularly true considering
More information1 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
More informationSCHEME 7. 1 Introduction. 2 Primitives COMPUTER SCIENCE 61A. October 29, 2015
SCHEME 7 COMPUTER SCIENCE 61A October 29, 2015 1 Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write Scheme programs,
More informationProgramming with Python
Programming with Python Dr Ben Dudson Department of Physics, University of York 21st January 2011 http://www-users.york.ac.uk/ bd512/teaching.shtml Dr Ben Dudson Introduction to Programming - Lecture 2
More information1. Consider the following program in a PCAT-like language.
CS4XX INTRODUCTION TO COMPILER THEORY MIDTERM EXAM QUESTIONS (Each question carries 20 Points) Total points: 100 1. Consider the following program in a PCAT-like language. PROCEDURE main; TYPE t = FLOAT;
More informationA Functional Evaluation Model
A Functional Evaluation Model COS 326 Andrew W. Appel Princeton University slides copyright 2013-2015 David Walker and Andrew W. Appel A Functional Evaluation Model In order to be able to write a program,
More informationAn introduction to suffix trees and indexing
An introduction to suffix trees and indexing Tomáš Flouri Solon P. Pissis Heidelberg Institute for Theoretical Studies December 3, 2012 1 Introduction Introduction 2 Basic Definitions Graph theory Alphabet
More informationDr. D.M. Akbar Hussain
Syntax Analysis Parsing Syntax Or Structure Given By Determines Grammar Rules Context Free Grammar 1 Context Free Grammars (CFG) Provides the syntactic structure: A grammar is quadruple (V T, V N, S, R)
More information9/24/ Hash functions
11.3 Hash functions A good hash function satis es (approximately) the assumption of SUH: each key is equally likely to hash to any of the slots, independently of the other keys We typically have no way
More informationLexical 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
More informationImplementing Programming Languages
Out of print; full text available for free at http://www.gustavus.edu/+max/concrete-abstractions.html CHAPTER TEN Implementing Programming Languages 10.1 Introduction The Scheme system you ve been using
More informationCMSC th Lecture: Graph Theory: Trees.
CMSC 27100 26th Lecture: Graph Theory: Trees. Lecturer: Janos Simon December 2, 2018 1 Trees Definition 1. A tree is an acyclic connected graph. Trees have many nice properties. Theorem 2. The following
More informationFormal semantics of loosely typed languages. Joep Verkoelen Vincent Driessen
Formal semantics of loosely typed languages Joep Verkoelen Vincent Driessen June, 2004 ii Contents 1 Introduction 3 2 Syntax 5 2.1 Formalities.............................. 5 2.2 Example language LooselyWhile.................
More information1.1 evaluating expressions 2017 ink.notebook. August 18, page 7 page 8 Unit 1 Basic Equations and Inequalities. 1.1 Order of Operations.
1.1 evaluating expressions 2017 ink.notebook page 7 page 8 Unit 1 Basic Equations and Inequalities 1.1 Order of Operations page 9 page 10 Lesson Objectives Standards 1.1 Order of Operations Press the tabs
More informationBasic Structure of Denotational Definitions
asic Structure of Denotational Definitions This chapter presents the format for denotational definitions. We use the abstract syntax and semantic algebra formats to define the appearance and the meaning
More informationLecture-14 Lookup Functions
Lecture-14 Lookup Functions How do I write a formula to compute tax rates based on income? Given a product ID, how can I look up the product s price? Suppose that a product s price changes over time. I
More informationMeeting 1 Introduction to Functions. Part 1 Graphing Points on a Plane (REVIEW) Part 2 What is a function?
Meeting 1 Introduction to Functions Part 1 Graphing Points on a Plane (REVIEW) A plane is a flat, two-dimensional surface. We describe particular locations, or points, on a plane relative to two number
More informationWhat Is It? Instruction Register Address Register Data Register
What Is It? Consider the following set of 32 binary digits, written in blocks of four so that the example is not impossible to read. 0010 0110 0100 1100 1101 1001 1011 1111 How do we interpret this sequence
More informationyqgm_rules documentation(version 1) Feng Shao Warren Wong Computer Science Department Cornell University
yqgm_rules documentation(version 1) Feng Shao Warren Wong Computer Science Department Cornell University fshao@cs.cornell.edu ww58@cornell.edu 1. Introduction In Quark, a query is first parsed by the Parser
More informationUNIT I Programming Language Syntax and semantics. Kainjan Sanghavi
UNIT I Programming Language Syntax and semantics B y Kainjan Sanghavi Contents Language Definition Syntax Abstract and Concrete Syntax Concept of binding Language Definition Should enable a person or computer
More information1.0 Languages, Expressions, Automata
.0 Languages, Expressions, Automata Alphaet: Language: a finite set, typically a set of symols. a particular suset of the strings that can e made from the alphaet. ex: an alphaet of digits = {-,0,,2,3,4,5,6,7,8,9}
More informationCSCI-401 Examlet #5. Name: Class: Date: True/False Indicate whether the sentence or statement is true or false.
Name: Class: Date: CSCI-401 Examlet #5 True/False Indicate whether the sentence or statement is true or false. 1. The root node of the standard binary tree can be drawn anywhere in the tree diagram. 2.
More informationprogramming languages need to be precise a regular expression is one of the following: tokens are the building blocks of programs
Chapter 2 :: Programming Language Syntax Programming Language Pragmatics Michael L. Scott Introduction programming languages need to be precise natural languages less so both form (syntax) and meaning
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 informationData Structures. Binary Trees. Root Level = 0. number of leaves:?? leaves Depth (Maximum level of the tree) leaves or nodes. Level=1.
Data Structures inary Trees number of leaves:?? height leaves Depth (Maximum level of the tree) leaves or nodes Root Level = 0 Level=1 57 feet root 2 Level=2 Number of nodes: 2 (2+1) - 1 = 7 2 inary Trees
More information