Improved division split

This commit is contained in:
2024-07-28 18:12:42 +02:00
parent bb74c0cf50
commit c2c147f1b4
11 changed files with 84 additions and 64 deletions

View File

@ -15,7 +15,7 @@ func Count(body AST, buffer []byte, kind token.Kind, name string) uint8 {
count += node.Expression.Count(buffer, kind, name)
case *Define:
count += node.Value.Count(buffer, kind, name)
count += node.Expression.Count(buffer, kind, name)
case *Return:
if node.Value != nil {

View File

@ -2,11 +2,9 @@ package ast
import (
"git.akyoto.dev/cli/q/src/build/expression"
"git.akyoto.dev/cli/q/src/build/token"
)
// Define represents a variable definition.
type Define struct {
Value *expression.Expression
Name token.Token
Expression *expression.Expression
}

View File

@ -83,9 +83,7 @@ func toASTNode(tokens token.List, buffer []byte) (Node, error) {
return nil, errors.New(errors.MissingOperand, nil, expr.Token.End())
}
name := expr.Children[0].Token
value := expr.Children[1]
return &Define{Name: name, Value: value}, nil
return &Define{Expression: expr}, nil
case IsAssignment(expr):
if len(expr.Children) < 2 {