This is a tool for the Web IDL language.
pip install pywebidl2
Usage: pywebidl2 [OPTIONS] FILE
Options:
-a, --action [parse|validate]
--help Show this message and exit.
Download ANTLR4 tool
make parser
make test
from pprint import pprint
from pywebidl2 import parse
idl = '''
interface B {
void g([AllowAny] DOMString s);
};
'''
pprint(parse(idl))
[
{
"type": "interface",
"name": "B",
"inheritance": null,
"members": [
{
"type": "operation",
"name": "g",
"idl_type": {
"type": "return-type",
"ext_attrs": [],
"generic": "",
"nullable": false,
"union": false,
"idl_type": "void"
},
"arguments": [
{
"type": "argument",
"name": "s",
"ext_attrs": [
{
"type": "extended-attribute",
"name": "AllowAny",
"rhs": null,
"arguments": []
}
],
"idl_type": {
"type": "argument-type",
"ext_attrs": [],
"generic": "",
"nullable": false,
"union": false,
"idl_type": "DOMString"
},
"default": null,
"optional": false,
"variadic": false
}
],
"ext_attrs": [],
"special": ""
}
],
"ext_attrs": [],
"partial": false
}
]
See original parser
Any help is welcome and appreciated.
pywebidl2 is licensed under the terms of the MIT License (see the file LICENSE).