Skip to content

Commit

Permalink
Fixes test being broken because of typescript and bad fix for type er…
Browse files Browse the repository at this point in the history
…rors.

Also makes proprocessor keywords show up in the terms file
  • Loading branch information
alexkar598 committed Jul 10, 2024
1 parent 8b9a71e commit 8488af5
Show file tree
Hide file tree
Showing 7 changed files with 246 additions and 6 deletions.
5 changes: 5 additions & 0 deletions dm-lezer/babel.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
presets: [
"@babel/preset-typescript",
],
};
8 changes: 5 additions & 3 deletions dm-lezer/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
/** @type {import("jest").Config} */
const config = {
watchPathIgnorePatterns: [
"<rootDir>/src/parser.js",
"<rootDir>/src/parser.terms.js",
"<rootDir>/src/parser.ts",
"<rootDir>/src/parser.terms.ts",
"<rootDir>/node_modules",
],
moduleFileExtensions: ["js", "cjs", "test", "grammar"],
moduleFileExtensions: ["js", "ts", "cjs", "test", "grammar"],
extensionsToTreatAsEsm: [".ts"],
resolver: "jest-ts-webcompat-resolver",
};

module.exports = config;
165 changes: 165 additions & 0 deletions dm-lezer/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions dm-lezer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
"name": "dm-lezer",
"type": "module",
"devDependencies": {
"@babel/preset-typescript": "^7.24.7",
"@lezer/generator": "^1.7.1",
"@types/jest": "^29.5.12",
"@types/node": "^20.14.10",
"jest": "^30.0.0-alpha.5",
"jest-ts-webcompat-resolver": "^1.0.0",
"tsx": "^4.16.2"
},
"dependencies": {
Expand Down
6 changes: 4 additions & 2 deletions dm-lezer/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ export const ctx = new ContextTracker({
...context,
indent: new IndentLevel(context.indent, stack.pos - input.pos),
};
if (context.indent.parent == null) throw Error('Cannot dedent');
if (term === dedent) return { ...context, indent: context.indent.parent };
if (term === dedent) {
if (context.indent.parent == null) throw Error('Cannot dedent');
return { ...context, indent: context.indent.parent };
}
return context;
},
hash: (context) => context.indent.hash,
Expand Down
2 changes: 1 addition & 1 deletion dm-lezer/src/dm.grammar
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ PpPragma {
@else ppContent
}

ppDirective<name> { "#" Keyword[@name={name}] { name } }
ppDirective<name> { "#" @specialize[@name={name}]<PpIdentifier, name> }
ppKw<name> { @specialize[@name={name}]<PpIdentifier, name> }

StatementBlock {
Expand Down
64 changes: 64 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8488af5

Please sign in to comment.