开发者

Writing manual parser [closed]

开发者 https://www.devze.com 2023-01-26 08:28 出处:网络
Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing
Closed. This question is opinion-based. It is not currently accepting answers.

Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.

Closed 8 years ago.

Improve this question

I need write a parser manually. Can`t choose between LL(*) and LR (maybe try Earley?). 开发者_运维问答Should I use bottom-up parsing, because grammar for LL will be rather difficult?


I would go with either a recursive descent parser or maybe a tail-recursive descent parser (i.e. LL) or a top-down operator precedence parser.

The LR family of parsers, whether that be LR, LALR(k), LALR(1), GLR or whatever are just too "weird" to keep in your head. If you try to write one of those, you generally end up implementing a parser generator anyway, just to stay sane.


This depends on the grammar you try to use. LL has some troubles with uncertainities in grammars (you'll have to make everything left-recursion free).

If you cannot decide, go with LR(1) or LALR. Maybe even GLR.


Try XText. It is for you. Create your language, parser and editor fast and easy


The simplest type of parser to write by hand is a recursive descent parser, which is in the family of LL parsers. most other types of parser are either difficult to write by hand (LALR parsers, which use large state transition tables) or are for parsing complex languages (such as Earley parsers for parsing natural languages).

wikipedia has some good information on recursive descent parsing.

0

精彩评论

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