Added more tests
This commit is contained in:
@ -61,7 +61,7 @@ func toASTNode(tokens token.List) (Node, error) {
|
||||
switch {
|
||||
case IsVariableDefinition(expr):
|
||||
if len(expr.Children) < 2 {
|
||||
return nil, errors.New(errors.MissingAssignValue, nil, expr.Token.End())
|
||||
return nil, errors.New(errors.MissingOperand, nil, expr.Token.End())
|
||||
}
|
||||
|
||||
name := expr.Children[0].Token
|
||||
@ -70,7 +70,7 @@ func toASTNode(tokens token.List) (Node, error) {
|
||||
|
||||
case IsAssignment(expr):
|
||||
if len(expr.Children) < 2 {
|
||||
return nil, errors.New(errors.MissingAssignValue, nil, expr.Token.End())
|
||||
return nil, errors.New(errors.MissingOperand, nil, expr.Token.End())
|
||||
}
|
||||
|
||||
name := expr.Children[0].Token
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"git.akyoto.dev/cli/q/src/build/asm"
|
||||
"git.akyoto.dev/cli/q/src/build/ast"
|
||||
"git.akyoto.dev/cli/q/src/build/cpu"
|
||||
"git.akyoto.dev/cli/q/src/build/errors"
|
||||
"git.akyoto.dev/cli/q/src/build/expression"
|
||||
)
|
||||
|
||||
@ -23,6 +24,10 @@ func (f *Function) ExpressionToRegister(node *expression.Expression, register cp
|
||||
return err
|
||||
}
|
||||
|
||||
if len(node.Children) < 2 {
|
||||
return errors.New(errors.MissingOperand, f.File, node.Token.End())
|
||||
}
|
||||
|
||||
left := node.Children[0]
|
||||
right := node.Children[1]
|
||||
final := register
|
||||
|
@ -3,7 +3,7 @@ package errors
|
||||
var (
|
||||
InvalidStatement = &Base{"Invalid statement"}
|
||||
InvalidExpression = &Base{"Invalid expression"}
|
||||
MissingAssignValue = &Base{"Missing assignment value"}
|
||||
MissingOperand = &Base{"Missing operand"}
|
||||
MissingMainFunction = &Base{"Missing main function"}
|
||||
NotImplemented = &Base{"Not implemented"}
|
||||
)
|
||||
|
Reference in New Issue
Block a user