110 likes | 258 Views
CHAD. 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
E N D
CHAD 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 • IntegersTypical Operations (add,multiply,mod,compare) Functions: Min(a,b) and Max(a,b) • StringsOperations: (assignment =, concatenation +, comparison==) • ArraysSyntax: array[int|string, size] a; Functions: a.sortAZ(begin, end), a.sortZA(begin, end), a.swap(i,j) • QueuesSyntax: queue[int|string] q; Functions: q.enqueue(1); q.dequeue(); • StacksSyntax: stack[int|string] s; Functions: s.push(“string”); s.pop(); • FunctionsSyntax: 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 Load CHAD Source File RUN/STEP through Program CHADLexer/CHADParser StaticCHADWalker CHADWalker Parsing/Static Semantic Error Creation/Change In Visible Data Structure ERROR CHADGUI Update CHAD: Implementation • Lexer (CHADLexer) and Parser (CHADParser) written in ANTLR • Two tree walkers implemented with ANTRL • StaticCHADWalker: performs static semantics analysis • CHADWalker: the interpreter • CHADType class stores built-in types/data structures • CHADType object used by interpreter to evaluate binary operations and execute built-in functions
CHAD GUI Load CHAD Source File RUN/STEP through Program CHADLexer/CHADParser StaticCHADWalker CHADWalker Parsing/Static Semantic Error Creation/Change In Visible Data Structure ERROR CHADGUI Update CHAD: Implementation • CHAD GUI written with Java Swing and gives users the ability to load/run CHAD programs • GUI uses CHADParser to detect parser errors and StaticCHADWalker to perform static semantics analysis before allowing user to run CHAD program • GUI's "Step" button triggers use of CHADWalker to step through execution of the program one step at a time • GUI's “Run" button triggers use of CHADWalker to run through execution of entire program • GUI only displays data structures that are marked "visible" by the 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