Lifecycle hooks allow you to embed JavaScript in various parts of the generated parser. The syntax is simple:

on:lifecycle {
    Your JavaScript Here 
} 

Example:

on:import {
    let parses = 0;

    export function GetParseCount(){
        return parses;
    }
}

on:new {
    parses++;
}

Lifecycle Hooks

NameDescription
importWhen the grammar is loaded
newWhen ever a new parser is initialized