pegjs/lib/parser/ast.js
Futago-za Ryuu 93cc6c5b26 Parser calls AST node creator now
Before this commit, the PEG.js parser always created the AST using a plain JavaSctript object, but allthough simple and effective for the job, this method sacrificies performance slightly.

From now on the parser shall call a Node creator. This should help with performance, as well as in the future move some AST helpers into the new AST functions.
2018-01-16 02:46:41 +00:00

29 lines
408 B
JavaScript

"use strict";
class Node {
constructor( type, location ) {
this.type = type;
this.location = location;
}
}
exports.Node = Node;
class Grammar extends Node {
// Creates a new AST
constructor( initializer, rules, location ) {
super( "grammar", location );
this.initializer = initializer;
this.rules = rules;
}
}
exports.Grammar = Grammar;