aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2014-05-10 15:45:36 -0500
committerJoel Martin <github@martintribe.org>2014-05-10 15:45:36 -0500
commit70aff0c1fe3d3ba7953b4e12708e91fd41fed5eb (patch)
tree88d46c8326b233c271b9884197de6266a9f45427
parent3f26b8f601c96956029fe64e1aeac7b8b9f76911 (diff)
downloadmal-70aff0c1fe3d3ba7953b4e12708e91fd41fed5eb.tar.gz
mal-70aff0c1fe3d3ba7953b4e12708e91fd41fed5eb.zip
Bash: correctly treat commas as whitespace.
-rw-r--r--bash/reader.sh7
-rwxr-xr-xbash/step1_read_print.sh2
-rwxr-xr-xbash/step2_eval.sh2
-rwxr-xr-xbash/step3_env.sh2
-rwxr-xr-xbash/step4_if_fn_do.sh2
-rwxr-xr-xbash/step5_tco.sh2
-rwxr-xr-xbash/step6_file.sh2
-rwxr-xr-xbash/step7_quote.sh2
-rwxr-xr-xbash/step8_macros.sh2
-rwxr-xr-xbash/step9_interop.sh2
-rwxr-xr-xbash/stepA_more.sh2
11 files changed, 13 insertions, 14 deletions
diff --git a/bash/reader.sh b/bash/reader.sh
index 585b152..ee7e505 100644
--- a/bash/reader.sh
+++ b/bash/reader.sh
@@ -113,7 +113,7 @@ TOKENIZE () {
chunk=$(( chunk + ${chunksz} ))
fi
(( ${#str} == 0 )) && break
- [[ "${str}" =~ ^^([][{}\(\)^@])|^(~@)|(\"(\\.|[^\\\"])*\")|^(;[^$'\n']*)|^([~\'\`])|^([^][ ~\`\'\";{}\(\)^@]+)|^[,]|^[[:space:]]+ ]]
+ [[ "${str}" =~ ^^([][{}\(\)^@])|^(~@)|(\"(\\.|[^\\\"])*\")|^(;[^$'\n']*)|^([~\'\`])|^([^][ ~\`\'\";{}\(\)^@\,]+)|^[,]|^[[:space:]]+ ]]
match=${BASH_REMATCH[0]}
str="${str:${#match}}"
token="${match//$'\n'/}"
@@ -123,9 +123,8 @@ TOKENIZE () {
idx=$(( idx + 1 ))
fi
if [ -z "${match}" ]; then
- echo >&2 "Tokenizing error at: ${str:0:50}"
_error "Tokenizing error at: ${str:0:50}"
- break
+ return 1
fi
done
}
@@ -134,7 +133,7 @@ TOKENIZE () {
# read in r.
READ_STR () {
declare -a __reader_tokens
- TOKENIZE "${*}" # sets __reader_tokens
+ TOKENIZE "${*}" || return 1 # sets __reader_tokens
#set | grep ^__reader_tokens
if [ -z "${__reader_tokens[k]}" ]; then
r=
diff --git a/bash/step1_read_print.sh b/bash/step1_read_print.sh
index e7ca283..3f6c551 100755
--- a/bash/step1_read_print.sh
+++ b/bash/step1_read_print.sh
@@ -31,7 +31,7 @@ PRINT () {
# repl
REP () {
- READ "${1}" || return 1
+ READ "${1}"
EVAL "${r}"
PRINT "${r}"
}
diff --git a/bash/step2_eval.sh b/bash/step2_eval.sh
index 224f181..b59320b 100755
--- a/bash/step2_eval.sh
+++ b/bash/step2_eval.sh
@@ -74,7 +74,7 @@ PRINT () {
declare -A REPL_ENV
REP () {
r=
- READ "${1}" || return 1
+ READ "${1}"
EVAL "${r}" REPL_ENV
PRINT "${r}"
}
diff --git a/bash/step3_env.sh b/bash/step3_env.sh
index c81805a..a837e00 100755
--- a/bash/step3_env.sh
+++ b/bash/step3_env.sh
@@ -97,7 +97,7 @@ PRINT () {
ENV; REPL_ENV="${r}"
REP () {
r=
- READ "${1}" || return 1
+ READ "${1}"
EVAL "${r}" "${REPL_ENV}"
PRINT "${r}"
}
diff --git a/bash/step4_if_fn_do.sh b/bash/step4_if_fn_do.sh
index 07bf3bf..6fd7301 100755
--- a/bash/step4_if_fn_do.sh
+++ b/bash/step4_if_fn_do.sh
@@ -120,7 +120,7 @@ PRINT () {
ENV; REPL_ENV="${r}"
REP () {
r=
- READ "${1}" || return 1
+ READ "${1}"
EVAL "${r}" "${REPL_ENV}"
PRINT "${r}"
}
diff --git a/bash/step5_tco.sh b/bash/step5_tco.sh
index ea5b72d..fc36b46 100755
--- a/bash/step5_tco.sh
+++ b/bash/step5_tco.sh
@@ -139,7 +139,7 @@ PRINT () {
ENV; REPL_ENV="${r}"
REP () {
r=
- READ "${1}" || return 1
+ READ "${1}"
EVAL "${r}" "${REPL_ENV}"
PRINT "${r}"
}
diff --git a/bash/step6_file.sh b/bash/step6_file.sh
index 168698a..e6ee571 100755
--- a/bash/step6_file.sh
+++ b/bash/step6_file.sh
@@ -139,7 +139,7 @@ PRINT () {
ENV; REPL_ENV="${r}"
REP () {
r=
- READ "${1}" || return 1
+ READ "${1}"
EVAL "${r}" "${REPL_ENV}"
PRINT "${r}"
}
diff --git a/bash/step7_quote.sh b/bash/step7_quote.sh
index 8319f64..d71e24b 100755
--- a/bash/step7_quote.sh
+++ b/bash/step7_quote.sh
@@ -185,7 +185,7 @@ PRINT () {
ENV; REPL_ENV="${r}"
REP () {
r=
- READ "${1}" || return 1
+ READ "${1}"
EVAL "${r}" "${REPL_ENV}"
PRINT "${r}"
}
diff --git a/bash/step8_macros.sh b/bash/step8_macros.sh
index b21c25f..3be3651 100755
--- a/bash/step8_macros.sh
+++ b/bash/step8_macros.sh
@@ -221,7 +221,7 @@ PRINT () {
ENV; REPL_ENV="${r}"
REP () {
r=
- READ "${1}" || return 1
+ READ "${1}"
EVAL "${r}" "${REPL_ENV}"
PRINT "${r}"
}
diff --git a/bash/step9_interop.sh b/bash/step9_interop.sh
index 1e00ede..ec8d6eb 100755
--- a/bash/step9_interop.sh
+++ b/bash/step9_interop.sh
@@ -230,7 +230,7 @@ PRINT () {
ENV; REPL_ENV="${r}"
REP () {
r=
- READ "${1}" || return 1
+ READ "${1}"
EVAL "${r}" "${REPL_ENV}"
PRINT "${r}"
}
diff --git a/bash/stepA_more.sh b/bash/stepA_more.sh
index 6c3d6c9..2422643 100755
--- a/bash/stepA_more.sh
+++ b/bash/stepA_more.sh
@@ -245,7 +245,7 @@ PRINT () {
ENV; REPL_ENV="${r}"
REP () {
r=
- READ "${1}" || return 1
+ READ "${1}"
EVAL "${r}" "${REPL_ENV}"
PRINT "${r}"
}