开发者

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:

  1. Check if your target language can be effectively described with LR(1) grammar.
  2. 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.
  3. If no, well look for specific books or write your own parser.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