diff --git a/.civet/hera-plugin.mjs b/.civet/hera-plugin.mjs index b8be3bd4..3f8222a6 100644 --- a/.civet/hera-plugin.mjs +++ b/.civet/hera-plugin.mjs @@ -4,15 +4,14 @@ const { compile: heraCompile } = Hera export default { transpilers: [{ extension: ".hera", - target: ".cjs", + target: ".ts", compile: function (path, source) { - const code = heraCompile(source, { + return heraCompile(source, { filename: path, + sourceMap: true, + types: true, + module: true, }) - - return { - code - } } }], } diff --git a/lsp/package.json b/lsp/package.json index 8e4d4329..2311c683 100644 --- a/lsp/package.json +++ b/lsp/package.json @@ -94,7 +94,7 @@ "dependencies": {}, "devDependencies": { "@danielx/civet": "^0.6.72", - "@danielx/hera": "^0.7.12", + "@danielx/hera": "^0.8.11", "@types/mocha": "^9", "@types/node": "^14.17.0", "@types/vscode": "^1.63.0", diff --git a/lsp/source/extension.civet b/lsp/source/extension.civet index abb47812..bc3131b1 100644 --- a/lsp/source/extension.civet +++ b/lsp/source/extension.civet @@ -45,6 +45,7 @@ function activateClient(context: ExtensionContext) documentSelector: [ { scheme: 'file', language: 'civet' } { scheme: 'file', language: 'coffeescript' } + { scheme: 'file', language: 'hera' } { scheme: 'file', language: 'javascript' } { scheme: 'file', language: 'javascriptreact' } { scheme: 'file', language: 'typescript' } diff --git a/lsp/yarn.lock b/lsp/yarn.lock index 56a91a35..7bfafa4d 100644 --- a/lsp/yarn.lock +++ b/lsp/yarn.lock @@ -277,10 +277,10 @@ "@typescript/vfs" "^1.5.0" unplugin "^1.6.0" -"@danielx/hera@^0.7.12": - version "0.7.12" - resolved "https://registry.yarnpkg.com/@danielx/hera/-/hera-0.7.12.tgz#ce26d3ed052c39d23baf1b65e9c7de6dc38ad80d" - integrity sha512-YPqnLGZH7EML3t7u8KlBwjg9rv5h0gWIt8Kr3sZYB6rq1bqHgv30yQAyBs0hf1WTB76NQgA0ErJeIRbOuzRahw== +"@danielx/hera@^0.8.11": + version "0.8.11" + resolved "https://registry.yarnpkg.com/@danielx/hera/-/hera-0.8.11.tgz#ccf8ba4a231a0b1308bb0ee24b03c1c25d5b3488" + integrity sha512-1AQVUh0uji4ExSZk62vYQ6K152j+CZN1E6i39/Jb3z3A4b3VqYByezHwcg4mZloT4RWaPo35zT5pwtnwutNIcQ== "@esbuild/android-arm64@0.19.2": version "0.19.2" diff --git a/source/parser.hera b/source/parser.hera index ff0ad8a3..e919e87b 100644 --- a/source/parser.hera +++ b/source/parser.hera @@ -52,6 +52,10 @@ import { wrapIIFE, } from "./parser/lib.civet" +import type { + UpdateExpression, +} from "./parser/types.civet" + /** * A global object to hold methods used in rule handlers * We can probably transition away from this now that Hera @@ -455,7 +459,7 @@ NWTypePostfix # https://262.ecma-international.org/#prod-UpdateExpression UpdateExpression # NOTE: Not allowing whitespace betwen prefix and postfix increment operators and operand - UpdateExpressionSymbol UnaryWithoutParenthesizedAssignment -> + UpdateExpressionSymbol UnaryWithoutParenthesizedAssignment :: UpdateExpression -> return { type: "UpdateExpression", assigned: $2, diff --git a/source/parser/pipe.civet b/source/parser/pipe.civet index 53113c18..9c4c5b71 100644 --- a/source/parser/pipe.civet +++ b/source/parser/pipe.civet @@ -90,7 +90,6 @@ function constructPipeStep(fn, arg, returning) { return [constructInvocation(fn, arg), null] } - // head: expr // body: [ws, pipe, ws, expr][] diff --git a/source/parser/types.civet b/source/parser/types.civet index 61bae827..54800a90 100644 --- a/source/parser/types.civet +++ b/source/parser/types.civet @@ -62,6 +62,11 @@ export type StatementTuple = [IndentNode, ASTNode, StatementDelimiter?] export type Condition = ParenthesizedExpression +export type UpdateExpression + type: "UpdateExpression" + children: Children + assigned: ASTNode + export type ParenthesizedExpression type: "ParenthesizedExpression" children: Children