From 5ee33a6a4516b24bef365dc441f563c129fb602a Mon Sep 17 00:00:00 2001 From: NalaGinrut 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