Talk:Brace expansion: Difference between revisions

m
Line 66:
::::: What's scary about it? The rules for ''identifying'' (parsing) the layers, and the rules for how to ''expand'' the string based on this information, are conceptually two different things...
::::: '''Parsing''' happens by finding valid balanced braces <small>(using the given information that closing braces match the *nearest* opening brace to their left, and that groups without at least 2 alternatives are not valid)</small>.
::::: '''Expansion''' happens recursively (<small>i.e.in fromcase theof insidenested outgroups</small>), andas well as cumulatively (<small>in case of multiple groups on the same layer</small>).
::::: This is all explained in the spec, and demonstrated by the test cases.
::::: Regarding "''first identify the nesting, [...] and postpone expansion until all brace expansions have been identified''", you're free to do that if you feel that's the best way to solve the task in your language. In fact the Perl 6 solution does it that way: It uses a grammar to find where all the nested brace group parts are, and then passes the resulting AST tree to a recursive function which does the expansion. It's not a "requirement" though: The Perl and Python solutions both do identification and expansion in one go ''(albeit in rather different ways)''. The only requirement is that the function does the right thing; how it does it is up to you (based on what you think works best in your language).
Anonymous user