Skip to content

Commit

Permalink
parse if properly
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfv committed Sep 7, 2024
1 parent 7f68c18 commit 3a0c79d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions crates/deno_task_shell/src/grammar.pest
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ COMMENT = _{ "#" ~ (!NEWLINE ~ ANY)* }
QUOTED_WORD = { DOUBLE_QUOTED | SINGLE_QUOTED }

UNQUOTED_PENDING_WORD = ${
(!(WHITESPACE | OPERATOR | NEWLINE) ~ (
(!(RESERVED_WORD | WHITESPACE | OPERATOR | NEWLINE) ~ (
EXIT_STATUS |
UNQUOTED_ESCAPE_CHAR |
SUB_COMMAND |
Expand Down Expand Up @@ -102,8 +102,8 @@ pipeline = !{ Bang? ~ pipe_sequence }
pipe_sequence = !{ command ~ ((StdoutStderr | Stdout) ~ linebreak ~ pipe_sequence)? }

command = !{
simple_command |
compound_command ~ redirect_list? |
simple_command |
function_definition
}

Expand Down Expand Up @@ -185,7 +185,7 @@ simple_command = !{

cmd_prefix = !{ (io_redirect | ASSIGNMENT_WORD)+ }
cmd_suffix = !{ (io_redirect | UNQUOTED_PENDING_WORD)+ }
cmd_name = @{ (RESERVED_WORD | UNQUOTED_PENDING_WORD) }
cmd_name = @{ (UNQUOTED_PENDING_WORD) }
cmd_word = @{ (ASSIGNMENT_WORD | UNQUOTED_PENDING_WORD) }

redirect_list = !{ io_redirect+ }
Expand Down
5 changes: 4 additions & 1 deletion crates/deno_task_shell/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@ fn parse_pipe_sequence(pair: Pair<Rule>) -> Result<PipelineInner> {

fn parse_command(pair: Pair<Rule>) -> Result<Command> {
let inner = pair.into_inner().next().unwrap();
println!("inner: {:?}", inner);
match inner.as_rule() {
Rule::simple_command => parse_simple_command(inner),
Rule::compound_command => parse_compound_command(inner),
Expand Down Expand Up @@ -609,7 +610,9 @@ fn parse_simple_command(pair: Pair<Rule>) -> Result<Command> {
}
}
Rule::cmd_word | Rule::cmd_name => {
args.push(parse_word(item.into_inner().next().unwrap())?)
println!("cmd_word: {:?}", item);
println!("cmd_word: {:?}", item.into_inner());
// args.push(parse_word(item.into_inner().next().unwrap())?)
}
Rule::cmd_suffix => {
for suffix in item.into_inner() {
Expand Down

0 comments on commit 3a0c79d

Please sign in to comment.