[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: syntax



Paul Haahr writes:
 > > Perhaps you can make it regexp-based, using (.*) and \1, etc., to pull
 > > out bits of lines and glue them together.  Try all the regex
 > > pattern/replacements in turn, eval'ing the first one that fits.
 > 
 > repeated regular expression substitution sounds good as a first pass
 > for syntax extension, except that (as we remember from our intro to
 > compilers classes) regular languages are not powerful enough to detect
 > matched parentheses-like constructs, so we can't replace the current
 > rewriting rules with them.

Repeated regular expression substitution is as powerful as a Turing
machine (it's easy to implement a Turing machine with repeated regular
expression substitution).

For your example of matched parentheses, if you repeatedly substitute
the empty string for pairs of parentheses `()', you will terminate
with the empty string iff the original string had matched parentheses.

Carl Witty
cwitty@ai.mit.edu