summaryrefslogtreecommitdiffstats
path: root/eshtrans
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2016-02-21 12:19:00 (EST)
committer P. J. McDermott <pj@pehjota.net>2016-02-21 12:21:44 (EST)
commit38730b344f7027fa89097ca660300802842a18aa (patch)
treed26a177d24bfd92e69a5085e7c32029d950d83fd /eshtrans
parent506a0723291b4abc4b707a6353a840ef51f95ee8 (diff)
downloadeggshell-38730b344f7027fa89097ca660300802842a18aa.zip
eggshell-38730b344f7027fa89097ca660300802842a18aa.tar.gz
eggshell-38730b344f7027fa89097ca660300802842a18aa.tar.bz2
eshtrans/frontend: Don't eat char after wordexp in arithmetic
Before: Trying script: $(($foo + 1)) Tokens: T_FNAME<US>$(($foo+ 1))<RS>T_NEWLINE<RS>T_EOF<RS> Token: function name "$(($foo+ 1))" Token: newline Token: end of file Generated code: $(($foo+ 1)) Trying script: $((1 + $foo)) stdin:1: Syntax error: Arithmetic expansion: ")" unexpected FAIL After: Trying script: $(($foo + 1)) Tokens: T_FNAME<US>$(($foo + 1))<RS>T_NEWLINE<RS>T_EOF<RS> Token: function name "$(($foo + 1))" Token: newline Token: end of file Generated code: $(($foo + 1)) Trying script: $((1 + $foo)) Tokens: T_FNAME<US>$((1 + $foo))<RS>T_NEWLINE<RS>T_EOF<RS> Token: function name "$((1 + $foo))" Token: newline Token: end of file Generated code: $((1 + $foo))
Diffstat (limited to 'eshtrans')
-rw-r--r--eshtrans/frontend/lexer.esh4
-rw-r--r--eshtrans/main.esh5
2 files changed, 6 insertions, 3 deletions
diff --git a/eshtrans/frontend/lexer.esh b/eshtrans/frontend/lexer.esh
index d904aa0..6775bbc 100644
--- a/eshtrans/frontend/lexer.esh
+++ b/eshtrans/frontend/lexer.esh
@@ -783,8 +783,8 @@ scan_wordexp_arith()
arith=''
paren_lvl=0
+ lgetc
while :; do
- lgetc
case "${c}" in
'')
synerr 'end of file unexpected (%s)' \
@@ -823,11 +823,13 @@ scan_wordexp_arith()
# was run in a subshell.
lineno=$((${lineno} + ${ln_off}))
arith="${arith}${sub_wordexp}"
+ continue
;;
*)
arith="${arith}${c}"
;;
esac
+ lgetc
done
}
diff --git a/eshtrans/main.esh b/eshtrans/main.esh
index 46edd26..0177774 100644
--- a/eshtrans/main.esh
+++ b/eshtrans/main.esh
@@ -101,6 +101,7 @@ main()
#try 'foo' '#bar'
#try '# foo' 'bar'
#try '' 'foo'
-dbg=true
-try '\\ foo'
+#try '\\ foo'
+try '$(($foo + 1))'
+try '$((1 + $foo))'
}