Removed repeated use of simple
Getty Ritter
8 years ago
67 | 67 | |
68 | 68 | \code{\ttcom{(ed)} \ttkw{g}/this/\ttkw{g}/that/\ttkw{p} \ttcom{# bad!}} |
69 | 69 | |
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 |
|
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 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: | |
71 | 71 | |
72 | 72 | \code{\ttcom{(sam)} \ttkw{x}/.*\\n/\ttkw{g}/rob/\ttkw{v}/robot/\ttkw{p}} |
73 | 73 |