def h.doc.start

yaml-for-bend@0.1.1.0 · parse.bend:376

import yaml-for-bend@0.1.1.0/parse.bend as Parse
import Base
import yaml-for-bend@0.1.1.0/token.bend as T

376# A document starts: bare, when nothing came before or the last one ended
377# with "..."; or with directives and "---"; or the stream ends.
378def h.doc.start(+ended: Bool, +t: T.Token, +ps: Ps) -> PStep:
379  +start = tok.start(t)
380  +bare = Bool.not(tok.any(t, [VERSION(), TAG_DIR(), DOC_START(), STREAM_END()]))
381  when(PStep, tok.is(t, DOC_END()), u => PGo{take(ps)},
382    u => when(PStep, tok.is(t, STREAM_END()), u => PGo{goto(emit(take(ps), StreamEndEv{}, start), SEnd{})},
383      u => when(PStep, Bool.and(bare, ended), u => PGo{goto(push(emit(with.tags(ps, defaults()), DocStartEv{False{}}, start), SDocEnd{}), block.node())},
384        u => when(PStep, Bool.or(bare, Bool.and(Bool.not(ended), Bool.not(tok.is(t, DOC_START())))), u => fail(ps, "did not find expected <document start>", start),
385          u => dirs.done(dirs.go(ps.toks(ps), [], False{}), ps)))))

Uses (30)

Used by (1)