Brace expansion: Difference between revisions
→{{header|TXR}}: Some explanatory notes.
(→{{header|TXR}}: Handle all required cases: backslash, braces without commas, dangling braces.) |
(→{{header|TXR}}: Some explanatory notes.) |
||
Line 5,146:
</pre>
=={{header|TXR}}==
The approach here is to parse the notation into a nested tree of strings. In the following diagram the <code>-></code> arrow indicates that the tree on the left denotes the list of output strings on the right.
A list with no operator symbol denotes catenation:
<pre>("foo" "bar") -> ("foobar")</pre>
The <code>/</code> symbol (slash, usually denoting arithmetic division) denotes alternation:
<pre>(/ "foo" "bar") -> ("foo" "bar")
("inter" (/ "pol" "pret") "ation") -> ("interpolation" "interpretation")</pre>
This notation is processed by the <code>bexp-expand</code> function to produce the list of strings which it denotes. The <code>bexp-parse</code> function parses a string containing brace expansion into the above notation.
<syntaxhighlight lang="txrlisp">;; API
(defun brace-expand (str)
|