Dr. Philip Cannata 1 with ReL. Dr. Philip Cannata 2 10 Java (Object Oriented) ASP RDF (Horn Clause Deduction, Semantic Web) Relation Jython in Java This.

Slides:



Advertisements
Similar presentations
Plt /7/ Data Abstraction Programming Language Essentials 2nd edition Chapter 2.2 An Abstraction for Inductive Data Types.
Advertisements

AST Generation Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Programming Language Concepts Lecture 9.
Abstract Syntax Mooly Sagiv html:// 1.
1 Compiler Construction Intermediate Code Generation.
Chapter 5 Syntax Directed Translation. Outline Syntax Directed Definitions Evaluation Orders of SDD’s Applications of Syntax Directed Translation Syntax.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 14 Functional Programming It is better to.
Cse322, Programming Languages and Compilers 1 6/21/2015 Lecture #5, April 17, 2007 Array Access Case stmt Jump tables Procedure call Machine dependent.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 10 Function Implementation In theory, there.
Environments and Evaluation
CS 110 Intro to Computer Science I Sami Rollins Fall 2006.
Programming Introduction November 9 Unit 7. What is Programming? Besides being a huge industry? Programming is the process used to write computer programs.
The TXL Programming Language Mariano Ceccato ITC-Irst Istituto per la ricerca Scientifica e Tecnologica
Chapter 2 A Simple Compiler
Getting to Know Decaf Goals for Today: Get acquainted with the Decaf language Get experience with ASTs.
Dr. Philip Cannata 1 Programming Languages. Dr. Philip Cannata 2 10 Java (Object Oriented) ASP RDF (Horn Clause Deduction, Semantic Web) Relation Jython.
Dr. Philip Cannata 1 Programming Languages. Dr. Philip Cannata 2 10 Java (Object Oriented) ACL2 (Propositional Induction) Algorithmic Information Theory.
Dr. Philip Cannata 1 Programming Languages Syllogisms and Proof by Contradiction Midterm Review.
Dr. Philip Cannata 1 fJyswan. Dr. Philip Cannata 2 10 Java (Object Oriented) ASP RDF (Horn Clause Deduction, Semantic Web) Relation Jython in Java This.
Dr. Philip Cannata 1 Programming Languages. Dr. Philip Cannata 2 Class Website
1 October 1, October 1, 2015October 1, 2015October 1, 2015 Azusa, CA Sheldon X. Liang Ph. D. Computer Science at Azusa Pacific University Azusa.
Dr. Philip Cannata 1 Programming Languages. Dr. Philip Cannata 2 Class Website
Interpretation Environments and Evaluation. CS 354 Spring Translation Stages Lexical analysis (scanning) Parsing –Recognizing –Building parse tree.
Dr. Philip Cannata 1 Functions and Recursion. Dr. Philip Cannata 2 10 Java (Object Oriented) ASP RDF (Horn Clause Deduction, Semantic Web) Relation Jython.
CS453 LectureIntroduction1 CS453 Compiler Construction Instructor:Wim Bohm Computer Science Building 470 TA: tba
5-1 5 Compilation  Overview  Compilation phases –syntactic analysis –contextual analysis –code generation  Abstract syntax trees  Case study: Fun language.
CS 4720 Dynamic Web Applications CS 4720 – Web & Mobile Systems.
Mitchell McMullen Paul Nguyen SWAN. Python written entirely in C#. Can access all.NET libraries and Silverlight. Created by the same guy as Jython. No.
Scribe Sumbission Date: 28 th October, 2013 By M. Sudeep Kumar.
Lambda Expressions Version 1.0
The x86 Instruction Set Lecture 16 Mon, Mar 14, 2005.
A SParqly Jython++ A SParqly Jython++ an ASP/SPARQL enhanced Jython Cliff Cheng Carlos Urrutia Francisco Garcia.
Milos Hauskrecht (PDF) Hieu D. Vu (PPT) LISP PROGARMMING LANGUAGE.
Continue the Development of SQL in fJySwan Blake Kobelan, Brittany Blassingill, Andrew Spence.
Dr. Philip Cannata 1 RDF. Dr. Philip Cannata 2 10 Java (Object Oriented) ASP RDF (Horn Clause Deduction, Semantic Web) Relation Jython in Java This Course.
An Attribute Grammar for Tiny Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Programming Language Principles Lecture 18.
Code Generation CPSC 388 Ellen Walker Hiram College.
Implementation of the Python Bytecode Compiler Jeremy Hylton Google.
1 Languages and Compilers (SProg og Oversættere) Lecture 9 (1) Bent Thomsen Department of Computer Science Aalborg University With acknowledgement to Norm.
Homework 4 Basic Blocks and Control Flow Graphs CS4430 Spring 2012 Due: April 2 nd by 2pm* * There will be absolutely no extensions for this assignment.
Bernd Fischer COMP2010: Compiler Engineering Abstract Syntax Trees.
LECTURE 2 Python Basics. MODULES So, we just put together our first real Python program. Let’s say we store this program in a file called fib.py. We have.
Dr. Philip Cannata 1 Functions and Recursion Programming Languages.
Winter 2016CISC101 - Prof. McLeod1 CISC101 Reminders Quiz 3 next week. See next slide. Both versions of assignment 3 are posted. Due today.
Semantic Analysis. Find 6 problems with this code. These issues go beyond syntax.
Dr. Philip Cannata 1 Names, Types, and Functions standard hue names.
01 – Overview of Compilers
Reminder About Functions
Programming Languages
Lecture 2 Python Basics.
CS 3304 Comparative Languages
6.001 Jeopardy.
Introduction Python is an interpreted, object-oriented and high-level programming language, which is different from a compiled one like C/C++/Java. Its.
An Attribute Grammar for Tiny
Tutorial Lecture for EE562 Artificial Intelligence for Engineers
PLAI Types Chapters 24 – 30 Types, Type Judgments, Type Systems and Type Safety - Chapters Type Inference – Chapter 30.
Is everyone signed up on piazza?
Programming Languages
First Python Program Professor Hugh C. Lauer CS-1004 — Introduction to Programming for Non-Majors (Slides include materials from Python Programming: An.
Group Project Justin Hust Ethan Petuchowski Simon Doty
CSC1018F: Intermediate Python
3.4 Local Binding Recall Scheme's let: > (let ((x 5)‏ (y 6))
CS 153: Concepts of Compiler Design October 30 Class Meeting
Review Session Biggest discrepancy questions
Intermediate Representations Hal Perkins Autumn 2005
Bottom-up derivation tree generation
Names, Types, and Functions
Assignments and Procs w/Params
Programming Languages
Functions John R. Woodward.
Control 9 / 25 / 19.
Presentation transcript:

Dr. Philip Cannata 1 with ReL

Dr. Philip Cannata 2 10 Java (Object Oriented) ASP RDF (Horn Clause Deduction, Semantic Web) Relation Jython in Java This Course High Level Languages

Dr. Philip Cannata 3 svn co jythonhttps://jython.svn.sourceforge.net/svnroot/jython/trunk/jython ant. BUILD SUCCESSFUL Total time: 46 seconds dist/bin/jython Jython 2.6a0+ (trunk:7292M, Sep , 21:48:21) [Java HotSpot(TM) 64-Bit Server VM (Apple Inc.)] on java1.6.0_33 Type "help", "copyright", "credits" or "license" for more information. >>> >>> quit() Download and build Jython

Dr. Philip Cannata 4 A grammar file for the python language –./grammar/python.g Java classes that get instantiated as nodes on the Abstract Syntax Tree –./src/org/python/antlr/ast A way of printing the Abstract Syntax Tree –./dist/bin/jython ast/astview.py file.py Visitor classes for the interpreter –./org/python/antlr/ast/VisitorBase.java./org/python/antlr/ast/VisitorIF.java./org/python/antlr/Visitor.java A way to hook into the visitor’s process of setting up the runtime stack –./org/python/compiler/Code.java./org/python/compiler/CodeCompiler.java A way to work with the results from the jython interpreter – an example that we’ll use a lot is./org/python/core/PyTuple.java What would you expect to find in Jython

Dr. Philip Cannata 5 # Download ReL.zip from the class website to../../Download/ReL.zip cp -R../ReL/*. ant. BUILD SUCCESSFUL Total time: 46 seconds dist/bin/jython Jython 2.6a0+ (trunk:7292M, Sep , 21:48:21) [Java HotSpot(TM) 64-Bit Server VM (Apple Inc.)] on java1.6.0_33 Type "help", "copyright", "credits" or "license" for more information. >>> >>> quit() Overlay ReL code on top of Jython

Dr. Philip Cannata 6 ('body', ('BinOp (6,59)', ('left', ('Name (6,59)', ('id', 'x'), ('ctx', ('Load',)))), ('op', ('Add',)), ('right', ('Num (6,61)', ('n', 1))))))), ('args', ('Num (6,65)', ('n', 4))), ('keywords',), ('starargs', None), ('kwargs', None)), ('Name (6,69)', ('id', 'i'), ('ctx', ('Load',))), ('Name (6,72)', ('id', 'x'), ('ctx', ('Load',)))), ('ctx', ('Load',)))))), ('orelse',)), ('Print (7,0)', ('dest', None), ('values', ('Tuple (7,7)', ('elts',), ('ctx', ('Load',)))), ('nl', True)), ('Print (8,0)', ('dest', None), ('values', ('Tuple (8,7)', ('elts',), ('ctx', ('Load',)))), ('nl', True)), ('Print (9,0)', ('dest', None), ('values', ('Tuple (9,7)', ('elts', ('Name (9,52)', ('id', 'x'), ('ctx', ('Load',)))), ('ctx', ('Load',)))), ('nl', True)))) $ cat tests/demo.py ; dist/bin/jython ast/astview.py tests/demo.py MAKECONNECT URL UNAME cs345_50 PWORD cs345_50p; DROP TABLE NEWTEST1; # CREATE TABLE NEWTEST1 (VAL1 NUMBER, VAL2 NUMBER, VAL3 NUMBER); x=3 for i in [2, 4, 7]: INSERT INTO NEWTEST1 (VAL1, VAL2, VAL3) VALUES ((lambda x:x+1) (4), i, x); print (SELECT * FROM NEWTEST1;) print (SELECT VAL2 FROM NEWTEST1;) print (SELECT VAL1, VAL2 FROM NEWTEST1 WHERE VAL3 = x;) ('Module', ('body', ('Expr (1,0)', ('value', ('Connection (1,0)', ('elts',), ('ctx', ('Load',))))), ('Expr (2,0)', ('value', ('Tuple (2,0)', ('elts',), ('ctx', ('Load',))))), ('Assign (4,0)', ('targets', ('Name (4,0)', ('id', 'x'), ('ctx', ('Store',)))), ('value', ('Num (4,2)', ('n', 3)))), ('For (5,0)', ('target', ('Name (5,4)', ('id', 'i'), ('ctx', ('Store',)))), ('iter', ('List (5,9)', ('elts', ('Num (5,10)', ('n', 2)), ('Num (5,13)', ('n', 4)), ('Num (5,16)', ('n', 7))), ('ctx', ('Load',)))), ('body', ('Expr (6,1)', ('value', ('Tuple (6,1)', ('elts', ('Call (6,49)', ('func', ('Lambda (6,50)', ('args', ('arguments', ('args', ('Name (6,57)', ('id', 'x'), ('ctx', ('Param',)))), ('vararg', AST

