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
Name | Description |
---|---|
import | When the grammar is loaded |
new | When ever a new parser is initialized |