liveBook · Manning

AST object

As explained in Building User-Friendly DSLs

An individual structured object representing a node or element within an abstract syntax tree.

An AST object is a structured node in an abstract syntax tree. Its concept label identifies its kind, while settings hold contained AST objects, references, arrays, or simple values. section 3.3.1

Generic processing visits an AST object as a whole, inspects its settings, recursively traverses contained objects and array items, follows reference targets without traversing them, and backtracks after descendants finish. section 3.3.1

AST objects support projection and editing through their structure:

  • A projection first recognizes an AST object, then dispatches on its concept label to render a focused result. section 4.2
  • A containing object performs structural edits for its containees because a contained object does not know its property, siblings, or position. section 6.3.1
  • New objects can be added as record attributes or as initial values, including Attribute Reference and Number objects. section 6.1

Deleting an initial value

When a selected initial-value object receives Backspace or Delete, its containing attribute supplies a replacement action that removes settings["initial value"]. The deletion callback is passed through Projection to AstObjectUiWrapper, which handles the keyboard event. section 6.3.1

Figure 3.15 Traversing an AST generically
figure

Use the traversal diagram to follow containment relations, array order, reference targets, and backtracking around an AST object. section 3.3.1

How Building User-Friendly DSLs covers it

How deep it goes
Explains labels, settings, containment, references, arrays, recursion, and deletion ownership, but does not define a formal AST schema.
Examples
Uses a rental record type, Data Attribute, Attribute Reference, Number, HTML projection, and initial-value deletion.
What it assumes
Assumes JavaScript objects and arrays, while introducing AST structure, containment, references, and recursive traversal operationally.
What you can do after
Apply it via JavaScript and React to traverse, project, add, and delete structured AST objects.
How it connects
Connects AST objects to abstract syntax trees, depth-first tree traversal, reference objects, projections, containment, and React event handling.

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.