From 86edc08a39931bf99cce6d86f6d2058383ecb51c Mon Sep 17 00:00:00 2001 From: Erik Demaine Date: Fri, 1 Nov 2024 15:10:52 -0400 Subject: [PATCH] Robust parsing of `foo.` with error node --- source/parser.hera | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/source/parser.hera b/source/parser.hera index 25932f79..9bfdbd92 100644 --- a/source/parser.hera +++ b/source/parser.hera @@ -1681,6 +1681,18 @@ PropertyAccess children: [ dot, ...comments, ...id.children ], } + # NOTE: For LSP completion / robustness, parse `foo.` but with an error node + ExplicitAccessStart:dot &EOS -> + return { + type: "PropertyAccess", + name: "", + dot, + children: [ dot, { + type: "Error", + message: "Missing property name after '.'", + }] + } + ImplicitAccessStart:dot ( PrivateIdentifier / LengthShorthand ):id -> return { type: "PropertyAccess",