Created
November 16, 2015 01:18
-
-
Save kimitoboku/c7775cf34f5700804e50 to your computer and use it in GitHub Desktop.
prgoram-language-no6-parse
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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