Parser inputs #
Iterators for common parser inputs, with HasPos instances for error reporting:
CharIteratoriterates over the characters of aString.Slice. UnlikeString.Slice.chars, its type does not depend on the slice, so parsers can name it.ByteIteratoriterates over the bytes of aByteArray.BitIteratoriterates over the bits of aBitVec, least significant bit first.- Core's
ArrayIterator(fromArray.iter) reports its index as the position.
Iterator over the characters of a String.Slice.
- slice : String.Slice
The slice being iterated over.
The current position in
slice.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Positions are byte offsets into the slice.
Equations
- ParseIt.CharIterator.instHasPosChar = { Pos := String.Pos.Raw, pos := fun (it : Std.Iter Char) => it.internalState.pos.offset }
Iterator over the characters of s.
Instances For
The remaining characters as a slice.
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Positions are byte indices.
Equations
- ParseIt.ByteIterator.instHasPosUInt8 = { Pos := Nat, pos := fun (it : Std.Iter UInt8) => it.internalState.pos }
Equations
- One or more equations did not get rendered due to their size.
Positions are bit indices.
Equations
- ParseIt.BitIterator.instHasPosBool = { Pos := Nat, pos := fun (it : Std.Iter Bool) => it.internalState.pos }
Positions are array indices.
Equations
- ParseIt.instHasPosArrayIterator = { Pos := Nat, pos := fun (it : Std.Iter α) => it.internalState.pos }
Running parsers #
captureSlice p parses p and returns its result together with the slice of input that p
consumed. The slice is a view into the input; no characters are copied.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Run p on the characters of s.
Equations
- p.parseSlice s = p.parse (ParseIt.CharIterator.ofSlice s)
Instances For
Run p on the characters of s.
Equations
- p.parseString s = p.parseSlice s.toSlice
Instances For
Run p on the bytes of data.
Equations
- p.parseByteArray data = p.parse (ParseIt.ByteIterator.ofByteArray data)
Instances For
Run p on the bits of bits, least significant bit first.
Equations
- p.parseBitVec bits = p.parse (ParseIt.BitIterator.ofBitVec bits)
Instances For
Run p on the elements of xs.
Equations
- p.parseArray xs = p.parse xs.iter
Instances For
Run p on the elements of xs. Vectors use the array iterator.
Equations
- p.parseVector xs = p.parse xs.iter