gdritter repos when-computer / 9d61e4e
s/allow/allowed/ Getty Ritter 8 years ago
1 changed file(s) with 1 addition(s) and 1 deletion(s). Collapse all Expand all
6767
6868 \code{\ttcom{(ed)} \ttkw{g}/this/\ttkw{g}/that/\ttkw{p} \ttcom{# bad!}}
6969
70 but we can't do this: \tt{\ttkw{g}} commands aren't allow to invoke other \tt{\ttkw{g}} commands, only simpler commands like \tt{\ttkw{p}}rinting or \tt{\ttkw{d}}eletion. But in structural regular expressions, the primitive components are \em{designed} to be used in a recursive way, composing complicated commands out of simple regular expressions and sets of commands, which has the wonderful side-effect that the regular expressions you actually write are much simpler. To borrow a few examples from Rob Pike's paper: with structural regular expressions, if we wanted to print every line that contained \tt{rob} but not \tt{robot}, we could write a command to focus on lines, keep only those that contain \tt{rob}, filter out those that contain \tt{robot}, and print them:
70 but we can't do this: \tt{\ttkw{g}} commands aren't allowed to invoke other \tt{\ttkw{g}} commands, only simpler commands like \tt{\ttkw{p}}rinting or \tt{\ttkw{d}}eletion. But in structural regular expressions, the primitive components are \em{designed} to be used in a recursive way, composing complicated commands out of simple regular expressions and sets of commands, which has the wonderful side-effect that the regular expressions you actually write are much simpler. To borrow a few examples from Rob Pike's paper: with structural regular expressions, if we wanted to print every line that contained \tt{rob} but not \tt{robot}, we could write a command to focus on lines, keep only those that contain \tt{rob}, filter out those that contain \tt{robot}, and print them:
7171
7272 \code{\ttcom{(sam)} \ttkw{x}/.*\\n/\ttkw{g}/rob/\ttkw{v}/robot/\ttkw{p}}
7373