diff options
author | Ben Longbons <b.r.longbons@gmail.com> | 2014-08-13 14:55:49 -0700 |
---|---|---|
committer | Ben Longbons <b.r.longbons@gmail.com> | 2014-08-27 11:29:45 -0700 |
commit | 9951ad78c80e144c166a7d476cad7ffdf84332a9 (patch) | |
tree | 9f5498a9a3c23b62dc928288e72081e99f958f46 /src/sexpr | |
parent | 749fec734c4583153fb2dbc80f1d21db2c2ab457 (diff) | |
download | tmwa-9951ad78c80e144c166a7d476cad7ffdf84332a9.tar.gz tmwa-9951ad78c80e144c166a7d476cad7ffdf84332a9.tar.bz2 tmwa-9951ad78c80e144c166a7d476cad7ffdf84332a9.tar.xz tmwa-9951ad78c80e144c166a7d476cad7ffdf84332a9.zip |
Debug debugging
Diffstat (limited to 'src/sexpr')
-rw-r--r-- | src/sexpr/parser.py | 18 | ||||
-rw-r--r-- | src/sexpr/variant.py | 22 |
2 files changed, 38 insertions, 2 deletions
diff --git a/src/sexpr/parser.py b/src/sexpr/parser.py index 201f457..885c63c 100644 --- a/src/sexpr/parser.py +++ b/src/sexpr/parser.py @@ -1,6 +1,4 @@ class SExpr(object): - ''' print a SExpr - ''' __slots__ = ('_value') name = 'tmwa::sexpr::SExpr' enabled = True @@ -23,3 +21,19 @@ class SExpr(object): if t == 3: yield '(token)', v['_str'] yield '_span', v['_span'] + + test_extra = ''' + #include "../strings/fwd.hpp" + using tmwa::operator "" _s; + ''' + + tests = [ + ('tmwa::sexpr::SExpr(); value._type = tmwa::sexpr::LIST; value._list = {tmwa::sexpr::SExpr(), tmwa::sexpr::SExpr()}', + '{(list) = std::vector of length 2, capacity 2 = {{(list) = std::vector of length 0, capacity 0, _span = {begin = {<tmwa::io::Line> = {text = "", filename = "", line = 0, column = 0}, <No data fields>}, end = {<tmwa::io::Line> = {text = "", filename = "", line = 0, column = 0}, <No data fields>}}}, {(list) = std::vector of length 0, capacity 0, _span = {begin = {<tmwa::io::Line> = {text = "", filename = "", line = 0, column = 0}, <No data fields>}, end = {<tmwa::io::Line> = {text = "", filename = "", line = 0, column = 0}, <No data fields>}}}}, _span = {begin = {<tmwa::io::Line> = {text = "", filename = "", line = 0, column = 0}, <No data fields>}, end = {<tmwa::io::Line> = {text = "", filename = "", line = 0, column = 0}, <No data fields>}}}'), + ('tmwa::sexpr::SExpr(); value._type = tmwa::sexpr::INT; value._int = 42', + '{(int) = 42, _span = {begin = {<tmwa::io::Line> = {text = "", filename = "", line = 0, column = 0}, <No data fields>}, end = {<tmwa::io::Line> = {text = "", filename = "", line = 0, column = 0}, <No data fields>}}}'), + ('tmwa::sexpr::SExpr(); value._type = tmwa::sexpr::STRING; value._str = "Hello"_s', + '{(str) = "Hello", _span = {begin = {<tmwa::io::Line> = {text = "", filename = "", line = 0, column = 0}, <No data fields>}, end = {<tmwa::io::Line> = {text = "", filename = "", line = 0, column = 0}, <No data fields>}}}'), + ('tmwa::sexpr::SExpr(); value._type = tmwa::sexpr::TOKEN; value._str = "Hello"_s', + '{(token) = "Hello", _span = {begin = {<tmwa::io::Line> = {text = "", filename = "", line = 0, column = 0}, <No data fields>}, end = {<tmwa::io::Line> = {text = "", filename = "", line = 0, column = 0}, <No data fields>}}}'), + ] diff --git a/src/sexpr/variant.py b/src/sexpr/variant.py new file mode 100644 index 0000000..3be402a --- /dev/null +++ b/src/sexpr/variant.py @@ -0,0 +1,22 @@ +class Variant(object): + __slots__ = ('_value') + name = 'tmwa::sexpr::Variant' + enabled = True + + def __init__(self, value): + self._value = value + + def to_string(self): + return None + + def children(self): + value = self._value + data = value['data'] + state = value['state'] + ty = value.type.template_argument(state) + yield '(%s)' % ty, data.address.cast(ty.pointer()).dereference() + + tests = [ + ('tmwa::sexpr::Variant<int, const char *>(42)', '{(int) = 42}'), + ('tmwa::sexpr::Variant<int, const char *>("Hello, World!")', '{(const char *) = "Hello, World!"}'), + ] |