mirror of
https://github.com/hazemKrimi/jack-compiler.git
synced 2026-05-01 17:48:57 +00:00
chore: sample parser for testing the tokenizer output
This commit is contained in:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user