ISO 10303-14: issues resolution - another grammar issue?

Ed Barkmeyer edbark at nist.gov
Wed Nov 13 12:46:55 EST 2002


Jochen proposes:
 > To resolve the conflict the grammar probably needs to be changed, e.g. in
 > the following way:
 >
 > original:
 >
 > 81 foreach_expr = EACH var_id IN expression [where_clause] RETURN expression .
 > 82 forloop_expr = repeat_control RETURN expression .
 > 85 for_expr = FOR (foreach_expr | forloop_expr ) .
 >
 > corrected variant:
 >
 > 81 foreach_expr = EACH var_id IN expression [where_clause]
 >        RETURN '('expression ')' .
 > 82 forloop_expr = repeat_control RETURN '(' expression ')'  .
 > 85 for_expr = FOR (foreach_expr | forloop_expr ) .

There is an alternative.  Using the Ada approach, the equivalent fix would be:

  81 foreach_expr = EACH var_id IN expression [where_clause] RETURN expression .
  82 forloop_expr = repeat_control RETURN expression .
  85 for_expr = FOR (foreach_expr | forloop_expr ) END_FOR .
or:
  85 for_expr = '(' FOR (foreach_expr | forloop_expr ) ')' .

That is, to parenthesize the whole FOR expression rather than just the RETURN 
expression.

Also, in general, I think the semantics of the construct may be better served by 
the equivalent grammar productions:

  81 foreach_control = EACH var_id IN expression [where_clause] .
  85 for_expr = FOR ( foreach_control | repeat_control )
         RETURN '(' expression ')'  .

That is, the foreach_expr is not an expression, it is a loop control, and it is 
functionally equivalent to a repeat_control.  There is nothing special about 
var_id in the return expression, only in the where_clause, which is similar to 
the significance of the control variable in the repeat_control.

-Ed

-- 
Edward J. Barkmeyer                       Email: edbark at nist.gov
National Institute of Standards & Technology
Manufacturing Systems Integration Division
100 Bureau Drive, Mail Stop 8260          Tel: +1 301-975-3528
Gaithersburg, MD 20899-8260               FAX: +1 301-975-4694

"The opinions expressed above do not reflect consensus of NIST,
and have not been reviewed by any Government authority."




More information about the wg11 mailing list