BROOM: A Matrix Language Chris Tobin Michael Weiss Gabe Glaser Brian Pellegrini.

Slides:



Advertisements
Similar presentations
Chapter 8 Technicalities: Functions, etc. Bjarne Stroustrup
Advertisements

CS3012: Formal Languages and Compilers Static Analysis the last of the analysis phases of compilation type checking - is an operator applied to an incompatible.
CPSC 388 – Compiler Design and Construction
Symbol Table.
Semantics Static semantics Dynamic semantics attribute grammars
1 Mooly Sagiv and Greta Yorsh School of Computer Science Tel-Aviv University Modern Compiler Design.
1 Compiler Construction Intermediate Code Generation.
Chapter 7 User-Defined Methods. Chapter Objectives  Understand how methods are used in Java programming  Learn about standard (predefined) methods and.
Slides prepared by Rose Williams, Binghamton University ICS201 Exception Handling University of Hail College of Computer Science and Engineering Department.
Compilation Encapsulation Or: Why Every Component Should Just Do Its Damn Job.
Nov 10, Fall 2006IAT 8001 Debugging. Nov 10, Fall 2006IAT 8002 How do I know my program is broken?  Compiler Errors –easy to fix!  Runtime Exceptions.
Slides prepared by Rose Williams, Binghamton University Chapter 1 Getting Started 1.1 Introduction to Java.
WPSM Programming Language A simple language that transform simple data structure into complex xML format Wai Y. Wong Peter Chen Seema Gupta Miqdad Mohammed.
1 Intermediate representation Goals: –encode knowledge about the program –facilitate analysis –facilitate retargeting –facilitate optimization scanning.
GRIMM Choose-Your-Own-Story Language Mike Lenner Billy Liu Mariya Nomanbhoy Becky Plummer.
Environments and Evaluation
Chapter 3 Program translation1 Chapt. 3 Language Translation Syntax and Semantics Translation phases Formal translation models.
Transformation of Java Card into Diet Java Semester Project Presentation Erich Laube.
Project Overview Team: Ben Smith, Avrum Tilman, Josh Weinberg, Ron Weiss Mapwad: A Maze Generation language.
Programming Languages and Translators Prof. Stephen Edwards, Fall 2003 Team Members: Haronil Estevez ~ Diana Jackson ~ Catherine MacInnes ~ Adam Rosenzweig.
EMDL Extended Motion Description Language. EMDL vs. MDL.
Wizard of House Management - Programming Language and Translators Project Rui Kuang Arvid Bessen Andrey Butov Svetlana Starshinina.
1. 2 Chapter 1 Introduction to Computers, Programs, and Java.
Writing algorithms using the while-statement. Previously discussed Syntax of while-statement:
CSC 8310 Programming Languages Meeting 2 September 2/3, 2014.
Language Evaluation Criteria
CIS Computer Programming Logic
COP4020 Programming Languages
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
Boardr The Racing Board Game Creation Language. Project Manager: Eric Leung Language and Tools Guru: Shensi Ding System Architect: Seong Jin Park System.
{ Graphite Grigory Arashkovich, Anuj Khanna, Anirban Gangopadhyay, Michael D’Egidio, Laura Willson.
1 COMP 3438 – Part II-Lecture 1: Overview of Compiler Design Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ.
Pemrograman Dasar Arrays PTIIK - UB. Arrays  An array is a container object that holds a fixed number of values of a single type.  The length of an.
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.
Testing and Debugging Version 1.0. All kinds of things can go wrong when you are developing a program. The compiler discovers syntax errors in your code.
D. M. Akbar Hussain: Department of Software & Media Technology 1 Compiler is tool: which translate notations from one system to another, usually from source.
Chapter 1 Section 1.1 Introduction to Java Slides prepared by Rose Williams, Binghamton University Kenrick Mock, University of Alaska Anchorage.
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.
Semantic Analysis. Find 6 problems with this code. These issues go beyond syntax.
BUILD ON THE POLYGLOT COMPILER FRAMEWORK MIHAL BRUMBULLI 7th Workshop “SEERE” Montenegro-Risan 9-14 September 2007 SimJ Programming Language.
Looping and Counting Lecture 3 Hartmut Kaiser
CMP-MX21: Lecture 4 Selections Steve Hordley. Overview 1. The if-else selection in JAVA 2. More useful JAVA operators 4. Other selection constructs in.
Towards the better software metrics tool motivation and the first experiences Gordana Rakić Zoran Budimac.
1 Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
PLT Final Project---COLOGO Lixing Dong, Zhou Ma, Chao Song, Siyuan Lu, Dongyang Jiang.
Chapter 1 Introduction Study Goals: Master: the phases of a compiler Understand: what is a compiler Know: interpreter,compiler structure.
CS536 Semantic Analysis Introduction with Emphasis on Name Analysis 1.
Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java.
Celluloid An interactive media sequencing language.
The Functions and Purposes of Translators Syntax (& Semantic) Analysis.
Weaving a Debugging Aspect into Domain-Specific Language Grammars SAC ’05 PSC Track Santa Fe, New Mexico USA March 17, 2005 Hui Wu, Jeff Gray, Marjan Mernik,
. n COMPILERS n n AND n n INTERPRETERS. -Compilers nA compiler is a program thatt reads a program written in one language - the source language- and translates.
CS101: Introduction to Computer Science Slides adapted from Sedgewick and Wayne Copyright © Your First Java.
David LOU – Project Manager Markus SCHANTA – Language Guru Long CHEN – System Architect Xiaolong JIANG – System Integrator Jingbo YANG – Tester & Validator.
EMuse “Rapid Screenplay Prototyping Language” Mark Ayzenshtat Elena Filatova Kristina Holst Vlad Shchogolev.
CS412/413 Introduction to Compilers Radu Rugina Lecture 13 : Static Semantics 18 Feb 02.
Agenda Comments Identifiers Keywords Syntax and Symentics Indentation Variables Datatype Operator.
©SoftMoore ConsultingSlide 1 Structure of Compilers.
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
Aryeh Tasher Brian Ramos Qijun Zhong Michael Li Tian Zhang.
Lecture 9 Symbol Table and Attributed Grammars
Introduction to Compiler Construction
Constructing Precedence Table
CS 3304 Comparative Languages
Semantic Analysis with Emphasis on Name Analysis
Lecture Note Set 1 Thursday 12-May-05
CS 536 / Fall 2017 Introduction to programming languages and compilers
Lecture 15 (Notes by P. N. Hilfinger and R. Bodik)
The Recursive Descent Algorithm
Presentation transcript:

BROOM: A Matrix Language Chris Tobin Michael Weiss Gabe Glaser Brian Pellegrini

Broom Overview and Summary  A high-level language for manipulating matrices  Many useful built in matrix operations.  Ability to define and build more complicated functions for specialized analysis of information

Motivation  Matrices are universal mathematical constructs  Learning curve is not as steep  Specialized use, without extraneous things to understand other than what you need it for.  No need for expensive software

Goals  Intuitive syntax  High level  Very portable  Flexible  Useful and informative error checking

Broom Syntax  Intuitive  for ( ) … endfor  Freeform  whitespace inserted at will  Smooth built-in matrix operation syntax  A = inv(B); // finds the inverse of B  Features:  Control flow constructs: for, while, if  Nested logical operators and expressions  A wide range of built-in functions

Built-in Functions  Many useful built-in function calls:  det  colswap, rowswap  inv  gauss  appendUD, appendLR  setCol, setRow  Too numerous to list…22 total

Semantics  Broom features:  Function definitions  Allow for modularity, power, and reusable code.  Variable definitions  Two intuitive mathematical types  Number  Matrix  Scoping rules:  local – for functions  global – accessible by all  All functions call-by-value for simplicity

Compiler Components and Composition  There are 5 main components of BCC, the Broom translator  Lexer  Parser  Static Semantics Checker  W/Symbol Tables  BroomMatrix.java  Contains Matrix manipulation code and functions  Code Generator

ANTLR  The Lexer and Parser were implemented using ANTLR.  ANTLR’s AST class was used to create the Abstract Syntax Tree and Nodes.  The Static Semantics Checker was implemented as a TreeWalker of the ANTLR AST and maintained Symbol Tables for the various scopes.  Symbol Tables were written as a simple Java class  Code Generator was also implemented as a TreeWalker of ANTLR AST.  Accumulates a “program string” as it walks the AST and prints string to file upon finishing traversal

Block Diagram of Compiler

Example of Generated Code MyProgram.broom:MyProgram global Matrix myMatrix; myMatrix = [1,2; 3,4;]; 3,4;]; //function definitions here... start() Number value; value = det( myMatrix * [1,3; 7,8;]); 7,8;]); //print the value you got value.print(); //print the global Matrix myMatrix.print();endstart MyProgram.java public class MyProgram { BroomMatrix myMatrix; public MyProgram() { float[][] _temp0 = {{(float) 1, (float) 2}, {(float) 3, (float) 4}}; myMatrix = new BroomMatrix( _temp0); } public void start() { float value; float[][] _temp1 = {{(float) 1, (float) 3}, {(float) 7, (float) 8}}; value = BroomMatrix.det(BroomMatrix.multiply(m yMatrix, new BroomMatrix( _temp1))); BroomMatrix.printVariable(value);BroomMatrix.printVariable(myMatrix);} public static void main(String[] args) {MyProgram myProgram = new MyProgram(); myProgram.start();}}

