mirror of
https://github.com/hazemKrimi/jack-compiler.git
synced 2026-05-01 17:48:57 +00:00
28 lines
452 B
Go
28 lines
452 B
Go
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
|
|
}
|