From b55fa7a69f286149092cd25902871019c6795b9d Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 6 Dec 2013 08:47:36 -0800 Subject: * eval.c (eval_init): Update registration of regex-compile to reflect that it has two arguments now. * parser.y (grammar): Update calls to regex_compile to pass two arguments. Since we don't expect regex_compile to parse, we specify the error stream as nil. (spec): The "secret syntax" for a regex is simplified not to include the slashes. This provides better diagnostics for unterminated syntax and requires less string processing to generate. Also, the form returned doesn't have the regex symbol consed onto it, which parse_regex just throws away. * regex.c (regex_compile): Now takes a stream argument. * regex.h (regex_compile): Declaration updated. * txr.1: Updated --- parser.y | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'parser.y') diff --git a/parser.y b/parser.y index 321b32e0..917f2208 100644 --- a/parser.y +++ b/parser.y @@ -114,7 +114,7 @@ static val parsed_spec; spec : clauses { parsed_spec = $1; } | /* empty */ { parsed_spec = nil; } - | SECRET_ESCAPE_R regex { parsed_spec = $2; } + | SECRET_ESCAPE_R regexpr { parsed_spec = $2; end_of_regex(); } | error '\n' { parsed_spec = nil; if (errors >= 8) YYABORT; @@ -320,12 +320,12 @@ text : TEXT { $$ = rl(string_own($1), num(lineno)); } | SPACE { if ($1[0] == ' ' && $1[1] == 0) { val spaces = list(oneplus_s, chr(' '), nao); - $$ = cons(regex_compile(spaces), spaces); + $$ = cons(regex_compile(spaces, nil), spaces); rl($$, num(lineno)); free($1); } else { $$ = rl(string_own($1), num(lineno)); }} - | regex { $$ = cons(regex_compile(rest($1)), + | regex { $$ = cons(regex_compile(rest($1), nil), rest($1)); rl($$, num(lineno)); } ; @@ -652,7 +652,7 @@ var_op : '*' { $$ = list(t, nao); } ; modifiers : NUMBER { $$ = cons($1, nil); } - | regex { $$ = cons(cons(regex_compile(rest($1)), + | regex { $$ = cons(cons(regex_compile(rest($1), nil), rest($1)), nil); rlcp($$, $1); } | list { $$ = cons($1, nil); } @@ -742,7 +742,7 @@ expr : IDENT { $$ = rl(intern(string_own($1), nil), | vector { $$ = $1; } | hash { $$ = $1; } | meta_expr { $$ = $1; } - | lisp_regex { $$ = cons(regex_compile(rest($1)), + | lisp_regex { $$ = cons(regex_compile(rest($1), nil), rest($1)); rlcp($$, $1); } | chrlit { $$ = rl($1, num(lineno)); } -- cgit v1.2.3