93cc6c5b26
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.
29 lines
408 B
JavaScript
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;
|