Repository: alecthomas/chroma
Pull request #1045 (2025-01-30 13:47:48)

add Janet lexer
Converted from pygments, with some manual adjustments.


Patch:
diff --git a/lexers/embedded/janet.xml b/lexers/embedded/janet.xml
new file mode 100644
index 0000000..fe139e8
--- /dev/null
+++ b/lexers/embedded/janet.xml
@@ -0,0 +1,48 @@
+
+<lexer>
+  <config>
+    <name>Janet</name>
+    <alias>janet</alias>
+    <filename>*.janet</filename>
+    <filename>*.jdn</filename>
+    <mime_type>text/x-janet</mime_type>
+    <mime_type>application/x-janet</mime_type>
+  </config>
+  <rules>
+    <state name="root">
+      <rule pattern="#.*$"><token type="CommentSingle"/></rule>
+      <rule pattern="\s+"><token type="TextWhitespace"/></rule>
+      <rule pattern="(?x)
+                  [+-]? [0-9]{1,2} r [0-9a-zA-Z][0-9a-zA-Z_]* \. ([0-9a-zA-Z][0-9a-zA-Z_]*)?
+                  (&amp;[+-]?[0-9a-zA-Z]+)?
+               "><token type="LiteralNumber"/></rule>
+      <rule pattern="(?x)
+                  [+-]? [0-9]{1,2} r (\.)? [0-9a-zA-Z][0-9a-zA-Z_]*
+                  (&amp;[+-]?[0-9a-zA-Z]+)?
+               "><token type="LiteralNumber"/></rule>
+      <rule pattern="(?x) [+-]? 0x [0-9a-fA-F][0-9a-fA-F_]* \. ([0-9a-fA-F][0-9a-fA-F_]*)?"><token type="LiteralNumberHex"/></rule>
+      <rule pattern="(?x) [+-]? 0x (\.)? [0-9a-fA-F][0-9a-fA-F_]*"><token type="LiteralNumberHex"/></rule>
+      <rule pattern="(?x) [+-]? [0-9][0-9_]* \. ([0-9][0-9_]*)? ([eE][+-]?[0-9]+)?"><token type="LiteralNumberFloat"/></rule>
+      <rule pattern="(?x) [+-]? (\.)? [0-9][0-9_]* ([eE][+-]?[0-9]+)?"><token type="LiteralNumberFloat"/></rule>
+      <rule pattern="@?&quot;"><token type="LiteralString"/><push state="string"/></rule>
+      <rule pattern="@?(`+)(.|\n)+?\1"><token type="LiteralString"/></rule>
+      <rule pattern="[&#x27;~,;|]"><token type="Operator"/></rule>
+      <rule pattern="@?[(\[{]|[)\]}]"><token type="Punctuation"/></rule>
+      <rule pattern="(false|nil|true)(?=\s|#|[)\]]|$)"><token type="NameBuiltinPseudo"/></rule>
+      <rule pattern="(:(([0-9:]|[a-zA-Z!$%&amp;*+\-./&lt;=&gt;?@^_]))+|:)"><token type="NameConstant"/></rule>
+      <rule pattern="(debugger\-env|default\-peg\-grammar|janet/build|janet/config\-bits|janet/version|load\-image\-dict|make\-image\-dict|math/\-inf|math/e|math/inf|math/int\-max|math/int\-min|math/int32\-max|math/int32\-min|math/nan|math/pi|module/cache|module/loaders|module/loading|module/paths|root\-env|stderr|stdin|stdout)(?=\s|#|[)\]]|$)"><token type="NameVariableGlobal"/></rule>
+      <rule pattern="(?&lt;=\()(break|def|do|fn|if|quote|quasiquote|splice|set|unquote|upscope|var|while)(?=\s|#|[)\]]|$)"><token type="KeywordReserved"/></rule>
+      <rule pattern="(?&lt;=\()(%=|\*=|\+\+|\+=|\-\-|\-=|\-&gt;|\-&gt;&gt;|\-\?&gt;|\-\?&gt;&gt;|/=|and|as\-&gt;|as\-macro|as\?\-&gt;|assert|case|catseq|chr|comment|compif|comptime|compwhen|cond|coro|def\-|default|defdyn|defer|defmacro|defmacro\-|defn|defn\-|delay|doc|each|eachk|eachp|edefer|ev/do\-thread|ev/gather|ev/spawn|ev/spawn\-thread|ev/with\-deadline|ffi/defbind|fiber\-fn|for|forever|forv|generate|if\-let|if\-not|if\-with|import|juxt|label|let|loop|match|or|prompt|protect|repeat|seq|short\-fn|tabseq|toggle|tracev|try|unless|use|var\-|varfn|when|when\-let|when\-with|with|with\-dyns|with\-syms|with\-vars|eachy)(?=\s|#|[)\]]|$)"><token type="NameBuiltin"/></rule>
+      <rule pattern="(?&lt;=\()(%|\*|\+|\-|/|&lt;|&lt;=|=|&gt;|&gt;=|abstract\?|accumulate|accumulate2|all|all\-bindings|all\-dynamics|any\?|apply|array|array/clear|array/concat|array/ensure|array/fill|array/insert|array/new|array/new\-filled|array/peek|array/pop|array/push|array/remove|array/slice|array/trim|array/weak|array\?|asm|bad\-compile|bad\-parse|band|blshift|bnot|boolean\?|bor|brshift|brushift|buffer|buffer/bit|buffer/bit\-clear|buffer/bit\-set|buffer/bit\-toggle|buffer/blit|buffer/clear|buffer/fill|buffer/format|buffer/from\-bytes|buffer/new|buffer/new\-filled|buffer/popn|buffer/push|buffer/push\-at|buffer/push\-byte|buffer/push\-string|buffer/push\-word|buffer/slice|buffer/trim|buffer\?|bxor|bytes\?|cancel|cfunction\?|cli\-main|cmp|comp|compare|compare&lt;|compare&lt;=|compare=|compare&gt;|compare&gt;=|compile|complement|count|curenv|debug|debug/arg\-stack|debug/break|debug/fbreak|debug/lineage|debug/stack|debug/stacktrace|debug/step|debug/unbreak|debug/unfbreak|debugger|debugger\-on\-status|dec|deep\-not=|deep=|defglobal|describe|dictionary\?|disasm|distinct|div|doc\*|doc\-format|doc\-of|dofile|drop|drop\-until|drop\-while|dyn|eflush|empty\?|env\-lookup|eprin|eprinf|eprint|eprintf|error|errorf|ev/acquire\-lock|ev/acquire\-rlock|ev/acquire\-wlock|ev/all\-tasks|ev/call|ev/cancel|ev/capacity|ev/chan|ev/chan\-close|ev/chunk|ev/close|ev/count|ev/deadline|ev/full|ev/give|ev/give\-supervisor|ev/go|ev/lock|ev/read|ev/release\-lock|ev/release\-rlock|ev/release\-wlock|ev/rselect|ev/rwlock|ev/select|ev/sleep|ev/take|ev/thread|ev/thread\-chan|ev/write|eval|eval\-string|even\?|every\?|extreme|false\?|ffi/align|ffi/call|ffi/calling\-conventions|ffi/close|ffi/context|ffi/free|ffi/jitfn|ffi/lookup|ffi/malloc|ffi/native|ffi/pointer\-buffer|ffi/pointer\-cfunction|ffi/read|ffi/signature|ffi/size|ffi/struct|ffi/trampoline|ffi/write|fiber/can\-resume\?|fiber/current|fiber/getenv|fiber/last\-value|fiber/maxstack|fiber/new|fiber/root|fiber/setenv|fiber/setmaxstack|fiber/status|fiber\?|file/close|file/flush|file/lines|file/open|file/read|file/seek|file/tell|file/temp|file/write|filter|find|find\-index|first|flatten|flatten\-into|flush|flycheck|freeze|frequencies|from\-pairs|function\?|gccollect|gcinterval|gcsetinterval|gensym|get|get\-in|getline|getproto|group\-by|has\-key\?|has\-value\?|hash|idempotent\?|identity|import\*|in|inc|index\-of|indexed\?|int/s64|int/to\-bytes|int/to\-number|int/u64|int\?|interleave|interpose|invert|juxt\*|keep|keep\-syntax|keep\-syntax!|keys|keyword|keyword/slice|keyword\?|kvs|last|length|lengthable\?|load\-image|macex|macex1|maclintf|make\-env|make\-image|map|mapcat|marshal|math/abs|math/acos|math/acosh|math/asin|math/asinh|math/atan|math/atan2|math/atanh|math/cbrt|math/ceil|math/cos|math/cosh|math/erf|math/erfc|math/exp|math/exp2|math/expm1|math/floor|math/gamma|math/gcd|math/hypot|math/lcm|math/log|math/log\-gamma|math/log10|math/log1p|math/log2|math/next|math/pow|math/random|math/rng|math/rng\-buffer|math/rng\-int|math/rng\-uniform|math/round|math/seedrandom|math/sin|math/sinh|math/sqrt|math/tan|math/tanh|math/trunc|max|max\-of|mean|memcmp|merge|merge\-into|merge\-module|min|min\-of|mod|module/add\-paths|module/expand\-path|module/find|module/value|nan\?|nat\?|native|neg\?|net/accept|net/accept\-loop|net/address|net/address\-unpack|net/chunk|net/close|net/connect|net/flush|net/listen|net/localname|net/peername|net/read|net/recv\-from|net/send\-to|net/server|net/setsockopt|net/shutdown|net/write|next|nil\?|not|not=|number\?|odd\?|one\?|os/arch|os/cd|os/chmod|os/clock|os/compiler|os/cpu\-count|os/cryptorand|os/cwd|os/date|os/dir|os/environ|os/execute|os/exit|os/getenv|os/isatty|os/link|os/lstat|os/mkdir|os/mktime|os/open|os/perm\-int|os/perm\-string|os/pipe|os/posix\-exec|os/posix\-fork|os/proc\-close|os/proc\-kill|os/proc\-wait|os/readlink|os/realpath|os/rename|os/rm|os/rmdir|os/setenv|os/shell|os/sigaction|os/sleep|os/spawn|os/stat|os/strftime|os/symlink|os/time|os/touch|os/umask|os/which|pairs|parse|parse\-all|parser/byte|parser/clone|parser/consume|parser/eof|parser/error|parser/flush|parser/has\-more|parser/insert|parser/new|parser/produce|parser/state|parser/status|parser/where|partial|partition|partition\-by|peg/compile|peg/find|peg/find\-all|peg/match|peg/replace|peg/replace\-all|pos\?|postwalk|pp|prewalk|prin|prinf|print|printf|product|propagate|put|put\-in|quit|range|reduce|reduce2|repl|require|resume|return|reverse|reverse!|run\-context|sandbox|scan\-number|setdyn|signal|slice|slurp|some|sort|sort\-by|sorted|sorted\-by|spit|string|string/ascii\-lower|string/ascii\-upper|string/bytes|string/check\-set|string/find|string/find\-all|string/format|string/from\-bytes|string/has\-prefix\?|string/has\-suffix\?|string/join|string/repeat|string/replace|string/replace\-all|string/reverse|string/slice|string/split|string/trim|string/triml|string/trimr|string\?|struct|struct/getproto|struct/proto\-flatten|struct/to\-table|struct/with\-proto|struct\?|sum|symbol|symbol/slice|symbol\?|table|table/clear|table/clone|table/getproto|table/new|table/proto\-flatten|table/rawget|table/setproto|table/to\-struct|table/weak|table/weak\-keys|table/weak\-values|table\?|take|take\-until|take\-while|thaw|trace|true\?|truthy\?|tuple|tuple/brackets|tuple/setmap|tuple/slice|tuple/sourcemap|tuple/type|tuple\?|type|unmarshal|untrace|update|update\-in|values|varglobal|walk|warn\-compile|xprin|xprinf|xprint|xprintf|yield|zero\?|zipcoll|tarray/buffer|tarray/copy\-bytes|tarray/length|tarray/new|tarray/properties|tarray/slice|tarray/swap\-bytes|thread/close|thread/current|thread/exit|thread/new|thread/receive|thread/send)(?=\s|#|[)\]]|$)"><token type="NameFunction"/></rule>
+      <rule pattern="[a-zA-Z!$%&amp;*+\-./&lt;=&gt;?@^_](([0-9:]|[a-zA-Z!$%&amp;*+\-./&lt;=&gt;?@^_]))*"><token type="NameVariable"/></rule>
+    </state>
+    <state name="string">
+      <rule pattern="\\(u[0-9a-fA-F]{4}|U[0-9a-fA-F]{6})"><token type="LiteralStringEscape"/></rule>
+      <rule pattern="\\x[0-9a-fA-F]{2}"><token type="LiteralStringEscape"/></rule>
+      <rule pattern="\\."><token type="LiteralStringEscape"/></rule>
+      <rule pattern="&quot;"><token type="LiteralString"/><pop depth="1"/></rule>
+      <rule pattern="[^\\&quot;]+"><token type="LiteralString"/></rule>
+    </state>
+  </rules>
+</lexer>
+


