Commit Graph

638 Commits

Author SHA1 Message Date
Qi Xiao
72f92911e2 Put myself in foreground after pipeline finishes.
This fixes #105.
2016-02-11 18:59:18 +01:00
Qi Xiao
a21f2a1bb7 Handle SIGINT when waiting for tasks to exit.
Tasks are given 50ms to exit. If they didn't, they are left running but has a
special "still running" exit status.

This mitigates #100.
2016-02-11 15:55:22 +01:00
Qi Xiao
655688e719 Use channel, not shared array to collect exit status.
Don't communicate by sharing memory, share memory by communicating.
2016-02-11 15:32:44 +01:00
Qi Xiao
bf10f121d7 eval.getHome -> osutil.GetHome 2016-02-11 00:12:48 +01:00
Qi Xiao
8a18ca4fa1 Implement an Indexer -> Caller adapter.
This fixes #90.
2016-02-10 22:01:56 +01:00
Qi Xiao
5e02996838 Fix outdated error message. 2016-02-10 21:52:48 +01:00
Qi Xiao
018de2ad8b EvalInteractive now uses a closed channel for input.
This prevents commands like `from-json` from hanging elvish when they appear
as the first form of a pipeline.
2016-02-10 21:46:02 +01:00
Qi Xiao
307f7fe6f0 Add a builtin -sleep. 2016-02-09 18:18:18 +01:00
Qi Xiao
a768ba8f40 Fix last commit... 2016-02-09 18:08:39 +01:00
Qi Xiao
67b9de70ce eval: When compounding, reuse vs with caution.
This fixes #99.
2016-02-09 18:07:06 +01:00
Qi Xiao
6097cfd76d eval: Introduce (*Port).Fork. 2016-02-09 01:40:36 +01:00
Qi Xiao
4ff3f771d1 eval: Don't close ports in (*Evaler).Eval. 2016-02-09 01:34:19 +01:00
Qi Xiao
63bc4ec9c9 eval: Use sync.WaitGroup. 2016-02-09 01:23:40 +01:00
Qi Xiao
f3c82a65b0 Don't close ports in Closure.Call.
This fixes #92.
2016-02-09 01:18:26 +01:00
Qi Xiao
9159cacf42 Parse globs correctly. 2016-02-09 00:05:34 +01:00
Qi Xiao
832448e047 logutil.Sink -> .Discard 2016-02-08 20:51:44 +01:00
Qi Xiao
b8684428bf Support binding key to elvish function.
This fully resolves #39.
2016-02-08 20:40:39 +01:00
Qi Xiao
6f5babd294 eval: More exports. 2016-02-08 20:30:00 +01:00
Qi Xiao
692f101de5 eval: Exports and cleanup. 2016-02-08 20:11:20 +01:00
Qi Xiao
7d33e0379e eval: Remove commented code; expose NewTopEvalCtx. 2016-02-08 19:33:10 +01:00
Qi Xiao
aa441ae0e7 eval: Make handling of ports in Eval explicit. 2016-02-08 18:51:06 +01:00
Qi Xiao
24c2b665c5 eval: Omit receivers in Type() implementations. 2016-02-08 01:25:03 +01:00
Qi Xiao
8125e2f9e6 golint fixes. 2016-02-07 23:23:16 +01:00
Qi Xiao
9e40b129e1 Implement basic wildcard.
Implicit concat in compounds is much more strict now.
2016-02-07 20:39:03 +01:00
Qi Xiao
d4e8659853 Remove outdated comment. 2016-02-07 14:45:07 +01:00
Qi Xiao
2296221e65 Implement tilde expansion. 2016-02-07 14:44:08 +01:00
Qi Xiao
802c7b5e19 eval: Generate boilerplate *Begins functions. 2016-02-07 14:13:12 +01:00
Qi Xiao
97d8aa2cb2 * -> mul; / -> div. 2016-02-07 14:12:19 +01:00
Qi Xiao
db12e5711c Implement take and drop builtins. 2016-02-07 03:50:38 +01:00
Qi Xiao
c91767cebc visisted-dirs -> dirs; jump-dir -> jump 2016-02-07 03:17:10 +01:00
Qi Xiao
087bddcc31 Implement splicing with $@varname.
This fixes #81.
2016-02-07 03:12:54 +01:00
Qi Xiao
91d1da7caf Pretty poor support for variadic function. 2016-02-07 02:50:11 +01:00
Qi Xiao
9fd7154b2b Implement $args and $kwargs.
Functions do not support named arguments yet, so $kwargs is always [&]. This
fixes #80.
2016-02-07 02:39:06 +01:00
Qi Xiao
64401af225 Variable nodes now have the variable name in .Value. 2016-02-07 02:31:11 +01:00
Qi Xiao
04ce6ddc67 Fix implicit cd. 2016-02-07 01:15:10 +01:00
Qi Xiao
5c55af6866 Regenerate eval/type_string.go. 2016-02-07 01:06:34 +01:00
Qi Xiao
70917927b0 Test against Repr method of Value types. 2016-02-07 00:55:42 +01:00
Qi Xiao
01d73158c0 Fix Repr of empty Map. 2016-02-07 00:47:45 +01:00
Qi Xiao
d8702d78c5 Implement multi-error. 2016-02-07 00:47:25 +01:00
Qi Xiao
a41182a48a Parsing of ?( and []{ is now safe; quote \n with ' 2016-02-07 00:41:31 +01:00
Qi Xiao
4b7746e95a Fix test cases. 2016-02-06 00:43:51 +01:00
Qi Xiao
ddb7396046 Highlight compiling errors.
This fixes #64.
2016-02-05 23:25:13 +00:00
Qi Xiao
5c8a8d5eec Make parse report all errors. 2016-02-06 00:08:39 +01:00
Qi Xiao
fa92057e05 eval: Remove a "hanger" test case since it no longer hangs. 2016-02-05 22:30:43 +01:00
Qi Xiao
3e0dc9c57b parse and compile argumentless lambdas 2016-02-05 01:04:52 +01:00
Qi Xiao
6a5f6bf244 indexed -> indexing 2016-02-03 15:36:12 +00:00
Qi Xiao
e0f3ab6ec0 Don't Open then Stat, just Stat.
This fixes #58.
2016-02-02 15:55:29 +00:00
Qi Xiao
6c73af7b47 eval: support setting list and map elements 2016-02-01 11:42:28 +01:00
Qi Xiao
eccf8c58fb eval: fix unpack and put-all to use List instead of *List 2016-02-01 11:36:33 +01:00
Qi Xiao
4715a349a4 eval: implement output redir correctly in Evaler.evalWithChanOut 2016-02-01 11:23:30 +01:00
Qi Xiao
aacb662a38 Support Value keys in Map.
The definition of Map has also been changed to make it comparable. The =
builtin now simply wraps the = operator of golang; a new builtin deepeq
compares values recursively.
2016-02-01 09:20:01 +01:00
Qi Xiao
b7726decb3 eval: remove the error from the return value of Indexer.Index 2016-02-01 08:20:57 +01:00
Qi Xiao
e0bc455b70 typo fix 2016-02-01 08:10:20 +01:00
Qi Xiao
9cbf1c2567 eval: support assignment 2016-01-31 20:36:14 +01:00
Qi Xiao
f15bbaeab5 eval: Foreign interface now uses plain error 2016-01-31 02:29:46 +01:00
Qi Xiao
cf651e0ba8 eval: remove explicit Error from builtin functions 2016-01-31 02:21:46 +01:00
Qi Xiao
bd6b7f47f0 eval: remove explicit Exitus from Call 2016-01-31 02:11:10 +01:00
Qi Xiao
8d8fdb94fc eval: start the switch to using throw/catch for error handling 2016-01-31 02:00:31 +01:00
Qi Xiao
c1b7701a68 combine Error and error into an error in eval functions 2016-01-31 01:40:49 +01:00
Qi Xiao
c2507ad73b eval: make List a struct 2016-01-31 01:07:35 +01:00
Qi Xiao
8860d1ef0e eval: make Error a wrapper around error 2016-01-31 01:04:00 +01:00
Qi Xiao
82e027e435 Exitus -> Error 2016-01-30 17:11:43 +01:00
Qi Xiao
8095ba64da new "bind" builtin to modify keybinding 2016-01-30 16:47:11 +01:00
Qi Xiao
94f1991482 eval: remove exitusChOp 2016-01-30 15:12:24 +00:00
Qi Xiao
1a46de7f4b eval: ele -> le 2016-01-29 14:37:50 +01:00
Qi Xiao
fd99288e10 eval: fix exitus of ele 2016-01-29 14:06:15 +01:00
Qi Xiao
a3c2bf37d8 eval: NewEvaler no longer takes dataDir 2016-01-29 14:01:51 +01:00
Qi Xiao
e795b6de40 eval: internalVariable -> ptrVariable 2016-01-29 13:59:00 +01:00
Qi Xiao
268fc50c95 eval: remove HasFailure 2016-01-29 13:56:44 +01:00
Qi Xiao
44695ad145 eval: expose most Value funcs 2016-01-29 13:55:14 +01:00
Qi Xiao
313565ed5d new ele builtin to call line editor from script 2016-01-29 04:10:25 +00:00
Qi Xiao
3b57424e6f eval: expose Exitus 2016-01-29 03:51:47 +00:00
Qi Xiao
b0568168e8 exitus cleanup 2016-01-28 23:39:20 +01:00
Qi Xiao
96a891321c eval: tiny cleanup 2016-01-28 22:26:24 +01:00
Qi Xiao
c5cf525d88 eval: remove the duty of closePorts from callable.Call 2016-01-28 22:18:10 +01:00
Qi Xiao
d794dbf210 eval: (*evalCtx).copy -> fork 2016-01-28 22:04:31 +01:00
Qi Xiao
d0a88e4961 eval: make all "exec" funcs synchronous 2016-01-28 22:00:50 +01:00
Qi Xiao
4c4313eeb0 eval: test against pure channel pipeline 2016-01-28 21:30:32 +01:00
Qi Xiao
c1d3eb11dd eval: ditch stateUpdate; just use exitus 2016-01-28 21:06:02 +01:00
Qi Xiao
dfc8451627 eval: parse-ng -> parse in boilerplate 2016-01-28 21:06:01 +01:00
Qi Xiao
0a30f08356 fancy unicode for printing bad exitus 2016-01-28 14:03:12 +01:00
Qi Xiao
389e3c14f8 new -stack builtin to show stacks of all goroutines 2016-01-28 14:02:39 +01:00
Qi Xiao
ce5c22d88a color and complete autocd; support autocd for .. 2016-01-28 00:40:50 +01:00
Qi Xiao
0b293b3ba1 eval: fix printing of map 2016-01-28 00:25:36 +01:00
Qi Xiao
23a8d139cd eval: implement implicit cd
This fixes #68.
2016-01-27 23:20:29 +00:00
Qi Xiao
32108f2316 eval: break implementation of indexing into methods 2016-01-27 22:58:24 +00:00
Qi Xiao
8d65044d54 eval: table is now callable 2016-01-27 21:38:49 +00:00
Qi Xiao
8c849af711 prefix for functions is now "&". 2016-01-27 21:24:17 +00:00
Qi Xiao
4ef1f82e96 eval: fix deadlock with evalWithOut 2016-01-27 20:47:41 +00:00
Qi Xiao
0efb651e25 eval: (out capt) now also captures bytes 2016-01-27 20:34:58 +00:00
Qi Xiao
989e10cdb7 eval: synchronize conversion of channel to stdout correctly 2016-01-27 20:05:02 +00:00
Qi Xiao
c5bb836835 eval: add $paths 2016-01-27 19:16:41 +00:00
Qi Xiao
0851184d50 add a put-all builtin 2016-01-27 00:11:47 +01:00
Qi Xiao
5e410a733f fix - builtin 2016-01-26 20:59:34 +01:00
Qi Xiao
1b93fcd988 eval: builtin revamps 2016-01-26 19:17:28 +01:00
Qi Xiao
c3c75bf67e eval: remove BuiltinFnNames 2016-01-26 18:02:50 +01:00
Qi Xiao
a48fab1ed8 eval: builtin true is synonym with : 2016-01-26 17:49:46 +01:00
Qi Xiao
e763f70226 builtins {print,feed}chan -> {into,from}-lines; parse-json -> from-json 2016-01-26 17:48:41 +01:00
Qi Xiao
76c1c97d46 expose eval.fnPrefix; update docstring for fn 2016-01-26 17:42:37 +01:00
Qi Xiao
58bc615caa expose Evaler.global via .Global 2016-01-26 00:41:52 +01:00
Qi Xiao
673c2438d2 eval: Factor out DontSearch 2016-01-26 00:26:49 +01:00
Qi Xiao
ad73f297c2 eval: move Evaler.Search to separate file; expose isExecutable 2016-01-26 00:04:54 +01:00
Qi Xiao
a65ff31b29 eval: expose Evaler.search 2016-01-25 23:57:22 +01:00
Qi Xiao
e2292b9680 eval: there is no builtin: namespace anymore. 2016-01-25 23:53:40 +01:00
Qi Xiao
743185f6f3 eval: make lexical scoping less broken 2016-01-25 23:53:17 +01:00
Qi Xiao
0e1f1fe408 eval: add a new failing test case on lexical scoping 2016-01-25 23:28:24 +01:00
Qi Xiao
5c4de3302a add semantic coloring of variables 2016-01-25 23:09:47 +01:00
Qi Xiao
4b2fbce4bc parse: Don't expose Node.N() 2016-01-24 19:04:15 +01:00
Qi Xiao
9eee803638 eval: mention command name in "command not found" message 2016-01-24 18:35:14 +01:00
Qi Xiao
233a8f4b07 parse-ng -> parse 2016-01-24 18:15:21 +01:00
Qi Xiao
3f320f1356 eval: Add a test for closure behavior 2016-01-24 18:15:16 +01:00
Qi Xiao
d0de8606cf eval: test exitus when tt.wantExitus==nil 2016-01-24 18:15:16 +01:00
Qi Xiao
a3ad98875a eval: Type is now just an enum; small fixes 2016-01-24 18:15:15 +01:00
Qi Xiao
db5c34ec61 eval: var.go -> variable.go 2016-01-24 18:15:15 +01:00
Qi Xiao
66d3c84fad eval: remove code related to static type 2016-01-24 18:15:14 +01:00
Qi Xiao
b88b9a0793 eval: fn is back 2016-01-24 18:15:14 +01:00
Qi Xiao
8457b23924 eval: enable more test cases 2016-01-24 18:15:14 +01:00
Qi Xiao
1cca989a6b eval: set and del are back.
There is no `var` any more; `set` automatically creates variables in the local
scope if they do not yet exist. To force shadowing an outer variable with the
same name, use `set local:varname = value`.
2016-01-24 18:15:13 +01:00
Qi Xiao
884e59dc99 eval: small refactors 2016-01-24 18:15:12 +01:00
Qi Xiao
9ffb2ee2a2 eval: registerVariableAccess -> registerVariableGet; add registerVariableSet 2016-01-24 18:15:12 +01:00
Qi Xiao
9b7448fdd7 eval: refine tests 2016-01-24 18:13:30 +01:00
Qi Xiao
435c6e8974 Disable builtins and failing tests; refine tests 2016-01-24 18:13:29 +01:00
Qi Xiao
aa7ca8eea1 New eval. Currently broken. 2016-01-24 18:13:20 +01:00
Cheer Xiao
aa9d1e10de Synchronize channel capture correctly
I don't know why it used to work...
2015-08-24 11:37:07 +08:00
Cheer Xiao
55c66c743e "success" -> "ok" 2015-08-23 22:46:33 +08:00
Cheer Xiao
fdd1bbecf9 Relax some type assertions of *closure to callable 2015-07-08 17:39:20 +02:00
Cheer Xiao
2ec97be300 Let each pass through unknown exituses 2015-07-08 13:42:26 +02:00
Cheer Xiao
78d37ea274 Support break and continue in each 2015-07-08 13:41:16 +02:00
Cheer Xiao
7c6ff510f9 Flow exitus values are now contagious 2015-07-08 13:35:56 +02:00
Cheer Xiao
b4ed398564 Teach fn to capture returns 2015-07-08 12:31:40 +02:00
Cheer Xiao
892ba3c28c Add builtins return, break and continue 2015-07-08 12:22:10 +02:00
Cheer Xiao
d8ff95e973 Add exitus sorts for flow control. Add a missing return. 2015-07-08 12:19:43 +02:00
Cheer Xiao
d1de05f259 Introduce exitus.Sort 2015-07-08 12:12:54 +02:00
Cheer Xiao
837ab3bdd8 Add traceback as a subtype of exitus 2015-07-08 12:03:10 +02:00
Cheer Xiao
6dfa18bf4c Expose eval.HasFailure 2015-07-08 00:13:50 +02:00
Cheer Xiao
f68b0eb1f9 A chunk now stops execution as soon as a failure is encountered. 2015-07-08 00:12:24 +02:00
Cheer Xiao
5f41e104dc Evalling error and compiling error are now called "error" and "static error" 2015-07-07 22:26:17 +02:00
Cheer Xiao
3fad7f2ef1 Print status with color 2015-07-06 19:40:11 +02:00
Cheer Xiao
8794232b26 Support completion of commands 2015-07-06 17:58:51 +02:00
Cheer Xiao
404c7debdb Implement the nop builtin ":" 2015-03-01 14:43:35 +01:00
Cheer Xiao
05e97720ca Move util/strings{"" _test} into dedicated strutil package 2015-02-26 17:04:07 +01:00
Cheer Xiao
6a88395a95 Work on comments of eval 2015-02-26 15:17:05 +01:00
Cheer Xiao
2d960cea6e Work on comment 2015-02-26 15:04:58 +01:00
Cheer Xiao
f9838c90c6 Avoid superfluous .String calls in evalSubscript 2015-02-26 15:03:18 +01:00
Cheer Xiao
d13b6eff1b Magic number 0644 -> const defaultFileRedirPerm 2015-02-26 14:59:33 +01:00
Cheer Xiao
06b0a1d283 Fix typo, fix compilation 2015-02-26 14:57:01 +01:00
Cheer Xiao
478d7df34f Replace a comment on os.Unsetenv 2015-02-26 14:54:23 +01:00
Cheer Xiao
e92abca968 Better type check for set 2015-02-26 14:50:48 +01:00
Cheer Xiao
f6c031a82d Make pipeline channels buffered 2015-02-26 12:56:43 +01:00
Cheer Xiao
3c5f192dd6 Check arity of subscript operands at runtime 2015-02-26 12:53:44 +01:00
Cheer Xiao
91af2a8e8c Don't use dashes in golang sources 2015-02-25 16:43:31 +01:00
Cheer Xiao
b5bf7f2dba line -> cmd; visited_dir -> dir 2015-02-25 16:40:48 +01:00
Cheer Xiao
57cc156293 Move mutable states of Compiler into compileCtx.
This concludes issue #47.
2015-02-25 15:04:10 +01:00
Cheer Xiao
970f23f20a Test multiple invocations of Evaler.Eval 2015-02-25 14:47:50 +01:00
Cheer Xiao
7590f5055e Keep global ns in the Evaler 2015-02-25 12:27:18 +01:00
Cheer Xiao
e82e67fd4e Move mutable states of Evaler into evalCtx.
This is work on #47.
2015-02-25 12:21:06 +01:00
Cheer Xiao
9495a6adfa Evaluator -> Evaler 2015-02-25 00:37:18 +01:00
Cheer Xiao
1c5637e149 statusCb -> failHandler, called only when there is failure 2015-02-25 00:31:45 +01:00
Cheer Xiao
7de48274b1 Strip all parse.Node structs of the Node suffix 2015-02-24 21:59:14 +01:00
Cheer Xiao
0a629830a5 golint fixes for eval 2015-02-24 21:40:17 +01:00
Cheer Xiao
464214a61f Replace the magic string "fn-" with const fnPrefix 2015-02-24 10:21:27 +01:00
Cheer Xiao
1d59566aaf Implement module file search mechanism for "use"
This resolves issue #44.
2015-02-23 18:36:46 +01:00
Cheer Xiao
5fda0bc0a4 Implement builtin special form "use".
This resolves issue #8.
2015-02-10 14:50:58 +01:00
Cheer Xiao
6c318d116f Introduce namespaces for modules 2015-02-10 13:00:27 +01:00
Cheer Xiao
1ee7200cdd eval: captured -> up
This agrees with the more common term "upvalue" for closures.
2015-02-10 12:48:56 +01:00
Cheer Xiao
bf75920385 eval: Invent types ns and staticNS 2015-02-10 12:47:18 +01:00
Cheer Xiao
dd5d80ea98 Strip the "compile" prefix of Compiler methods 2015-02-10 12:28:14 +01:00
Cheer Xiao
c7054dcbcd Implement if as a special form
This concludes issue #14.
2015-02-10 11:43:01 +01:00
Cheer Xiao
a5f4e60b5d Don't reuse first value when evaluating a compound.
This resolves issue #43.
2015-02-10 09:41:50 +01:00
Cheer Xiao
0ebbe47a3b Require the first arg to fn to be a string literal 2015-02-10 09:32:58 +01:00
Cheer Xiao
ef803e4b7f Allow redefinition of functions with fn 2015-02-10 09:31:42 +01:00
Cheer Xiao
fd2e26700a Move error-related utilities from util to errutil 2015-02-09 12:28:36 +01:00
Cheer Xiao
b9dfd552b2 util.{Panic Recover} -> util.{Throw Catch} 2015-02-09 12:11:47 +01:00
Cheer Xiao
ec8fcfe43c Add utility func newRat 2015-02-05 13:33:42 +01:00
Cheer Xiao
a2b75e105d Implement rat as a struct instead 2015-02-05 13:31:22 +01:00
Cheer Xiao
7facdf5b73 Add utility func toRat 2015-02-05 13:22:23 +01:00
Cheer Xiao
e443e76b60 Introduce new type "rat" 2015-02-05 10:52:57 +01:00
Cheer Xiao
55ae6dd58e eval: Update a comment 2015-01-26 19:40:13 +01:00
Cheer Xiao
b6ff425bc5 eval: op -> Op 2015-01-26 19:34:45 +01:00
Cheer Xiao
e336982f5a eval: FdNil -> fdNil 2015-01-26 19:33:13 +01:00
Cheer Xiao
dd1d9875d7 eval: Export even less 2015-01-26 19:13:34 +01:00
Cheer Xiao
5dce88f4d2 eval: Remove StreamType 2015-01-26 19:11:05 +01:00
Cheer Xiao
3e0f8257d7 eval: Op -> op 2015-01-26 19:08:11 +01:00
Cheer Xiao
9fadb23e7e eval: Export less, document more 2015-01-26 19:05:42 +01:00
Cheer Xiao
d200d78bad golint fixes 2015-01-26 18:53:08 +01:00
Cheer Xiao
baae6cbdeb Remove a now-bogus BUG comment 2015-01-26 18:29:15 +01:00
Cheer Xiao
7a50c04bd4 Implement builtins "visisted-dirs" and "jump-dir".
This addresses issue #27.
2015-01-26 17:05:29 +01:00
Cheer Xiao
b20b0acf9d Make store.Store part of Evaluator 2015-01-26 16:43:32 +01:00
Cheer Xiao
fe5a68917d Type port and friends get their own file 2015-01-26 16:27:24 +01:00
Cheer Xiao
13423000ee Eliminate unused types 2015-01-26 16:26:25 +01:00
Cheer Xiao
b5eb9dc06b Unify user-defined fn resolution with builtin fn resolution 2015-01-26 16:25:30 +01:00
Cheer Xiao
b9c20d4e45 Eliminate String() from Value interface 2015-01-26 16:21:13 +01:00
Cheer Xiao
523680194a Eliminate Bool() from Value interface 2015-01-26 16:16:18 +01:00
Cheer Xiao
2aba6fa03f Fix last commit: add missing file 2015-01-26 16:13:16 +01:00
Cheer Xiao
4ed2991125 Variable and its implementations now get a separate file. 2015-01-26 16:12:58 +01:00
Cheer Xiao
aa6d4d9684 Eliminate (*Evaluator).exec{BuiltinFunc Closure External} 2015-01-26 16:11:00 +01:00
Cheer Xiao
146a536da2 Introduce new value type "External" 2015-01-26 16:06:50 +01:00
Cheer Xiao
e21cb5264b Introduce value type BuiltinFn 2015-01-26 15:59:25 +01:00
Cheer Xiao
c0839757e2 Introduce a Callable interface.
(*Evaluator).execClosure(*Closure, []Value) is now
(*Closure).Exec(*Evaluator, []Value) instead.
2015-01-26 15:47:38 +01:00
Cheer Xiao
83ab97996d The type "closure" is now called "callable" instead 2015-01-26 15:37:04 +01:00