Re: The dragon book says separating lexical analysis and parsing is beneficial, so why doesn't ANTLR separate them?

George Neuner <gneuner2@comcast.net>
Sat, 11 Jun 2022 18:15:06 -0400

          From comp.compilers

Related articles
| List of all articles for this month |
From: George Neuner <gneuner2@comcast.net>
Newsgroups: comp.compilers
Date: Sat, 11 Jun 2022 18:15:06 -0400
Organization: A noiseless patient Spider
References: 22-06-023
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="13702"; mail-complaints-to="abuse@iecc.com"
Keywords: design
Posted-Date: 11 Jun 2022 19:38:42 EDT

On Thu, 9 Jun 2022 14:52:59 +0000, Roger L Costello
<costello@mitre.org> wrote:




>[elided quote] seem like compelling reasons for separating the lexical analysis
>from parsing, so why does ANTLR not do so; i.e., why does ANTLR combine them?
>
>/Roger
>
>[1] Compilers: Principles, Techniques, and Tools by Aho, Sethi, and Ullman.


Technically ANTLR does /not/ combine them ... it generates separate
lexer and parser.


What ANTLR /does/ do is allow specifying both the parser and lexer in
a single input file. It also can recognize textual constants within
the parser specification and generate lexer rules for them.


Note that Yacc and Bison also recognize textual constants in the parser
grammar and generate a token id for the (seperately specified) lexer
to return. ANTLR goes further only because it can: ANTLR can create a
lexer whereas Yacc and Bison cannot.


George


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.