From 40a627b5ca2f472b1a1146892e364f9c9a27768c Mon Sep 17 00:00:00 2001 From: Simon Forman Date: Thu, 17 Dec 2020 22:06:28 -0800 Subject: [PATCH] Let '==' separate names from definition bodies. --- joy/library.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/joy/library.py b/joy/library.py index 6b4943e..2409954 100644 --- a/joy/library.py +++ b/joy/library.py @@ -258,7 +258,19 @@ class DefinitionWrapper(object): Given some text describing a Joy function definition parse it and return a DefinitionWrapper. ''' - return class_(*(n.strip() for n in defi.split(None, 1))) + # At some point I decided that the definitions file should NOT + # use '==' to separate the name from the body. But somehow the + # xerblin\gui\default_joy_home\definitions.txt file didn't get + # the memo. Nor did the load_definitions() method. + # So I think the simplest way forward at the moment will be to + # edit this function to expect '=='. + + name, part, body = defi.partition('==') + if part: + return class_(name.strip(), body.strip()) + raise ValueError("No '==' in definition text %r" % (defi,)) + + # return class_(*(n.strip() for n in defi.split(None, 1))) @classmethod def add_definitions(class_, defs, dictionary): @@ -289,7 +301,9 @@ def _text_to_defs(text): return ( line.strip() for line in text.splitlines() - if line and not line.startswith('#') + if line + and not line.startswith('#') + and '==' in line ) -- 2.11.0