--national-information-infrastructure/Geraldton/UNSCOM/IH870SYMAk
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable
fucc is universal parser generator for Common Lisp. This is first
alpha version of the parser, and only LR(0), SLR, LALR and LR1 are
implemented.
Another features:
* BNF-like operators in grammar: :MAYBE, :OR, :LIST, *, +;
* priorities and associativity;
* context-sensitive parsing;
* lispy ways to define actions.
Project page is http://www.common-lisp.net/project/fucc/
Example of grammar definition:
(fucc:defparser *calculator-parser*
s ; Initial non-terminal
;; List of terminal
(+ - * / =3D :semicolon :id :const)
;; List of rules
((s (:form (format t "Value: ~S" (first (last exp-list))))
(:var exp-list (:list exp :semicolon))
(:maybe :semicolon))
;; Assignment
(exp (:form (setf (gethash var *dictionary*)
exp))
(:var var :id) =3D (:var exp exp))
;; Binary operations
(exp (:action (lambda (a op b)
(funcall op a b)))
exp
(:or (:or + -) ; Nested OR here is just for fun
* /)
exp)
;; Constants and variables
(exp (:action #'identity)
:const)
(exp (:action (lambda (var)
(or (gethash var *dictionary*)
(error "Undefined variable: ~S" var))))
:id))
;; Precedence info
:prec-info
((:right =3D) ; Actually associativity doesn't matter here because
; it is enforsed by rule structure anyway.
(:left + -) ; But here it matters.
(:left * /)))
=2D-=20
Ivan Boldyrev
Sorry my terrible English, my native language is Lisp!
--national-information-infrastructure/Geraldton/UNSCOM/IH870SYMAk
Content-Type: application/pgp-signature
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.4-ecc0.1.6 (GNU/Linux)
iEYEABECAAYFAkS0xjwACgkQ4rmsj66VbheGkwCbB9D0XVr4MY3GoTLncpkiAGK2
yh4An0mJztF5h3fCFUaTvUOdA7XI1igM
=OVaR
-----END PGP SIGNATURE-----
--national-information-infrastructure/Geraldton/UNSCOM/IH870SYMAk--