I would be interested in somehow getting an AST for a QML JS function, is there anything in the Qt stack that I could use for that?
Any tips for this outside Qt? I see there are some open-source parsers for JS written in JS, I might try some of those if necessary.
Do you mean something like esprima ?
Also I am wondering if it is really so that no tool in the Qt stack really produces an AST for JS or QML+JS? If I have understood correctly it might be indeed so that this stuff is generated straight into bytecode instructions or so on.
AFAIK, no. QML is backed by a dedicated engine. You can see this in the qtdeclarative module.
I am currently using Esprima, running on Node.js, via XmlHttpRequest. Was easy to setup.
Found a "hack" to integrate esprima to the build somewhat easily: By using QML WebView that loads a resource-included html page that includes the resource-included esprima.js file, and has some custom js functions to utilize it. The "experimental" features of WebView can be used to communicate with the js functions of the page -- or directly with esprima of course.
Simply importing esprima.js to a QML file does not work on Qt 5.4 (not sure about later versions), as there seems to be some problems with the parsing. It seems, however, that the WV engine can utilize it, I think it uses V8 (likely does, as it is based on the Chromium project, if I have understood correctly).
Also, as a curiosity, I am using the esprima.js file that is fetched when you install the esprima module to a Node.js project with npm. This file is not present in this form in the Git repository.