DEPRECATED. Use peg.compiler.visitor
added in PEG.js 0.10.0 instead.
pegjs-each-code
npm install pegjs-each-code
var eachCode =
-
The function passed to
eachCode
will be run once for each node with acode
property, such as “action”, “semantic and” and “semantic not” nodes, except the initializer. -
labels
is an array of all the labels that are available to the code snippet. -
ruleName
is the name of the rule that the code snippet occurs in.
eachCode
is useful when making a plugin for a compile-to-js language (such as
CoffeeScript and TypeScript) or a linter.
If such a processor throws an error, use eachCode.getFilePosition(node, {line: Number, column: Number})
to make the line and column of the error relative to
the entire file, rather than to node
(the code snippet). It returns an object
with a line
and a column
property.