Which Parser: EBNF, Custom, Parser Combinator (and their derivatives)?
I have previously developed custom parsers, played around with bnf-driven parsers, briefly introduced myself to parser combinators a开发者_JS百科nd read about derivatives of parser combinators.
My, rather broad, question is how do you decide which strategy/technology is right? Obviously there are pragmatic elements to it, ie if you only know custom parsers and time is against you then perhaps your choice is limited or perhaps if the language (and community) doesn't provide the tools/support and you'd end up having to write the infrastructure yourself (which of course may be possible), but rather in principle are there any "rules of thumb" concerning the parsing strategies/technologies themselves which help to inform the decision.
TIA
Simon
I would recommend the following:
- Check if your target language can be effectively described with LR(1) grammar.
- If yes, then use one of the variety of tools like YACC. These tools are nice and you need to find a reason why you do not want to use them.
- If no, well look for specific books or write your own parser.
精彩评论