diff --git a/src/js/parser/javascript/charset_range.js b/src/js/parser/javascript/charset_range.js index 499e346..a330091 100644 --- a/src/js/parser/javascript/charset_range.js +++ b/src/js/parser/javascript/charset_range.js @@ -1,9 +1,13 @@ +// CharsetRange nodes are used for `[a-z]` regular expression syntax. The two +// literal or escape nodes are rendered with a hyphen between them. + import util from '../../util.js'; import _ from 'lodash'; export default { type: 'charset-range', + // Renders the charset range into the currently set container _render() { var contents = [ this.first, @@ -11,11 +15,13 @@ export default { this.last ]; + // Render the nodes of the range. return Promise.all([ this.first.render(this.container.group()), this.last.render(this.container.group()) ]) .then(() => { + // Space the nodes and hyphen horizontally. util.spaceHorizontally(contents, { padding: 5 }); @@ -23,9 +29,12 @@ export default { }, setup() { + // The two nodes for the range. In `[a-z]` these would be + // [Literal](./literal.html) nodes for "a" and "z". this.first = this.properties.first; this.last = this.properties.last; + // Report invalid expression when extents of the range are out of order. if (this.first.ordinal > this.last.ordinal) { throw `Range out of order in character class: ${this.textValue}`; }