![Page 1: 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](https://reader036.vdocument.in/reader036/viewer/2022062409/56649f305503460f94c4a270/html5/thumbnails/1.jpg)
Mitchell McMullenPaul Nguyen
SWA
N
![Page 2: 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](https://reader036.vdocument.in/reader036/viewer/2022062409/56649f305503460f94c4a270/html5/thumbnails/2.jpg)
• Python written entirely in C#.• Can access all .NET libraries and
Silverlight.• Created by the same guy as Jython.• No design documentation or developer’s
guide for source code =(
![Page 3: 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](https://reader036.vdocument.in/reader036/viewer/2022062409/56649f305503460f94c4a270/html5/thumbnails/3.jpg)
IronPySwan• Added Oracle Database Connectivity.• Embedded SQL commands/queries.• Allows arbitrary python expressions within
SQL commands/queries. (Using back ticks)
![Page 4: 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](https://reader036.vdocument.in/reader036/viewer/2022062409/56649f305503460f94c4a270/html5/thumbnails/4.jpg)
Overview
![Page 5: 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](https://reader036.vdocument.in/reader036/viewer/2022062409/56649f305503460f94c4a270/html5/thumbnails/5.jpg)
Tokenizer
• Breaks up the source code into tokens.• IronPython uses a mostly hand-written
tokenizer and parser.• Some token recognition code is auto-
generated.
MAKECONNECT
INSERT
_________________
______________
![Page 6: 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](https://reader036.vdocument.in/reader036/viewer/2022062409/56649f305503460f94c4a270/html5/thumbnails/6.jpg)
Parser
• Identifies tokens as they come in.• Implements the Python (BNF) grammar directly.• Constructs the Python AST.
![Page 7: 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](https://reader036.vdocument.in/reader036/viewer/2022062409/56649f305503460f94c4a270/html5/thumbnails/7.jpg)
MSAstNode Declaration
• This is where a statement/expression is turned into a node fit for the AST.
• The statement/expression’s Reduce() method is called, which returns a simpler node.
• Typically, reduce() links to implementation code.
![Page 8: 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](https://reader036.vdocument.in/reader036/viewer/2022062409/56649f305503460f94c4a270/html5/thumbnails/8.jpg)
AstMethods
• Big collection of Method signatures, used for reflection/indirection to PythonOps.
Connection
Statement (Nonquery)
Expression (Query)
AstMethods
![Page 9: 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](https://reader036.vdocument.in/reader036/viewer/2022062409/56649f305503460f94c4a270/html5/thumbnails/9.jpg)
PythonOps
• Pretty much another layer of indirection, and a repository for some helper functions.
Connection
Statement (Nonquery)
Expression (Query)
![Page 10: 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](https://reader036.vdocument.in/reader036/viewer/2022062409/56649f305503460f94c4a270/html5/thumbnails/10.jpg)
Runtime Behavior
• This is the implementation-ey kind of stuff. In the end, this is where the heavy lifting for each method call is located.
• We have one class, PySwanSqlRunner, which houses the connection and passes the final SQL strings on to the database.
• These methods are executed by the interpreter.
![Page 11: 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](https://reader036.vdocument.in/reader036/viewer/2022062409/56649f305503460f94c4a270/html5/thumbnails/11.jpg)
PySwanSqlRunnerConnection
Statement (Nonquery)
Expression (Query)
![Page 12: 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](https://reader036.vdocument.in/reader036/viewer/2022062409/56649f305503460f94c4a270/html5/thumbnails/12.jpg)
Stuff That Still Really Needs Work
• Error handling is pretty primitive.• No RDF. (Sorry, Dr. Cannata!!)• SQL must be well-formed.
![Page 13: 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](https://reader036.vdocument.in/reader036/viewer/2022062409/56649f305503460f94c4a270/html5/thumbnails/13.jpg)
Programming Language Terms
• Terminal/Nonterminal (Tokenizer.cs).• Abstract Syntax Tree (Parser.cs).• Parse tree is implicitly built.
(Parser.cs)• Python.g BNF is implemented directly
(Parser.cs• Some SQL involved.
![Page 14: 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](https://reader036.vdocument.in/reader036/viewer/2022062409/56649f305503460f94c4a270/html5/thumbnails/14.jpg)
Demonstration
• Hope you enjoy!
![Page 15: 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](https://reader036.vdocument.in/reader036/viewer/2022062409/56649f305503460f94c4a270/html5/thumbnails/15.jpg)
Questions?