Hi all, This small discussion refers to the current head of the guile-log branch. When the parser framework is rich enough I will issue a new release of it.
As you know I'm currently working with guile-log to attach decent parser tools in for anyone wanting to do parsing in a logic programming environment. My next task have been to develop grep and sed like tools using the parser framework. This is now successful and I would ask for what features will be needed for it to be good enough. This will be a kind of testbed to develop the parser further. So, the background is that we designed a regular expressions like functionality via e.g. (s-and m1 ... mn) m1 ... and mn must both match mn is used for consuming the stream s-and! the same as s-and but only successes one time (s-seq m1 m2 ...) m1 match then m2 match ... (s-or m1 m2 ...) m1 match else m2 match else s-or! the same as s-or but successes only one time (s-not m) if m does not match then consume one character s-not! the same as s-not but will store the character pr-not the same as s-not but prints the character to stdout (s-tag tag) (s-tag a) matches a, (s-tag "a") matches a s-tag! the same as s-tag, but stores the character pr-tag the sa,e as s-tag, but prints the character to stdout (s-reg pat) (s-ref ".") matches any character the pattern should be a regular expression matching one character s-reg! pr-reg as above With this basic regular expressions can be built. Currently the grep and sed facilities comes in 1) (grep m expr #:key (a 0) (b 0) (c 0)) the standard output of the expr is captured by grep and if the matcher m matches starting at line i, then lines: (- i (max a c)) -> (+ i (max b c)) will be printed 2) (par-grep m expr #:key (a 0) (b 0) (c 0) (d 0)) This grepper knows about scheme code and will work basically the same but print the lines containing the form including the matched sentence and d enclosing forms above. a b c is as before but now defines the extra lines printed appart from the target form. Example: scheme@(guile-user)> (par-grep (s-tag x) (f1) #:d 0) (a (b c "x ") scheme@(guile-user)> (par-grep (s-tag x) (f1) #:d 1) (a (b c "x ") (d e) (b (f g h))) 3) (sed m expr) This will print out on std output all lines not matched by m, if m is matched then that expr will make sure to print the correct way An example matcher is m := (s-tr a b) which will replace a by b 4) (par-sed m expr) This is the same as sed but knows about scheme. There is nothing interesting with this right know. Have fun!