A parser generator is a tool or framework that turns a grammar specification into a parser for textual DSL content. Parsing recognizes text that conforms to the grammar and produces a parse tree, which may already be an AST or may require transformation. section 15.1
A parsing-based DSL workflow connects these stages:
- Write a grammar describing permitted textual combinations. section 15.1
- Generate a parser that recognizes conforming text. section 15.1
- Transform the parse tree into an AST when their structures differ. section 15.1
- Pass the AST to language services for completion, constraint checking, syntax highlighting, type information, or tooltips. section 15.1
Rental record DSL
A textual Rental record declares attributes such as rental period, rental price, discount, and an initially derived value. An EBNF grammar specifies strings, types, numbers, attribute references, attributes, and the complete record type.
