Skip to content

Commit 8488af5

Browse files
committed
Fixes test being broken because of typescript and bad fix for type errors.
Also makes proprocessor keywords show up in the terms file
1 parent 8b9a71e commit 8488af5

7 files changed

+246
-6
lines changed

dm-lezer/babel.config.cjs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
presets: [
3+
"@babel/preset-typescript",
4+
],
5+
};

dm-lezer/jest.config.cjs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
/** @type {import("jest").Config} */
22
const config = {
33
watchPathIgnorePatterns: [
4-
"<rootDir>/src/parser.js",
5-
"<rootDir>/src/parser.terms.js",
4+
"<rootDir>/src/parser.ts",
5+
"<rootDir>/src/parser.terms.ts",
66
"<rootDir>/node_modules",
77
],
8-
moduleFileExtensions: ["js", "cjs", "test", "grammar"],
8+
moduleFileExtensions: ["js", "ts", "cjs", "test", "grammar"],
9+
extensionsToTreatAsEsm: [".ts"],
10+
resolver: "jest-ts-webcompat-resolver",
911
};
1012

1113
module.exports = config;

dm-lezer/package-lock.json

+165
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dm-lezer/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
"name": "dm-lezer",
33
"type": "module",
44
"devDependencies": {
5+
"@babel/preset-typescript": "^7.24.7",
56
"@lezer/generator": "^1.7.1",
67
"@types/jest": "^29.5.12",
78
"@types/node": "^20.14.10",
89
"jest": "^30.0.0-alpha.5",
10+
"jest-ts-webcompat-resolver": "^1.0.0",
911
"tsx": "^4.16.2"
1012
},
1113
"dependencies": {

dm-lezer/src/context.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ export const ctx = new ContextTracker({
2121
...context,
2222
indent: new IndentLevel(context.indent, stack.pos - input.pos),
2323
};
24-
if (context.indent.parent == null) throw Error('Cannot dedent');
25-
if (term === dedent) return { ...context, indent: context.indent.parent };
24+
if (term === dedent) {
25+
if (context.indent.parent == null) throw Error('Cannot dedent');
26+
return { ...context, indent: context.indent.parent };
27+
}
2628
return context;
2729
},
2830
hash: (context) => context.indent.hash,

dm-lezer/src/dm.grammar

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ PpPragma {
107107
@else ppContent
108108
}
109109

110-
ppDirective<name> { "#" Keyword[@name={name}] { name } }
110+
ppDirective<name> { "#" @specialize[@name={name}]<PpIdentifier, name> }
111111
ppKw<name> { @specialize[@name={name}]<PpIdentifier, name> }
112112

113113
StatementBlock {

package-lock.json

+64
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)