Skip to content

Commit

Permalink
chore: remove unused helper functions
Browse files Browse the repository at this point in the history
  • Loading branch information
MlkMahmud committed Aug 21, 2023
1 parent 4df29c5 commit 3cb6a06
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 23 deletions.
21 changes: 0 additions & 21 deletions helpers/helpers.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package helpers

import (
"path/filepath"

"github.com/MlkMahmud/jack-compiler/types"
)

Expand Down Expand Up @@ -46,22 +44,3 @@ func Contains[T comparable](arr []T, elem T) bool {
}
return false
}

func WriteSymbol(lexeme string) string {
switch lexeme {
case "<":
return "&lt;"
case ">":
return "&gt;"
case "&":
return "&amp;"
default:
return lexeme
}
}

func ReplaceFileExt(filename, ext string) string {
extension := filepath.Ext(filename)
basename := filename[0 : len(filename)-len(extension)]
return basename + ext
}
17 changes: 15 additions & 2 deletions lexer/lexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 "&lt;"
case ">":
return "&gt;"
case "&":
return "&amp;"
default:
return lexeme
}
}


func readFileContent(filename string) string {
file, _ := os.Open(filename)
bytes, err := io.ReadAll(file)
Expand All @@ -39,7 +52,7 @@ func writeTokensToXML(tokens []Token, dest string) {
fmt.Sprintf(
" <%s> %s </%s>\n",
token.TokenType.String(),
WriteSymbol(token.Lexeme),
writeSymbol(token.Lexeme),
token.TokenType.String(),
),
)
Expand Down

0 comments on commit 3cb6a06

Please sign in to comment.