;;; -*- Mode: Lisp; Syntax: Common-Lisp; -*- File: language/grammars.lisp ;;;; Definition of Lexicons and Grammars (define-language E-0 ;; Figure 22.5 and 22.6 [p 665] :lexicon ("Noun => stench | breeze | glitter | nothing | wumpus | pit | pits | gold | north | south | east | west" "Verb => is | see | smell | shoot | feel | stinks | go | grab | carry | kill | turn" "Adjective => right | left | east | south | back | smelly" "Adverb => here | there | nearby | ahead | right | left | east | south | back" "Pronoun => me | you | I | it" "Name => John | Mary | Boston | Aristotle" "Article => the | a | an" "Preposition => to | in | on | near" "Conjunction => and | or | but" "Digit => 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9" "That => that") :grammar ("S => NP VP | S Conjunction S" "NP => Pronoun | Noun | Article Noun | Digit Digit | NP PP | NP RelClause" "VP => Verb | VP NP | VP Adjective | VP PP | VP Adverb" "PP => Preposition NP" "RelClause => That VP")) (define-language Arithmetic ;; Figure 22.13 [p 673] :grammar ("Exp(sem) => Exp(sem1) + Operator(op) + Exp(sem2) + {sem = Apply(op, sem1,sem2)}" ((Exp sem) => (Exp sem1) (Operator op) (Exp sem2)