Parser Generator for Objective C?
I've been advised to use a Parser Generator to create a parser for my domain specific language.
Ideally I'd like it to output an objective-C parser and tak开发者_运维问答e BNF input to describe the language.
There seems to be very little choice.. is it possible to use one of the more popular Parser Generators with objective C?
Thanks!
Code generation is not the “true way” in dynamic languages like Objective-C. Anything that can be achieved by a parser generator can be achieved at runtime. So, I'd suggest you try something like ParseKit, which will take a BNF-like grammar, and give you various delegate hooks you can implement to construct your parser.
Check out this tutorial for more details.
There's (of course) your expected answers of things like Bison or YACC or whatever, but if you want a native Objective-C solution, there are the couple that have already been mentioned. (Hammer and ParseKit) Another one that I know of is "CoreParse": https://github.com/beelsebob/CoreParse
You could certainly use any of the C-based parser generators if you're familiar with them. Another Objective-C runtime parser is Hammer by the irrepressible Rob Rix.
精彩评论