You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 8b7870c
Browse filesBrowse the repository at this point in the historyBrowse files
feat(javascript): parseProgram and parseError, as CSS and HTML have
parseProgram parses into a SyntaxTree read through A until the next parse,
as parseHtml and the CSS parseA* do. Its parseError option reports each
parse error with Babel's reasonCode kebab-cased, which generate-js-data.js
reads off a probe per message: an error the parse reads past as a warning,
one that stops it as an error, the call then returning undefined.
Copy file name to clipboardExpand all lines: docs/syntax.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -84,7 +84,7 @@ One visitor serves several node types through an array, resolved once in `use()`
84
84
Conventions every language keeps, and a new member follows:
85
85
86
86
-**A node is an integer id**, valid until the next parse; `0` is no node, and an HTML attribute's id is negative. The path is one object rebound before each callback; read it during the callback, never keep it.
87
-
-**A parse entry point returns ids too**, read through the exported path `A` (`parseHtml`, CSS's `parseA*`), and takes a `parseError(input, code, start, end, severity)` option reporting each parse error of the tokenizer and of the parser or tree construction,`"error"` where end of input cuts a token or rule shortand `"warning"` otherwise. WHATWG names only one tree-construction error, so HTML's use html5lib-python's names; CSS Syntax names none, so CSS's are webpack's own.
87
+
-**A parse entry point returns ids too**, read through the exported path `A`until the next parse (`parseHtml`, CSS's `parseA*`, JavaScript's `parseProgram`), and takes a `parseError(input, code, start, end, severity)` option reporting each parse error of the tokenizer and of the parser or tree construction:`"error"` where end of input cuts a token or rule short, or where a JavaScript one stops the parse, and `"warning"` otherwise. No spec names them all, so HTML's tree-construction errors take html5lib-python's names, JavaScript's take Babel's `reasonCode` kebab-cased (read off probes by `tooling/generate-js-data.js`), and CSS's are webpack's own.
88
88
-**The node is the last argument and optional**, defaulting to the current one: `path.range()`, `path.range(other)`, `path.child(0)`.
89
89
-**A node has at most one `name` and one `value`; every other part is a `Field`, a `Flag` or a `Part`** (its position, and its text when it has more than the name and value), so the generic members cover any grammar instead of one method per part.
90
90
-**`name` and `value` are what the language's spec defines**, decoded as ESTree's `Identifier.name` and `Literal.value` are: escapes and character references resolved, a number as a number, a comment's text without its delimiters. **`source` is exactly the input**, so the spelling as written is `source(path.startOf(Part.name), path.endOf(Part.name))`. A node without a name or value answers `""`, a missing part `null`.
0 commit comments