On Sun, 2006-09-10 at 15:12 -0700, Erick Tryzelaar wrote:
> Also, can we do this already?
>
> match Some "hi" with
> | Some _ as ?x => ... // x == Some "hi"
> | None => ...
> endmatch
Yes, but you don't need the ? here: just
| Some _ as x =>
will work.
Note that whilst messing with pattern calculi Alain Frisch
has tree-automata as in XDuce, which is an extension
of patterns to full regularity (with subpattern parsing!).
In other words, patterns PLUS
* // Kleene closure, repetition
and of course including concatenation and alternation.
Unlike TRE and other regular recognizers, XDuce
doesn't return "last submatch", it is a full parser:
x*
returns ALL the matches as a list. By using nesting,
you get a parse tree. This of course handles 'optional'
as just an empty list. XDuce was designed for matching
trees like XML. The main downside is it requires two
passes, that is, the supplier must be a forward iterator,
wheres ordinary deterministic automata only require
an input iterator.
I've talked to Alain a couple of times, and apart from
being a genius he's also very nice, offered to help
if I ever wanted to integrate his algorithm into Felix.
The paper (which is on the Felix website I think)
is also eminently readable. The key idea is that a
regular expression is a *TYPE*, that is, it is
a subtype of 'string', which allows a lot of the work
to be transferred to the domain of type systems...
things just drop out, it is very sweet.
--
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language