nushell/crates/nu-parser/Cargo.toml
Leonhard Kipp 3e6e3a207c
Feature/def signature with comments (#2905)
* Put parse_definition related funcs into own module

* Add failing lexer test

* Implement Parsing of definition signature

This commit applied changes how the signature of a function is parsed. Before
there was a little bit of "quick-and-dirty" string-matching/parsing involved.
Now, a signature is a little bit more properly parsed.
The grammar of a definition signature understood by these parsing-functions is
as follows:
 `[ (parameter | flag | <eol>)* ]`
where
parameter is:
    `name (<:> type)? (<,> | <eol> | (#Comment <eol>))?`
flag is:
    `--name (-shortform)? (<:> type)? (<,> | <eol> | (#Comment <eol>))?`
(Note: After the last item no <,> has to come.)
Note: It is now possible to pass comments to flags and parameters
Example:
[
  d:int          # The required d parameter
  --x (-x):string # The all powerful x flag
  --y (-y):int    # The accompanying y flag
]

(Sadly there seems to be a bug (Or is this expected behaviour?) in the lexer, because of which `--x(-x)` would
be treated as one baseline token and is therefore not correctly recognized as 2. For
now a space has to be inserted)

During the implementation of the module, 2 question arose:
Should flag/parameter names be allowed to be type names?
Example case:
```shell
def f [ string ] { echo $string }
```
Currently an error is thrown

* Fix clippy lints

* Remove wrong comment

* Add spacing

* Add Cargo.lock
2021-01-12 06:53:58 +13:00

31 lines
886 B
TOML

[package]
authors = ["The Nu Project Contributors"]
description = "Nushell parser"
edition = "2018"
license = "MIT"
name = "nu-parser"
version = "0.25.1"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
bigdecimal = {version = "0.2.0", features = ["serde"]}
codespan-reporting = "0.11.0"
derive-new = "0.5.8"
indexmap = {version = "1.6.1", features = ["serde-1"]}
log = "0.4.11"
num-bigint = {version = "0.3.1", features = ["serde"]}
num-traits = "0.2.14"
serde = "1.0.118"
shellexpand = "2.1.0"
derive_is_enum_variant = "0.1.1"
nu-errors = {version = "0.25.1", path = "../nu-errors"}
nu-protocol = {version = "0.25.1", path = "../nu-protocol"}
nu-source = {version = "0.25.1", path = "../nu-source"}
nu-test-support = {version = "0.25.1", path = "../nu-test-support"}
dunce = "1.0.1"
[features]
stable = []
trace = []