[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: parser : which library ?
- From: Tony Finch <dot@...>
- Date: Tue, 31 May 2011 08:26:18 +0100
On 31 May 2011, at 05:15, Miles Bader <email@example.com> wrote:
> The "LPEG way", of using a single grammar all the way down to the
> character level, seems to work great, and in my experience is simpler
> and less annoying than "traditional way" (separate lexer/parser)...
> [What _is_ the reason for the traditional split anyway? ....]
Lexical analysis requires multiple character look-ahead to distinguish tokens. Standard algorithms for parsing context-free grammars use one token of lookahead - hence LALR(1) and LL(1) - so they aren't powerful enough for many lexical syntaxes.
More modern algorithms such as GLR are powerful enough to handle lexical analysis as well as higher level parsing, so unified grammars are becoming more popular.
f.anthony.n.finch <firstname.lastname@example.org> http://dotat.at/