diff --git a/package-lock.json b/package-lock.json index b6bc5f71..8da5961a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ecmarkup", - "version": "18.3.0", + "version": "18.3.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "ecmarkup", - "version": "18.3.0", + "version": "18.3.1", "license": "MIT", "dependencies": { "chalk": "^4.1.2", @@ -16,7 +16,7 @@ "ecmarkdown": "^8.1.0", "eslint-formatter-codeframe": "^7.32.1", "fast-glob": "^3.2.7", - "grammarkdown": "^3.2.0", + "grammarkdown": "^3.3.2", "highlight.js": "11.0.1", "html-escape": "^1.0.2", "js-yaml": "^3.13.1", @@ -1861,12 +1861,13 @@ "dev": true }, "node_modules/grammarkdown": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/grammarkdown/-/grammarkdown-3.2.0.tgz", - "integrity": "sha512-pEVUvG2Kxv/PwM3Dm3kFEU1/GHRkNcFWmk/zkqN/y0uoQtPaZ+5VaBacMQAaFOIL9WGYjHXtqpkT5YRvySsISQ==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/grammarkdown/-/grammarkdown-3.3.2.tgz", + "integrity": "sha512-inNbeEotDr7MENqoZlms3x4gBzvK73wR2NGpNVnw4oEZcsq2METUbAh0J3VWtEqd9t2+U3poEqiJ9CDgBXr5Tg==", "dependencies": { "@esfx/async-canceltoken": "^1.0.0-pre.13", - "@esfx/cancelable": "^1.0.0-pre.13" + "@esfx/cancelable": "^1.0.0-pre.13", + "@esfx/disposable": "^1.0.0-pre.13" }, "bin": { "grammarkdown": "bin/grammarkdown" @@ -4921,12 +4922,13 @@ "dev": true }, "grammarkdown": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/grammarkdown/-/grammarkdown-3.2.0.tgz", - "integrity": "sha512-pEVUvG2Kxv/PwM3Dm3kFEU1/GHRkNcFWmk/zkqN/y0uoQtPaZ+5VaBacMQAaFOIL9WGYjHXtqpkT5YRvySsISQ==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/grammarkdown/-/grammarkdown-3.3.2.tgz", + "integrity": "sha512-inNbeEotDr7MENqoZlms3x4gBzvK73wR2NGpNVnw4oEZcsq2METUbAh0J3VWtEqd9t2+U3poEqiJ9CDgBXr5Tg==", "requires": { "@esfx/async-canceltoken": "^1.0.0-pre.13", - "@esfx/cancelable": "^1.0.0-pre.13" + "@esfx/cancelable": "^1.0.0-pre.13", + "@esfx/disposable": "^1.0.0-pre.13" } }, "graphemer": { diff --git a/package.json b/package.json index af3be09b..b3f4a42f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ecmarkup", - "version": "18.3.0", + "version": "18.3.1", "description": "Custom element definitions and core utilities for markup that specifies ECMAScript and related technologies.", "main": "lib/ecmarkup.js", "typings": "lib/ecmarkup.d.ts", @@ -54,7 +54,7 @@ "ecmarkdown": "^8.1.0", "eslint-formatter-codeframe": "^7.32.1", "fast-glob": "^3.2.7", - "grammarkdown": "^3.2.0", + "grammarkdown": "^3.3.2", "highlight.js": "11.0.1", "html-escape": "^1.0.2", "js-yaml": "^3.13.1", diff --git a/src/formatter/grammarkdown.ts b/src/formatter/grammarkdown.ts index 4215139c..4bb7e873 100644 --- a/src/formatter/grammarkdown.ts +++ b/src/formatter/grammarkdown.ts @@ -6,6 +6,7 @@ import type { OneOfList, ParameterList, Trivia, + UnicodeCharacterLiteral, } from 'grammarkdown'; import { NewLineKind, @@ -249,6 +250,20 @@ class EmitterWithComments extends GrammarkdownEmitter { this.writer.write('> '); node.fragments && this.emitNodes(node.fragments); } + + emitUnicodeCharacterLiteral(node: UnicodeCharacterLiteral) { + if (node.text?.startsWith('U+')) { + return super.emitUnicodeCharacterLiteral(node); + } + if (!(node.text?.startsWith('<') && node.text?.endsWith('>'))) { + throw new Error( + `unreachable: unicode character literal is not wrapped in <>: ${JSON.stringify(node.text)}`, + ); + } + this.writer.write('<'); + this.writer.write(node.text.slice(1, -1)); + this.writer.write('>'); + } } // uuuuugh, grammarkdown is only async diff --git a/test/formatter.js b/test/formatter.js index 56371cd7..6244fae7 100644 --- a/test/formatter.js +++ b/test/formatter.js @@ -339,6 +339,8 @@ describe('grammar formatting', () => { A : B C#prod2 + <ASCII> + U+2000 `, dedentKeepingTrailingNewline` @@ -351,6 +353,8 @@ describe('grammar formatting', () => { A : B C #prod2 + <ASCII> + U+2000 `, ); diff --git a/test/lint.js b/test/lint.js index 00d3bcf9..d2e6f044 100644 --- a/test/lint.js +++ b/test/lint.js @@ -20,7 +20,7 @@ describe('linting whole program', () => { { ruleId: 'grammarkdown:2008', nodeType: 'emu-grammar', - message: "Parameter 'a' is unused.", + message: "Parameter 'a' is unused", }, ); }); @@ -56,7 +56,7 @@ describe('linting whole program', () => { { ruleId: 'grammarkdown:2007', nodeType: 'emu-grammar', - message: "There is no argument given for parameter 'a'.", + message: "There is no argument given for parameter 'a'", }, ); }); @@ -69,7 +69,7 @@ describe('linting whole program', () => { { ruleId: 'grammarkdown:2008', nodeType: 'emu-grammar', - message: "Parameter 'a' is unused.", + message: "Parameter 'a' is unused", }, ); }); @@ -84,7 +84,7 @@ describe('linting whole program', () => { { ruleId: 'grammarkdown:2000', nodeType: 'emu-grammar', - message: "Cannot find name: 'Bar'.", + message: "Cannot find name: 'Bar'", }, ); });