move int parsing to after word check

This commit is contained in:
David 2021-02-20 19:22:36 -05:00
parent ff5346994f
commit 0676cad34d
1 changed files with 9 additions and 10 deletions

19
eval.go
View File

@ -46,17 +46,10 @@ func (c *Context) Eval(line string) error {
ifcheck, _ := c.IfStack.Pick(0)
if len(c.IfStack.values) == 0 || (len(c.IfStack.values) > 0 && ifcheck == 1) || w.BranchCheck {
int, err := strconv.Atoi(sword)
if err == nil {
// it was a number! put it on the stack.
c.Stack.Push(int)
word = []byte{}
continue
}
// run word
c.RStack.Push(i)
if err = c.Exec(w); err != nil {
err := c.Exec(w)
if err != nil {
return err
}
i, err = c.RStack.Pop()
@ -88,7 +81,13 @@ func (c *Context) Exec(w Word) error {
return err
}
} else {
return fmt.Errorf("unable to parse word %s", w.Name)
it, err := strconv.Atoi(w.Name)
if err == nil {
// it was a number! put it on the stack.
c.Stack.Push(it)
} else {
return fmt.Errorf("unable to parse word %s", w.Name)
}
}
return nil
}