A Move Parser
Project description
Marso is a Move language parser that supports error recovery and round-trip parsing . Marso is also able to list multiple syntax errors in your move source file.
Marso has been battle-tested by jedi.
Marso consists of a small API to parse Move language and analyse the syntax tree.
A simple example:
>>> import marso
>>> module = marso.parse('hello + 1', version="3.6")
>>> expr = module.children[0]
>>> expr
PythonNode(arith_expr, [<Name: hello@1,0>, <Operator: +>, <Number: 1>])
>>> print(expr.get_code())
hello + 1
>>> name = expr.children[0]
>>> name
<Name: hello@1,0>
>>> name.end_pos
(1, 5)
>>> expr.end_pos
(1, 9)
To list multiple issues:
>>> grammar = marso.load_grammar()
>>> module = grammar.parse('foo +\nbar\ncontinue')
>>> error1, error2 = grammar.iter_errors(module)
>>> error1.message
'SyntaxError: invalid syntax'
>>> error2.message
"SyntaxError: 'continue' not properly in loop"
Resources
Installation
pip install marso
Acknowledgements
David Halter (@davidhalter) for the original Parso project.
Guido van Rossum (@gvanrossum) for creating the parser generator pgen2 (originally used in lib2to3).
Changelog
0.0.1 (2020-05-29)
Test publish as a pip package, not work yet.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
marso-0.0.1.tar.gz
(369.9 kB
view hashes)
Built Distribution
marso-0.0.1-py2.py3-none-any.whl
(89.4 kB
view hashes)
Close
Hashes for marso-0.0.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f95e86a2a03dff4b30cc612c7e7d08430df6d00e20c7801914cbe4050204944b |
|
MD5 | b983410ac86998d14cb2aa007d04608d |
|
BLAKE2b-256 | 4e918c9f5688ba999595c4b10dde12cc2572a2ea9fc140a878890a98ed45dd56 |