wip: extracting tokens

This commit is contained in:
2026-04-17 15:37:36 +01:00
parent 01f59b8770
commit 1b8f598222
3 changed files with 94 additions and 18 deletions
+10 -1
View File
@@ -6,16 +6,25 @@ import (
"path/filepath"
"regexp"
"strings"
"github.com/hazemKrimi/jack-compiler/internal/tokenizer"
)
func process(inputPath string) error {
outputPath := strings.Replace(inputPath, ".jack", ".xml", 1)
source, err := os.ReadFile(inputPath)
if err != nil {
return err
}
tokens := make([]tokenizer.Token, 0, 1000)
if err := tokenizer.ExtractTokens(&tokens, source); err != nil {
return err
}
outputPath := strings.Replace(inputPath, ".jack", ".xml", 1)
if err := os.WriteFile(outputPath, source, 0644); err != nil {
return err
}