mirror of
https://github.com/hazemKrimi/jack-compiler.git
synced 2026-05-01 17:48:57 +00:00
feat: compile first test program
This commit is contained in:
@@ -1,11 +1,5 @@
|
||||
package table
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type VariableKind int
|
||||
|
||||
const (
|
||||
@@ -59,27 +53,6 @@ func UseVariable(symbolTables []*map[string]Variable, name string) {
|
||||
}
|
||||
}
|
||||
|
||||
func WriteImplicitThis(output *strings.Builder, symbolTables []*map[string]Variable) error {
|
||||
variable, found := GetVariable(symbolTables, "this")
|
||||
|
||||
if found {
|
||||
tokenDefinition := "<implicitVariable> "
|
||||
tokenDefinition += "name: this, "
|
||||
tokenDefinition += "type: " + variable.Type + ", "
|
||||
tokenDefinition += "kind: " + fmt.Sprint(variable.Kind) + ", "
|
||||
tokenDefinition += "count: " + fmt.Sprint(variable.Count) + ", "
|
||||
tokenDefinition += "declared: " + strconv.FormatBool(variable.IsDeclared) + ", "
|
||||
tokenDefinition += "used: " + strconv.FormatBool(variable.IsUsed)
|
||||
tokenDefinition += "</variable>\n"
|
||||
|
||||
if _, err := output.WriteString(tokenDefinition); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func AppendVariable(symbolTable *map[string]Variable, name string, variableType string, kind VariableKind) {
|
||||
(*symbolTable)[name] = Variable{Type: variableType, Kind: kind, Count: CountVariables(symbolTable, kind) + 1, IsDeclared: true}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user