Dr. Philip Cannata 7 MAKECONNECT – Python.g

Dr. Philip Cannata 8 MAKECONNECT– Python.g

Dr. Philip Cannata 9 MAKECONNECT– Python.g

Dr. Philip Cannata 10 MAKECONNECT– Python.g

Dr. Philip Cannata 11 MAKECONNECT– Python.g

Dr. Philip Cannata 12 MAKECONNECT– Python.g

Dr. Philip Cannata 13 Connection.java

Dr. Philip Cannata 14 Connection.java

Dr. Philip Cannata 15 VisitorBase.java

Dr. Philip Cannata 16 VisitorIF.java

Dr. Philip Cannata 17 Code.java

Dr. Philip Cannata 18 CodeCompiler.java

Dr. Philip Cannata 19 CodeCompiler.java

Dr. Philip Cannata 20 CodeCompiler.java

Dr. Philip Cannata 21 SELECT– Python.g

Dr. Philip Cannata 22 SELECT– Python.g

Dr. Philip Cannata 23 Tuple.java and PyTuple.java fjyswan files $ find. -type f -print./build.xml./extlibs/jsqlparser./extlibs/jsqlparser.jar./extlibs/META-INF./extlibs/ojdbc6.jar./fjyswanreadme.txt./grammar/Python.g./src/org/python/antlr/ast/Connection.java./src/org/python/antlr/ast/Tuple.java./src/org/python/antlr/ast/VisitorBase.java./src/org/python/antlr/ast/VisitorIF.java./src/org/python/compiler/Code.java./src/org/python/compiler/CodeCompiler.java./src/org/python/core/PyTuple.java./tests/astdemo.py./tests/demo.py

