2.2. Token Parser (Syntactic Layer)
The token parser (TokenParser.lean, 790 lines)
consumes the YamlToken stream and produces an Array YamlDocument.
It implements the spec's grammar-layer (S) productions via hand-written
recursive descent (no parser combinator library).
Key responsibilities:
-
Multi-document support — handles
---and...boundaries -
Alias resolution — substitutes
*anchorreferences with previously anchored values -
Tag resolution — applies
%TAGdirective handle expansion and schema-level type resolution -
Schema application — resolves untagged scalars to typed values (
null,bool,int,float,str) via the Core Schema