Skip to main content

WebIDL tool

Project description

pywebidl2

Build Status Codecov License Python Version

Description

This is a tool for the Web IDL language.

Quick start

pip install pywebidl2

Usage

Usage: pywebidl2 [OPTIONS] FILE

Options:
  -a, --action [parse|validate]
  --help                         Show this message and exit.

For Developer

Antlr4

Download ANTLR4 tool

Getting Started with ANTLR v4

Create a python parser and lexer.

make parser

Tests

make test

Example

Parser

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
    }
]

Documentation

See original parser

Contributing

Any help is welcome and appreciated.

License

pywebidl2 is licensed under the terms of the MIT License (see the file LICENSE).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pywebidl2-0.1.7.tar.gz (120.0 kB view hashes)

Uploaded Source

Built Distribution

pywebidl2-0.1.7-py3-none-any.whl (64.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page