80 likes | 216 Views
Group Project. Justin Hust Ethan Petuchowski Simon Doty LISP Interpreter using JavaCC and jjTree SQL Subquery in ReL. Lisp Interpreter Overview. Created LISP interpreter by building an Abstract Syntax Tree that is visitable.
E N D
Group Project • Justin Hust • Ethan Petuchowski • Simon Doty • LISP Interpreter using JavaCC and jjTree • SQL Subquery in ReL
Lisp Interpreter Overview • Created LISP interpreter by building an Abstract Syntax Tree that is visitable. • A different node type for each terminal, non-terminal gets hung on the AST. • Uses three visitors – displayAST, build environment, interpret. • Modes for static and dynamic scoping
AST Nodes • ASTIdentifier x, y, f • ASTNum 1000, 3.14 • ASTArithExpr (+ 4 3) • ASTLambdaExpr (lambda (x) (+ x 3)) Function Application: • ASTFunctionExpr ((lambda (y) (+ y y)) 5) • ASTNamedFunctionApp (f 5)
AST Print Visitor • Visitor for AST Printing • Displays abstract syntax for nodes
Interpret Visitor • Interpret visitor visits each node and (eagerly) evaluates. • Visitor takes scoping mode parameter. • Preprocesses all lets to lambdas. • Saves deferred substitutions as an ArrayList of TreeMaps ( e.g. x → 5 ; f → (lambda (y) y) )
Environment Visitor • Builds environment with FAE-like syntax.
SQL Subquery in ReL • Modified Python.g to recognize subselect inside of WHERE clause. • Creates sqlsubquery node when it sees SELECT keyword. • Modified SQLVisitor.java subSelect() method. • Cleans up subselect statement, casts to jsqlparser Select statement, and adds to ArrayList of subselects. • Calls getSelect( ) on main select statement and again on each subselect statement using a new instance of SQLVisitor
SQL Subquery in ReL (cont') • Now that ArrayList of subselects has elements, SQL to RDF conversion is different. • If “subselects” list has elements, WHERE clause must operate on the result from the subquery. • e.g. <select> WHERE TYPEID_PETS in <subselect>… • WHERE clauses without subqueries are added to the “filters” list as before.