diff --git a/clyx-go/clyx.go b/clyx-go/clyx.go index 3a11fc5..5922035 100644 --- a/clyx-go/clyx.go +++ b/clyx-go/clyx.go @@ -270,6 +270,9 @@ func (c *Clyx) popCallerToken() any { if err != nil { fmt.Fprintf(os.Stderr, "Error: %v\n", err); return nil } return qParsed } + if s, ok := t.(string); ok { + return normToken(s) + } return t } @@ -284,6 +287,9 @@ func (c *Clyx) cmdDefw() { if isQForm { val = c.popCallerToken() } } if val == nil { val = c.pop() } + if s, ok := val.(string); ok { + val = normToken(s) + } nameVal := c.pop() var name string if s, ok := nameVal.(string); ok { diff --git a/clyx-python/clyx/clyx.py b/clyx-python/clyx/clyx.py index 59c7f91..024b1d5 100755 --- a/clyx-python/clyx/clyx.py +++ b/clyx-python/clyx/clyx.py @@ -103,10 +103,17 @@ class Clyx: def _cmd_qset(self): i, v, x = self._stack.pop(), self._stack.pop(), self._stack.pop(); (v.pop(int(i)), v.insert(int(i), x)) if isinstance(v, list) else None; self._stack.append(v if isinstance(v, list) else None) def _exec_loop(self, c, b): while (self._exec_qform(c), self._stack.pop())[1]: self._exec_qform(b) - _pop_caller_token = lambda self: (lambda t: (t.pop(0) if t[0] != '[' else self._parse_qform((t.pop(0), t)[1])) if t else None)(self._token_streams[-1] if self._token_streams else self._tokens) + def _pop_caller_token(self): + t = self._token_streams[-1] if self._token_streams else self._tokens + if not t: return None + val = t.pop(0) + if val == '[': return self._parse_qform(t) + if isinstance(val, str): return self._norm_token(val) + return val def _cmd_defw(self): t = self._token_streams[-1] if self._token_streams else 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) name = self._stack.pop() if isinstance(name, str): name = self._norm_token(name) self._words[name] = val diff --git a/test.clx b/test.clx index b9b4fed..237a3d4 100644 --- a/test.clx +++ b/test.clx @@ -226,6 +226,8 @@ my_inline 100 = if [ " :: (inline) PASS" puts cr ] [ " :: (inline) FAIL" puts ":: source_test_word [ 99 ]" "test_source.clx" writef drop source test_source.clx source_test_word 99 = if [ "test_source.clx" delf " source PASS" puts cr ] [ "test_source.clx" delf " source FAIL" puts cr ] # Test source my_is_word is [ 200 ] my_is_word 200 = +my_str_word is "abc" +my_str_word "abc" streq and :: "my_inline_string_word" [ 400 ] my_inline_string_word 400 = and if [ " is PASS" puts cr ] [ " is FAIL" puts cr ] # Test is