-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add multiline test script #65
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
// grammar.pest | ||
|
||
// Whitespace and comments | ||
WHITESPACE = _{ " " | "\t" | ("\\" ~ WHITESPACE* ~ NEWLINE) } | ||
WHITESPACE = _{ " " | "\t" | ESCAPED_NEWLINE } | ||
ESCAPED_NEWLINE = _{ "\\" ~ NEWLINE } | ||
COMMENT = _{ "#" ~ (!NEWLINE ~ ANY)* } | ||
|
||
// Basic tokens | ||
|
@@ -25,11 +24,13 @@ QUOTED_PENDING_WORD = ${ ( | |
QUOTED_ESCAPE_CHAR | | ||
SUB_COMMAND | | ||
("$" ~ VARIABLE) | | ||
QUOTED_CHAR | ||
QUOTED_CHAR | | ||
NEWLINE | | ||
ESCAPED_NEWLINE | ||
)* } | ||
|
||
UNQUOTED_ESCAPE_CHAR = ${ ("\\" ~ "$" | "$" ~ !"(" ~ !VARIABLE) | "\\" ~ (" " | "`" | "\"" | "(" | ")")* } | ||
QUOTED_ESCAPE_CHAR = ${ "\\" ~ "$" | "$" ~ !"(" ~ !VARIABLE | "\\" ~ ("`" | "\"" | "(" | ")" | "'")* } | ||
QUOTED_ESCAPE_CHAR = @{ "\\" ~ ("$" | "`" | "\"" | "(" | ")" | "'" | "\n" | "\r\n") } | ||
|
||
UNQUOTED_CHAR = ${ ("\\" ~ " ") | !("(" | ")" | "{" | "}" | "<" | ">" | "|" | "&" | ";" | "\"" | "'" | "$") ~ ANY } | ||
QUOTED_CHAR = ${ !"\"" ~ ANY } | ||
|
@@ -38,12 +39,11 @@ VARIABLE = ${ (ASCII_ALPHANUMERIC | "_")+ } | |
SUB_COMMAND = { "$(" ~ complete_command ~ ")" } | ||
|
||
DOUBLE_QUOTED = @{ "\"" ~ QUOTED_PENDING_WORD ~ "\"" } | ||
SINGLE_QUOTED = @{ "'" ~ (!"'" ~ ANY)* ~ "'" } | ||
SINGLE_QUOTED = @{ "'" ~ (!"'" ~ (NEWLINE | ESCAPED_NEWLINE | ANY))* ~ "'" } | ||
|
||
NAME = ${ (ASCII_ALPHA | "_") ~ (ASCII_ALPHANUMERIC | "_")* } | ||
ASSIGNMENT_WORD = { NAME ~ "=" ~ UNQUOTED_PENDING_WORD? } | ||
IO_NUMBER = @{ ASCII_DIGIT+ } | ||
|
||
// Special tokens | ||
AND_IF = { "&&" } | ||
OR_IF = { "||" } | ||
|
@@ -60,7 +60,6 @@ CLOBBER = { ">|" } | |
AMPERSAND = { "&" } | ||
EXIT_STATUS = ${ "$?" } | ||
|
||
|
||
// Operators | ||
OPERATOR = _{ | ||
AND_IF | OR_IF | DSEMI | DLESS | DGREAT | LESSAND | GREATAND | LESSGREAT | DLESSDASH | CLOBBER | | ||
|
@@ -203,8 +202,8 @@ filename = _{ FILE_NAME_PENDING_WORD } | |
io_here = !{ (DLESS | DLESSDASH) ~ here_end } | ||
here_end = @{ ("\"" ~ UNQUOTED_PENDING_WORD ~ "\"") | UNQUOTED_PENDING_WORD } | ||
|
||
newline_list = _{ NEWLINE+ } | ||
linebreak = _{ NEWLINE* } | ||
newline_list = _{ (NEWLINE | ESCAPED_NEWLINE)+ } | ||
linebreak = _{ (NEWLINE | ESCAPED_NEWLINE)* } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pest automatically parses |
||
separator_op = { "&" | ";" } | ||
separator = _{ separator_op ~ linebreak | newline_list } | ||
sequential_sep = !{ ";" ~ linebreak | newline_list } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
pub mod parser; | ||
|
||
#[cfg(feature = "shell")] | ||
mod shell; | ||
pub mod shell; | ||
|
||
#[cfg(feature = "shell")] | ||
pub use shell::*; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,4 +26,4 @@ mod types; | |
#[cfg(test)] | ||
mod test; | ||
#[cfg(test)] | ||
mod test_builder; | ||
pub mod test_builder; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
source: crates/deno_task_shell/src/shell/test.rs | ||
expression: stdout | ||
--- | ||
foo bla | ||
foo | ||
bla | ||
foo " bar |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
echo "foo \ | ||
bla" | ||
|
||
echo "foo | ||
bla" | ||
|
||
echo "foo \" bar" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason behind adding
"$" ~ !"(" ~ !VARIABLE
toQUOTED_ESCAPE_CHAR
was since bash parses$
as is when not followed by a variable, subcommand or brace_group - we need to add support for brace_groups later as well.For example:
echo "$"
prints the same value asecho \$
"