Test patch:
diff --git a/lexers/testdata/janet.actual b/lexers/testdata/janet.actual
new file mode 100644
index 0000000..ac1f8c9
--- /dev/null
+++ b/lexers/testdata/janet.actual
@@ -0,0 +1,43 @@
+# A game of life implementation
+
+(def- window
+  (seq [x :range [-1 2]
+         y :range [-1 2]
+         :when (not (and (zero? x) (zero? y)))]
+       [x y]))
+
+(defn- neighbors
+  [[x y]]
+  (map (fn [[x1 y1]] [(+ x x1) (+ y y1)]) window))
+
+(defn tick
+  "Get the next state in the Game Of Life."
+  [state]
+  (def cell-set (frequencies state))
+  (def neighbor-set (frequencies (mapcat neighbors state)))
+  (seq [coord :keys neighbor-set
+         :let [count (get neighbor-set coord)]
+         :when (or (= count 3) (and (get cell-set coord) (= count 2)))]
+      coord))
+
+(defn draw
+  "Draw cells in the game of life from (x1, y1) to (x2, y2)"
+  [state x1 y1 x2 y2]
+  (def cellset @{})
+  (each cell state (put cellset cell true))
+  (loop [x :range [x1 (+ 1 x2)]
+         :after (print)
+         y :range [y1 (+ 1 y2)]]
+    (file/write stdout (if (get cellset [x y]) "X " ". ")))
+  (print))
+
+#
+# Run the example
+#
+
+(var *state* '[(0 0) (-1 0) (1 0) (1 1) (0 2)])
+
+(for i 0 20
+  (print "generation " i)
+  (draw *state* -7 -7 7 7)
+  (set *state* (tick *state*)))
diff --git a/lexers/testdata/janet.expected b/lexers/testdata/janet.expected
new file mode 100644
index 0000000..5c1e4ab
--- /dev/null
+++ b/lexers/testdata/janet.expected
@@ -0,0 +1,392 @@
+[
+  {"type":"CommentSingle","value":"# A game of life implementation"},
+  {"type":"TextWhitespace","value":"\n\n"},
+  {"type":"Punctuation","value":"("},
+  {"type":"NameBuiltin","value":"def-"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"window"},
+  {"type":"TextWhitespace","value":"\n  "},
+  {"type":"Punctuation","value":"("},
+  {"type":"NameBuiltin","value":"seq"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"["},
+  {"type":"NameVariable","value":"x"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameConstant","value":":range"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"["},
+  {"type":"LiteralNumberFloat","value":"-1"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"LiteralNumberFloat","value":"2"},
+  {"type":"Punctuation","value":"]"},
+  {"type":"TextWhitespace","value":"\n         "},
+  {"type":"NameVariable","value":"y"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameConstant","value":":range"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"["},
+  {"type":"LiteralNumberFloat","value":"-1"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"LiteralNumberFloat","value":"2"},
+  {"type":"Punctuation","value":"]"},
+  {"type":"TextWhitespace","value":"\n         "},
+  {"type":"NameConstant","value":":when"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"("},
+  {"type":"NameFunction","value":"not"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"("},
+  {"type":"NameBuiltin","value":"and"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"("},
+  {"type":"NameFunction","value":"zero?"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"x"},
+  {"type":"Punctuation","value":")"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"("},
+  {"type":"NameFunction","value":"zero?"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"y"},
+  {"type":"Punctuation","value":")))]"},
+  {"type":"TextWhitespace","value":"\n       "},
+  {"type":"Punctuation","value":"["},
+  {"type":"NameVariable","value":"x"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"y"},
+  {"type":"Punctuation","value":"]))"},
+  {"type":"TextWhitespace","value":"\n\n"},
+  {"type":"Punctuation","value":"("},
+  {"type":"NameBuiltin","value":"defn-"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"neighbors"},
+  {"type":"TextWhitespace","value":"\n  "},
+  {"type":"Punctuation","value":"[["},
+  {"type":"NameVariable","value":"x"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"y"},
+  {"type":"Punctuation","value":"]]"},
+  {"type":"TextWhitespace","value":"\n  "},
+  {"type":"Punctuation","value":"("},
+  {"type":"NameFunction","value":"map"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"("},
+  {"type":"KeywordReserved","value":"fn"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"[["},
+  {"type":"NameVariable","value":"x1"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"y1"},
+  {"type":"Punctuation","value":"]]"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"[("},
+  {"type":"NameFunction","value":"+"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"x"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"x1"},
+  {"type":"Punctuation","value":")"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"("},
+  {"type":"NameFunction","value":"+"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"y"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"y1"},
+  {"type":"Punctuation","value":")])"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"window"},
+  {"type":"Punctuation","value":"))"},
+  {"type":"TextWhitespace","value":"\n\n"},
+  {"type":"Punctuation","value":"("},
+  {"type":"NameBuiltin","value":"defn"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"tick"},
+  {"type":"TextWhitespace","value":"\n  "},
+  {"type":"LiteralString","value":"\"Get the next state in the Game Of Life.\""},
+  {"type":"TextWhitespace","value":"\n  "},
+  {"type":"Punctuation","value":"["},
+  {"type":"NameVariable","value":"state"},
+  {"type":"Punctuation","value":"]"},
+  {"type":"TextWhitespace","value":"\n  "},
+  {"type":"Punctuation","value":"("},
+  {"type":"KeywordReserved","value":"def"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"cell-set"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"("},
+  {"type":"NameFunction","value":"frequencies"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"state"},
+  {"type":"Punctuation","value":"))"},
+  {"type":"TextWhitespace","value":"\n  "},
+  {"type":"Punctuation","value":"("},
+  {"type":"KeywordReserved","value":"def"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"neighbor-set"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"("},
+  {"type":"NameFunction","value":"frequencies"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"("},
+  {"type":"NameFunction","value":"mapcat"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"neighbors"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"state"},
+  {"type":"Punctuation","value":")))"},
+  {"type":"TextWhitespace","value":"\n  "},
+  {"type":"Punctuation","value":"("},
+  {"type":"NameBuiltin","value":"seq"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"["},
+  {"type":"NameVariable","value":"coord"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameConstant","value":":keys"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"neighbor-set"},
+  {"type":"TextWhitespace","value":"\n         "},
+  {"type":"NameConstant","value":":let"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"["},
+  {"type":"NameVariable","value":"count"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"("},
+  {"type":"NameFunction","value":"get"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"neighbor-set"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"coord"},
+  {"type":"Punctuation","value":")]"},
+  {"type":"TextWhitespace","value":"\n         "},
+  {"type":"NameConstant","value":":when"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"("},
+  {"type":"NameBuiltin","value":"or"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"("},
+  {"type":"NameFunction","value":"="},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"count"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"LiteralNumberFloat","value":"3"},
+  {"type":"Punctuation","value":")"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"("},
+  {"type":"NameBuiltin","value":"and"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"("},
+  {"type":"NameFunction","value":"get"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"cell-set"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"coord"},
+  {"type":"Punctuation","value":")"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"("},
+  {"type":"NameFunction","value":"="},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"count"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"LiteralNumberFloat","value":"2"},
+  {"type":"Punctuation","value":")))]"},
+  {"type":"TextWhitespace","value":"\n      "},
+  {"type":"NameVariable","value":"coord"},
+  {"type":"Punctuation","value":"))"},
+  {"type":"TextWhitespace","value":"\n\n"},
+  {"type":"Punctuation","value":"("},
+  {"type":"NameBuiltin","value":"defn"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"draw"},
+  {"type":"TextWhitespace","value":"\n  "},
+  {"type":"LiteralString","value":"\"Draw cells in the game of life from (x1, y1) to (x2, y2)\""},
+  {"type":"TextWhitespace","value":"\n  "},
+  {"type":"Punctuation","value":"["},
+  {"type":"NameVariable","value":"state"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"x1"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"y1"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"x2"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"y2"},
+  {"type":"Punctuation","value":"]"},
+  {"type":"TextWhitespace","value":"\n  "},
+  {"type":"Punctuation","value":"("},
+  {"type":"KeywordReserved","value":"def"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"cellset"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"@{})"},
+  {"type":"TextWhitespace","value":"\n  "},
+  {"type":"Punctuation","value":"("},
+  {"type":"NameBuiltin","value":"each"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"cell"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"state"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"("},
+  {"type":"NameFunction","value":"put"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"cellset"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"cell"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameBuiltinPseudo","value":"true"},
+  {"type":"Punctuation","value":"))"},
+  {"type":"TextWhitespace","value":"\n  "},
+  {"type":"Punctuation","value":"("},
+  {"type":"NameBuiltin","value":"loop"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"["},
+  {"type":"NameVariable","value":"x"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameConstant","value":":range"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"["},
+  {"type":"NameVariable","value":"x1"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"("},
+  {"type":"NameFunction","value":"+"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"LiteralNumberFloat","value":"1"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"x2"},
+  {"type":"Punctuation","value":")]"},
+  {"type":"TextWhitespace","value":"\n         "},
+  {"type":"NameConstant","value":":after"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"("},
+  {"type":"NameFunction","value":"print"},
+  {"type":"Punctuation","value":")"},
+  {"type":"TextWhitespace","value":"\n         "},
+  {"type":"NameVariable","value":"y"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameConstant","value":":range"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"["},
+  {"type":"NameVariable","value":"y1"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"("},
+  {"type":"NameFunction","value":"+"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"LiteralNumberFloat","value":"1"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"y2"},
+  {"type":"Punctuation","value":")]]"},
+  {"type":"TextWhitespace","value":"\n    "},
+  {"type":"Punctuation","value":"("},
+  {"type":"NameFunction","value":"file/write"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariableGlobal","value":"stdout"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"("},
+  {"type":"KeywordReserved","value":"if"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"("},
+  {"type":"NameFunction","value":"get"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"cellset"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"["},
+  {"type":"NameVariable","value":"x"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"y"},
+  {"type":"Punctuation","value":"])"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"LiteralString","value":"\"X \""},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"LiteralString","value":"\". \""},
+  {"type":"Punctuation","value":")))"},
+  {"type":"TextWhitespace","value":"\n  "},
+  {"type":"Punctuation","value":"("},
+  {"type":"NameFunction","value":"print"},
+  {"type":"Punctuation","value":"))"},
+  {"type":"TextWhitespace","value":"\n\n"},
+  {"type":"CommentSingle","value":"#"},
+  {"type":"TextWhitespace","value":"\n"},
+  {"type":"CommentSingle","value":"# Run the example"},
+  {"type":"TextWhitespace","value":"\n"},
+  {"type":"CommentSingle","value":"#"},
+  {"type":"TextWhitespace","value":"\n\n"},
+  {"type":"Punctuation","value":"("},
+  {"type":"KeywordReserved","value":"var"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"*state*"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Operator","value":"'"},
+  {"type":"Punctuation","value":"[("},
+  {"type":"LiteralNumberFloat","value":"0"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"LiteralNumberFloat","value":"0"},
+  {"type":"Punctuation","value":")"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"("},
+  {"type":"LiteralNumberFloat","value":"-1"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"LiteralNumberFloat","value":"0"},
+  {"type":"Punctuation","value":")"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"("},
+  {"type":"LiteralNumberFloat","value":"1"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"LiteralNumberFloat","value":"0"},
+  {"type":"Punctuation","value":")"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"("},
+  {"type":"LiteralNumberFloat","value":"1"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"LiteralNumberFloat","value":"1"},
+  {"type":"Punctuation","value":")"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"("},
+  {"type":"LiteralNumberFloat","value":"0"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"LiteralNumberFloat","value":"2"},
+  {"type":"Punctuation","value":")])"},
+  {"type":"TextWhitespace","value":"\n\n"},
+  {"type":"Punctuation","value":"("},
+  {"type":"NameBuiltin","value":"for"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"i"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"LiteralNumberFloat","value":"0"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"LiteralNumberFloat","value":"20"},
+  {"type":"TextWhitespace","value":"\n  "},
+  {"type":"Punctuation","value":"("},
+  {"type":"NameFunction","value":"print"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"LiteralString","value":"\"generation \""},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"i"},
+  {"type":"Punctuation","value":")"},
+  {"type":"TextWhitespace","value":"\n  "},
+  {"type":"Punctuation","value":"("},
+  {"type":"NameVariable","value":"draw"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"*state*"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"LiteralNumberFloat","value":"-7"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"LiteralNumberFloat","value":"-7"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"LiteralNumberFloat","value":"7"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"LiteralNumberFloat","value":"7"},
+  {"type":"Punctuation","value":")"},
+  {"type":"TextWhitespace","value":"\n  "},
+  {"type":"Punctuation","value":"("},
+  {"type":"KeywordReserved","value":"set"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"*state*"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"("},
+  {"type":"NameVariable","value":"tick"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameVariable","value":"*state*"},
+  {"type":"Punctuation","value":")))"},
+  {"type":"TextWhitespace","value":"\n"}
+]