Previous: Error recovery, Up: Wisent Parsing [Contents][Index]

### 3.5 Debugging semantic actions

Each semantic action is represented by a symbol interned in an obarray that is part of the LALR(1) automaton (see Compiling a grammar). `symbol-function` on a semantic action symbol return the semantic action lambda expression.

A semantic action symbol name has the form `nonterminal:index`, where nonterminal is the name of the nonterminal symbol the action belongs to, and index is an action sequence number within the scope of nonterminal. For example, this nonterminal definition:

    input:
       line                     [input:0]
     | input line
       (format "%s %s" $1 $2)   [input:1]
     ;

Will produce two semantic actions, and associated symbols:

`input:0`

  A default action that returns `$1`.

`input:1`

  That returns `(format "%s %s" $1 $2)`.

Debugging uses the Lisp debugger to investigate what is happening during execution of semantic actions. Three commands are available to debug semantic actions. They receive two arguments:

- The automaton that contains the semantic action.
- The semantic action symbol.

Command: wisent-debug-on-entry automaton function

  Request automaton’s function to invoke debugger each time it is called. function must be a semantic action symbol that exists in automaton.

Command: wisent-cancel-debug-on-entry automaton function

  Undo effect of `wisent-debug-on-entry` on automaton’s function. function must be a semantic action symbol that exists in automaton.

Command: wisent-debug-show-entry automaton function

  Show the source of automaton’s semantic action function. function must be a semantic action symbol that exists in automaton.