[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
HELP LISP
- To: info-mcl
- Subject: HELP LISP
- From: cs_a206@kingston.ac.uk (Richard Smart)
- Date: 9 Dec 91 12:35:19 GMT
- Newsgroups: comp.lang.lisp.mcl
- Organization: Kingston Polytechnic
- Sender: news@kingston.ac.uk (Network News)
DEAR ALL NEWSGROUP MEMBERS.
; HAVE YOU GOT ANY PROGRAM WHICH SIMULATES A PARSING ALGORITHM
; I GOT THE FOLLOWING BUT IT DOES NOT WORK WITH FRANZ LISP.
; IT IS CALED USING (PARSER). ANYONE ANY SUGGESTIONS TO HELP ?
; ------------------------------------------------------------------------------
; Richard Smart
; Kingston Polytechnic \
; cs_a206@uk.ac.king.ux ____________________/_____ ______________________
; NSF: rsmart@nsf /_] # # INTERCITY # # [_| |[][___][___][___][___]
; ===================== <__________________________] |Ll____________________
; +~o--o~==============~o--o~+-+~ o=o"""""""""""""""""
; ------------------------------------------------------------------------------
(defun expression ((tree))
(setq tree (term))
(loop
(while (or (eq cursym '+)(eq cursym '-)) tree)
(setq tree (list (nextsym) tree (term)))))
(defun term ((tree))
(setq tree (factor))
(loop
(while (or (eq cursym '*)(eq cursym '/)) tree)
(setq tree (list (nextsym) tree (factor)))))
(defun factor ((tree))
(cond
((eq cursym lpar)
(nextsym)
(setq tree (expression))
(nextsym) tree)
(t (nextsym))))
(defun nextsym ((prev))
(setq prev cursym)
(loop
(setq cursym (getchar))
(princ cursym)
(while (eq cursym blank) prev)))
(defun parser ((cursym))
(nextsym)
(expression))