forked from x/ContextOS
Merge branch 'tce'
This commit is contained in:
commit
62af8f9a2e
@ -99,6 +99,7 @@ func (cli *CLI) Start(m *ctx.Message, arg ...string) bool { // {{{
|
|||||||
yac.Cmd("train", "num", "num", "mul{", "0", "-?[1-9][0-9]*", "0[0-9]+", "0x[0-9]+", "}")
|
yac.Cmd("train", "num", "num", "mul{", "0", "-?[1-9][0-9]*", "0[0-9]+", "0x[0-9]+", "}")
|
||||||
yac.Cmd("train", "str", "str", "mul{", "\"[^\"]*\"", "'[^']*'", "}")
|
yac.Cmd("train", "str", "str", "mul{", "\"[^\"]*\"", "'[^']*'", "}")
|
||||||
yac.Cmd("train", "tran", "tran", "mul{", "@", "$", "}", "opt{", "[a-zA-Z0-9_]+", "}")
|
yac.Cmd("train", "tran", "tran", "mul{", "@", "$", "}", "opt{", "[a-zA-Z0-9_]+", "}")
|
||||||
|
yac.Cmd("train", "tran", "tran", "$", "(", "cache", ")")
|
||||||
|
|
||||||
yac.Cmd("train", "op1", "op1", "mul{", "$", "@", "}")
|
yac.Cmd("train", "op1", "op1", "mul{", "$", "@", "}")
|
||||||
yac.Cmd("train", "op1", "op1", "mul{", "-z", "-n", "}")
|
yac.Cmd("train", "op1", "op1", "mul{", "-z", "-n", "}")
|
||||||
@ -317,9 +318,13 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
|||||||
|
|
||||||
if len(arg) > 0 {
|
if len(arg) > 0 {
|
||||||
if i, e := strconv.Atoi(arg[0]); e == nil {
|
if i, e := strconv.Atoi(arg[0]); e == nil {
|
||||||
|
m.Option("time_format", m.Conf("time_format"))
|
||||||
t = time.Unix(int64(i/m.Confi("time_unit")), 0)
|
t = time.Unix(int64(i/m.Confi("time_unit")), 0)
|
||||||
arg = arg[1:]
|
arg = arg[1:]
|
||||||
m.Option("time_format", m.Conf("time_format"))
|
} else if n, e := time.ParseInLocation(m.Confx("time_format"), arg[0], time.Local); e == nil {
|
||||||
|
m.Option("parse", arg[0])
|
||||||
|
arg = arg[1:]
|
||||||
|
t = n
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -380,7 +385,7 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
|||||||
// }}}
|
// }}}
|
||||||
}},
|
}},
|
||||||
"echo": &ctx.Command{Name: "echo arg...", Help: "函数调用, name: 函数名, arg: 参数", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
"echo": &ctx.Command{Name: "echo arg...", Help: "函数调用, name: 函数名, arg: 参数", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||||
m.Echo("%s", strings.Join(arg[1:], ""))
|
m.Echo("%s", strings.Join(arg, ""))
|
||||||
}},
|
}},
|
||||||
|
|
||||||
"tran": &ctx.Command{Name: "tran word", Help: "", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
"tran": &ctx.Command{Name: "tran word", Help: "", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||||
|
@ -239,7 +239,10 @@ var Index = &ctx.Context{Name: "mdb", Help: "数据中心",
|
|||||||
"show": &ctx.Command{
|
"show": &ctx.Command{
|
||||||
Name: "show table fields... [where conditions] [group fields] [order fields] [limit fields] [offset fields] [save filename] [other rest...]",
|
Name: "show table fields... [where conditions] [group fields] [order fields] [limit fields] [offset fields] [save filename] [other rest...]",
|
||||||
Help: "查询数据库, table: 表名, fields: 字段, where: 查询条件, group: 聚合字段, order: 排序字段",
|
Help: "查询数据库, table: 表名, fields: 字段, where: 查询条件, group: 聚合字段, order: 排序字段",
|
||||||
Form: map[string]int{"where": 1, "group": 1, "order": 1, "limit": 1, "offset": 1, "extras": 1, "extra_format": 1, "trans_field": 1, "trans_map": 2, "save": 1, "export": 1, "other": -1},
|
Form: map[string]int{
|
||||||
|
"where": 1, "group": 1, "order": 1, "limit": 1, "offset": 1,
|
||||||
|
"extras": 1, "extra_format": 1, "trans_field": 1, "trans_map": 2,
|
||||||
|
"save": 1, "save_format": 1, "csv_col_sep": 1, "export": 1, "other": -1},
|
||||||
Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||||
if mdb, ok := m.Target().Server.(*MDB); m.Assert(ok) { // {{{
|
if mdb, ok := m.Target().Server.(*MDB); m.Assert(ok) { // {{{
|
||||||
table := m.Confx("table", arg, 0)
|
table := m.Confx("table", arg, 0)
|
||||||
@ -282,7 +285,15 @@ var Index = &ctx.Context{Name: "mdb", Help: "数据中心",
|
|||||||
}
|
}
|
||||||
|
|
||||||
m.Table(func(maps map[string]string, lists []string, line int) bool {
|
m.Table(func(maps map[string]string, lists []string, line int) bool {
|
||||||
|
args := []interface{}{}
|
||||||
|
|
||||||
for i, v := range lists {
|
for i, v := range lists {
|
||||||
|
if m.Options("save_format") {
|
||||||
|
key := m.Meta["append"][i]
|
||||||
|
value := maps[key]
|
||||||
|
args = append(args, value)
|
||||||
|
continue
|
||||||
|
}
|
||||||
if m.Options("save") {
|
if m.Options("save") {
|
||||||
key := m.Meta["append"][i]
|
key := m.Meta["append"][i]
|
||||||
value := maps[key]
|
value := maps[key]
|
||||||
@ -302,10 +313,17 @@ var Index = &ctx.Context{Name: "mdb", Help: "数据中心",
|
|||||||
m.Echo(v)
|
m.Echo(v)
|
||||||
}
|
}
|
||||||
if i < len(lists)-1 {
|
if i < len(lists)-1 {
|
||||||
m.Echo(m.Conf("csv_col_sep"))
|
m.Echo(m.Confx("csv_col_sep"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m.Echo(m.Conf("csv_row_sep"))
|
if m.Options("save_format") {
|
||||||
|
if line > -1 {
|
||||||
|
m.Echo(fmt.Sprintf(m.Option("save_format"), args...))
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
m.Echo(m.Confx("csv_row_sep"))
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -186,7 +186,9 @@ func (yac *YAC) train(m *ctx.Message, page, hash int, word []string) (int, []*Po
|
|||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
func (yac *YAC) parse(m *ctx.Message, out *ctx.Message, page int, void int, line string, level int) (string, []string) { // {{{
|
func (yac *YAC) parse(m *ctx.Message, out *ctx.Message, page int, void int, line string, level int) (string, []string) { // {{{
|
||||||
// m.Log("debug", nil, "%s\\%d %s(%d): %s", m.Conf("label")[0:level], level, yac.name(page), page, line)
|
if m.Confs("debug") {
|
||||||
|
m.Log("debug", nil, "%s\\%d %s(%d): %s", m.Conf("label")[0:level], level, yac.name(page), page, line)
|
||||||
|
}
|
||||||
|
|
||||||
hash, word := 0, []string{}
|
hash, word := 0, []string{}
|
||||||
for star, s := 0, page; s != 0 && len(line) > 0; {
|
for star, s := 0, page; s != 0 && len(line) > 0; {
|
||||||
@ -249,7 +251,10 @@ func (yac *YAC) parse(m *ctx.Message, out *ctx.Message, page int, void int, line
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// m.Log("debug", nil, "%s/%d %s(%d): %v", m.Conf("label")[0:level], level, yac.name(page), page, word)
|
if m.Confs("debug") {
|
||||||
|
m.Log("debug", nil, "%s/%d %s(%d): %v", m.Conf("label")[0:level], level, yac.name(page), page, word)
|
||||||
|
}
|
||||||
|
|
||||||
return line, word
|
return line, word
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -368,6 +373,7 @@ var Index = &ctx.Context{Name: "yac", Help: "语法中心",
|
|||||||
"nparse": &ctx.Cache{Name: "nparse", Value: "0", Help: "解析器数量"},
|
"nparse": &ctx.Cache{Name: "nparse", Value: "0", Help: "解析器数量"},
|
||||||
},
|
},
|
||||||
Configs: map[string]*ctx.Config{
|
Configs: map[string]*ctx.Config{
|
||||||
|
"debug": &ctx.Config{Name: "debug", Value: "true", Help: "词法集合的最大数量"},
|
||||||
"ncell": &ctx.Config{Name: "词法上限", Value: "128", Help: "词法集合的最大数量"},
|
"ncell": &ctx.Config{Name: "词法上限", Value: "128", Help: "词法集合的最大数量"},
|
||||||
"nlang": &ctx.Config{Name: "语法上限", Value: "32", Help: "语法集合的最大数量"},
|
"nlang": &ctx.Config{Name: "语法上限", Value: "32", Help: "语法集合的最大数量"},
|
||||||
"label": &ctx.Config{Name: "嵌套标记", Value: "####################", Help: "嵌套层级日志的标记"},
|
"label": &ctx.Config{Name: "嵌套标记", Value: "####################", Help: "嵌套层级日志的标记"},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user