summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--parsing/lexer.sh18
-rw-r--r--parsing/parse.sh22
2 files changed, 34 insertions, 6 deletions
diff --git a/parsing/lexer.sh b/parsing/lexer.sh
index e1d3aab..b03878d 100644
--- a/parsing/lexer.sh
+++ b/parsing/lexer.sh
@@ -389,6 +389,19 @@ scan_wordexp()
;;
'(')
# Arithmetic expansion or command substitution
+ pgetc
+ case "${c}" in
+ '(')
+ # Arithmetic expansion
+ synerr 'Arithmetic expansion is %s' \
+ 'not yet supported'
+ ;;
+ *)
+ # Command substitution
+ synerr 'Command substitution is %s' \
+ 'not yet supported'
+ ;;
+ esac
;;
[@*#?$!A-Za-z0-9_-])
res="$(scan_param)"
@@ -586,10 +599,11 @@ error()
init_lexer()
{
local fn="${1}"
- shift 1
+ local ln="${2}"
+ shift 2
fname="${fn}"
- lineno=1
+ lineno=${ln}
tokens=''
pgetc
next
diff --git a/parsing/parse.sh b/parsing/parse.sh
index 8168c48..faf4637 100644
--- a/parsing/parse.sh
+++ b/parsing/parse.sh
@@ -580,12 +580,13 @@ sequential_sep()
return 1
}
-parse()
+parse_sub()
{
local fn="${1}"
- shift 1
+ local ln="${2}"
+ shift 2
- init_lexer "${fn}"
+ init_lexer "${fn}" ${ln}
# If this returns (does not exit), there are no errors.
complete_command
@@ -598,6 +599,17 @@ parse()
return 0
}
+parse()
+{
+ local fn="${1}"
+ shift 1
+
+ if parse_sub "${fn}" 1; then
+ return 0
+ fi
+ return 1
+}
+
try()
{
local tokens=
@@ -638,6 +650,8 @@ 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 )'
+try 'foo $(bar)'
+#try 'foo $((1 + 1))'