diff --git a/clyx-go/clyx.go b/clyx-go/clyx.go index 04f047b..1c707a5 100644 --- a/clyx-go/clyx.go +++ b/clyx-go/clyx.go @@ -268,11 +268,7 @@ func (c *Clyx) popCallerToken() any { } } if stream == nil { - if len(c.tokenStreams) == 0 { - stream = &c.tokens - } else { - return nil - } + stream = &c.tokens } if len(*stream) == 0 { return nil } t := (*stream)[0] @@ -296,11 +292,11 @@ func (c *Clyx) cmdDefw() { break } } - if stream == nil && len(c.tokenStreams) == 0 { + if stream == nil { stream = &c.tokens } var val any - if stream != nil && len(*stream) > 0 { + if len(*stream) > 0 { t0 := (*stream)[0] isQForm := false if s, ok := t0.(string); ok && s == "[" { isQForm = true } else if _, ok := t0.([]any); ok { isQForm = true } diff --git a/clyx-python/clyx/clyx.py b/clyx-python/clyx/clyx.py index 81d32df..a8df406 100755 --- a/clyx-python/clyx/clyx.py +++ b/clyx-python/clyx/clyx.py @@ -108,10 +108,7 @@ class Clyx: t = stream break if t is None: - if not self._token_streams: - t = self._tokens - else: - return None + t = self._tokens if not t: return None val = t.pop(0) if val == '[': return self._parse_qform(t) @@ -123,7 +120,7 @@ class Clyx: if stream: t = stream break - if t is None and not self._token_streams: + if t is None: t = self._tokens val = self._pop_caller_token() if (t and (t[0] == '[' or isinstance(t[0], list))) else self._stack.pop() if isinstance(val, str): val = self._norm_token(val) diff --git a/test.clx b/test.clx index 0937a13..1105abf 100644 --- a/test.clx +++ b/test.clx @@ -230,6 +230,7 @@ if [ "Testing definition words..." puts cr "my_const" [ 99 ] defw my_const 99 = if [ " defw (no-inline) PASS" puts cr ] [ " defw (no-inline) FAIL" puts cr ] # Test defw +"test_defw_map" [ [ 1 2 3 ] [ 2 * ] map ] defw test_defw_map [ 2 4 6 ] streq if [ " map inside defw PASS" puts cr ] [ " map inside defw FAIL" puts cr ] # Test map inside defw :: my_inline [ 100 ] my_inline 100 = if [ " :: (inline) PASS" puts cr ] [ " :: (inline) FAIL" puts cr ] # Test inline :: 5 then 5 = if [ " then PASS" puts cr ] [ " then FAIL" puts cr ] # Test then