Re: Best tools for writing an assembler?

rpw3@rpw3.org (Rob Warnock)
25 Feb 2014 13:00:36 GMT

          From comp.compilers

Related articles
[16 earlier articles]
Re: Best tools for writing an assembler? ivan@ootbcomp.com (Ivan Godard) (2014-02-24)
Re: Best tools for writing an assembler? ivan@ootbcomp.com (Ivan Godard) (2014-02-24)
Re: Best tools for writing an assembler? james.harris.1@gmail.com (James Harris) (2014-02-24)
Re: Best tools for writing an assembler? hu47121@usenet.kitty.sub.org (2014-02-25)
Re: Best tools for writing an assembler? DrDiettrich1@aol.com (Hans-Peter Diettrich) (2014-02-25)
Re: Best tools for writing an assembler? DrDiettrich1@aol.com (Hans-Peter Diettrich) (2014-02-25)
Re: Best tools for writing an assembler? rpw3@rpw3.org (2014-02-25)
Re: Best tools for writing an assembler? walter@bytecraft.com (Walter Banks) (2014-02-27)
Re: Best tools for writing an assembler? noitalmost@cox.net (noitalmost) (2014-02-27)
Re: Best tools for writing an assembler? gneuner2@comcast.net (George Neuner) (2014-03-01)
Re: Best tools for writing an assembler? federation2005@netzero.com (2014-03-26)
Re: Best tools for writing an assembler? federation2005@netzero.com (2014-04-13)
| List of all articles for this month |

From: rpw3@rpw3.org (Rob Warnock)
Newsgroups: comp.compilers
Date: 25 Feb 2014 13:00:36 GMT
Organization: Rob Warnock, Consulting Systems Architect
References: 14-02-018 14-02-030 14-02-031 14-02-035
Keywords: assembler
Posted-Date: 27 Feb 2014 19:08:02 EST
Originator: rpw3@rpw3.org (Rob Warnock)

Ivan Godard <ivan@ootbcomp.com> 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 <rpw3@rpw3.org>
627 26th Avenue <http://rpw3.org/>
San Mateo, CA 94403



Post a followup to this message

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