Contents    Page-10    Prev    Next    Page+10    Index   

Restaurant Database Grammar


; (gramcom grammar)
(def grammar
'((command  -> (show me) true)
  (command  -> (what is) true)
  (qual     -> ((quality))
                    (restrictb '>= 'rating $1))
  (qualb    -> (rated above (number))
                    (restrictb '>= 'rating $3))
  (resttype -> ((kindfood))
                    (restrict 'foodtype $1))
  (loc      -> (in (city))   (restrict 'city $2))
  (loc      -> (in (county)) (restrict 'county $2))
  (s -> ((command) (a/an)? (qual)? (resttype)?
         (restword) (qualb)? (loc)?)
              (retrieve 'restaurant) )
  (s -> (how many (qual)? (resttype)? food ?
                  (restword) (loc)?)
        (do (retrieve 'restaurant)
              (postpr '(length (quote $$)))) )