From 3cb6a0637e8a32e7e06cdbbc08e8a31f8af8f358 Mon Sep 17 00:00:00 2001 From: Malik Mahmud Date: Mon, 21 Aug 2023 19:26:27 +0100 Subject: [PATCH] chore: remove unused helper functions --- helpers/helpers.go | 21 --------------------- lexer/lexer_test.go | 17 +++++++++++++++-- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/helpers/helpers.go b/helpers/helpers.go index 1801da0..6ad804b 100644 --- a/helpers/helpers.go +++ b/helpers/helpers.go @@ -1,8 +1,6 @@ package helpers import ( - "path/filepath" - "github.com/MlkMahmud/jack-compiler/types" ) @@ -46,22 +44,3 @@ func Contains[T comparable](arr []T, elem T) bool { } return false } - -func WriteSymbol(lexeme string) string { - switch lexeme { - case "<": - return "<" - case ">": - return ">" - case "&": - return "&" - default: - return lexeme - } -} - -func ReplaceFileExt(filename, ext string) string { - extension := filepath.Ext(filename) - basename := filename[0 : len(filename)-len(extension)] - return basename + ext -} diff --git a/lexer/lexer_test.go b/lexer/lexer_test.go index e3d2bf9..5f7d473 100644 --- a/lexer/lexer_test.go +++ b/lexer/lexer_test.go @@ -9,12 +9,25 @@ import ( "testing" . "github.com/MlkMahmud/jack-compiler/types" - . "github.com/MlkMahmud/jack-compiler/helpers" . "github.com/MlkMahmud/jack-compiler/lexer" ) const TEST_DATA_PATH = "../testdata" +func writeSymbol(lexeme string) string { + switch lexeme { + case "<": + return "<" + case ">": + return ">" + case "&": + return "&" + default: + return lexeme + } +} + + func readFileContent(filename string) string { file, _ := os.Open(filename) bytes, err := io.ReadAll(file) @@ -39,7 +52,7 @@ func writeTokensToXML(tokens []Token, dest string) { fmt.Sprintf( " <%s> %s \n", token.TokenType.String(), - WriteSymbol(token.Lexeme), + writeSymbol(token.Lexeme), token.TokenType.String(), ), )