Skip to content

Instantly share code, notes, and snippets.

@kimitoboku
Created November 16, 2015 01:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kimitoboku/c7775cf34f5700804e50 to your computer and use it in GitHub Desktop.
Save kimitoboku/c7775cf34f5700804e50 to your computer and use it in GitHub Desktop.
prgoram-language-no6-parse
(defun parse (functions data)
(cond ((and (consp functions) (funcall (car functions) (cdr functions) data) ))
((eq functions data) 't)
('t 'nil)))
(defun terminal-symbol (list rest data)
(cond ((and (consp data) (member (car data) list))
(parse rest (cdr data)))
('t 'nil)))
(defun article (rest data)
(terminal-symbol '(a the) rest data))
(defun noun (rest datap)
(terminal-symbol '(I you book me) rest data))
(defun noun-phrase (rest data)
(or (parse (append (list #'article #'noun) rest) data)
(parse (append (list #'noun) rest ) data)))
(defun sentense (rest data)
(or (parse (append (list #'noun-phrase #'verb-phrase) rest ) data)
(parse (append (list #'noun-phrase #'verb-phrase #'noun-phrase) rest) data)))
(defun verb-phrase (rest data)
(terminal-symbol '(have get love live) rest data))
(defun check(data)
(parse (list 'sentense) data))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment