mirror of
https://github.com/lloeki/wasp.git
synced 2025-12-06 10:44:39 +01:00
let's get more serious (splat that mess)
This commit is contained in:
parent
91020ddfe6
commit
e8a036bb16
7 changed files with 132 additions and 96 deletions
37
wasp/parser/box.py
Normal file
37
wasp/parser/box.py
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
from rply.token import BaseBox
|
||||
|
||||
class Quote(BaseBox):
|
||||
def __init__(self, sexpr):
|
||||
self.sexpr = sexpr
|
||||
|
||||
def sexpr(self):
|
||||
return self.sexpr
|
||||
|
||||
def __str__(self):
|
||||
return "'%s" % self.sexpr
|
||||
|
||||
|
||||
class Pair(BaseBox):
|
||||
def __init__(self, x, y=None):
|
||||
self.x = x
|
||||
self.y = y
|
||||
|
||||
def __str__(self):
|
||||
if self.y is None:
|
||||
y = "NIL"
|
||||
else:
|
||||
y = self.y
|
||||
return "(%s . %s)" % (self.x, y)
|
||||
|
||||
|
||||
class Atom(BaseBox):
|
||||
def __init__(self, atom):
|
||||
self.atom = atom
|
||||
|
||||
def atom(self):
|
||||
return self.atom
|
||||
|
||||
def __str__(self):
|
||||
return "%s" % (self.atom)
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue