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?
-
2It depends in large part on what kind of language you're trying to parse. Without more information about your application, it's impossible to give any kind of reasonable suggestion. You might also want to look at the "Related" questions (scroll down and look to the right). There are lots of questions here about parsing, and lots of good discussion. – Jim Mischel Nov 23 '10 at 21:02
-
Why do you *need* to write a parser manually? There's generally not a lot of value in this. – Ira Baxter Nov 23 '10 at 21:43
-
I can`t use yacc or other parsers, where my parser will work – mystdeim Nov 24 '10 at 10:47
-
Why not? They produce some tables and some code. Surely where you will put your parser, allows some tables and some code. – Ira Baxter Nov 24 '10 at 14:33
-
Perhaps you are right, I should try their tables – mystdeim Nov 24 '10 at 20:55
4 Answers
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.

- 363,080
- 75
- 446
- 653
-
Oh nonsense. I've been using LALR since 1979 without any necessity to implement my own parser generator. – user207421 Aug 17 '14 at 23:46
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.

- 151,563
- 33
- 264
- 304
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.

- 13,745
- 8
- 34
- 37
Try XText. It is for you. Create your language, parser and editor fast and easy

- 9,646
- 2
- 59
- 113