Commit Graph

40 Commits

Author SHA1 Message Date
193b00764b Stream support (#812)
* Moves off of draining between filters. Instead, the sink will pull on the stream, and will drain element-wise. This moves the whole stream to being lazy.
* Adds ctrl-c support and connects it into some of the key points where we pull on the stream. If a ctrl-c is detect, we immediately halt pulling on the stream and return to the prompt.
* Moves away from having a SourceMap where anchor locations are stored. Now AnchorLocation is kept directly in the Tag.
* To make this possible, split tag and span. Span is largely used in the parser and is copyable. Tag is now no longer copyable.
2019-10-13 17:12:43 +13:00
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
ce947d70b0 Rename SpanSource to AnchorLocation 2019-09-29 18:18:59 +13:00
caed87c125 Rename origin to anchor 2019-09-29 18:13:56 +13:00
9891e5ab81 Use async-stream crate to replace most async_stream_block invocations 2019-09-26 02:39:20 +02:00
72e6222992 Switch to using Uuid::nil() and fix test 2019-09-18 19:05:33 +12:00
2cf7249794 Fix autoview breakage 2019-09-18 18:37:04 +12:00
7fbd6ce232 Fix internal paths 2019-09-17 14:09:15 +12:00
ab915f1c44 Revert "Revert "Migrate most uses of the Span concept to Tag""
This reverts commit bee7c5639c.
2019-09-14 11:30:24 -05:00
bee7c5639c Revert "Migrate most uses of the Span concept to Tag" 2019-09-11 19:53:05 +12:00
58b7800172 Migrate most uses of the Span concept to Tag
Also migrate mv, rm and commands like that to taking a
SyntaxType::Pattern instead of a SyntaxType::Path for their first
argument.
2019-09-10 20:41:03 -07:00
030d73147e can view help for a given command by entering a command. 2019-09-03 04:05:52 -05:00
8504c7a8e6 Adopt field init shorthand in a few places
Found by running 'egrep "(\b[a-zA-Z]+): \1\b" -R src'
2019-09-01 23:39:59 +02:00
ca0c6eaf58 This commit introduces a basic help feature. We can go to it
with the `help` command to explore and list all commands available.

Enter will also try to see if the location to be entered is an existing
Nu command, if it is it will let you inspect the command under `help`.

This provides baseline needed so we can iterate on it.
2019-08-31 19:06:11 -05:00
761cc3db14 Finish up enter and save 2019-08-31 12:59:21 +12:00
f730296e45 WIP supporting from/to automatically 2019-08-29 15:53:45 +12:00
721a7b159d switch from reqwest to surf 2019-08-25 07:36:19 +12:00
dd18122a24 WIP 2019-08-15 17:02:02 +12:00
99b881e42f Add first per-item commands 2019-08-15 05:02:39 +12:00
aadacc2d36 Merge master 2019-08-09 16:51:21 +12:00
c231dd32cd Multi shells (#254)
Add multi-shells
2019-08-08 05:49:11 +12:00
2ed46046bd Cleanup for upcoming release 2019-07-17 07:10:25 +12:00
7e555a0ef2 "Add plugin arg errors. Bring remaining errors to parity" 2019-07-14 04:59:59 +12:00
7c2a1c619e Tests pass 2019-07-12 19:20:26 -07:00
7b68739b52 WIP 2019-07-12 19:20:26 -07:00
34033afce4 WIP improve error infrastructure
Also simplify commands and reduce papercuts
2019-07-12 19:20:26 -07:00
65a0d27c8a Add binary type and tree sink 2019-07-04 17:11:56 +12:00
cfcf43ca93 Add content-type to open, refactor open/enter 2019-06-26 19:40:43 +12:00
d0860837d2 Merge branch 'nom2' into nom4 2019-06-22 18:20:13 -04:00
4036bf1ffd &str -> Text 2019-06-22 16:46:16 -04:00
9af08eb911 Fix flag oversight 2019-06-23 06:02:23 +12:00
9ae9beb94a WIP 2019-06-22 15:43:37 +12:00
e981129f1f Things work 2019-06-21 21:36:57 -04:00
1000ec21b5 Add .ini loading/saving 2019-06-16 18:43:40 +12:00
eae83d85d2 Add more error checking 2019-06-16 11:03:49 +12:00
416d1c8cbb Merge branch 'master' into touchups 2019-06-16 06:41:26 +12:00
54be5bf16e Update errors and improve ctrl-c 2019-06-16 06:36:17 +12:00
910869b79d Get stream errors working 2019-06-16 05:52:55 +12:00
8cdd567b0e Rewrite README and do some touchups 2019-06-15 14:24:13 +12:00
f40089f29b Better cd and ls 2019-06-14 09:47:25 +12:00