[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: LR Parser for MCL
- To: firstname.lastname@example.org (John Matthews)
- Subject: Re: LR Parser for MCL
- From: moon (David A. Moon)
- Date: Wed, 22 Jan 92 13:45:21 EST
- Cc: info-mcl
> From: email@example.com (John Matthews)
> Date: 20 Jan 92 23:42:30 GMT
> Does anyone know of a way I could get my hands on a general
> LR (or other) parser package? I would use it to parse and analyze
> C and C++ programs. I could use YACC and the foriegn-function package,
> but I would then lose all of the benefits of LISP for the parsing portion
> of my program.
I don't know whether there is a general parser package available, but the
C++ parser that I wrote just uses READ (with a modified *READTABLE*) to do
the lexical parsing (perhaps you would call it tokenizing) and it works fine.
The higher level or grammatical parsing is easily programmed in Lisp in an ad hoc way.
Most C++ tokens parse as symbols, but I let the undecorated integer literals
come through as Lisp integers. It's even quite fast. I had to write my own
reader-macros for strings, comments, and digraphs and trigraphs such as &= or
<<=. Look up set-macro-character, set-syntax-from-char, and setf of readtable-case
in the Common Lisp manual. I hope you find these hints helpful.