Permalink
Browse files

lineno, return the current line number

  • Loading branch information...
1 parent 94feadd commit 094c94194fdca2c420ce82fcfac52bb1b7a037a6 @youngnh committed Sep 13, 2012
Showing with 8 additions and 0 deletions.
  1. +8 −0 src/the/parsatron.clj
View
@@ -143,6 +143,14 @@
(Continue. #(p state cok eerr eok eerr))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defn lineno
+ "A parser that returns the current line number. It consumes no input"
+ []
+ (fn [state _ _ eok _]
+ (eok (get-in state [:pos :line]) state)))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; token
(defn token
"Consume a single item from the head of the input if (consume? item)

0 comments on commit 094c941

Please sign in to comment.