lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On 31 May 2011, at 05:15, Miles Bader <> 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  <>