Skip to content
Browse files

New example for Quick Introduction.

  • Loading branch information...
1 parent ef160e9 commit 72eb734cc746beb3a0adda874cc79a9a31a44bb6 Volkan YAZICI committed Jul 15, 2007
Showing with 12 additions and 1 deletion.
  1. +12 −1 README
View
13 README
@@ -36,7 +36,18 @@ CREATE-PARSER-CONTEXT methods and DEFRULE, DEFRENDERER macros.
In some certain situations, you may also need to use DEFATOM too. See
atoms.lisp for DEFATOM examples.
-Here is a tiny example:
+Here is a couple of tiny examples:
+
+ (defrule integer? (&aux (sign 1) d (num 0)) ()
+ (:? (:and "-" (:assign sign -1)))
+ (:? "+")
+ (:+ (:assign d (:type digit?))
+ (:assign num (+ (* num 10)
+ (- (char-code d) #.(char-code #\0)))))
+ (:return (* sign num)))
+
+ (integer? (create-parser-context "+123")) ==> 123
+ (integer? (create-parser-context "-12")) ==> -123
(defrule integer?
(&aux sign c (num 0))

0 comments on commit 72eb734

Please sign in to comment.
Something went wrong with that request. Please try again.