diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-04-27 06:45:23 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-04-27 06:45:23 -0700 |
commit | 7afbcc19bef877560f096c02e63b22f9f650b74e (patch) | |
tree | 088feceb91b034a6695f9dd0eb2e0de126eb06f6 /match.c | |
parent | c43eb573779da0965ecb84feb23e21b39405bb4b (diff) | |
download | txr-7afbcc19bef877560f096c02e63b22f9f650b74e.tar.gz txr-7afbcc19bef877560f096c02e63b22f9f650b74e.tar.bz2 txr-7afbcc19bef877560f096c02e63b22f9f650b74e.zip |
Diagnose empty clauses better in parallel constructs.
In this change we allow the grammar, as such, to express empty
clauses in the parallel constructs like @(some), @(cases),
@(gather) and so forth. However, we raise an error when these
occur. This results in a cleaner diagnostic behavior.
In the future, empty clauses may be allowed; the semantics has
to be worked out. An empty clause should neither succeed nor
fail; the behavior should be as if it is not there.
The general strategy in this patch is to eliminate the use
of the clauses terminal symbol (completely) and use
clauses_opt everywhere, and then diagnose when that
produces a nil. Some elems are similarly changed to elems_opt
in the horizontal versions of directives.
* parser.y (clauses): Nonterminal symbol completely removed.
(spec): Empty production rule removed, by using clauses_opt
instead of clauses.
(all_clause, some_clause, none_clause,
maybe_clause, cases_clause, choose_clause, gather_clause):
Instead of diagnosing empty clauses via a dedicated
grammar rule, diagnose by looking for nil subtree emerging
from from a clauses phrase.
(gather_parts): Use clauses_opt. Yield nil instead of
a cons if this clauses_opt is nil.
(additional_gather_parts): Simplify grammar and actions
by recursing back to gather_parts. If gather_parts produces
nil, diagnose the empty and/or subclause situation.
(collect_clause): Use clauses_opt and diagnose empty.
Simplify error production, which doesn't have to look
at the lookahead token yychar any more to implement
the empty diagnostic.
(clause_parts): Use clauses_opt instad of clauses. Yield
nil instead of a cons if clause_opt yields nil.
(additional_parts): Grammar and actions simplified by
recursing back to clause_parts. If the recursive
clause_parts produces nil, generate empty and/or
subclause diagnostic.
(elem): Use elems_opt for the various horizontal clauses
and implement empty checks for them. Explicit empty
productions are eliminated.
(clause_parts_h): Changed in way analogous to clause_parts.
(additional_parts_h): Changed analogously to
additional_parts.
(try_clause): Use clauses_opt and catch empties.
Eliminate the second error production.
(catch_clauses_opt): Diagnose empty catch and finally, unless
in compatibility mode with 139 or less. The grammar already
uses clauses_opt here; empty catches and finally had been
allowed. Fixed messages in error productions for catch
and finally to refer to catch and finally rather than try.
Diffstat (limited to 'match.c')
0 files changed, 0 insertions, 0 deletions