From 992f774baaedc75b924a478b16801cea8c4f31ca Mon Sep 17 00:00:00 2001 From: Loic Nageleisen Date: Fri, 24 Jan 2014 21:35:12 +0100 Subject: [PATCH] flake8 compliance --- requirements.txt | 1 + test.py | 5 ++++- wasp/parser/__init__.py | 2 ++ wasp/parser/box.py | 3 +-- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index f676474..fb6921e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ rply==0.6.1 +flake8==2.1.0 diff --git a/test.py b/test.py index 08a1533..a366b4d 100644 --- a/test.py +++ b/test.py @@ -1,6 +1,7 @@ from unittest import TestCase import wasp.parser as parser + class TestParser(TestCase): def test_atom(self): self.assertEqual(str(parser.parse("1")), "1") @@ -28,12 +29,14 @@ class TestParser(TestCase): def test_lists_in_list(self): self.assertEqual(str(parser.parse("(+ (* 4 5) (* 3 2))")), - "(+ . ((* . (4 . (5 . NIL))) . ((* . (3 . (2 . NIL))) . NIL)))") + "(+ . ((* . (4 . (5 . NIL))) " + + ". ((* . (3 . (2 . NIL))) . NIL)))") def test_quote_in_list(self): self.assertEqual(str(parser.parse("(+ '1 (* 3 2))")), "(+ . ('1 . ((* . (3 . (2 . NIL))) . NIL)))") + if __name__ == '__main__': import unittest unittest.main() diff --git a/wasp/parser/__init__.py b/wasp/parser/__init__.py index a1c1dda..77f0c0b 100644 --- a/wasp/parser/__init__.py +++ b/wasp/parser/__init__.py @@ -47,8 +47,10 @@ def list(p): else: return box.Pair(p[0], p[1]) + lexer = lg.build() parser = pg.build() + def parse(string): return parser.parse(lexer.lex(string)) diff --git a/wasp/parser/box.py b/wasp/parser/box.py index 45317f8..0cc5ee7 100644 --- a/wasp/parser/box.py +++ b/wasp/parser/box.py @@ -1,5 +1,6 @@ from rply.token import BaseBox + class Quote(BaseBox): def __init__(self, sexpr): self.sexpr = sexpr @@ -33,5 +34,3 @@ class Atom(BaseBox): def __str__(self): return "%s" % (self.atom) - -