summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--parsing/parse.sh26
1 files changed, 17 insertions, 9 deletions
diff --git a/parsing/parse.sh b/parsing/parse.sh
index 66506b4..6f3018e 100644
--- a/parsing/parse.sh
+++ b/parsing/parse.sh
@@ -29,10 +29,8 @@ list()
{
dbg 'list()'
if and_or; then
- while separator_op; do
- if ! and_or; then
- return 1
- fi
+ while separator && and_or; do
+ :
done
return 0
fi
@@ -291,6 +289,7 @@ until_clause()
function_body()
{
+ dbg 'function_body()'
if compound_command; then
redirect_list
fi
@@ -323,7 +322,7 @@ simple_command()
cmd_suffix
fi
return 0
- elif cmd_name; then
+ elif accept T_FNAME; then
if accept T_LPAREN; then
expect T_RPAREN
if linebreak && function_body; then
@@ -333,6 +332,9 @@ simple_command()
cmd_suffix
return 0
fi
+ elif cmd_name; then
+ cmd_suffix
+ return 0
fi
return 1
}
@@ -359,6 +361,7 @@ cmd_word()
cmd_prefix()
{
+ dbg 'cmd_prefix()'
if io_redirect || accept T_ASSIGNMENT_WORD; then
while io_redirect || accept T_ASSIGNMENT_WORD; do
:
@@ -370,6 +373,7 @@ cmd_prefix()
cmd_suffix()
{
+ dbg 'cmd_suffix()'
if io_redirect || accept T_WORD; then
while io_redirect || accept T_WORD; do
:
@@ -381,6 +385,7 @@ cmd_suffix()
redirect_list()
{
+ dbg 'redirect_list()'
if io_redirect; then
while io_redirect; do
:
@@ -392,6 +397,7 @@ redirect_list()
io_redirect()
{
+ dbg 'io_redirect()'
if io_file || io_here; then
return 0
fi
@@ -492,9 +498,10 @@ parse()
init_lexer "${fn}"
# If this returns (does not exit), there are no errors.
- while ! accept T_EOF; do
- complete_command
- done
+ complete_command
+ if ! accept T_EOF; then
+ synexp ''
+ fi
get_tokens
@@ -541,5 +548,6 @@ try()
#try 'if ; then ; fi'
#try 'while foo; do bar; done'
#try 'while ; do ; done'
-try 'foo(){ bar; }'
+#try 'foo(){ bar; }'
#try 'case foo in bar) baz;; (qux) quux;; quux);; esac'
+try 'foo bar ( baz )'