idl2js
Grammar-based Fuzzer that uses WebIDL as a grammar.
Quick start
pip install idl2js
Build from source
Get source and install dependencies
git clone https://gitlab.com/PrVrSs/idl2js.git
cd idl2js
poetry install
Download ANTLR tool
wget https://www.antlr.org/download/antlr-4.10.1-complete.jar
Generate parser
make grammar
Run tests
make unit
Examples
import logging
from pathlib import Path
from pprint import pprint
from idl2js import InterfaceTarget, Transpiler
class Module(InterfaceTarget):
kind = 'Module'
class Global(InterfaceTarget):
kind = 'Global'
class Table(InterfaceTarget):
kind = 'Table'
class Memory(InterfaceTarget):
kind = 'Memory'
def main():
logging.getLogger('idl2js').setLevel(logging.DEBUG)
transpiler = Transpiler(
idls=(
str((Path(__file__).parent / 'webassembly.webidl').resolve()),
)
)
transpiler.transpile(
targets=[
Module,
Global,
Table,
Memory,
]
)
pprint(transpiler.js_instances)
if __name__ == '__main__':
main()
Output
try {v_0805c1325a3048aca879de7ce5f8c9a5 = new Int8Array()} catch(e){}
try {v_cfa435d6211f41df8a6af0a8543b3b37 = new WebAssembly.Module(v_0805c1325a3048aca879de7ce5f8c9a5)} catch(e){}
try {v_5deaeb375b774b54b6140be12322296a = {value: 'v128', mutable: true}} catch(e){}
try {v_788c98fd9d97444688f48fedb824130b = 'meoein'} catch(e){}
try {v_c3fcd21aecdd4ef6bb2060cbb0bd70fb = new WebAssembly.Global(v_5deaeb375b774b54b6140be12322296a, v_788c98fd9d97444688f48fedb824130b)} catch(e){}
try {v_73a4bd166ae34681a13acc70c2a67876 = {element: 'anyfunc', initial: 290477176, maximum: 3297392043}} catch(e){}
try {v_061571cb277b42beb33546c8d8c3ed07 = 'pahfbx'} catch(e){}
try {v_0c4bc44857394e40a9ade62f0eaadfca = new WebAssembly.Table(v_73a4bd166ae34681a13acc70c2a67876, v_061571cb277b42beb33546c8d8c3ed07)} catch(e){}
try {v_06ab1c4441d543ae8d4289c13a07c895 = {initial: 2477011723, maximum: 3809510539}} catch(e){}
try {v_5e251ff6ba8647e48a2d633ba42386f8 = new WebAssembly.Memory(v_06ab1c4441d543ae8d4289c13a07c895)} catch(e){}
Links
- searchfox - webidl
- original webidl parser
- TSJS-lib-generator
- ECMAScript® 2021 Language Specification
- Web IDL
- Web IDL Spec
Contributing
Any help is welcome and appreciated.
License
idl2js is licensed under the terms of the Apache-2.0 License (see the file LICENSE).
Release files for idl2js 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| idl2js-0.1.3.tar.gz | 195.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| idl2js-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 315.0 kB
Release files / idl2js-0.1.3.tar.gz
| Download URL | idl2js-0.1.3.tar.gz |
|---|---|
| Size | 195.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
47f21ffe13453c7f43dc721876e7bd8cef83087ea2323dedd01f806a101da091
|
|
BLAKE2b-256 checksum How to use checksums |
e22f5e2f44f14738120bb9d699655aec17f44ccf8b2d5ac923272f67c756ef66
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.10.4 Linux/5.13.0-39-generic
|
Release files / idl2js-0.1.3-py3-none-any.whl
| Download URL | idl2js-0.1.3-py3-none-any.whl |
|---|---|
| Size | 119.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3372a3dd0929489224e4338683bd29c6095c2f4017a8075eb34a3e7e158cffcd
|
|
BLAKE2b-256 checksum How to use checksums |
eaa5f3d9b541e751e2c7c3eb0d18dd88043c2bfa879c6cec1b496cb3d3b9686d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.10.4 Linux/5.13.0-39-generic
|