From bd4ba6c81ddbeed2fdb5e6dc97cb3b2966b8873f Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Sat, 20 Feb 2016 02:40:00 -0500 Subject: Implement I/O operator parsing --- (limited to 'parsing') diff --git a/parsing/parse.sh b/parsing/parse.sh index 5ac622d..e0852bb 100644 --- a/parsing/parse.sh +++ b/parsing/parse.sh @@ -367,49 +367,80 @@ cmd_word() cmd_prefix() { - : TODO: Implement + if io_redirect || accept T_ASSIGNMENT_WORD; then + while io_redirect || accept T_ASSIGNMENT_WORD; do + : + done + return 0 + fi return 1 } cmd_suffix() { - : TODO: Implement + if io_redirect || accept T_WORD; then + while io_redirect || accept T_WORD; do + : + done + return 0 + fi return 1 } redirect_list() { - : TODO: Implement + if io_redirect; then + while io_redirect; do + : + done + return 0 + fi return 1 } io_redirect() { - : TODO: Implement + if io_file || io_here; then + return 0 + fi return 1 } io_file() { - : TODO: Implement + if accept T_LESS || accept T_LESSAND || accept T_GREAT || \ + accept T_GREATAND || accept T_DGREAT || \ + accept T_LESSGREAT || accept T_CLOBBER; then + if filename; then + return 0 + fi + fi return 1 } filename() { - : TODO: Implement + if accept T_WORD; then + return 0 + fi return 1 } io_here() { - : TODO: Implement + if accept T_DLESS || accept T_DLESSDASH; then + if here_end; then + return 0 + fi + fi return 1 } here_end() { - : TODO: Implement + if accept T_WORD; then + return 0 + fi return 1 } @@ -502,7 +533,7 @@ try() } #try '"foo bar" && $baz || qux' '${quux%uux quuux' -#try '"foo bar" && $baz || qux' '${quux%uux } quuux' +try '"foo bar" && $baz || qux' '${quux%uux } quuux' #try 'foo ${bar}' #try 'foo ${#bar}' #try 'foo ${bar#baz}' -- cgit v0.9.1