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(), ), )