Final presentation

Download Report

Transcript Final presentation

Programming Languages and Translators
Prof. Stephen Edwards, Fall 2003
Team Members:
Haronil Estevez ~ Diana Jackson ~ Catherine MacInnes ~ Adam Rosenzweig
CHAD: Overview
An interpreted language
Interpreter creates a graphical display of the
program
5 native data types
 Integers
 Strings
 Arrays
 Queues
 Stacks
Types have native operations
Used to implement most algorithms
CHAD: Motivation
Graphic representations are a very powerful
teaching tool
Teachers don't want to spend a lot of time
coding an algorithm just so that their
students can see what is going on
There are no current languages which make
it easy to graphically represent algorithms
In CHAD you can write a graphical
representation of simple algorithms in less
than 15min.
CHAD: Tutorial
Program Order/Structure: Declarations,
Expressions, Functions
Declarations terminate in semicolon
Control Statements end in an end keyword
for appropriate type (e.g. if/endif,
else/endelse, for/endfor)
Most CHAD Types have the same
syntactical structure and typical operations
as the most common languages
Supports comments (// /* */)
CHAD: Tutorial
 Integers





Typical Operations (add,multiply,mod,compare)
Functions: Min(a,b) and Max(a,b)
Strings
Operations: (assignment =, concatenation +, comparison==)
Arrays
Syntax: array[int|string, size] a;
Functions: a.sortAZ(begin, end), a.sortZA(begin, end), a.swap(i,j)
Queues
Syntax: queue[int|string] q;
Functions: q.enqueue(1); q.dequeue();
Stacks
Syntax: stack[int|string] s;
Functions: s.push(“string”); s.pop();
Functions Syntax:
function [return type] functionName(parameters)
Body of Declarations
Body of Expressions
Return statement
endfunction
CHAD: Tutorial
 Insertion Sort
 Primary Focus(red), Secondary Focus(green)
handled by Interpreter
 Detailed description/explanation in final report
CHAD GUI
CHAD: Implementation
Load CHAD
Source File
CHADLexer/CHADParser
RUN/STEP
through Program
StaticCHADWalker
Parsing/Static
Semantic Error
ERROR
• Lexer (CHADLexer) and Parser
(CHADParser) written in ANTLR
• Two tree walkers implemented
with ANTRL
– StaticCHADWalker: performs static
semantics analysis
– CHADWalker: the interpreter
CHADWalker
Creation/Change In
Visible Data Structure
CHADGUI Update
• CHADType class stores built-in
types/data structures
• CHADType object used by
interpreter to evaluate binary
operations and execute built-in
functions
CHAD GUI
CHAD: Implementation
Load CHAD
Source File
CHADLexer/CHADParser
RUN/STEP
through Program
StaticCHADWalker
Parsing/Static
Semantic Error
ERROR
CHADWalker
Creation/Change In
Visible Data Structure
CHADGUI Update
• GUI's "Step" button triggers use of
• CHAD GUI written with Java
CHADWalker to step through
Swing and gives users the ability
execution of the program one step
to load/run CHAD programs
at a time
• GUI uses CHADParser to detect
• GUI's “Run" button triggers use of
parser errors and
CHADWalker to run through
StaticCHADWalker to perform
execution of entire program
static semantics analysis before • GUI only displays data structures
allowing user to run CHAD
that are marked "visible" by the
program
interpreter
CHAD: Summary
Simple language to implement basic
algorithms with familiar syntax
Automatic animations of algorithms
Excellent instructional tool
CHAD: Future Paths
More basic data structures implemented
Linked lists
Trees
Graphs, etc.
Enhanced simulator functionality
Variable timed run steps
More code-control over displayed variables
CHAD: Lessons Learned
Multiple paths to all goals
Every time you think about it, you’ll find
something else you didn’t handle yet
So, start early and stay ahead
Keep all members up to date on each aspect
of project (especially if it’s a part they’re
not working on)
Provide more descriptive error messages ->
easier to debug