Output of The Simple Program $ javac MyProgram.java $ java MyProgram

Error Checking  Two main types of errors  Semantic Errors  Invalid use of logical ops  Invalid type assignments  Use of reserved words as variable names, etc.  Run-Time Errors  Reference to non-existent index  Use of improperly formatted matrix. * Note: If “de ja vu” is experienced something in your matrix may have been changed.

Example Test Program wrongNumColls // Test for number of columns errors // Author Brian Pellegrini // This is supposed to make sure that error checking for //assignment of matrix values works...it is supposed to fail // MUA HAHAHHAHAHHAH global Matrix A,B; A= [1, 0, 1; 0, 1;]; B= [0, 1; 1, 0, 2;]; start() print ("If this printed checker didn't work"); endstart

Example Test Results BroomProgram did not compile; the following errors were detected: * Error in *global declaration* : invalid matrix specification. Expected a row with 3 elements, but got 2 Expected a row with 3 elements, but got 2 Error in *global declaration* : invalid matrix specification. Expected a row with 2 elements, but got 3 Expected a row with 2 elements, but got 3  BROOM compiler found all the errors!  During testing one has to be careful that errors being tested are the only ones present in the program  Inadvertent bugs can cause lots of lost time spend debugging “ghost bugs”

Lessons Learned  Leave no stone unturned  Need to test every possible error user might encounter  Need to test both errors in user’s code, and errors in generated JAVA code  Exhaustive testing pays off in the end  Have someone else try it!  Have a friend write a program, they might find errors that the testing team simply overlooked.