Cursor
is a cursor over the parser input: pos (byte offset),
line, and col. Newline-aware: \n advances line and resets
col to 1. Users mostly see Cursor values via ParseErr for error
reporting.
=
defn
(Fn [(Ref Cursor a), (Ref Cursor a)] Bool)
(= o1 o2)
advance
defn
(Fn [(Ref Cursor a), Char] Cursor)
(advance cur b)
advances the cursor past one byte. If the byte is a
newline, line increments and col resets to 1.
col
instantiate
(Fn [(Ref Cursor a)] (Ref Int a))
gets the col property of a Cursor.
copy
instantiate
(Fn [(Ref Cursor a)] Cursor)
copies a Cursor.
delete
instantiate
(Fn [Cursor] ())
deletes a Cursor. Should usually not be called manually.
init
instantiate
(Fn [Int, Int, Int] Cursor)
creates a Cursor.
line
instantiate
(Fn [(Ref Cursor a)] (Ref Int a))
gets the line property of a Cursor.
pos
instantiate
(Fn [(Ref Cursor a)] (Ref Int a))
gets the pos property of a Cursor.
prn
instantiate
(Fn [(Ref Cursor a)] String)
converts a Cursor to a string.
set-col
instantiate
(Fn [Cursor, Int] Cursor)
sets the col property of a Cursor.
set-col!
instantiate
(Fn [(Ref Cursor a), Int] ())
sets the col property of a Cursor in place.
set-line
instantiate
(Fn [Cursor, Int] Cursor)
sets the line property of a Cursor.
set-line!
instantiate
(Fn [(Ref Cursor a), Int] ())
sets the line property of a Cursor in place.
set-pos
instantiate
(Fn [Cursor, Int] Cursor)
sets the pos property of a Cursor.
set-pos!
instantiate
(Fn [(Ref Cursor a), Int] ())
sets the pos property of a Cursor in place.
str
instantiate
(Fn [(Ref Cursor a)] String)
converts a Cursor to a string.
update-col
instantiate
(Fn [Cursor, (Ref (Fn [Int] Int a) b)] Cursor)
updates the col property of a Cursor using a function f.
update-line
instantiate
(Fn [Cursor, (Ref (Fn [Int] Int a) b)] Cursor)
updates the line property of a Cursor using a function f.
update-pos
instantiate
(Fn [Cursor, (Ref (Fn [Int] Int a) b)] Cursor)
updates the pos property of a Cursor using a function f.
zero
defn
(Fn [] Cursor)
(zero)
is the initial cursor: pos=0, line=1, col=1.