Talk:Brace expansion: Difference between revisions

Line 63:
 
:::: That said, perhaps you are suggesting a system where we first identify the nesting, from the inside out, and postpone expansion until all brace expansions have been identified. That would be relatively straightforward to implement and would explain the stack data structures I've noticed in other implementations. Still, if that is the requirement I would like it to be stated explicitly rather than implicitly or through a reference implementation. --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 21:34, 31 January 2014 (UTC)
 
::::: 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. from the inside out</small>), and 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).
::::: --[[User:Smls|Smls]] ([[User talk:Smls|talk]]) 22:01, 31 January 2014 (UTC)
Anonymous user