From 02cbe999421e5d435cf5bc8691f797355909d8fb Mon Sep 17 00:00:00 2001 From: Ulysses Souza Date: Sat, 23 Mar 2024 19:48:07 +0100 Subject: [PATCH] Fix entries starting with `export ` This is a workaround. The problem should be fixed in the grammar Signed-off-by: Ulysses Souza --- envlang_test.go | 11 ++++++++++- handlers/filehandler.go | 5 +++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/envlang_test.go b/envlang_test.go index 33993a9..9d2f4cb 100644 --- a/envlang_test.go +++ b/envlang_test.go @@ -228,6 +228,14 @@ A = "aaa ${B} ccc " "EMPTY_VAR": strPtr(""), }, }, + { + "PrefixExport", + `export A = aaa"`, + map[string]*string{ + "A": strPtr("aaa"), + }, + nil, + }, } for _, tt := range tests { @@ -256,7 +264,7 @@ H="my_value" I = bar baz - +export EXPORTED_VAR = exported_value J = "foo bar" @@ -322,6 +330,7 @@ VAR_DEFAULT_EMPTY = "${EMPTY_VAR:-eee}" "VAR_DEFAULT_UNSET": strPtr("uuu"), "VAR_DEFAULT_UNSET_OR_EMPTY": strPtr(""), "VAR_DEFAULT_EMPTY": strPtr("eee"), + "EXPORTED_VAR": strPtr("exported_value"), } d := dao.NewDefaultDao() diff --git a/handlers/filehandler.go b/handlers/filehandler.go index 28e4d77..1c52e4d 100644 --- a/handlers/filehandler.go +++ b/handlers/filehandler.go @@ -33,6 +33,11 @@ func (l *EnvLangFileListener) ExitEntry(c *fileparser.EntryContext) { if id == "" { return } + + // TODO: Implement the logic to handle the export keyword in the grammar file + id, _ = strings.CutPrefix(id, "export ") + id = strings.TrimSpace(id) + hasAssign := true if c.ASSIGN() == nil || c.ASSIGN().GetText() == "" { hasAssign = false