Files
zeekay 2e7efc5c45 compiler: whitespace-significant schema syntax via desugar preprocessor
Add a source preprocessor desugar(src)->braceSrc that rewrites ZAP
whitespace-significant schema syntax into the brace/Cap'n-Proto syntax the
existing lexer/parser already accepts. It runs BEFORE the proven brace
front-end, which is left untouched, so brace files keep parsing byte-identical
(back-compat) while whitespace files compile to the same code_generator_request.

Placed in libzapc (compiler/desugar.{h,c++}) and invoked from BOTH source-read
sites — compiler/module-loader.c++ (the 'zap compile' CLI the LSP shells out to)
and schema-parser.c++ (the SchemaParser API every language plugin, incl.
zap-ocaml, uses) — so LSP and all codegen plugins inherit whitespace support
from one place. Desugar is gated by isWhitespaceSchema(): pure brace input is
bypassed and returned verbatim (zero behavioral change).

Rules: line/indent based; blank+full-line-# lines transparent; headers
(struct/interface/enum/union/group, name:union, name:group) get '{'/'}';
fields 'name Type'->'name @n :Type' with per-struct ordinals (union/group
members share the enclosing struct's sequence per Cap'n Proto); explicit @N
and :Type preserved; members get ';' terminators. Lines containing '{' are
treated as brace syntax and passed through (fixes inline 'struct Foo { ... }').

Tests (compiler/desugar-test.c++, 22 cases): brace fixtures idempotent;
whitespace twins desugar to the brace twin; regression over test.zap,
rpc-twoparty.zap, grammar.zap etc. is byte-identical; a ws/brace fixture pair
parses to identical ASTs (0 errors, same decls) through the real lexer+parser.
2026-06-19 19:22:07 -07:00
..
2013-03-29 22:09:51 -07:00
2013-03-29 22:09:51 -07:00
2013-03-31 20:04:23 -07:00
2013-03-29 22:09:51 -07:00
2013-03-29 22:09:51 -07:00
2013-08-29 05:47:00 -07:00
2013-03-29 22:09:51 -07:00
2013-12-11 01:02:06 -08:00