BROOM: A Matrix Language - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

BROOM: A Matrix Language

Description:

Broom Overview and Summary. A high-level language for ... Broom features: Function definitions. Allow for modularity, power, and ... BROOM compiler found ... – PowerPoint PPT presentation

Number of Views:28
Avg rating:3.0/5.0
Slides: 17
Provided by: gaill7
Category:
Tags: broom | broom | language | matrix

less

Transcript and Presenter's Notes

Title: BROOM: A Matrix Language


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

2
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

3
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

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

5
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

6
Built-in Functions
  • Many useful built-in function calls
  • det
  • colswap, rowswap
  • inv
  • gauss
  • appendUD, appendLR
  • setCol, setRow
  • Too numerous to list22 total

7
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

8
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

9
ANTLR
  • The Lexer and Parser were implemented using
    ANTLR.
  • ANTLRs 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

10
Block Diagram of Compiler
11
Example of Generated Code
  • 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(myM
    atrix, new BroomMatrix( _temp1)))
  • BroomMatrix.printVariable(value)
  • BroomMatrix.printVariable(myMatrix)
  • public static void main(String args)
  • MyProgram.broom
  • MyProgram
  • global Matrix myMatrix
  • myMatrix 1,2
  • 3,4
  • //function definitions here...
  • start()
  • Number value
  • value det( myMatrix
  • 1,3
  • 7,8)
  • //print the value you got
  • value.print()
  • //print the global Matrix
  • myMatrix.print()
  • endstart

12
Output of The Simple Program
  • javac MyProgram.java
  • java MyProgram
  • 26.0
  • 1.0 2.0
  • 3.0 4.0

13
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.

14
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

15
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
  • Error in global declaration invalid matrix
    specification.
  • 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

16
Lessons Learned
  • Leave no stone unturned
  • Need to test every possible error user might
    encounter
  • Need to test both errors in users 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.
Write a Comment
User Comments (0)
About PowerShow.com