Parser search for QML files

I need to do some static analysis of QML format files ( wiki ), but I can not find parsers for them. The only way I can see is to use the source code of the Qt Declarative module or write your own parser. I can not find anything on the Internet. Can someone tell me some tool, converter to XML or Perl / Python for easy parsing of elements from QML files?

Many thanks for your help!

+7
source share
2 answers

You can see the source code of the QML Viewer that comes with the SDK. Source code is available on Gitorious. The QML Viewer code is in C ++, not Python or Perl.

Another possible solution for using Python without dependencies with Qt is to use the standard Javascript parser and modify it so that it can understand QML. From the wiki link you provided:

Because QML and JavaScript are very similar, almost all JavaScript editors will do the job.

I found pynarcissus which is a Javascript interpreter in Python. Maybe you can change it a bit so that it can interpret the source QML files?

+3
source

The qt-declarative parser is in src / qml / qml / parser, and most of it is generated using qlalr (the same place as the previous link, but with qlalr instead of qtdeclarative). You can also look at the parser used in qt-creator src / libs / qmljs / parser, which is derived from qt-declarative.

+6
source

All Articles