Parsing and Canonical Deparsing
Parsing and formatting have often been identified as problems that
do not have elegant and widely accepted solutions in ANSI Common
Lisp. Format strings tend to be parsimonious and can be very
difficult to read. Destructuring primitives exist only for lists
and their utility in parsing is further limited by the lack of
non-determistic features in Common Lisp. This paper demonstrates a
simple implementation of non-deterministic parsing and canonical
deparsing in Common Lisp. This method can provide a solution to
both of these problems in a simple unified way. A single relation
is constructed between an input string and a data-structure. This
relation can provide a data-structure associated with a string, or
construct a canonical string from the data-structure. While this
type of solution may not meet performance requirements in some
situations it is elegant, quite general and is easy to work with.
[Show PDF]