move int parsing to after word check
This commit is contained in:
parent
ff5346994f
commit
0676cad34d
19
eval.go
19
eval.go
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user