Visitor-Based HMM Israel Perez, Fayz Rahman, Chinedu Egboh.

Slides:



Advertisements
Similar presentations
CPSC 388 – Compiler Design and Construction
Advertisements

Execute Blocks of Code Multiple Times Svetlin Nakov Telerik Corporation
Loops –Do while Do While Reading for this Lecture, L&L, 5.7.
Type Checking, Inference, & Elaboration CS153: Compilers Greg Morrisett.
CSE341: Programming Languages Lecture 2 Functions, Pairs, Lists Dan Grossman Winter 2013.
Execute Blocks of Code Multiple Times Telerik Software Academy C# Fundamentals – Part 1.
The Singleton Pattern II Recursive Linked Structures.
Java Review Interface, Casting, Generics, Iterator.
Winter Compiler Construction T7 – semantic analysis part II type-checking Mooly Sagiv and Roman Manevich School of Computer Science Tel-Aviv.
Getting started with ML ML is a functional programming language. ML is statically typed: The types of literals, values, expressions and functions in a.
ML: a quasi-functional language with strong typing Conventional syntax: - val x = 5; (*user input *) val x = 5: int (*system response*) - fun len lis =
Cs784(TK)1 Semantics of Procedures and Scopes. Kinds of Scope Static or Lexical scope –determined by structure of program –Scheme, C++, Java, and many.
CS 240 Week 2. Introduction to Project 2 Command Line Syntax java Spell word -- source file hard wired into program Run Demo.
1 Scheme Scheme is a functional language. Scheme is based on lambda calculus. lambda abstraction = function definition In Scheme, a function is defined.
Names and Scopes CS 351. Program Binding We should be familiar with this notion. A variable is bound to a method or current block e.g in C++: namespace.
Introduction to ML - Part 2 Kenny Zhu. What is next? ML has a rich set of structured values Tuples: (17, true, “stuff”) Records: {name = “george”, age.
Repetition Statements repeat block of code until a condition is satisfied also called loops Java supports 3 kinds of loops: while statement – repeats a.
Building An Interpreter After having done all of the analysis, it’s possible to run the program directly rather than compile it … and it may be worth it.
Programming Languages 2nd edition Tucker and Noonan Chapter 6 Types I was eventually persuaded of the need to design programming notations so as to maximize.
PPL Syntax & Formal Semantics Lecture Notes: Chapter 2.
The Interpreter Pattern. Defining the Interpreter Intent Given a language, define a representation for its grammar along with an interpreter that uses.
Python – Part 4 Conditionals and Recursion. Modulus Operator Yields the remainder when first operand is divided by the second. >>>remainder=7%3 >>>print.
OCaml The PL for the discerning hacker.. Hello. I’m Zach, one of Sorin’s students.
Chap 3 – PHP Quick Start COMP RL Professor Mattos.
Putting it all together: LINQ as an Example. The Problem: SQL in Code Programs often connect to database servers. Database servers only “speak” SQL. Programs.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
CS412/413 Introduction to Compilers and Translators Spring ’99 Lecture 8: Semantic Analysis and Symbol Tables.
Interpretation Environments and Evaluation. CS 354 Spring Translation Stages Lexical analysis (scanning) Parsing –Recognizing –Building parse tree.
Dr. Philip Cannata 1 Functions and Recursion. Dr. Philip Cannata 2 10 Java (Object Oriented) ASP RDF (Horn Clause Deduction, Semantic Web) Relation Jython.
CMSC 330: Organization of Programming Languages
Programming Languages 2nd edition Tucker and Noonan Chapter 6 Type Systems I was eventually persuaded of the need to design programming notations so as.
CS 345 Project Presentation OOH A More Object-Oriented Hmm++ Alysha Behn Jesse Vera.
1 do-while Statement 2 Do-While Statement Is a looping control structure in which the loop condition is tested after each iteration of the loop. SYNTAX.
In the last lesson we discussed about: Casting Precedence The “=“ used as an assignment operator Made a calculate average program.
CMSC 330: Organization of Programming Languages Operational Semantics a.k.a. “WTF is Project 4, Part 3?”
Error Example - 65/4; ! Toplevel input: ! 65/4; ! ^^ ! Type clash: expression of type ! int ! cannot have type ! real.
CS345 Project Presentation Language: H-- Mikhail Iakhiaev.
1 For Loops l From Chapter 9 l A shorthand way of coding count loops.
1 Looping Dale/Weems/Headington. 2 KA/JS/P Warning l Save your work often! l In the Khan Academy, JavaScript environment, infinite loops will lock up.
CS412/413 Introduction to Compilers Radu Rugina Lecture 13 : Static Semantics 18 Feb 02.
Interpreters and Higher-Order Functions CSE 413 Autumn 2008 Credit: CSE341 notes by Dan Grossman.
CMSC 330: Organization of Programming Languages Operational Semantics.
BY: JAKE TENBERG & CHELSEA SHIPP PROJECT REVIEW: JGIBBERISH.
CSE 425: Functional Programming I Programs as Functions Some programs act like mathematical functions –Associate a set of input values from the function’s.
CSE 3341/655; Part 3 35 This is all very wrong! What would the SW1/SW2 (RESOLVE) people say if they saw this? Problem: Lack of data abstraction; What would.
Lecture 9 Symbol Table and Attributed Grammars
CS 240 Week 2.
Test 2 Review Outline.
CSE341: Programming Languages Lecture 17 Implementing Languages Including Closures Dan Grossman Spring 2017.
ML: a quasi-functional language with strong typing
Lambda Expressions By Val Feldsher.
Programming Languages Dan Grossman 2013
Representation, Syntax, Paradigms, Types
Emily Leland (Not Nick) Spring 2017
REBOL Writing Functions.
Chapter 4 LOOPS © Bobby Hoggard, Department of Computer Science, East Carolina University / These slides may not be used or duplicated without permission.
Iteration with While You can say that again.
Conditional Statements
CSE341: Programming Languages Lecture 17 Implementing Languages Including Closures Dan Grossman Autumn 2018.
Lecture 15 (Notes by P. N. Hilfinger and R. Bodik)
Group Project Justin Hust Ethan Petuchowski Simon Doty
Representation, Syntax, Paradigms, Types
CSE341: Programming Languages Lecture 17 Implementing Languages Including Closures Zach Tatlock Winter 2018.
Interpreter Pattern.
CSE341: Programming Languages Lecture 17 Implementing Languages Including Closures Dan Grossman Spring 2016.
Course Overview PART I: overview material PART II: inside a compiler
CSE341: Programming Languages Lecture 17 Implementing Languages Including Closures Dan Grossman Autumn 2017.
Recursive Procedures and Scopes
Brett Wortzman Summer 2019 Slides originally created by Dan Grossman
CSE341: Programming Languages Lecture 17 Implementing Languages Including Closures Dan Grossman Spring 2019.
Presentation transcript:

Visitor-Based HMM Israel Perez, Fayz Rahman, Chinedu Egboh

Changes to HMM Edited AbstractSyntaxTree class – All “node” classes now have accept methods. Added VisitorIF interface – Defines an interface for a Visitor. Has visit methods for all “node” classes in AST. Not all are used, but they are there if needed in the future. Edited Hmm.java – Edited to utilize our new additions.

Changes to HMM Added PrinterVisitor – A Visitor that prints out the Abstract Syntax Tree. Added StaticTypeCheckVisitor – A Visitor that performs static-type checking on the Abstract Syntax Tree. Added InterpreterVisitor – A Visitor that interprets the Abstract Syntax Tree and “runs” the program.

Changes to HMM Added Souvenir class – Some AST nodes return different things in different contexts. This class holds returns of type boolean, Value, and Type. Used as a unified return type for each method in the visitor interface. Added additional test programs

Why the Visitor Pattern? We are separating Functionality from Structure. We can add a new operation to an existing structure of objects without having to alter the classes of those objects. – In our project, we added PrintVisitor, StaticTypeCheckVisitor, and InterpreterVisitor. All use the same AST, but do very different things.

Interpretation in HMM Old HMM Evaluates global variables Finds main method, gets its body, calls runStatement(body) – Goes through list of if/elseif instanceof blocks, and do whatever it needs to for that node. Possibly recursive. – If node is an Expression, call runExpression go through more if/elseif instanceof blocks. Possibly recursive. Visitor-Based HMM Evaluates global variables Finds main method, gets its body, creates new Visitor, calls runStatement(Visitor) Visitor finds correct visitor for specific node type, and does whatever it needs to for that node. Possibly recursive.

Demo Time?

Refresher: Features of HMM List Comprehension Support for Tuples and Lists Support for Strings Built-in functions: – print – println int main() { list test = createTest(); list select = [(name1, name2) | (name1, name2) <- test, name1 == “Fayz” ]; println("Group Members: ”, test); println("Member: “, select); } list createTest() { return[("Fayz", "Rahman"), ("Nick", "Egboh"), ("Israel", "Perez")]; }

Refresher: Features of HMM Lambda Expressions For-each loop int main() { list count = [1,2,3]; for (n <- count) { int doubleFunc = application(n, (\x -> x*2) ); println("(\x -> (2*x)) applied to ", n, " = ", doubleFunc); } int application(object x, (object, object) a) { int result = a(x); return result; }

Refresher: Features of HMM Static Scoping Static Binding (variables in lambdas) int main() { list count = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]; int x = 10; list output = selector(count, lambdaFilter()); println("Count: ", count); println("Filtered: ", output); } (object, bool) lambdaFilter() { int x = 30; return (\y -> y < x); } list selector(list nums, (object, bool) filter) { return [ x | x <- nums, filter(x) ]; }