Commit Graph

14 Commits

Author SHA1 Message Date
Qi Xiao
c211679f0c Move all variable creations to start of lexical scope.
Commit 8c71635ca3 moved the creation to the start
of pipelines; the approach works for simplistic cases like "x = 1 | nop", but
fails in more complex cases, such as "nop (x = 1) | nop".

The correct place to hoist variable creations is the lexical scope, and this
commit implements this approach.

This fixes #623.
2020-04-26 19:05:16 +01:00
Qi Xiao
3e9d5e9e60 pkg/eval/str: Add join, replace and split.
The implementations are mostly copied from the builtin joins, replaces and
splits, with small changes to the error behavior in the join function.

The versions in the builtin module are now deprecated.
2020-04-26 17:01:10 +01:00
Qi Xiao
c767f92d01 Support compile-time deprecation.
This fixes #898.
2020-04-26 13:14:51 +01:00
Qi Xiao
88122a019e pkg: Simplify some APIs by using parse.Tree. 2020-04-25 19:36:35 +01:00
Qi Xiao
20979b44a2 pkg/parse: Use Source values, not pointers.
The Source type is small enough that using values is likely more efficient.
2020-04-25 19:22:38 +01:00
Qi Xiao
b8505c7065 pkg/eval/source.go -> pkg/parse/source.go. 2020-04-25 18:26:17 +01:00
Qi Xiao
8c71635ca3 pkg/eval: Move all assignments to the start of the pipeline they belong in.
This avoids race conditions of accessing the local scope. The test case
"x = 1", "put $x | y = (all)" used to contain a race condition but no longer
does.

This addresses #73.
2020-03-28 23:49:30 +00:00
Qi Xiao
9bebf49b40 pkg/diag: Let NewContext accept a Ranging. 2020-03-28 22:12:42 +00:00
Qi Xiao
3abfc42a8e [cleanup] pkg/eval: Remove boilerplate.go. 2020-03-28 21:33:55 +00:00
Qi Xiao
e6b7d06e80 [cleanup] pkg/eval: Remove compiler.errorf and compiler.compiling.
All errors are now written using compiler.errorpf.
2020-03-28 21:33:55 +00:00
Qi Xiao
d306f33af6 [cleanup] pkg/eval: Let compiler.errorpf accept a single diag.Ranger. 2020-03-28 21:33:55 +00:00
Qi Xiao
4ef43e0bde pkg/eval: Inline the use of util.{Throw,Catch} in the compiler. 2020-01-12 17:55:17 -05:00
Qi Xiao
b3a48ed510 pkg/eval: Revamp Source. 2020-01-11 03:01:30 +00:00
Qi Xiao
e45fdf7228 Move all libraries to new pkg/. 2019-12-23 20:00:59 +00:00