This repository has been archived by the owner on Dec 22, 2021. It is now read-only.
/
throff.go
61 lines (52 loc) · 1.58 KB
/
throff.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
//"log"
"os"
"strings"
"github.com/abadojack/whatlanggo"
"github.com/donomii/throfflib"
)
//_ "net/http/pprof"
var lang = "en"
func main() {
go func() {
//log.Println(http.ListenAndServe("localhost:6060", nil))
}()
t := throfflib.MakeEngine()
strs := os.Args[1:]
if len(strs) == 1 {
if strs[0] == "--shell" {
t = t.RunString(throfflib.BootStrapString(), "Internal Bootstrap")
//t.RunString(" PRINTLN [ Welcome to Throff Shell v0.1 ] PRINTLN NEWLINE ", "repl")
throfflib.Shell(t, lang == "en")
}
for _, arg := range strs {
if whatlanggo.Jpn == whatlanggo.Detect(arg).Lang {
lang = "jp"
//log.Println("Japanese detected")
}
}
}
//t = t.RunFile("bootstrapgo.lib")
t = t.RunString(throfflib.BootStrapString(), "Internal Bootstrap")
if len(strs) == 0 {
if strings.Contains(os.Args[0], "小日本語") {
lang = "jp"
t = t.RunString("PRINTLN [ 小日本語 0.1. 使い方ヘップを入力しなさい ] PRINTLN NEWLINE ", "repl")
} else {
t = t.RunString("PRINTLN [ Welcome to Throff v0.1. Type HELP for help. ] PRINTLN NEWLINE ", "repl")
}
throfflib.Repl(t, lang == "jp")
} else {
throfflib.PrintWarnings = false
if lang == "jp" {
throfflib.BraceMode = "forth"
strs = strings.Split(strs[0], " ")
}
t = t.RunString("SPACE", "Command line evaluator") //We print the top of the stack after the calculation. If the calculation returns nothing, we don't want to print "Stack empty"
tokens := throfflib.StringsToTokens(strs)
t.LoadTokens(tokens)
t = t.Run()
t.RunString("PRINTLN", "replprint")
}
}