(collect-extra-elements r)Drains the rest of a segment, returning the elements no parser claimed. A composite comes back as a vector of its components.
The case used to have two branches and no default, so an undeclared
composite ended the parse with No matching clause: START_COMPOSITE -- an
IllegalArgumentException naming the event and nothing else, from a function
whose whole job is to be tolerant of what it does not recognise. Anything
still unaccounted for now says where it was.
Drains the rest of a segment, returning the elements no parser claimed. A composite comes back as a vector of its components. The `case` used to have two branches and no default, so an undeclared composite ended the parse with `No matching clause: START_COMPOSITE` -- an IllegalArgumentException naming the event and nothing else, from a function whose whole job is to be tolerant of what it does not recognise. Anything still unaccounted for now says where it was.
(consume-composite r)Drains what is left of the current composite and steps past its END_COMPOSITE.
It used to advance only when the reader was already sitting exactly on END_COMPOSITE, so a composite carrying more components than the schema declares left the reader inside it and desynchronised everything after.
Drains what is left of the current composite and steps past its END_COMPOSITE. It used to advance only when the reader was already sitting exactly on END_COMPOSITE, so a composite carrying more components than the schema declares left the reader inside it and desynchronised everything after.
(lookahead-reader r)A reader a parser can read one segment ahead on. make-parser wraps its
reader itself; call this only to run a loop or segment parser directly.
A reader a parser can read one segment ahead on. `make-parser` wraps its reader itself; call this only to run a loop or segment parser directly.
(segment-values r)The segment the reader is on, read AHEAD without consuming it, as
{[element component] text} -- first occurrence of each position. A simple
element is component 1 of its position, which is also how the reader
reports a composite that travelled with its first component and no
separator. The reader goes on to replay the segment to whichever parser
takes it.
The segment the reader is on, read AHEAD without consuming it, as
`{[element component] text}` -- first occurrence of each position. A simple
element is component 1 of its position, which is also how the reader
reports a composite that travelled with its first component and no
separator. The reader goes on to replay the segment to whichever parser
takes it.(skip-composite r)Advances from a composite's START_COMPOSITE to just past its END_COMPOSITE.
Advances from a composite's START_COMPOSITE to just past its END_COMPOSITE.
(skip-elements element-pos from-pos)Positions the reader at element element-pos, counting from from-pos, and
returns the reader -- or nil when the segment ran out before that position.
An element is a POSITION, not an event. A simple element is one ELEMENT_DATA, but a composite occupies one position and spans START_COMPOSITE .. END_COMPOSITE, so passing over it means passing the whole span.
Counting events instead was the single defect behind every composite symptom
this parser had. At a START_COMPOSITE the old gate matched nothing and
returned nil, so the composite was neither entered nor skipped and the
reader stayed parked on it -- every later parser for that segment then
no-opped in turn, and consume-segment drained into a case with no
START_COMPOSITE branch. Hence No matching clause: START_COMPOSITE for a
composite the schema declared perfectly well, and silently empty segments
(HI, say) where the composites were merely dropped.
Positions the reader at element `element-pos`, counting from `from-pos`, and returns the reader -- or nil when the segment ran out before that position. An element is a POSITION, not an event. A simple element is one ELEMENT_DATA, but a composite occupies one position and spans START_COMPOSITE .. END_COMPOSITE, so passing over it means passing the whole span. Counting events instead was the single defect behind every composite symptom this parser had. At a START_COMPOSITE the old gate matched nothing and returned nil, so the composite was neither entered nor skipped and the reader stayed parked on it -- every later parser for that segment then no-opped in turn, and `consume-segment` drained into a `case` with no START_COMPOSITE branch. Hence `No matching clause: START_COMPOSITE` for a composite the schema declared perfectly well, and silently empty segments (HI, say) where the composites were merely dropped.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |