liveBook · Manning

Parse tree

As explained in Building User-Friendly DSLs

A tree-shaped representation of the syntactic structure recognized while parsing text.

A parse tree is the structured result of parsing textual DSL content against a grammar. It may already serve as an abstract syntax tree (AST), or it may be transformed into one before language services use it. section 15.1

In a parsing-based DSL architecture, the parse tree connects:

  • Textual DSL content to a grammar that specifies permitted character combinations. section 15.1
  • A parser generator to a generated parser that produces the parse tree. section 15.1
  • The resulting AST to language services such as content assist, constraint checking, syntax highlighting, and type information. section 15.1

Rental record DSL

A textual Rental record declares attributes such as a rental period, prices, and a discount. An EBNF grammar describes strings, types, values, attributes, and the complete record type that a parser can recognize.

How Building User-Friendly DSLs covers it

How deep it goes
Defines parse-tree production and its possible AST transformation, but leaves the transformation design as an exercise.
Examples
Uses a textual Rental record and an EBNF grammar covering attributes, types, values, and initial values.
What it assumes
Assumes familiarity with textual DSL content while introducing grammars, parser generators, parse trees, and ASTs together.
What you can do after
Evaluate how textual DSL content becomes an AST that supports editor language services.
How it connects
Links grammar, parser generators, abstract syntax trees, textual DSLs, and language services.

Also explained in

Compare how 2 books explain parse tree →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building User-Friendly DSLs. The section links point to the parts of the book it draws on.