Commit Graph

30 Commits

Author SHA1 Message Date
1ad9d6f199 Overhaul the expansion system
The main thrust of this (very large) commit is an overhaul of the
expansion system.

The parsing pipeline is:

- Lightly parse the source file for atoms, basic delimiters and pipeline
  structure into a token tree
- Expand the token tree into a HIR (high-level intermediate
  representation) based upon the baseline syntax rules for expressions
  and the syntactic shape of commands.

Somewhat non-traditionally, nu doesn't have an AST at all. It goes
directly from the token tree, which doesn't represent many important
distinctions (like the difference between `hello` and `5KB`) directly
into a high-level representation that doesn't have a direct
correspondence to the source code.

At a high level, nu commands work like macros, in the sense that the
syntactic shape of the invocation of a command depends on the
definition of a command.

However, commands do not have the ability to perform unrestricted
expansions of the token tree. Instead, they describe their arguments in
terms of syntactic shapes, and the expander expands the token tree into
HIR based upon that definition.

For example, the `where` command says that it takes a block as its first
required argument, and the description of the block syntactic shape
expands the syntax `cpu > 10` into HIR that represents
`{ $it.cpu > 10 }`.

This commit overhauls that system so that the syntactic shapes are
described in terms of a few new traits (`ExpandSyntax` and
`ExpandExpression` are the primary ones) that are more composable than
the previous system.

The first big win of this new system is the addition of the `ColumnPath`
shape, which looks like `cpu."max ghz"` or `package.version`.
Previously, while a variable path could look like `$it.cpu."max ghz"`,
the tail of a variable path could not be easily reused in other
contexts. Now, that tail is its own syntactic shape, and it can be used
as part of a command's signature.

This cleans up commands like `inc`, `add` and `edit` as well as
shorthand blocks, which can now look like `| where cpu."max ghz" > 10`
2019-10-10 08:27:51 -07:00
f61144006f config test harness. 2019-09-10 05:08:01 -05:00
df9ff44956 Filesystem change directory coverage. 2019-09-08 03:09:05 -05:00
9da896ad4e Attempt so simplify classified 2019-09-08 14:00:04 +12:00
05e858fa94 Add test 2019-09-03 22:37:26 -04:00
9810df25b4 Readability improvement. 2019-08-29 01:31:56 -05:00
a07817e0e0 cover pipeline helper. 2019-08-28 20:30:51 -05:00
55fb1f8dda Yo quiero Playground taconushell. 2019-08-28 19:32:42 -05:00
f82cc4291f Migrate commands_test 2019-08-28 10:58:00 -07:00
2c65b2fc2f Migrate mv 2019-08-28 10:28:58 -07:00
21ad06b1e1 Remove unwraps and clean up playground
The original intent of this patch was to remove more unwraps to reduce
panics. I then lost a ton of time to the fact that the playground isn't
in a temp directory (because of permissions issues on Windows).

This commit improves the test facilities to:

- use a tempdir for the playground
- change the playground API so you instantiate it with a block that
  encloses the lifetime of the tempdir
- the block is called with a `dirs` argument that has `dirs.test()` and
  other important directories that we were computing by hand all the time
- the block is also called with a `playground` argument that you can use
  to construct files (it's the same `Playground` as before)
- change the nu! and nu_error! macros to produce output instead of
  taking a variable binding
- change the nu! and nu_error! macros to do the cwd() transformation
  internally
- change the nu! and nu_error! macros to take varargs at the end that
  get interpolated into the running command

I didn't manage to finish porting all of the tests, so a bunch of tests
are currently commented out. That will need to change before we land
this patch.
2019-08-28 10:01:16 -07:00
0e14ba86ae [from|to]csv additions/refactoring.
Introduced flag to tell `from-to` / `to-csv` whether we want headers parsed and/or written.
2019-08-25 12:32:08 -05:00
5dd20850b5 Refactoring and unwrap cleanup beginnings. 2019-08-18 20:28:55 -05:00
121237ee4b Reverted test removal from (dfcbaed) 2019-08-14 15:55:26 -05:00
dfcbaed1c6 More descriptive test playground names for commands other than the basic ones. 2019-08-14 15:29:05 -05:00
aadacc2d36 Merge master 2019-08-09 16:51:21 +12:00
c8b5329c5c mkdir. 2019-08-07 13:24:20 -05:00
1b7dd52713 Tests pass. 2019-08-07 13:23:02 -05:00
b38d54e033 Dont let Nu childs become zombies. 2019-08-07 13:18:02 -05:00
fc173c46d8 Restructuring 2019-08-02 12:15:07 -07:00
4821707f96 Test for external quoted strings 2019-08-03 04:33:52 +12:00
375f311331 Wildcard support adventure starting with rm command. 2019-08-01 16:01:53 -05:00
610a91a658 Test coverage for pull #235 2019-08-01 03:31:41 -05:00
73deeb69db Clean up lint errors 2019-07-23 21:10:48 -07:00
5a8e041a48 Tests pass! 2019-07-23 15:22:11 -07:00
191dacdd8b Introduced conversion to csv command. 2019-07-21 02:08:05 -05:00
514da5bfa7 Can remove files and directories. 2019-07-18 05:21:24 -05:00
00b3106f05 Improve open URL. Format and remove warning in tests 2019-07-18 06:56:15 +12:00
c7531d6b3d Windows speaks \r 2019-07-16 05:58:40 -05:00
5ca9d307c6 Integration tests refactoring and visibility in them. 2019-07-16 05:33:41 -05:00