: ) wonderful world ( :

lalr(1) in cl

Posted in lisp, parser by grault on October 23rd, 2007

I decided to play a bit with cl-yacc (which is an lalr(1) parser generator). I felt the need to convert the resulting parse tree back to the sequence which it was before. You can do it with this:

(defun toseq (ptree)
  (if (consp ptree)
      (append (toseq (car ptree))
	      (toseq (cdr ptree)))
      (if (null ptree)
	  nil
	  (list ptree))))

Leave a Reply