diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2011-11-06 17:23:55 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2011-11-06 17:23:55 -0800 |
commit | 687fd6ab7031aa573cbcd1b3ae624eb02530a25c (patch) | |
tree | 34bc63f8a0d81c8d7a0aeefe24919673f7a07c10 /parser.y | |
parent | d435df363ff8e2ac5303cb837c9ff2604920ae56 (diff) | |
download | txr-687fd6ab7031aa573cbcd1b3ae624eb02530a25c.tar.gz txr-687fd6ab7031aa573cbcd1b3ae624eb02530a25c.tar.bz2 txr-687fd6ab7031aa573cbcd1b3ae624eb02530a25c.zip |
Task #11581
* match.c (gather_s): New keyword variable.
(v_gather): New function.
(syms_init): gather_s initialized.
(dir_tables_init): v_gather entered into table.
* match.h (gather_s): Declared.
* parser.l: GATHER token scanning added.
* parser.y: GATHER token added. gather_clause nonterminal added.
* txr.1: New directive documented.
* txr.vim: gather keyword introduced.
Diffstat (limited to 'parser.y')
-rw-r--r-- | parser.y | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -59,7 +59,7 @@ static val parsed_spec; } %token <lexeme> SPACE TEXT IDENT KEYWORD METAVAR -%token <lexeme> ALL SOME NONE MAYBE CASES CHOOSE +%token <lexeme> ALL SOME NONE MAYBE CASES CHOOSE GATHER %token <lexeme> AND OR END COLLECT %token <lexeme> UNTIL COLL OUTPUT REPEAT REP SINGLE FIRST LAST EMPTY DEFINE %token <lexeme> TRY CATCH FINALLY @@ -72,7 +72,7 @@ static val parsed_spec; %type <val> spec clauses clauses_opt clause %type <val> all_clause some_clause none_clause maybe_clause -%type <val> cases_clause choose_clause collect_clause until_last +%type <val> cases_clause choose_clause gather_clause collect_clause until_last %type <val> clause_parts additional_parts %type <val> output_clause define_clause try_clause catch_clauses_opt %type <val> line elems_opt elems clause_parts_h additional_parts_h @@ -123,6 +123,7 @@ clause : all_clause { $$ = list(num(lineno - 1), $1, nao); } | cases_clause { $$ = list(num(lineno - 1), $1, nao); } | choose_clause { $$ = list(num(lineno - 1), $1, nao); } | collect_clause { $$ = list(num(lineno - 1), $1, nao); } + | gather_clause { $$ = list(num(lineno - 1), $1, nao); } | define_clause { $$ = list(num(lineno - 1), define_transform($1), nao); } | try_clause { $$ = list(num(lineno - 1), $1, nao); } @@ -184,6 +185,21 @@ choose_clause : CHOOSE exprs_opt ')' yyerror("empty choose clause"); } ; +gather_clause : GATHER exprs_opt ')' + newl clause_parts { $$ = list(gather_s, + append2(mapcar(curry_12_1(func_n2(cons), nil), + first($5)), rest($5)), + $2, nao); } + | GATHER exprs_opt ')' + newl error { $$ = nil; + yybadtoken(yychar, + lit("gather clause")); } + | GATHER exprs_opt ')' + newl END newl { $$ = nil; + yyerror("empty gather clause"); } + ; + + collect_clause : COLLECT exprs_opt ')' newl clauses END newl { $$ = list(collect_s, $5, nil, $2, |