Greetings. If memory serves, not long ago someone posted to this group
inquiring about Zebu (a nice parser generator for Common Lisp). I've
taken the most recent version (3.5.5, from what I could find) and
adapted it for CMUCL; it really didn't need that much work. Also, I've
written a system definition file for Zebu that works with MK:DEFSYSTEM
(version 3.2i as found in the CLOCC project at sourceforge).
I've only tested the defsystem file against cmucl on Linux; if there's
*sufficient* interest I would be willing to obtain ACL and LispWorks and
ensure it works on those platforms as well. At one time I was using Zebu
on ACL, so that shouldn't be an issue.
In any event, drop me a line if you'd like a copy of what I have. I've
tried contacting the Zebu author but haven't heard from him, so I don't
know what the story is on maintenance or licensing; the license wording
implies free for commercial and non-commercial, but I've no legal
background.
It might actually be nice if Zebu could be added to CLOCC. Any thoughts?
Regards,
--
-----------------------------------------------------------------
David E. Young
Fujitsu Network Communications "The fact that ... we still
(···········@fnc.fujitsu.com) live well cannot ease the pain of
feeling that we no longer live nobly."
-- John Updike
"Programming should be fun,
programs should be beautiful"
-- P. Graham
This is a good thing.
Although I still believe that the "input" syntax for Zebu is a little
too funky.
Cheers
--
Marco Antoniotti =============================================================
NYU Bioinformatics Group tel. +1 - 212 - 998 3488
719 Broadway 12th Floor fax +1 - 212 - 995 4122
New York, NY 10003, USA http://galt.mrl.nyu.edu/valis
Like DNA, such a language [Lisp] does not go out of style.
Paul Graham, ANSI Common Lisp
Marco Antoniotti wrote:
> This is a good thing.
>
> Although I still believe that the "input" syntax for Zebu is a little
> too funky.
>
Yeah, and I have to decide whether to bundle Zebu with my open source project
(which includes an embedded lisp-related language) or write the parser by hand.
Lisp folks seem to prefer hand-writing their parsers, so perhaps that's a better
route...
Regards,
--
-----------------------------------------------------------------
David E. Young
Fujitsu Network Communications "The fact that ... we still
(···········@fnc.fujitsu.com) live well cannot ease the pain of
feeling that we no longer live nobly."
-- John Updike
"Programming should be fun,
programs should be beautiful"
-- P. Graham
In article <·················@nc.rr.com>, ·······@nc.rr.com wrote:
> Lisp folks seem to prefer hand-writing their parsers, so perhaps that's a better
> route...
There are some parsers available. MCL comes with a couple on its
CDROM. Genera has a complete substrate that has been used
for their Fortran, C and Pascal compilers.
Another handy thing is Baker's parser from the paper
"Pragmatic Parsing in Common Lisp". (Usually
his stuff should be at ftp://ftp.netcom.com/pub/hb/hbker/home.html ,
but I can't reach it.) This also shows the
coolness of Common Lisp. Here is an exerpt:
; Pragmatic Parsing in Common Lisp
; Henry G. Baker
; January, 1991
;
; We review META, a classic technique for building recursive descent parsers, that is both simple
; and efficient. While META does not handle all possible regular or context-free grammars, it
; handles a surprisingly large fraction of the grammars encountered by Lisp programmers. We
; show how META can be used to parse streams, strings and lists�including Common Lisp's hairy
; lambda expression parameter lists. Finally, we compare the execution time of this parsing method
; to the built-in methods of Common Lisp.
(defstruct (meta
(:print-function
(lambda (m s d &aux (char (meta-char m)) (form (meta-form m)))
(ecase char
((··@ #\! #\$) (format s "~A~A" char form))
(#\[ (format s "[~{~A~^ ~}]" form))
(#\{ (format s "{~{~A~^ ~}}" form))))))
char
form)
(defun meta-reader (s c)
(make-meta :char c :form (read s)))
(mapc (lambda (c) (set-macro-character c #'meta-reader))
'(··@ #\$ #\!))
(set-macro-character #\[
(lambda (s c)
(make-meta :char c :form (read-delimited-list #\] s t))))
(set-macro-character #\{
(lambda (s c)
(make-meta :char c :form (read-delimited-list #\} s t))))
(mapc (lambda (c)
(set-macro-character c (get-macro-character #\) nil)))
'(#\] #\}))
(defmacro match-type (x v)
`(when (typep (peek-char nil *standard-input* nil nil) ',x)
(setq ,v (read-char))))
(defmacro match (x)
`(when (eql (peek-char nil *standard-input* nil nil) ',x)
(read-char)))
(defun compileit (x)
(typecase x
(meta
(ecase (meta-char x)
(#\! (meta-form x))
(#\[ `(and ,@(mapcar #'compileit (meta-form x))))
(#\{ `(or ,@(mapcar #'compileit (meta-form x))))
(#\$ `(not (do ()((not ,(compileit (meta-form x)))))))
(··@ (let ((f (meta-form x))) `(match-type ,(car f) ,(cadr f))))))
(t `(match ,x))))
(defmacro matchit (x)
(compileit x))
; Example: Parsing Integers
; {a0 .. an} Alternatives
; [s0 .. sn] Sequence
; !sexpr Lisp expression
; @expr Once
; $expr Zero or more
(deftype digit ()
'(member #\0 #\1 #\2 #\3 #\4 #\5 #\6 #\7 #\8 #\9))
(defun ctoi (d)
(- (char-code d) #.(char-code #\0)))
(defun parse-int (&aux (s +1) d (n 0))
(and
(matchit
[{#\+ [#\- !(setq s -1)] []}
@(digit d) !(setq n (ctoi d))
$[@(digit d) !(setq n (+ (* n 10) (ctoi d)))]])
(* s n)))
(with-input-from-string (*standard-input* "123")
(parse-int))
--
Rainer Joswig, Hamburg, Germany
Email: ·············@corporate-world.lisp.de
Web: http://corporate-world.lisp.de/
Rainer Joswig <······@corporate-world.lisp.de> writes:
> Another handy thing is Baker's parser from the paper
> "Pragmatic Parsing in Common Lisp". (Usually
> his stuff should be at ftp://ftp.netcom.com/pub/hb/hbker/home.html ,
> but I can't reach it.) This also shows the
> coolness of Common Lisp. Here is an exerpt:
just fyi, on 30-sep netcom pulled the plug on the shell accounts (and
associated ftp space). i sure hope the above-referenced info surfaces
elsewhere.
thi (another axed shell-account customer)
Rainer Joswig wrote:
> In article <·················@nc.rr.com>, ·······@nc.rr.com wrote:
>
> > Lisp folks seem to prefer hand-writing their parsers, so perhaps that's a better
> > route...
>
> There are some parsers available. MCL comes with a couple on its
> CDROM. Genera has a complete substrate that has been used
> for their Fortran, C and Pascal compilers.
>
> Another handy thing is Baker's parser from the paper
> "Pragmatic Parsing in Common Lisp". (Usually
> his stuff should be at ftp://ftp.netcom.com/pub/hb/hbker/home.html ,
> but I can't reach it.)
I've seen mention of this but haven't been able to locate it. I'd be interested in taking a look if
anyone comes across META's new home.
Regards,
--
-----------------------------------------------------------------
David E. Young
Fujitsu Network Communications "The fact that ... we still
(···········@fnc.fujitsu.com) live well cannot ease the pain of
feeling that we no longer live nobly."
-- John Updike
"Programming should be fun,
programs should be beautiful"
-- P. Graham
In article <·················@nc.rr.com>,
·······@nc.rr.com wrote:
> Rainer Joswig wrote:
>
> > In article <·················@nc.rr.com>, ·······@nc.rr.com wrote:
> >
> > > Lisp folks seem to prefer hand-writing their parsers, so perhaps that's a better
> > > route...
> >
> > There are some parsers available. MCL comes with a couple on its
> > CDROM. Genera has a complete substrate that has been used
> > for their Fortran, C and Pascal compilers.
> >
> > Another handy thing is Baker's parser from the paper
> > "Pragmatic Parsing in Common Lisp". (Usually
> > his stuff should be at ftp://ftp.netcom.com/pub/hb/hbker/home.html ,
> > but I can't reach it.)
>
> I've seen mention of this but haven't been able to locate it. I'd be interested in taking a look if
> anyone comes across META's new home.
If you just need this paper, here is a PDF version:
http://corporate-world.lisp.de/documents/prag-parse.pdf
Sent via Deja.com http://www.deja.com/
Before you buy.