Derived from:
Created via this link.
XDress completely outsources the task of parsing source code to other projects. It mostly outsources the syntax tree too.
Parses that XDress supports currently are:
This tactic of relying on external parsers enables flexibility w.r.t. the source language.
To keep them as a portable as possible, they are nothing fancy.
In memory descriptions (desc) are just Python strings, ints, dicts, tuples, lists, and other built-in types. They can easily be translated into a JSON format.
Code is generated from descriptions of API elements to produce idomatic Python wrappers.
brienne_desc = {
'name': 'Brienne',
'parents': ['LordSelwyn'],
'namespace': 'westeros',
'attrs': {'moniker': 'str'},
'methods': {
('Brienne',): None,
('Brienne', ('monkier', 'str', '"Maid of Tarth"')): None,
('~Brienne',): None,
('attack', ('person', ('char' '*'), ('weapon_id', 'i2', 1))): 'float32',
},
'docstrings': {
'class': "I am so tall!",
'attrs': {
'monkier': 'extra name for character',
},
'methods': {
'attack': "Attack someone with a weapon and returns damage."
},
},
'extra': {},
}
They heavy lifting of the API decsriptions is done by the type system.
The primary one is called cythongen and targets Python via Cython.