reorder built-ins a bit

This commit is contained in:
David 2021-02-24 20:46:31 -05:00
parent 4727312da4
commit 241470248b

View File

@ -30,9 +30,12 @@ func main() {
// word definitions
dict.AddWord(":", Word{Name: ":", Impl: b.Colon(&c)})
dict.AddWord(";", Word{Name: ";", Impl: b.Semicolon(&c), Immediate: true})
// comments
// comments and strings
dict.AddWord("(", Word{Name: "(", Impl: b.OpenComment(&c), Immediate: true})
dict.AddWord(")", Word{Name: ")", Impl: b.CloseComment(&c), Immediate: true})
dict.AddWord(`."`, Word{Name: `."`, Impl: b.OpenQuote(os.Stdout, &rstack, '"')})
dict.AddWord(`"`, Word{Name: `"`, Impl: b.CloseQuote(&c)})
dict.AddWord(`.(`, Word{Name: `.(`, Impl: b.OpenQuote(os.Stdout, &rstack, ')'), Immediate: true})
// math
dict.AddWord("+", Word{Name: "+", Impl: b.Add(&stack)})
dict.AddWord("-", Word{Name: "-", Impl: b.Sub(&stack)})
@ -50,10 +53,6 @@ func main() {
dict.AddWord(".", Word{Name: ".", Impl: b.Print(os.Stdout, &stack)})
dict.AddWord("EMIT", Word{Name: "EMIT", Impl: b.Emit(os.Stdout, &stack)})
dict.AddWord("CR", Word{Name: "CR", Source: []string{"10", "EMIT"}}) // emit a newline
// strings
dict.AddWord(`."`, Word{Name: `."`, Impl: b.OpenQuote(os.Stdout, &rstack, '"')})
dict.AddWord(`"`, Word{Name: `"`, Impl: b.CloseQuote(&c)})
dict.AddWord(`.(`, Word{Name: `.(`, Impl: b.OpenQuote(os.Stdout, &rstack, ')'), Immediate: true})
// logic
dict.AddWord("=", Word{Name: "=", Impl: b.Eq(&stack)})
dict.AddWord("0=", Word{Name: "0=", Source: []string{"0", "="}})