From 57e8117374d0dd7227b3fbdf76c45fde67123951 Mon Sep 17 00:00:00 2001 From: Erez Shinan Date: Sat, 11 Feb 2017 11:12:15 +0200 Subject: [PATCH] Some package fixes --- docs/json_tutorial.md | 2 +- examples/calc.py | 3 +-- examples/json_parser.py | 4 +-- lark/__init__.py | 7 ++++- setup.py | 60 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 70 insertions(+), 6 deletions(-) create mode 100644 setup.py diff --git a/docs/json_tutorial.md b/docs/json_tutorial.md index 734a70b..b67907b 100644 --- a/docs/json_tutorial.md +++ b/docs/json_tutorial.md @@ -234,7 +234,7 @@ This is pretty close. Let's write a full transformer that can handle the tokens Also, our definitions of list and dict are a bit verbose. We can do better: ```python -from lark.tree import Transformer +from lark import Transformer class TreeToJson(Transformer): def string(self, (s,)): diff --git a/examples/calc.py b/examples/calc.py index bebb5a0..d53f393 100644 --- a/examples/calc.py +++ b/examples/calc.py @@ -1,5 +1,4 @@ -from lark.tree import InlineTransformer -from lark.lark import Lark +from lark import Lark, InlineTransformer calc_grammar = """ ?start: sum diff --git a/examples/json_parser.py b/examples/json_parser.py index 9e4b952..ca95e2d 100644 --- a/examples/json_parser.py +++ b/examples/json_parser.py @@ -1,6 +1,6 @@ import sys -from lark.lark import Lark, inline_args -from lark.tree import Transformer + +from lark import Lark, inline_args, Transformer json_grammar = r""" ?start: value diff --git a/lark/__init__.py b/lark/__init__.py index 11fc59f..1f221dd 100644 --- a/lark/__init__.py +++ b/lark/__init__.py @@ -1 +1,6 @@ -from .lark import Lark, Transformer +from .tree import Tree, Transformer, InlineTransformer +from .common import ParseError, GrammarError +from .lark import Lark +from .utils import inline_args + +__version__ = "0.1.0" diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..4e5f8db --- /dev/null +++ b/setup.py @@ -0,0 +1,60 @@ +import re +from setuptools import setup + +__version__ ,= re.findall('__version__ = "(.*)"', open('lark/__init__.py').read()) + +setup( + name = "lark-parser", + version = __version__, + packages = ['lark', 'tests', 'lark.parsers', 'examples', 'docs'], + + requires = [], + install_requires = [], + + package_data = { + '': ['*.md', '*.g'], + 'docs': ['*.png'], + }, + + # metadata for upload to PyPI + author = "Erez Shinan", + author_email = "erezshin@gmail.com", + description = "a modern parsing library", + license = "MIT", + keywords = "Earley LALR parser parsing ast", + url = "https://github.com/erezsh/lark", + download_url = "https://github.com/erezsh/lark/tarball/master", + long_description=''' +Lark is a modern general-purpose parsing library for Python. + +Lark focuses on simplicity and power. It lets you choose between two parsing algorithms: + +Earley : Parses all context-free grammars (even ambiguous ones)! It is the default. +LALR(1): Only LR grammars. Outperforms PLY and most if not all other pure-python parsing libraries. +Both algorithms are written in Python and can be used interchangably with the same grammar (aside for algorithmic restrictions). See "Comparison to other parsers" for more details. + +Lark can automagically build an AST from your grammar, without any more code on your part. + +Features: + +- EBNF grammar with a little extra +- Earley & LALR(1) +- Builds an AST automagically based on the grammar +- Automatic line & column tracking +- Automatic token collision resolution (unless both tokens are regexps) +- Python 2 & 3 compatible +- Unicode fully supported +''', + + classifiers=[ + "Development Status :: 3 - Alpha", + "Intended Audience :: Developers", + "Programming Language :: Python :: 2.7", + "Programming Language :: Python :: 3", + "Topic :: Software Development :: Libraries :: Python Modules", + "Topic :: Text Processing :: General", + "License :: OSI Approved :: MIT License", + ], + +) +