Dr. Philip Cannata 24 Tuple.java

Dr. Philip Cannata 25 Tuple.java

Dr. Philip Cannata 26 CodeCompiler.java

Dr. Philip Cannata 27 PyTuple.java

Dr. Philip Cannata 28 PyTuple.java

Dr. Philip Cannata 29 PyTuple.java

Dr. Philip Cannata 30 PyTuple.java

Dr. Philip Cannata 31 PyTuple.java Continues until line 319

Dr. Philip Cannata 32 $ dist/bin/jython tests/demo.py DROP TABLE NEWTEST1 INSERT INTO NEWTEST1 (VAL1, VAL2, VAL3) VALUES (5, 2, 3) INSERT INTO NEWTEST1_RDF_DATA VALUES (1, SDO_RDF_TRIPLE_S('NEWTEST1_CS345_RICK', ' ' ' INSERT INTO NEWTEST1_RDF_DATA VALUES (2, SDO_RDF_TRIPLE_S('NEWTEST1_CS345_RICK', ' ' ' INSERT INTO NEWTEST1_RDF_DATA VALUES (3, SDO_RDF_TRIPLE_S('NEWTEST1_CS345_RICK', ' ' ' INSERT INTO NEWTEST1 (VAL1, VAL2, VAL3) VALUES (5, 4, 3) INSERT INTO NEWTEST1_RDF_DATA VALUES (4, SDO_RDF_TRIPLE_S('NEWTEST1_CS345_RICK', ' ' ' INSERT INTO NEWTEST1_RDF_DATA VALUES (5, SDO_RDF_TRIPLE_S('NEWTEST1_CS345_RICK', ' ' ' INSERT INTO NEWTEST1_RDF_DATA VALUES (6, SDO_RDF_TRIPLE_S('NEWTEST1_CS345_RICK', ' ' ' INSERT INTO NEWTEST1 (VAL1, VAL2, VAL3) VALUES (5, 7, 3) INSERT INTO NEWTEST1_RDF_DATA VALUES (7, SDO_RDF_TRIPLE_S('NEWTEST1_CS345_RICK', ' ' ' INSERT INTO NEWTEST1_RDF_DATA VALUES (8, SDO_RDF_TRIPLE_S('NEWTEST1_CS345_RICK', ' ' ' INSERT INTO NEWTEST1_RDF_DATA VALUES (9, SDO_RDF_TRIPLE_S('NEWTEST1_CS345_RICK', ' ' ' Interpretation output

Dr. Philip Cannata 33 SELECT * FROM NEWTEST1 SELECT sub, pred, obj FROM TABLE(SEM_MATCH('(?sub ?pred ?obj)', SEM_Models('NEWTEST1_CS345_RICK'), null, SEM_ALIASES(SEM_ALIAS('',' null)) (('SUB', 'PRED', 'OBJ'), (' ' ' (' WTEST1/1', ' ' (' ' ' (' ' ' (' rg/NEWTEST1/2', ' ' (' ' 3', ' (' ' ' (' ple.org/NEWTEST1/3', ' ' (' ' 1/VAL3', ' SELECT VAL2 FROM NEWTEST1 SELECT b FROM TABLE(SEM_MATCH('(?sub :VAL2 ?b)', SEM_Models('NEWTEST1_CS345_RICK'), null, SEM_ALIASES(SEM_ALIAS('',' null)) (('B',), (' (' (' SELECT VAL1, VAL2 FROM NEWTEST1 WHERE VAL3 = 3 SELECT b, c FROM TABLE(SEM_MATCH('(?sub :VAL1 ?b) (?sub :VAL2 ?c) (?sub :VAL3 :3)', SEM_Models('NEWTEST1_CS345_RICK'), null, SEM_ALIASES(SEM_ALIAS('',' null)) (('B', 'C'), (' ' (' ' ('w ww.example.org/NEWTEST1/5', ' SQLSPARQL