Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
(defautomata netstring
(word (* any ? bytes-remaining $ track-word % print-word))
(frame (+ digit $ track-size) ":" word)
(start (* frame ",") frame))
(defn- parse-buffer [buf]
(loop [cs (initial-state netstring)
i 0
size 0
word []
char (get-char buf i)]
(defexecution netstring [i size word]
(bytes-remaining (> size 0))
(track-size (next-action i (+ size (char-to-int char)) word))
(track-word (next-action i size (conj word char)))
(print-word (println word))
(recur cs (inc i) size char))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.