[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

"[5mPlease Read This Message0[0m"



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))