|
Re: Heron.NET or JHeron?
|
Posted: Dec 10, 2004 10:35 AM
|
|
Hi Christopher.
> > Not a comment about target platform, but for writing a > > language parser, then if you haven't already, you may > want > > to consider Boost.Spirit, which lets you specify the > > grammar rather elegantly as approximated EBNF, directly > in > > C++ (http://spirit.sourceforge.net/). > > I am looking at it right now, and it seems very > interesting. Can you share any more insight into it? Is it > efficient and bug-free?
Regarding bug-free, it definitely seems robust and stable, yes. As you can see, it has been accepted into Boost (which is quite a statement of approval in itself).
Regarding efficiency, it uses static binding (the grammar is compiled as a C++ expression) so it should have potential to be very efficient, although I haven't seen any benchmarks around.
I haven't used it much, myself - only for a simple format-string use (i.e. "%<character>" in a string gets filled in with values).
It has a very modern/radical design, where you can attach "semantic actions" at each point along the parse tree. It also has full "lambda" support (but using that is optional). This calculator example should give you a feel for how it is:
http://cvs.sourceforge.net/viewcvs.py/boost/boost/libs/spirit/example/fundamental/phoenix_calc.cpp?view=markup
This uses Phoenix, Spirit's lambda, which supports things like closures, etc.
If I'd ever write a parser for a language, in C++, this is the first library/tool I'd consider (not lex/yacc, or other external tools), as it has the enourmous advantage of being able to encode the grammar directly in C++, so it may be used with any other code.
It is also well supported; the author is active at Boost, and they have a mailing list for it, as well (at the Spirit homepage).
If you wonder about Spirit's scalability to a programming language like Heron, it may be best to ask the author, himself (or at the Spirit list).
Also, feel free to contact me off-list at: tslettebo at broadpark dot no
Regards,
Terje
|
|