From ba84069bd76b68cfb6c455b54f5ccb0a8d0e7869 Mon Sep 17 00:00:00 2001 From: Jiashen Cao Date: Mon, 11 Jun 2018 20:03:11 -0400 Subject: [PATCH 1/2] Add python3 support --- parsetron/parsetron.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/parsetron/parsetron.py b/parsetron/parsetron.py index ba5b03d..5ee10fd 100644 --- a/parsetron/parsetron.py +++ b/parsetron/parsetron.py @@ -10,6 +10,8 @@ import copy from collections import deque from collections import Counter +from past.types import unicode, basestring +from past.builtins import xrange __doc__ = \ """ @@ -88,7 +90,7 @@ def __new__(typ, name, bases, dct): return super(MetaGrammar, typ).__new__(typ, name, bases, dct) -class Grammar(object): +class Grammar(object, metaclass=MetaGrammar): """ Grammar user interface. Users should inherit this grammar and define a final grammar GOAL as class variable. @@ -114,8 +116,10 @@ class Grammar(object): __metaclass__ = MetaGrammar def __new__(cls): + print(cls.__dict__['_grammar_']) return cls.__dict__['_grammar_'] + @staticmethod def test(): """ From a386e03ce41cc67fcfc4f7458b91e756d6a3c8a0 Mon Sep 17 00:00:00 2001 From: Jiashen Cao Date: Mon, 11 Jun 2018 20:04:34 -0400 Subject: [PATCH 2/2] Edit requirement page --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index a4e4a41..12176b3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,3 +10,4 @@ tox virtualenv coveralls sphinx_rtd_theme +future