Skip to content

Commit

Permalink
Merge pull request #48 from kit494way/fix-parsing-command
Browse files Browse the repository at this point in the history
Fix parsing of command
  • Loading branch information
fdncred authored Dec 27, 2023
2 parents edbb7dd + 603cc15 commit bddc79c
Show file tree
Hide file tree
Showing 7 changed files with 151,686 additions and 145,428 deletions.
22 changes: 22 additions & 0 deletions corpus/decl/alias.nu
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,25 @@ export alias change-directory = cd;
(pipe_element
(command
(cmd_identifier))))))

=====
alias-000-terminated-by-newline
=====

alias less = bat
let foo = "foo"

-----

(nu_script
(decl_alias
(cmd_identifier)
(pipeline
(pipe_element
(command
(cmd_identifier)))))
(stmt_let
(identifier)
(pipeline
(pipe_element
(val_string)))))
224 changes: 224 additions & 0 deletions corpus/expr/subexpr.nu
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
=====
subexpr-001-command
=====

(echo hello)

-----

(nu_script
(pipeline
(pipe_element
(expr_parenthesized
(pipeline
(pipe_element
(command
(cmd_identifier)
(val_string))))))))

=====
subexpr-002-multiline-command
=====

(
echo
one
two
thre
)

-----

(nu_script
(pipeline
(pipe_element
(expr_parenthesized
(pipeline
(pipe_element
(command
(cmd_identifier)
(val_string)
(val_string)
(val_string))))))))

=====
subexpr-003-pipeline
=====

(ls | where size > 10kb)

-----

(nu_script
(pipeline
(pipe_element
(expr_parenthesized
(pipeline
(pipe_element
(command
(cmd_identifier)))
(pipe_element
(where_command
(val_string)
(val_filesize
(val_number)))))))))

=====
subexpr-004-pipeline-multiline
=====

(
echo
one
two
thre | str replace t T
)

-----

(nu_script
(pipeline
(pipe_element
(expr_parenthesized
(pipeline
(pipe_element
(command
(cmd_identifier)
(val_string)
(val_string)
(val_string)))
(pipe_element
(command
(cmd_identifier)
(val_string)
(val_string)
(val_string))))))))


=====
subexpr-005-assignment
=====

let xs = (echo one two)

-----

(nu_script
(stmt_let
(identifier)
(pipeline
(pipe_element
(expr_parenthesized
(pipeline
(pipe_element
(command
(cmd_identifier)
(val_string)
(val_string)))))))))
=====
subexpr-006-multiline-assignment
=====

let xs = (echo
one two)

-----

(nu_script
(stmt_let
(identifier)
(pipeline
(pipe_element
(expr_parenthesized
(pipeline
(pipe_element
(command
(cmd_identifier)
(val_string)
(val_string)))))))))

=====
subexpr-007-path
=====

(ls).name

-----

(nu_script
(pipeline
(pipe_element
(expr_parenthesized
(pipeline
(pipe_element
(command
(cmd_identifier))))
(cell_path
(path))))))

=====
subexpr-008-contains-statement
=====

(let a = "hello";
echo $a)

-----

(nu_script
(pipeline
(pipe_element
(expr_parenthesized
(stmt_let
(identifier)
(pipeline
(pipe_element
(val_string))))
(pipeline
(pipe_element
(command
(cmd_identifier)
(val_variable
(identifier)))))))))

=====
subexpr-009-closure
=====

([1, 2, 3] | each
{|x|
let y = 2
$x * $y
})

-----

(nu_script
(pipeline
(pipe_element
(expr_parenthesized
(pipeline
(pipe_element
(val_list
(val_number)
(val_number)
(val_number)))
(pipe_element
(command
(cmd_identifier)
(val_closure
(parameter_pipes
(parameter
(identifier)))
(stmt_let
(identifier)
(pipeline
(pipe_element
(val_number))))
(pipeline
(pipe_element
(expr_binary
(val_variable
(identifier))
(val_variable
(identifier)))))))))))))
21 changes: 21 additions & 0 deletions corpus/pipe/commands.nu
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,24 @@ echo n
(command
(cmd_identifier)
(val_string)))))

=====
cmd-009-terminated-by-newline
=====

echo hello
let x = 42

-----

(nu_script
(pipeline
(pipe_element
(command
(cmd_identifier)
(val_string))))
(stmt_let
(identifier)
(pipeline
(pipe_element
(val_number)))))
33 changes: 33 additions & 0 deletions corpus/pipe/pipe.nu
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,36 @@ pipe-005-unquoted-1-character
(cmd_identifier)
(val_string)
(val_string)))))

=====
pipe-006-terminated-by-newline
=====

ls | each {|x| echo $x}
let x = 42

-----

(nu_script
(pipeline
(pipe_element
(command
(cmd_identifier)))
(pipe_element
(command
(cmd_identifier)
(val_closure
(parameter_pipes
(parameter
(identifier)))
(pipeline
(pipe_element
(command
(cmd_identifier)
(val_variable
(identifier)))))))))
(stmt_let
(identifier)
(pipeline
(pipe_element
(val_number)))))
Loading

0 comments on commit bddc79c

Please sign in to comment.