code: function toAST(res, mapping) {
    if (!(res instanceof MatchResult) || res.failed()) {
      throw new Error('toAST() expects a succesfull MatchResult as first parameter');
    }
  
    mapping = extend({}, mapping);
    var operation = extend({}, defaultOperation);
    for (var termName in mapping) {
      if (typeof mapping[termName] === 'function') {
        operation[termName] = mapping[termName];
        delete mapping[termName];
      }
    }
    var g = res._cst.grammar;
    var s = g.createSemantics().addOperation('toAST(mapping)', operation);
    return s(res).toAST(mapping);
  }
docs: Returns a plain JavaScript object that includes an abstract syntax tree (AST) for the given match result `res` containg a concrete syntax tree (CST) and grammar. The optional `mapping` parameter can be used to customize how the nodes of the CST are mapped to the AST (see /doc/extras.md#toastmatchresult-mapping).