mhtsai208 Posted May 26, 2023 Report Share Posted May 26, 2023 All foreach grammar rules (activity_foreach_stmt, foreach_constraint_item, and procedural_foreach_stmt) are ambiguous. Consider the grammar rule below (terminal symbols are enclosed in double quotes). procedural_foreach_stmt ::= foreach "(" [ iterator_identifier ":" ] expression [ "[" index_identifier "]" ] ")" procedural_stmt Assume there is an integer k and a map m. int k = 0; map< int, map<int, int> > m = { 0: {0: 0, 1: 1} }; Then the following statement is ambiguous. foreach (v : m[k]) ... There are two interpretations. for each value v with index k in m (index_identifier = k in this case) for each value v in m[k] (i.e., m[0]) (no index_identifier in this case) Quote Link to comment Share on other sites More sharing options...
karthickg Posted May 29, 2023 Report Share Posted May 29, 2023 It is a valid point. Have forwarded your question to the work-group. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.