Presentation is loading. Please wait.

Presentation is loading. Please wait.

BY: JAKE TENBERG & CHELSEA SHIPP PROJECT REVIEW: JGIBBERISH.

Similar presentations


Presentation on theme: "BY: JAKE TENBERG & CHELSEA SHIPP PROJECT REVIEW: JGIBBERISH."— Presentation transcript:

1 BY: JAKE TENBERG & CHELSEA SHIPP PROJECT REVIEW: JGIBBERISH

2 BASIC SYNTAX Types: Integers: 6, 5 Strings: [HelloWorld] Functions: Function call: @name@ Variable declaration: (param1,value) Variable reference/call: #param1# Enode and Fnode Single characters “e” and “f” Execution node ^

3 CONCEPTS IMPLEMENTED

4 CONCEPTS IMPLEMENTED (LISTED) Token Terminal Non-terminal Lexical analysis Syntactic analysis BNF Parse tree Abstract syntax Abstract syntax tree Interpretation Substitution Variables Static and dynamic scoping Types Type system Static and dynamic typing Functions Parameters and arguments Parameter passing Activation records Runtime stack First-class functions Recursion

5 PROJECT REQUIREMENTS Substitution -- ✔ First-class functions -- ✔ Static scoping with dynamic scoping if appropriate -- ✔ Static or dynamic typing -- ✔ Interpretation of an abstract syntax tree -- ✔

6 SUBSTITUTION Implemented through use of a variable table. When a function is called, the old variable table is pushed onto the runtime stack. Loop through the function’s parameters and get the values for those variables from the internal stack. These name and value pairs are put into the variable table. After the function is run, pop the old variable table off of the runtime stack.

7 FIRST-CLASS FUNCTIONS As seen in FirstClassMeows.gib (example file included in the project), functions can be passed as parameters to other functions. They are handled just like other variables Pushed onto the internal stack and popped off when needed

8 STATIC SCOPING Every time a variable is encountered, it is added to the variable table. When a function is encountered: Old variable table pushed onto runtime stack Parameters from the function are substituted with values popped from the stack These values are then added/changed in the variable table After the function finishes executing, the variable table is replaced with the one popped from the runtime stack This ensures that the same named variables have different values in different scopes

9 STATIC/DYNAMIC TYPING Mainly dynamically typed We throw exceptions at runtime if things aren’t the type we want (e.g. value instanceof String) However, the types are defined when things are declared (the syntax for declaration) Strings: enclosed in brackets Integers: plain numbers Functions: enclosed in angle brackets with special syntax distinguishing the name and parameters from the body In addition, Java is statically typed

10 INTERPRETATION OF ABSTRACT SYNTAX TREE Example AST of Double.gib (given a number in the program, outputs two times that number)

11 OUTPUT OF RUNTIME STACK Example runtime stack of FirstClassMeows.gib

12 SOME EXAMPLE PROGRAMS HelloWorld.gib : simple Hello World program. Good introduction to Gibberish syntax. FirstClassMeows.gib : uses first-class functions to output a series of meows. expGib.gib : uses variables “g” and “v”, which represent numbers, and compute g^v recursively. fibGib.gib : gets the given term of the Fibonacci. scopeGib.gib : shows static scoping! The value of the variable “a” changes depending on the scope. It has different values based on which function is being called.

13 IMPROVEMENTS FOR THE FUTURE Allow more types Right now we allow Strings, Integers (including multiple digits), and functions. Possible inclusions: doubles, booleans, arrays Allow the program to pass in parameters e.g. instead of hardcoding a value to find the Fibonacci number of, allow the user to pass in a value on the command line. SQL commands We tried to implement a few basic commands Better way of implementing errors, rather than just runtime exceptions

14 COOL FEATURES Theoretically infinite instruction sets Only limited by the size of an integer in java (2^32) The fifth instruction set is meows! We fully implemented the Gibberish language, from scratch Our implementation has features like static scoping, variables, and functions that other implementations don’t have Optional flags to toggle the following options: Seeing abstract syntax tree, runtime stack Not seeing output


Download ppt "BY: JAKE TENBERG & CHELSEA SHIPP PROJECT REVIEW: JGIBBERISH."

Similar presentations


Ads by Google