diff options
author | Juan Manuel Tomás <jtomas1815@gmail.com> | 2024-10-13 00:51:57 -0300 |
---|---|---|
committer | Juan Manuel Tomás <jtomas1815@gmail.com> | 2024-10-13 00:51:57 -0300 |
commit | 1af10ddc10e35805c6723d7a2a85d7e3768497f8 (patch) | |
tree | 10cb209d714c339b1bc99c900eca98424ef31c11 /input.lisp | |
parent | 7a6f4586c2e83ffcdb5a8b7b2c5591f6e80e038f (diff) | |
download | monparser-1af10ddc10e35805c6723d7a2a85d7e3768497f8.tar.gz monparser-1af10ddc10e35805c6723d7a2a85d7e3768497f8.zip |
Error out on parser failure
Diffstat (limited to 'input.lisp')
-rw-r--r-- | input.lisp | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -18,3 +18,14 @@ (defun cursor-distance (input1 input2) (- (input-cursor input1) (input-cursor input2))) + +(defun line-and-column (input) + (let ((line 1) (column 1)) + (dotimes (i (input-cursor input)) + (let ((c (char (input-data input) i))) + (case c + (#\Newline + (incf line) + (setf column 1)) + (t (incf column))))) + (values line column))) |