summaryrefslogtreecommitdiff
path: root/README
diff options
context:
space:
mode:
Diffstat (limited to 'README')
-rw-r--r--README46
1 files changed, 46 insertions, 0 deletions
diff --git a/README b/README
new file mode 100644
index 0000000..41f3d03
--- /dev/null
+++ b/README
@@ -0,0 +1,46 @@
+-*- org -*-
+
+Guile Parser Combinators
+
+* About
+
+ A simple, SRFI-41 stream-based, monadic parser combinator library
+ for Guile Scheme.
+
+* Example
+
+ #+BEGIN_SRC scheme
+ (define stream->string (compose list->string stream->list))
+
+ (define (parse-string str)
+ (lambda (stream)
+ (let ((input (stream->string (stream-take (string-length str) stream))))
+ (if (string=? str input)
+ (parse-result str (stream-drop (string-length str) stream))
+ %parse-failure))))
+
+ (define article
+ (parse-any (parse-string "the ") (parse-string "a ")))
+
+ (define noun
+ (parse-any (parse-string "student ") (parse-string "professor ")))
+
+ (define verb
+ (parse-any (parse-string "studies ") (parse-string "lectures ")))
+
+ (define noun-phrase
+ (parse-each article noun))
+
+ (define verb-phrase
+ (parse-each verb noun-phrase))
+
+ (define sentence
+ (parse-each noun-phrase verb-phrase))
+
+ (parse noun-phrase "the professor ")
+ (parse sentence "the professor lectures the student ")
+ #+END_SRC
+
+* License
+
+ GNU LGPL3+