On this page:
semantic-action?
splice-action
cut-action
label-action
8.12

5 Semantic Actions🔗ℹ

 (require yaragg/base/semantic-action) package: yaragg

A semantic action is a type of tree transformation that describes how to transform a node in a derivation tree into a node in a syntax object or S-expression. Semantic actions can join child trees into lists, insert labels, add metadata in the form of syntax properties, splice subtrees together, or even delete entire branches of the derivation tree.

procedure

(semantic-action? v)  boolean?

  v : any/c
A predicate for semantic actions.

A semantic action that splices a derivation’s subtrees together. Splice actions are useful for omitting internal parse tree nodes when they represent structure that’s only needed during parsing.

A semantic action omits a derivation entirely. Cut actions are useful for omitting subtrees that don’t represent useful information and only exist to facilitate parsing.

procedure

(label-action label 
  [#:label-properties label-properties 
  #:expression-properties expression-properties]) 
  semantic-action?
  label : any/c
  label-properties : hash? = (hash)
  expression-properties : hash? = (hash)
A semantic action that builds a list out of a derivation’s children, with label inserted into the head of the list. Label actions are useful for inserting artificial identifiers that weren’t part of the original parsed input.