X-Git-Url: http://git.hcoop.net/bpt/guile.git/blobdiff_plain/e610dc3851da716e6ee4568f94f5f7cace84d2d9..bdad13401611db73c57dcf8a1285b37e9b2ea31e:/doc/ref/expect.texi diff --git a/doc/ref/expect.texi b/doc/ref/expect.texi index 05c766999..140fd477e 100644 --- a/doc/ref/expect.texi +++ b/doc/ref/expect.texi @@ -4,15 +4,14 @@ @c Free Software Foundation, Inc. @c See the file guile.texi for copying conditions. -@page @node Expect @section Expect The macros in this section are made available with: -@smalllisp +@lisp (use-modules (ice-9 expect)) -@end smalllisp +@end lisp @code{expect} is a macro for selecting actions based on the output from a port. The name comes from a tool of similar functionality by Don Libes. @@ -30,14 +29,14 @@ which is matched against each of the patterns. When a pattern matches, the remaining expression(s) in the clause are evaluated and the value of the last is returned. For example: -@smalllisp +@lisp (with-input-from-file "/etc/passwd" (lambda () (expect-strings ("^nobody" (display "Got a nobody user.\n") (display "That's no problem.\n")) ("^daemon" (display "Got a daemon user.\n"))))) -@end smalllisp +@end lisp The regular expression is compiled with the @code{REG_NEWLINE} flag, so that the ^ and $ anchors will match at any newline, not just at the start @@ -54,13 +53,13 @@ The symbol @code{=>} can be used to indicate that the expression is a procedure which will accept the result of a successful regular expression match. E.g., -@smalllisp +@lisp ("^daemon" => write) ("^d(aemon)" => (lambda args (for-each write args))) ("^da(em)on" => (lambda (all sub) (write all) (newline) (write sub) (newline))) -@end smalllisp +@end lisp The order of the substrings corresponds to the order in which the opening brackets occur. @@ -135,12 +134,12 @@ expression. In the following example, a string will only be matched at the beginning of the file: -@smalllisp +@lisp (let ((expect-port (open-input-file "/etc/passwd"))) (expect ((lambda (s eof?) (string=? s "fnord!")) (display "Got a nobody user!\n")))) -@end smalllisp +@end lisp The control variables described for @code{expect-strings} also influence the behaviour of @code{expect}, with the exception of