[REBOL] Questions about block parsing
From: rudolf::meijer::telenet::be at: 21-Sep-2007 9:18
I was inspired to write this post by the following exchange:
[REBOL] Re: rebol yacc parser generators
From: greggirwin::mindspring::com at: 18-Apr-2002 10:46
Hi Bryan,
<< I'm wondering if there are any parser generators out there for rebol,
something on the line of yacc? also is there any parser written in rebol for
understanding asn.1? >>
Have you played with the PARSE function at all? That's where you should
start, and it might be where you stop. Who needs YACC? :)
--Gregg
I started to test REBOL block parsing as a tool for building a parser
generator for REBOL dialects. In a first instance I want to convert the
syntax rules for a language (of course this should be a REBOL dialect) into
a set of rules for block parsing a string of the language (converted into a
flat block of REBOL values) with actions added for creating the syntax tree
of that string (in practice a nested block structure) to show how the parse
went. To this end I started simply with inserting a diagnostic call to the
ALERT function after each alternative of the rules. I noticed from the
output that the way block parsing works is that all alternatives are tried
until the first one is found that succeeds, and this recursively depth
first. How then can we know during the visit of an alternative that this
will end up being successful? It looks like we need a stack of our own to
keep track. Any experiences? I have seen posts on string parsing, but I
think this is still different.
Furthermore, in order to add some semantic analysis to the parsing, I would
like to be able to tell the parse function that a certain alternative should
NOT succeed. Is there any way of communicating TO the parser while it goes
on?
Thanks for any insights and experience.
Rudolf Meijer