From a51499e14cd25a97f1f47b28fd07a3bc59db55bd Mon Sep 17 00:00:00 2001 From: Thakee Nathees Date: Tue, 29 Oct 2024 23:26:40 +0530 Subject: [PATCH] lark file keywords word boundry added --- jac/jaclang/compiler/__init__.py | 6 +++++- jac/jaclang/compiler/jac.lark | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/jac/jaclang/compiler/__init__.py b/jac/jaclang/compiler/__init__.py index d1b178b4fe..d421d765db 100644 --- a/jac/jaclang/compiler/__init__.py +++ b/jac/jaclang/compiler/__init__.py @@ -45,7 +45,11 @@ def generate_static_parser(force: bool = False) -> None: contextlib.suppress(ModuleNotFoundError) TOKEN_MAP = { - x.name: x.pattern.value + x.name: ( + x.pattern.value[2:-2] + if x.pattern.value.startswith("\\b") and x.pattern.value.endswith("\\b") + else x.pattern.value + ) for x in jac_lark.Lark_StandAlone().parser.lexer_conf.terminals } diff --git a/jac/jaclang/compiler/jac.lark b/jac/jaclang/compiler/jac.lark index 2a31e4f88a..ef7e79efc7 100644 --- a/jac/jaclang/compiler/jac.lark +++ b/jac/jaclang/compiler/jac.lark @@ -530,7 +530,7 @@ KW_TRY: "try" KW_EXCEPT: "except" KW_FINALLY: "finally" KW_RAISE: "raise" -KW_IN: "in" +KW_IN: /\bin\b/ KW_IS: "is" KW_PRIV: "priv" KW_PUB: "pub"