From 4200c6708e2141ce0e753ff7e4765d402f4fdc8f Mon Sep 17 00:00:00 2001 From: Simon Forman Date: Wed, 28 Sep 2022 18:18:20 -0700 Subject: [PATCH] Improve compiling of step combinator. --- implementations/Ocaml/helloworld/bin/main.ml | 7 +++---- implementations/oldlog/source/joy2py.pl | 6 ++++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/implementations/Ocaml/helloworld/bin/main.ml b/implementations/Ocaml/helloworld/bin/main.ml index 10c13ed..335e085 100644 --- a/implementations/Ocaml/helloworld/bin/main.ml +++ b/implementations/Ocaml/helloworld/bin/main.ml @@ -130,14 +130,13 @@ let stack_to_string stack = expression_to_string (List.rev stack) type token = Left_bracket | Right_bracket | Token of string -let delimiter str i = - i >= String.length str || String.contains "[] " (String.get str i) - +let delimiter : char -> bool = String.contains "[] " +let delimits str i = i >= String.length str || delimiter (String.get str i) let make_token str index i = (Token (String.sub str index (i - index)), i) (* string -> int -> int -> token * int *) let rec tokenize1 str index i = - if delimiter str i then make_token str index i else tokenize1 str index (i + 1) + if delimits str i then make_token str index i else tokenize1 str index (i + 1) let rec tokenize0 str index acc = if index >= String.length str then acc diff --git a/implementations/oldlog/source/joy2py.pl b/implementations/oldlog/source/joy2py.pl index 81ed8e5..02382b1 100644 --- a/implementations/oldlog/source/joy2py.pl +++ b/implementations/oldlog/source/joy2py.pl @@ -613,6 +613,8 @@ compile_fn(Name) --> gronk_fn(Name), cg, !. ╚██████╔╝██║ ██║╚██████╔╝██║ ╚████║██║ ██╗ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝ ╚═╝ +(GRONK stands for "I am bad at naming things.") + With gronk we're juggling four things: The incoming joy expression @@ -694,8 +696,8 @@ gronk_fn_list( gronk_fn_list(Js, [Term|Stack], StackOut, CGTail, Ck, IndentLevel). gronk_fn_list( - [list(Body), symbol(step)|Js], - [list(B)|Stack0], + [symbol(step)|Js], + [list(Body), list(B)|Stack0], Stack, CGTail, CodeGens, -- 2.11.0