Re: [ANN] CoreParse
Re: [ANN] CoreParse
- Subject: Re: [ANN] CoreParse
- From: Thomas Davie <email@hidden>
- Date: Mon, 06 Jun 2011 16:30:25 +0100
On 6 Jun 2011, at 16:10, Philip Mötteli wrote:
> Hi,
>
>
> Am 06.06.2011 um 00:12 schrieb Thomas Davie:
>> On 5 Jun 2011, at 18:22, Jens Alfke wrote:
>> On Jun 5, 2011, at 6:21 AM, Thomas Davie wrote:
>>>
>>>> I've just completed firming up the API and documentation for CoreParse. CoreParse provides a powerful tokenisation and parsing engine, which uses shift-reduce parsing (unlike ParseKit) to support a wide range of context free grammars.
>>>>
>>>> Parsers can be built quickly and easily using BNF like syntax.
>>>
>>> Cool! What advantages does this have over using a more-established tool like ANTLR? (“An Objective-C API” is an obvious answer, I suppose, but it doesn’t look that difficult to call into ANTLR-generated C++ code from Obj-C.)
>>
>> I've not investigated ANTLR, but you're right, my primary goal was a nice, clean, cocoa-like API in pure Obj-C only API. The only comparable API that I know of is ParseKit which uses recursive decent, and hence doesn't support a lot of grammars. By comparison there, I support SLR, LR(1) and LALR(1), so there's rather more coverage.
>>
>> I'd really appreciate you taking a look and reporting back if you find any interesting things that ANTLR or other tools does better.
>
> I really appreciate how BN support is implemented in ParseKit: <http://parsekit.com/grammars.html>. I like it very much, that there are no numbers, but call backs for every token, using method-names (c. f. above URL under "Instantiating Grammar Parsers in Objective-C").
Yep, I agree that my current implementation is not particularly nice in that respect. That said, I'm not entirely keen on ParseKit's design either. The alternative I'm pondering at the moment is to add a protocol defining -initWithSyntaxTree: and have CP do
id x = [NSStringFromClass(nonTerminalName) alloc];
if ([x conformsToProtocol:@protocol(CPParsing)])
{
return [[x initWithSyntaxTree:tree] autorelease];
}
else
{
return tree;
}
It strikes me that this has disadvantages for the user too (creating a lot of boiler plate classes potentially). It seems to fit cases where you actually want to construct a data structure from your parse nicely, but not so well when you want to do a computation as a result of the parse.
I will think about it some more, but I'd appreciate contributions on how to do this cleanly.
Thanks
Tom Davie_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden