chore: sample parser for testing the tokenizer output

This commit is contained in:
2026-04-17 18:49:36 +01:00
parent 1b8f598222
commit 738743e4ec
+27
View File
@@ -0,0 +1,27 @@
package parser
import (
"github.com/hazemKrimi/jack-compiler/internal/tokenizer"
)
func ParseTokens(tokens []tokenizer.Token) string {
output := "<tokens>\n"
for _, token := range tokens {
switch token.Type {
case tokenizer.SYMBOL:
{
output += "<symbol>" + token.Value + "</symbol>\n"
}
case tokenizer.KEYWORD:
{
output += "<keyword>" + token.Value + "</keyword>\n"
}
}
}
output += "</tokens>\n"
return output
}