Contents    Page-10    Prev    Next    Page+10    Index   

Parsing Functions

The parser works by recursive descent, but with the ability to fail and back up and try another path.


;  $$      $1   $2
; (loc -> (in (city))   (restrict 'city $2))
(defn locfn []
  (saveptr)
  (let [$1 (and (= atnword (quote in)) atnword)]
    (if $1
        (do (nextword)
            (let [$2 (wordcat (quote city))]
              (if $2
                  (do (nextword)
                      (success)
                      (restrict (quote city) $2))
                  (fail))))
        (fail))))

The program performs (saveptr) on entry and either (success) or (fail) before leaving.