mirror of
https://github.com/lloeki/wasp.git
synced 2025-12-06 02:34:39 +01:00
flake8 compliance
This commit is contained in:
parent
e8a036bb16
commit
992f774baa
4 changed files with 8 additions and 3 deletions
|
|
@ -1 +1,2 @@
|
||||||
rply==0.6.1
|
rply==0.6.1
|
||||||
|
flake8==2.1.0
|
||||||
|
|
|
||||||
5
test.py
5
test.py
|
|
@ -1,6 +1,7 @@
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
import wasp.parser as parser
|
import wasp.parser as parser
|
||||||
|
|
||||||
|
|
||||||
class TestParser(TestCase):
|
class TestParser(TestCase):
|
||||||
def test_atom(self):
|
def test_atom(self):
|
||||||
self.assertEqual(str(parser.parse("1")), "1")
|
self.assertEqual(str(parser.parse("1")), "1")
|
||||||
|
|
@ -28,12 +29,14 @@ class TestParser(TestCase):
|
||||||
|
|
||||||
def test_lists_in_list(self):
|
def test_lists_in_list(self):
|
||||||
self.assertEqual(str(parser.parse("(+ (* 4 5) (* 3 2))")),
|
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):
|
def test_quote_in_list(self):
|
||||||
self.assertEqual(str(parser.parse("(+ '1 (* 3 2))")),
|
self.assertEqual(str(parser.parse("(+ '1 (* 3 2))")),
|
||||||
"(+ . ('1 . ((* . (3 . (2 . NIL))) . NIL)))")
|
"(+ . ('1 . ((* . (3 . (2 . NIL))) . NIL)))")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import unittest
|
import unittest
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,10 @@ def list(p):
|
||||||
else:
|
else:
|
||||||
return box.Pair(p[0], p[1])
|
return box.Pair(p[0], p[1])
|
||||||
|
|
||||||
|
|
||||||
lexer = lg.build()
|
lexer = lg.build()
|
||||||
parser = pg.build()
|
parser = pg.build()
|
||||||
|
|
||||||
|
|
||||||
def parse(string):
|
def parse(string):
|
||||||
return parser.parse(lexer.lex(string))
|
return parser.parse(lexer.lex(string))
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
from rply.token import BaseBox
|
from rply.token import BaseBox
|
||||||
|
|
||||||
|
|
||||||
class Quote(BaseBox):
|
class Quote(BaseBox):
|
||||||
def __init__(self, sexpr):
|
def __init__(self, sexpr):
|
||||||
self.sexpr = sexpr
|
self.sexpr = sexpr
|
||||||
|
|
@ -33,5 +34,3 @@ class Atom(BaseBox):
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "%s" % (self.atom)
|
return "%s" % (self.atom)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue