On this page:
parser-derivation?
parser-derivation
parser-derivation->syntax
parser-derivation->datum
8.12

4 Derivation Trees🔗ℹ

 (require yaragg/base/derivation) package: yaragg

A derivation tree, or simply a derivation, is a tree that represents the structure a parser derived when parsing an input string according to some grammar. Derivation trees are similar to abstract syntax trees, but they tend to include more details that matter only to parsing. Derivation trees can be transformed into either syntax objects or plain S-expressions. Nodes within derivation trees can be labeled with semantic actions in order to transform the syntax objects and S-expressions produced from the tree.

procedure

(parser-derivation? v)  boolean?

  v : any/c
A predicate for derivations.

procedure

(parser-derivation token)  parser-derivation?

  token : token?
(parser-derivation action child ...+)  parser-derivation?
  action : semantic-action?
  child : parser-derivation?
Constructs a derivation. In the first case, a terminal derivation matching a single input token is constructed. In the second case, a nonterminal derivation containing each of the child derivations is constructed. The given action is applied to the children when the derivation is converted to a syntax object or S-expression.

procedure

(parser-derivation->syntax derivation)  syntax?

  derivation : parser-derivation?
Converts derivation into a syntax object.

procedure

(parser-derivation->datum derivation)  any/c

  derivation : parser-derivation?
Converts derivation into an S-expression.