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)
|
ifcheck, _ := c.IfStack.Pick(0)
|
||||||
if len(c.IfStack.values) == 0 || (len(c.IfStack.values) > 0 && ifcheck == 1) || w.BranchCheck {
|
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
|
// run word
|
||||||
c.RStack.Push(i)
|
c.RStack.Push(i)
|
||||||
if err = c.Exec(w); err != nil {
|
err := c.Exec(w)
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
i, err = c.RStack.Pop()
|
i, err = c.RStack.Pop()
|
||||||
@ -88,7 +81,13 @@ func (c *Context) Exec(w Word) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
} 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
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user