 (def &line-continuation
   (&do &backslash &eol))
 
+(def &whitespace
+  (&repeat (&or (&char-if whitespace) &line-continuation)))
+
 (def &leading-whitespace-continued
   (&let
     [column &leading-whitespace-raw


(defn &indent [column]
  (fn [[in [top :as is] out :as σ]]
    (if (> column top)
      [nil [in (conj is column) (conj out :indent)]]
      (loop [[top & ris :as is] is
             out out]
        (cond
         (= column top) [nil [in is out]]
         (or (empty? ris) (> column top)) ((&error {:r "invalid dedentation"}) σ)
         :else (recur ris (conj out :dedent)))))))

(def &comment-eol
  (&do (&optional (&do (&char= \#) (&repeat (&char-if-not crlf)))) &eol))

(defn python-lexer [input]
  (first (&python (init-state input))))

(comment
  (defn test-python-lexer [input]
    (try (python-lexer input) (catch clojure.lang.ExceptionInfo x (.data x))))

  (test-python-lexer "
def hello \"abcd\"
  foo\\
bar '1 2 3'
     # comment
  baz
def quux
  ur\"x\"")
  (python-lexer "def hello abcd\n  foo\n  baz\ndef quux\n  ur\"x\\\"\"")
);comment
