[x3d-public] JavaScript Python parser in ANTLR 4.7 anyone?

John Carlson yottzumm at gmail.com
Sun Apr 28 16:51:48 PDT 2019


Here’s the Python grammar for JS languages, I guess.

https://github.com/antlr/grammars-v4/blob/master/python3-js/Python3.g4

John
Sent from Mail for Windows 10

From: John Carlson
Sent: Sunday, April 28, 2019 6:34 PM
To: X3D Graphics public mailing list; Don Brutzman; aono at tut.jp; Andreas Plesch; Holger Seelig; myeongwonlee at gmail.com; Richard F. Puk
Subject: JavaScript Python parser in ANTLR 4.7 anyone?

Is anyone interested or is willing to contribute a Python X3D encoding (subset of Python limited to SAI-like constructor, set and add methods, property access, initialize with kwargs and simple assignment) to DOM translator using ANTLR 4.7 JavaScript based parser? We already have Python/Java solution which creates a DOM from an X3D API. I’d like to create an ANLTR grammar and API (SAX-like listeners and visitors) for just parsing Python scenegraphs using JavaScript for listener and visitor methods called by the parser to generate X3DOM/HTML DOM. I think this is possible, I just haven’t proved it yet.  That will keep me free of Java, XSLT and server-side code, and allow me to render Python code successfully to the web using X3DOM and X3DJSONLD, but without the full power of python.  If you want to the full power of X3DJSAIL with Python, use the pyjnius plugin (we do this already) with the exact same program!  There is no “Python/ANTLR” that I know of, but there is a “C++/C# ANTLR” You are welcome to use the latter for prototyping, but we want to focus on the JavaScript version of ANTLR and use X3DOM.   I am willing to convert programming language stuff to JavaScript, but one should make the grammars programming language independent.  You are also welcome to look at Python parser-generators as a replacement for ANTLR (good luck, I think ANTLR is WAY ahead).

Other solutions may be discussed.   This may already be in progress.   We will start work after the 5pm PST meeting Monday if everyone approves.

The code name for this effort is X3DPynt.  Cheers.  I have already “approved” this project with Don, but I think he wants me to pulse community efforts.

Suggestions for building ANTLR grammar are welcome.  Grammar generation from X3DUOM is probably likely.

Jeff, this parser will satisfy “building XML in python,” I think.  We’re merely writing an python interpreter in written and generated JavaScript to generate DOM from Python (replace whole scenegraph with a new scene).  I would now like to divert your efforts to writing a python parser (grammar and listener/visitor bodies) to generated DOM, “code generator”.  This will likely be quite a bit simpler, I think.   We don’t want a full bore Python yet, just a Python “lite” parser.

Please discuss your availability and any ideas you have.  We have a meeting at 8pm EST your time on 4/29.  I think the Python implementation will be discussed in addition to C, C++, C# APIS.  I will show you the various styles of python we generate (4-6+).    We’d like to have one python parser besides CPython, something in the web.  Snippets the DOM will be returned by visitors/listeners to generate the new structure.

The author of Python and the author of Objective-C both praise ANTLR. Eric Schmidt has worked with ANTLR in school.

When football season rolls around, we’ll have to have a reason to create X3DPunt. LOL

I suggest we use this to import Python into X_ITE, and X3DOM similar to the JSON parser.  Or add it in optional JS.

One may also want to consider Java or CIL bytecode targeted conversions.
A goal is to get an X3DOM animated scene into Jupyter Notebook.  I know how to it as a string, so our next goal is to get the DOM serialized to a XML string (I have code for this—focus on returning DOM from the parser).

Thanks,

John


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20190428/5ad2ce3e/attachment-0001.html>


More information about the x3d-public mailing list