According to previous discussion about Sweet expression, we should treat curly-brackets as delimiter, say: {+ 1 1} ==> 2 This patch added an option to read-option to enable this. And the patch will cause Guile treats curly-brackets as delimiter in default. We don't see any harm for this till now. But one may disable it with read-option as will.
Regards.
From 289a58122780e77968cf3e0d2ade1f786d344b1d Mon Sep 17 00:00:00 2001 From: NalaGinrut <nalagin...@gmail.com> Date: Tue, 13 Mar 2012 13:53:05 +0800 Subject: [PATCH 1/2] add SCM_CURLY_BRACKETS_P --- libguile/private-options.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/libguile/private-options.h b/libguile/private-options.h index 9d2d43c..637a8a4 100644 --- a/libguile/private-options.h +++ b/libguile/private-options.h @@ -67,7 +67,7 @@ SCM_INTERNAL scm_t_option scm_read_opts[]; #define SCM_R6RS_ESCAPES_P scm_read_opts[4].val #define SCM_SQUARE_BRACKETS_P scm_read_opts[5].val #define SCM_HUNGRY_EOL_ESCAPES_P scm_read_opts[6].val - +#define SCM_CURLY_BRACKETS_P scm_read_opts[7].val #define SCM_N_READ_OPTIONS 6 #endif /* PRIVATE_OPTIONS */ -- 1.7.0.4
From 5ee33a6a4516b24bef365dc441f563c129fb602a Mon Sep 17 00:00:00 2001 From: NalaGinrut <nalagin...@gmail.com> Date: Tue, 13 Mar 2012 13:54:03 +0800 Subject: [PATCH 2/2] treat curly-brackets as delimiter in default --- libguile/read.c | 19 ++++++++++++++++--- 1 files changed, 16 insertions(+), 3 deletions(-) diff --git a/libguile/read.c b/libguile/read.c index bbaf3f6..57f35e5 100644 --- a/libguile/read.c +++ b/libguile/read.c @@ -78,6 +78,8 @@ scm_t_option scm_read_opts[] = { "Treat `[' and `]' as parentheses, for R6RS compatibility."}, { SCM_OPTION_BOOLEAN, "hungry-eol-escapes", 0, "In strings, consume leading whitespace after an escaped end-of-line."}, + { SCM_OPTION_BOOLEAN, "curly-brackets", 1, + "Treat `{' and `}' as parentheses, for Sweet-Exp compatibility."}, { 0, }, }; @@ -186,7 +188,8 @@ scm_i_read_hash_procedures_set_x (SCM value) #define CHAR_IS_R5RS_DELIMITER(c) \ (CHAR_IS_BLANK (c) \ || (c == ')') || (c == '(') || (c == ';') || (c == '"') \ - || (SCM_SQUARE_BRACKETS_P && ((c == '[') || (c == ']')))) + || (SCM_SQUARE_BRACKETS_P && ((c == '[') || (c == ']'))) \ + || (SCM_CURLY_BRACKETS_P && ((c == '{') || (c == '}')))) #define CHAR_IS_DELIMITER CHAR_IS_R5RS_DELIMITER @@ -373,7 +376,7 @@ scm_read_sexp (scm_t_wchar chr, SCM port) { int c; SCM tmp, tl, ans = SCM_EOL; - const int terminating_char = ((chr == '[') ? ']' : ')'); + const int terminating_char = ((chr == '[') ? ']' : ((chr == '{') ? '}' : ')')); /* Need to capture line and column numbers here. */ long line = SCM_LINUM (port); @@ -405,7 +408,9 @@ scm_read_sexp (scm_t_wchar chr, SCM port) { SCM new_tail; - if (c == ')' || (SCM_SQUARE_BRACKETS_P && c == ']')) + if (c == ')' + || (SCM_SQUARE_BRACKETS_P && c == ']') + || (SCM_CURLY_BRACKETS_P && c == '}')) scm_i_input_error (FUNC_NAME, port, "in pair: mismatched close paren: ~A", scm_list_1 (SCM_MAKE_CHAR (c))); @@ -1449,6 +1454,10 @@ scm_read_expression (SCM port) if (!SCM_SQUARE_BRACKETS_P) return (scm_read_mixed_case_symbol (chr, port)); /* otherwise fall through */ + case '{': + if (!SCM_CURLY_BRACKETS_P) + return (scm_read_mixed_case_symbol (chr, port)); + /* otherwise fall through */ case '(': return (scm_read_sexp (chr, port)); case '"': @@ -1475,6 +1484,10 @@ scm_read_expression (SCM port) if (SCM_SQUARE_BRACKETS_P) scm_i_input_error (FUNC_NAME, port, "unexpected \"]\"", SCM_EOL); /* otherwise fall through */ + case '}': + if (SCM_CURLY_BRACKETS_P) + scm_i_input_error (FUNC_NAME, port, "unexpected \"}\"", SCM_EOL); + /* otherwise fall through */ case EOF: return SCM_EOF_VAL; case ':': -- 1.7.0.4