Implemented else blocks

This commit is contained in:
Eduard Urbach 2024-07-30 16:36:33 +02:00
parent ff86dfe590
commit e537e543cc
Signed by: eduard
GPG key ID: 49226B848C78F6C8
17 changed files with 118 additions and 25 deletions

View file

@ -7,19 +7,19 @@ import (
// Parse generates an AST from a list of tokens.
func Parse(tokens []token.Token, source []byte) (AST, error) {
tree := make(AST, 0, len(tokens)/64)
nodes := make(AST, 0, len(tokens)/64)
err := EachInstruction(tokens, func(instruction token.List) error {
node, err := parseNode(instruction, source)
node, err := parseNode(instruction, source, nodes)
if err == nil && node != nil {
tree = append(tree, node)
nodes = append(nodes, node)
}
return err
})
return tree, err
return nodes, err
}
// IsAssignment returns true if the expression is an assignment.