Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.misty.com!news.iecc.com!.POSTED!nerds-end From: Robert A Duff Newsgroups: comp.compilers Subject: Re: Should data filtering be done while building the parse tree or after the parse tree is built? Date: Thu, 06 Jun 2013 12:10:05 -0400 Organization: The World Public Access UNIX, Brookline, MA Lines: 13 Sender: johnl@iecc.com Approved: comp.compilers@iecc.com Message-ID: <13-06-009@comp.compilers> References: <13-06-005@comp.compilers> NNTP-Posting-Host: news.iecc.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: leila.iecc.com 1370536435 67305 64.57.183.58 (6 Jun 2013 16:33:55 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Thu, 6 Jun 2013 16:33:55 +0000 (UTC) Keywords: parse Posted-Date: 06 Jun 2013 12:33:55 EDT X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Xref: csiph.com comp.compilers:919 > Should I embed filtering rules into the grammar -- perform filtering as I > build the parse tree? > > Or, should I build the parse tree and then have an application perform > filtering on the parse tree? I think the second approach is usually simpler. Separation of concerns. A parser is working with text (or a sequence of tokens, or whatever). A syntax tree is an easier data structure to work with for doing various transformations. - Bob