Looking for a parser for QML-format files [closed]
We don’t allow questions seeking 开发者_如何学Pythonrecommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this questionI need to do some static analysis of QML-format files (wiki), but I can't find any parsers for them. The only way I see is to reuse source code of the Qt Declarative module or write my own parser. I can't find anything on the web. Can anyone point me to some tool, converter to XML or Perl/Python module to easily parse elements from QML files?
Thanks a lot for your help!
The parser in qt-declarative is in src/qml/qml/parser, and a big part of it is generated with qlalr (same place as the previous link, but with qlalr instead of qtdeclarative). You might want also to look at the parser used in qt-creator src/libs/qmljs/parser which is derived from the qt-declarative one.
You could look at the source code of the QML Viewer that comes with the SDK. The source code is available on Gitorious. QML Viewer code is in C++ not Python nor Perl.
Another possible solution, to use Python with no dependencies with Qt, is to use a standard Javascript parser and modify it so it can understand QML. From the wiki link you provided :
Because QML and JavaScript are very similar almost all code editors supporting JavaScript will do the job.
I found pynarcissus which is a Javascript interpreter in Python. May be you could modify it slightly so it can interprete corretly QML files?
精彩评论