summaryrefslogtreecommitdiffstats
path: root/parsing/lexer.sh
diff options
context:
space:
mode:
Diffstat (limited to 'parsing/lexer.sh')
-rw-r--r--parsing/lexer.sh51
1 files changed, 47 insertions, 4 deletions
diff --git a/parsing/lexer.sh b/parsing/lexer.sh
index b03878d..1e9b2e0 100644
--- a/parsing/lexer.sh
+++ b/parsing/lexer.sh
@@ -276,6 +276,7 @@ scan_wordexp()
local res=
local param=
local word=
+ local toks=
wordexp=''
ln_off=0
@@ -398,8 +399,30 @@ scan_wordexp()
;;
*)
# Command substitution
- synerr 'Command substitution is %s' \
- 'not yet supported'
+ if ! res="$(parse_sub "${fname}" \
+ ${lineno} "${c}" false)"
+ then
+ exit 1
+ fi
+ ln_off=${res%%${RS}*}
+ res="${res#*${RS}}"
+ c="${res%%${RS}*}"
+ res="${res#*${RS}}"
+ toks="${res%%${RS}*}"
+ lineno=${ln_off}
+ wordexp="\$(${STX}${toks}${ETX}"
+ # Get ")"
+ case "${c}" in
+ ')')
+ wordexp="${wordexp}${c}"
+ pgetc
+ ;;
+ *)
+ echo "c: '$c'" >&2
+ echo "wordexp: $wordexp" >&2
+ synerr 'Missing ")"'
+ ;;
+ esac
;;
esac
;;
@@ -600,15 +623,35 @@ init_lexer()
{
local fn="${1}"
local ln="${2}"
- shift 2
+ local char="${3}"
+ shift 3
fname="${fn}"
lineno=${ln}
tokens=''
- pgetc
+ case "${char}" in
+ '')
+ pgetc
+ ;;
+ *)
+ c="${char}"
+ ;;
+ esac
next
}
+get_lineno()
+{
+ printf '%d' ${lineno}
+ return 0
+}
+
+get_lexer_char()
+{
+ printf '%c' "${c}"
+ return 0
+}
+
get_tokens()
{
printf '%s' "${tokens}"