mirror of
https://github.com/hazemKrimi/jack-compiler.git
synced 2026-05-01 17:48:57 +00:00
fix: more errors found after further testing
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user