From 299cf1a312160556550c720a1c9e84483dd421f9 Mon Sep 17 00:00:00 2001 From: Daniel Moore Date: Mon, 19 Feb 2024 19:43:29 -0800 Subject: [PATCH] Annotating rule with type --- source/parser.hera | 6 +++++- source/parser/pipe.civet | 1 - source/parser/types.civet | 5 +++++ 3 files changed, 10 insertions(+), 2 deletions(-) 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