Skip to content

Commit

Permalink
Rename to pythonparser (pyparser is occupied in pypi).
Browse files Browse the repository at this point in the history
whitequark committed May 25, 2015
1 parent 9ffba43 commit 5f65387
Showing 20 changed files with 53 additions and 53 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -4,5 +4,5 @@ _build/
*.egg-info/
/build/
/dist/
/pyparser/coverage/parser.py
/pythonparser/coverage/parser.py
/doc/coverage/*
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
See http://m-labs.hk/pyparser/.
See http://m-labs.hk/pythonparser/.
60 changes: 30 additions & 30 deletions doc/index.rst
Original file line number Diff line number Diff line change
@@ -1,68 +1,68 @@
PyParser documentation
======================
PythonParser documentation
==========================

PyParser is a Python parser written specifically for use in tooling.
PythonParser is a Python parser written specifically for use in tooling.
It parses source code into an AST that is a superset of Python's
built-in :mod:`ast` module, but returns precise location information
for every token.

The most useful APIs of PyParser are :meth:`pyparser.parse`,
which parses the source, :mod:`pyparser.ast`, which provides access
The most useful APIs of PyParser are :meth:`pythonparser.parse`,
which parses the source, :mod:`pythonparser.ast`, which provides access
to the semantic and location information in the AST, and
:mod:`pyparser.diagnostic.Engine`, which provides a unified way
:mod:`pythonparser.diagnostic.Engine`, which provides a unified way
to report errors and warnings both to PyParser itself and to any
code that consumes the ASTs. The :class:`pyparser.source.Range` class,
code that consumes the ASTs. The :class:`pythonparser.source.Range` class,
instances of which are contained in the AST, allows to extract
location information in various convenient formats.

The :mod:`pyparser.algorithm` module contains some useful algorithms
The :mod:`pythonparser.algorithm` module contains some useful algorithms
to manipulate ASTs.

If a consumer of ASTs wishes to modify the original source without
losing formatting, it can use :class:`pyparser.source.Rewriter`
losing formatting, it can use :class:`pythonparser.source.Rewriter`
to insert code fragments around or instead of a known
:class:`pyparser.source.Range`. If the AST is not expected to
:class:`pythonparser.source.Range`. If the AST is not expected to
change after the modification, it is recommended to re-parse
the result and compare it to the original AST using
:meth:`pyparser.algorithm.compare`.
:meth:`pythonparser.algorithm.compare`.

For some applications, e.g. syntax highlighting,
:class:`pyparser.lexer.Lexer` will be able to provide a raw
:class:`pythonparser.lexer.Lexer` will be able to provide a raw
stream of tokens.

PyParser is licensed under 3-clause BSD.

:mod:`pyparser` Module
----------------------
:mod:`pythonparser` Module
--------------------------

.. automodule:: pyparser
.. automodule:: pythonparser
:members:

:mod:`pyparser.source` Module
-----------------------------
:mod:`pythonparser.source` Module
---------------------------------

.. automodule:: pyparser.source
.. automodule:: pythonparser.source
:members:
:show-inheritance:

:mod:`pyparser.diagnostic` Module
---------------------------------
:mod:`pythonparser.diagnostic` Module
-------------------------------------

.. automodule:: pyparser.diagnostic
.. automodule:: pythonparser.diagnostic
:members:
:show-inheritance:

:mod:`pyparser.lexer` Module
----------------------------
:mod:`pythonparser.lexer` Module
--------------------------------

.. automodule:: pyparser.lexer
.. automodule:: pythonparser.lexer
:members:
:show-inheritance:

:mod:`pyparser.ast` Module
--------------------------
:mod:`pythonparser.ast` Module
------------------------------

.. automodule:: pyparser.ast
.. automodule:: pythonparser.ast
:members: commonloc, beginendloc, keywordloc,
AST,
alias,
@@ -87,9 +87,9 @@ PyParser is licensed under 3-clause BSD.
withitem
:show-inheritance:

:mod:`pyparser.algorithm` Module
--------------------------------
:mod:`pythonparser.algorithm` Module
------------------------------------

.. automodule:: pyparser.algorithm
.. automodule:: pythonparser.algorithm
:members:
:show-inheritance:
2 changes: 1 addition & 1 deletion examples/quot_to_dquot.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys, re
from pyparser import source, lexer
from pythonparser import source, lexer

buf = None
with open(sys.argv[1]) as f:
10 changes: 5 additions & 5 deletions pyparser/__init__.py → pythonparser/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from __future__ import absolute_import, division, print_function, unicode_literals
import sys, pyparser.source, pyparser.lexer, pyparser.parser, pyparser.diagnostic
import sys, pythonparser.source, pythonparser.lexer, pythonparser.parser, pythonparser.diagnostic

def parse(source, filename='<unknown>', mode='exec',
flags=[], version=None, engine=None):
@@ -28,15 +28,15 @@ def parse(source, filename='<unknown>', mode='exec',
version = sys.version_info[0:2]

if engine is None:
engine = pyparser.diagnostic.Engine()
engine = pythonparser.diagnostic.Engine()

buffer = pyparser.source.Buffer(source, filename)
buffer = pythonparser.source.Buffer(source, filename)

lexer = pyparser.lexer.Lexer(buffer, version, engine)
lexer = pythonparser.lexer.Lexer(buffer, version, engine)
if mode in ('single', 'eval'):
lexer.interactive = True

parser = pyparser.parser.Parser(lexer, version, engine)
parser = pythonparser.parser.Parser(lexer, version, engine)
parser.add_flags(flags)

if mode == 'exec':
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -175,6 +175,6 @@ def report(parser, name='parser'):
file=os.path.basename(_buf.name),
content=content))

# Create the instrumented parser when `import pyparser.coverage.parser`
# Create the instrumented parser when `import pythonparser.coverage.parser`
# is invoked. Not intended for any use except running the internal testsuite.
instrument()
4 changes: 2 additions & 2 deletions pyparser/diagnostic.py → pythonparser/diagnostic.py
Original file line number Diff line number Diff line change
@@ -14,9 +14,9 @@ class Diagnostic:
:ivar level: (one of ``LEVELS``) severity level
:ivar reason: (format string) diagnostic message
:ivar arguments: (dictionary) substitutions for ``reason``
:ivar location: (:class:`pyparser.source.Range`) most specific
:ivar location: (:class:`pythonparser.source.Range`) most specific
location of the problem
:ivar highlights: (list of :class:`pyparser.source.Range`)
:ivar highlights: (list of :class:`pythonparser.source.Range`)
secondary locations related to the problem that are
likely to be on the same line
:ivar notes: (list of :class:`Diagnostic`)
12 changes: 6 additions & 6 deletions pyparser/lexer.py → pythonparser/lexer.py
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ class Token:
The :class:`Token` encapsulates a single lexer token and its location
in the source code.
:ivar loc: (:class:`pyparser.source.Range`) token location
:ivar loc: (:class:`pythonparser.source.Range`) token location
:ivar kind: (string) token kind
:ivar value: token value; None or a kind-specific class
"""
@@ -29,15 +29,15 @@ def __repr__(self):
class Lexer:
"""
The :class:`Lexer` class extracts tokens and comments from
a :class:`pyparser.source.Buffer`.
a :class:`pythonparser.source.Buffer`.
:class:`Lexer` is an iterable.
:ivar version: (tuple of (*major*, *minor*))
the version of Python, determining the grammar used
:ivar source_buffer: (:class:`pyparser.source.Buffer`)
:ivar source_buffer: (:class:`pythonparser.source.Buffer`)
the source buffer
:ivar diagnostic_engine: (:class:`pyparser.diagnostic.Engine`)
:ivar diagnostic_engine: (:class:`pythonparser.diagnostic.Engine`)
the diagnostic engine
:ivar offset: (integer) character offset into ``source_buffer``
indicating where the next token will be recognized
@@ -118,7 +118,7 @@ def __init__(self, source_buffer, version, diagnostic_engine, interactive=False)
try:
reserved = self._reserved[version]
except KeyError:
raise NotImplementedError("pyparser.lexer.Lexer cannot lex Python %s" % str(version))
raise NotImplementedError("pythonparser.lexer.Lexer cannot lex Python %s" % str(version))

# Sort for the regexp to obey longest-match rule.
re_reserved = sorted(reserved, reverse=True, key=len)
@@ -207,7 +207,7 @@ def next(self, eof_token=False):
Returns token at ``offset`` as a :class:`Token` and advances ``offset``
to point past the end of the token, where the token has:
- *range* which is a :class:`pyparser.source.Range` that includes
- *range* which is a :class:`pythonparser.source.Range` that includes
the token but not surrounding whitespace,
- *kind* which is a string containing one of Python keywords or operators,
``newline``, ``float``, ``int``, ``complex``, ``strbegin``,
2 changes: 1 addition & 1 deletion pyparser/parser.py → pythonparser/parser.py
Original file line number Diff line number Diff line change
@@ -454,7 +454,7 @@ def _init_version(self, version):
self.yield_expr = self.yield_expr__33
return

raise NotImplementedError("pyparser.parser.Parser cannot parse Python %s" %
raise NotImplementedError("pythonparser.parser.Parser cannot parse Python %s" %
str(version))

def _arguments(self, args=None, defaults=None, kwonlyargs=None, kw_defaults=None,
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -9,23 +9,23 @@ def initialize_options(self):
def finalize_options(self):
pass
def run(self):
os.system('rsync -avz doc/_build/html/ shell.serverraum.org:~/web/m-labs.hk/pyparser')
os.system('rsync -avz doc/_build/html/ shell.serverraum.org:~/web/m-labs.hk/pythonparser')

setup(
name="pyparser",
name="pythonparser",
version="0.0+dev",
author="whitequark",
author_email="whitequark@whitequark.org",
url="http://m-labs.hk/pyparser",
url="http://m-labs.hk/pythonparser",
description="A Python parser intended for use in tooling",
long_description=open("README.rst").read(),
long_description=open("README.md").read(),
license="BSD",
install_requires=['regex'],
extras_require={},
dependency_links=[],
packages=find_packages(exclude=['tests*']),
namespace_packages=[],
test_suite="pyparser.test",
test_suite="pythonparser.test",
package_data={},
ext_modules=[],
entry_points={},

0 comments on commit 5f65387

Please sign in to comment.