changeset fbcfdc819791 in joypy/Joypy details: http://hg.osdn.jp/view/joypy/Joypy?cmd=changeset;node=fbcfdc819791 user: Simon Forman <sform****@hushm*****> date: Sun May 17 16:02:43 2020 -0700 description: Don't use `==` for definitions. diffstat: joy/library.py | 85 +++++++++++++++++++++++++++++---------------------------- 1 files changed, 43 insertions(+), 42 deletions(-) diffs (109 lines): diff -r 79b07bb1d70c -r fbcfdc819791 joy/library.py --- a/joy/library.py Sun May 17 12:58:26 2020 -0700 +++ b/joy/library.py Sun May 17 16:02:43 2020 -0700 @@ -224,43 +224,43 @@ definitions = ('''\ -? == dup truthy -*fraction == [uncons] dip uncons [swap] dip concat [*] infra [*] dip cons -*fraction0 == concat [[swap] dip * [*] dip] infra -anamorphism == [pop []] swap [dip swons] genrec -average == [sum 1.0 *] [size] cleave / -binary == nullary [popop] dip -cleave == fork [popd] dip -codireco == cons dip rest cons -dinfrirst == dip infra first -unstack == ? [uncons ?] loop pop -down_to_zero == [0 >] [dup --] while -dupdipd == dup dipd -enstacken == stack [clear] dip -flatten == [] swap [concat] step -fork == [i] app2 -gcd == 1 [tuck modulus dup 0 >] loop pop -ifte == [nullary not] dipd branch -ii == [dip] dupdip i -least_fraction == dup [gcd] infra [div] concat map -make_generator == [codireco] ccons -nullary == [stack] dinfrirst -of == swap at -pam == [i] map -tailrec == [i] genrec -product == 1 swap [*] step -quoted == [unit] dip -range == [0 <=] [1 - dup] anamorphism -range_to_zero == unit [down_to_zero] infra -run == [] swap infra -size == 0 swap [pop ++] step -sqr == dup mul -step_zero == 0 roll> step -swoncat == swap concat -ternary == unary [popop] dip -unary == nullary popd -unquoted == [i] dip -while == swap [nullary] cons dup dipd concat loop +? dup truthy +*fraction [uncons] dip uncons [swap] dip concat [*] infra [*] dip cons +*fraction0 concat [[swap] dip * [*] dip] infra +anamorphism [pop []] swap [dip swons] genrec +average [sum 1.0 *] [size] cleave / +binary nullary [popop] dip +cleave fork [popd] dip +codireco cons dip rest cons +dinfrirst dip infra first +unstack ? [uncons ?] loop pop +down_to_zero [0 >] [dup --] while +dupdipd dup dipd +enstacken stack [clear] dip +flatten [] swap [concat] step +fork [i] app2 +gcd 1 [tuck modulus dup 0 >] loop pop +ifte [nullary not] dipd branch +ii [dip] dupdip i +least_fraction dup [gcd] infra [div] concat map +make_generator [codireco] ccons +nullary [stack] dinfrirst +of swap at +pam [i] map +tailrec [i] genrec +product 1 swap [*] step +quoted [unit] dip +range [0 <=] [1 - dup] anamorphism +range_to_zero unit [down_to_zero] infra +run [] swap infra +size 0 swap [pop ++] step +sqr dup mul +step_zero 0 roll> step +swoncat swap concat +ternary unary [popop] dip +unary nullary popd +unquoted [i] dip +while swap [nullary] cons dup dipd concat loop ''' # # @@ -376,10 +376,7 @@ Given some text describing a Joy function definition parse it and return a DefinitionWrapper. ''' - name, proper, body_text = (n.strip() for n in defi.partition('==')) - if not proper: - raise ValueError('Definition %r failed' % (defi,)) - return class_(name, body_text) + return class_(*(n.strip() for n in defi.split(maxsplit=1))) @classmethod def add_definitions(class_, defs, dictionary): @@ -408,7 +405,11 @@ def _text_to_defs(text): - return (line.strip() for line in text.splitlines() if '==' in line) + return ( + line.strip() + for line in text.splitlines() + if not line.startswith('#') + ) #