[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: lpeg.match
- From: Gavin Wraith <gavin@...>
- Date: Thu, 01 Mar 2007 13:20:47 GMT
In message <20070301122106.GA26709@inf.puc-rio.br> you wrote:
> > Would it not be more useful if an error object could be returned
> > as well?
>
> Do you think we need explicit support for this? Can't the application do
> it by itself? For instance, in your example, "Fail" could build a
> pattern that always matches and captures an error object.
Maybe I shot off too quickly. I am experimenting now with
wrapping up patterns inside a handler - expect(pattern,mesg) -
analogous to assert, that pushes mesg onto an errormessage stack
when the pattern fails. It seems the obvious thing to do. I am
still a bit confused, and excited, by all the possibilities,
and I guess I need to play around to discover what works. There
are obviously many ways of expressing the same pattern: do you
put everything into one big grammar? is it better to avoid
grammars and use them only when recursion is needed?
I have written a parser for xml style markup - start-tags <xyz .. >
push their names onto a stack, end-tags </xyz> pop from the stack
and compare, monotags <xyz .. /> also push but then drop the top
stack element. Having got that working I want to tackle the error
reporting and then move on to more language-specific matters;
what tagnames/attributes are allowed within a given tag, etc.
It is all wheel-reinvention necessary for my education.
--
Gavin Wraith (gavin@wra1th.plus.com)
Home page: http://www.wra1th.plus.com/