: ) wonderful world ( :

the metasyntactic variable

lalr(1) in cl

leave a comment »

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

Written by grault

October 23, 2007 - 10:30 am at October 23, 2007 - 10:30 am

Posted in lisp, parser

Leave a Reply