Adding more documentation
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
// Sets up the parser generated by canopy to use the
|
||||
// [Node](./javascript/node.html) subclasses in the generated tree. This is all
|
||||
// a bit of a hack that is dependent on how canopy creates nodes in its parse
|
||||
// tree.
|
||||
import parser from './grammar.peg';
|
||||
|
||||
import Node from './node.js';
|
||||
@@ -18,7 +22,15 @@ import RepeatOptional from './repeat_optional.js';
|
||||
import RepeatRequired from './repeat_required.js';
|
||||
import RepeatSpec from './repeat_spec.js';
|
||||
|
||||
// Canopy creates an instance of SyntaxNode for each element in the tree, then
|
||||
// adds any necessary fields to that instance. In this case, we're replacing
|
||||
// the default class with the Node class.
|
||||
parser.Parser.SyntaxNode = Node;
|
||||
|
||||
// Once the SyntaxNode instance is created, the specific node type object is
|
||||
// overlayed onto it. This causes the module attribute on the Node to be set,
|
||||
// which updates the Node instance into the more specific "subclass" that is
|
||||
// used for rendering.
|
||||
parser.Parser.Root = { module: Root };
|
||||
parser.Parser.Regexp = { module: Regexp };
|
||||
parser.Parser.Match = { module: Match };
|
||||
|
||||
@@ -1,13 +1,23 @@
|
||||
// State tracking for an in-progress parse and render.
|
||||
export default class ParserState {
|
||||
// - __progress__ - DOM node to update to indicate completion progress.
|
||||
constructor(progress) {
|
||||
// Tracks the number of capture groups in the expression.
|
||||
this.groupCounter = 1;
|
||||
// Cancels the in-progress render when set to true.
|
||||
this.cancelRender = false;
|
||||
// Warnings that have been generated while rendering.
|
||||
this.warnings = [];
|
||||
|
||||
// Used to display the progress indicator
|
||||
this._renderCounter = 0;
|
||||
this._maxCounter = 0;
|
||||
this._progress = progress;
|
||||
}
|
||||
|
||||
// Counts the number of in-progress rendering steps. As the counter goes up,
|
||||
// a maximum value is also tracked. The maximum value and current render
|
||||
// counter are used to calculate the completion process.
|
||||
get renderCounter() {
|
||||
return this._renderCounter;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user