You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a newline-sensitive lexer mode independent of indent (#14)
Some DSLs are newline-aware but not indent-aware: statements are
line-delimited, but nesting is via delimiters/expressions rather than
indentation (e.g. dotenv-style env specs). Until now the only way to get
significant newlines was to opt into `indent`, which also drags in
INDENT/DEDENT stack management and YAML block-scalar semantics.
This adds a `newline` mode as the line-boundary + flow-suspension layer
that `indent` already builds on (indent = newline + indent stack + YAML
semantics). A single `lineSensitive` gate shares the lexer machinery; the
line-start routine forks so a newline-only grammar emits one NEWLINE token
per significant boundary with no indent stack. The two modes are mutually
exclusive.
- types.ts: NewlineConfig + CstGrammar.newline
- api.ts: passthrough + indent/newline mutual-exclusion check
- gen-lexer.ts: the layered emission
- emit-parser.ts: bake the newline config for the standalone parser
- gen-treesitter.ts: NEWLINE as a stateless external scanner token
- test/newline-mode.ts: an inline env-spec grammar exercising all four
backends plus a real tree-sitter generate + parse
All existing grammars regenerate byte-identically; TS parser conformance,
the agnostic gate, and the tree-sitter accuracy gate are unchanged.
newline?: NewlineConfig;// opt-in NEWLINE-sensitive tokenization, independent of indent (no indent stack)
384
385
expression?: RuleRef;// the rule that produces an EXPRESSION; enables a derived `#expression` sub-grammar (expression-only embeds)
385
386
aliasScopes?: {scope: string;file: string}[];// extra grammars re-exposing this one under another scopeName (e.g. text.html.derivative)
386
387
canonicalRepoNames?: Record<string,string|string[]>;// official repo KEY NAME → structural key(s) for the SAME construct; gen-tm RENAMES the structural key (or synthesises a union wrapper) to emit the official name natively (the 限制器; see CstGrammar.canonicalRepoNames)
387
388
manifest?: import('./types.ts').ContributesManifest;// VS Code `contributes` packaging (emits a pasteable snippet)
newline?: NewlineConfig;// opt-in NEWLINE-sensitive tokenization, independent of indent (no indent stack); absent → byte-identical token stream
394
414
expressionRule?: string;// name of the rule that produces an EXPRESSION; lets gen-tm derive a `#expression` sub-grammar (for expression-only embeds, e.g. Vue `{{ }}`)
395
415
// Extra TextMate grammars that just RE-EXPOSE this one under another scopeName (thin
396
416
// `{scopeName, patterns:[{include: <this.scopeName>}]}` wrappers). HTML declares
0 commit comments