Grammar constructor

Grammar(
  1. List<GrammarToken> tokens, {
  2. Grammar rest()?,
})

A syntax grammar: an ordered list of GrammarToken rules applied to source text to produce styled spans.

Grammars are tree-shakeable: each language lives in its own library (e.g. highlight/dart.dart) exposing a single grammar, so importing one never references the others and unused languages are dropped by the compiler.

Implementation

Grammar(this.tokens, {Grammar Function()? rest}) : _rest = rest;