https://github.com/lfkdsk/parso-source-code-analyse
https://github.com/lfkdsk/parso-source-code-analyse
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/lfkdsk/parso-source-code-analyse
- Owner: lfkdsk
- License: other
- Created: 2018-01-31T17:11:17.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-01T03:04:05.000Z (almost 8 years ago)
- Last Synced: 2025-04-03T16:54:44.687Z (9 months ago)
- Language: Python
- Size: 382 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG.rst
- Contributing: CONTRIBUTING.md
- License: LICENSE.txt
- Authors: AUTHORS.txt
Awesome Lists containing this project
README
###################################################################
parso - A Python Parser Code Analyse
###################################################################
.. image:: https://secure.travis-ci.org/davidhalter/parso.png?branch=master
:target: http://travis-ci.org/davidhalter/parso
:alt: Travis-CI build status
.. image:: https://coveralls.io/repos/davidhalter/parso/badge.png?branch=master
:target: https://coveralls.io/r/davidhalter/parso
:alt: Coverage Status
.. image:: https://raw.githubusercontent.com/davidhalter/parso/master/docs/_static/logo_characters.png
Parso is a Python parser that supports error recovery and round-trip parsing
for different Python versions (in multiple Python versions). Parso is also able
to list multiple syntax errors in your python file.
Parso has been battle-tested by jedi_. It was pulled out of jedi to be useful
for other projects as well.
Parso consists of a small API to parse Python and analyse the syntax tree.
A simple example:
.. code-block:: python
>>> import parso
>>> module = parso.parse('hello + 1', version="3.6")
>>> expr = module.children[0]
>>> expr
PythonNode(arith_expr, [, , ])
>>> print(expr.get_code())
hello + 1
>>> name = expr.children[0]
>>> name
>>> name.end_pos
(1, 5)
>>> expr.end_pos
(1, 9)
To list multiple issues:
.. code-block:: python
>>> grammar = parso.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
=========
- `Testing `_
- `PyPI `_
- `Docs `_
- Uses `semantic versioning `_
Installation
============
pip install parso
Future
======
- There will be better support for refactoring and comments. Stay tuned.
- There's a WIP PEP8 validator. It's however not in a good shape, yet.
Known Issues
============
- `async`/`await` are already used as keywords in Python3.6.
- `from __future__ import print_function` is not ignored.
Acknowledgements
================
- Guido van Rossum (@gvanrossum) for creating the parser generator pgen2
(originally used in lib2to3).
- `Salome Schneider `_
for the extremely awesome parso logo.
.. _jedi: https://github.com/davidhalter/jedi