fix: more errors found after further testing

This commit is contained in:
2026-04-21 18:16:18 +01:00
parent f81aa97baa
commit b8af4eda84
@@ -81,7 +81,7 @@ func compileParameterList(output *strings.Builder, tokens []tokenizer.Token, ind
*(index)++
if tokens[*index].Type == tokenizer.SYMBOL && tokens[*index].Value == "," {
output.WriteString("<keyword> " + tokens[*index].Value + " </keyword>\n")
output.WriteString("<symbol> " + tokens[*index].Value + " </symbol>\n")
*(index)++
return compileParameterList(output, tokens, index)
@@ -95,6 +95,8 @@ func compileVariableDeclaration(output *strings.Builder, tokens []tokenizer.Toke
return nil
}
output.WriteString("<varDec>\n")
output.WriteString("<keyword> " + tokens[*index].Value + " </keyword>\n")
*(index)++
@@ -136,6 +138,8 @@ func compileVariableDeclaration(output *strings.Builder, tokens []tokenizer.Toke
output.WriteString("<symbol> " + tokens[*index].Value + " </symbol>\n")
(*index)++
output.WriteString("</varDec>\n")
return compileVariableDeclaration(output, tokens, index)
}
@@ -500,13 +504,9 @@ func compileStatements(output *strings.Builder, tokens []tokenizer.Token, index
func compileSubroutineBody(output *strings.Builder, tokens []tokenizer.Token, index *int) error {
if tokens[*index].Type == tokenizer.KEYWORD && tokens[*index].Value == "var" {
output.WriteString("<varDec>\n")
if err := compileVariableDeclaration(output, tokens, index); err != nil {
return err
}
output.WriteString("</varDec>\n")
}
output.WriteString("<statements>\n")