Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!news.linkpendium.com!news.linkpendium.com!news.iecc.com!.POSTED!nerds-end From: rpw3@rpw3.org (Rob Warnock) Newsgroups: comp.compilers Subject: Re: Best tools for writing an assembler? Date: 25 Feb 2014 13:00:36 GMT Organization: Rob Warnock, Consulting Systems Architect Lines: 41 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <14-02-041@comp.compilers> References: <14-02-018@comp.compilers> <14-02-030@comp.compilers> <14-02-031@comp.compilers> <14-02-035@comp.compilers> NNTP-Posting-Host: news.iecc.com X-Trace: miucha.iecc.com 1393546082 68255 64.57.183.58 (28 Feb 2014 00:08:02 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Fri, 28 Feb 2014 00:08:02 +0000 (UTC) Keywords: assembler Posted-Date: 27 Feb 2014 19:08:02 EST X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Originator: rpw3@rpw3.org (Rob Warnock) Xref: csiph.com comp.compilers:1120 Ivan Godard wrote: +--------------- | Programming languages, even assembler, have always tended to be LL(1) | to a first approximation. As a result, production compilers intended | for use by those unfamiliar with the internals have tended to be LL(1) | too, and usually recursive descent. The advantage of RD is that the | semantics can be done on the fly, and the semantics can be used to | guide the parse when the actual language is not a CFG (and most of | them are not, to at least some degree) without exponential explosion | of state. +--------------- Plus, there's a useful trick I learned from the BLISS-10 compiler, which is that you can very easily embed a simple operator precedence parser into a recursive descent parser, simply by giving keywords and flow-control operators [IF, CASE, etc.] very high operator precedences and "stoppers" [commas, semicolons, right brackets, FI, ESAC, etc.] very low precedences. This enables a recursive descent parser to handle complex arithmetic expressions without ending up with long chains of (otherwise useless) reductions in the parse graph. I've found this combination to be very convenient, and have used it a number of times over the years when a small DSL was needed, e.g., for a user interface or as part of a software build system. -Rob p.s. More detail on this construct, including some sample code [in Scheme], can be found in a couple of previous articles here from 2010, subject "Re: Is that difficult to write a Shift-Reduce parser", see: http://compilers.iecc.com/comparch/article/10-05-014 http://compilers.iecc.com/comparch/article/10-05-037 ----- Rob Warnock 627 26th Avenue San Mateo, CA 94403