Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.compilers > #1120

Re: Best tools for writing an assembler?

From rpw3@rpw3.org (Rob Warnock)
Newsgroups comp.compilers
Subject Re: Best tools for writing an assembler?
Date 2014-02-25 13:00 +0000
Organization Rob Warnock, Consulting Systems Architect
Message-ID <14-02-041@comp.compilers> (permalink)
References <14-02-018@comp.compilers> <14-02-030@comp.compilers> <14-02-031@comp.compilers> <14-02-035@comp.compilers>

Show all headers | View raw


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

Back to comp.compilers | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Best tools for writing an assembler? tpphysik@gmail.com - 2014-02-18 16:04 -0800
  Re: Best tools for writing an assembler? "C. Bergström" <cbergstrom@pathscale.com> - 2014-02-19 11:14 +0700
  Re: Best tools for writing an assembler? glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-02-19 04:25 +0000
  Re: Best tools for writing an assembler? Ivan Godard <ivan@ootbcomp.com> - 2014-02-18 23:23 -0800
    Re: Best tools for writing an assembler? Robert A Duff <bobduff@TheWorld.com> - 2014-02-19 18:20 -0500
      Re: Best tools for writing an assembler? Sébastien Fricker <sebastien.fricker@gmail.com> - 2014-02-21 12:00 +0100
      Re: Best tools for writing an assembler? "BartC" <bc@freeuk.com> - 2014-02-22 00:28 +0000
      Re: Best tools for writing an assembler? noitalmost <noitalmost@cox.net> - 2014-02-23 11:22 -0500
        Re: Best tools for writing an assembler? Sébastien Fricker <sebastien.fricker@gmail.com> - 2014-02-24 07:32 +0100
          Re: Best tools for writing an assembler? Louis Krupp <lkrupp@pssw.com> - 2014-02-24 15:39 -0700
          Re: Best tools for writing an assembler? Ivan Godard <ivan@ootbcomp.com> - 2014-02-24 15:04 -0800
            Re: Best tools for writing an assembler? rpw3@rpw3.org (Rob Warnock) - 2014-02-25 13:00 +0000
          Re: Best tools for writing an assembler? Hans-Peter Diettrich <DrDiettrich1@aol.com> - 2014-02-25 04:09 +0100
        Re: Best tools for writing an assembler? "James Harris" <james.harris.1@gmail.com> - 2014-02-24 23:18 +0000
        Re: Best tools for writing an assembler? noitalmost <noitalmost@cox.net> - 2014-02-27 18:11 -0500
          Re: Best tools for writing an assembler? George Neuner <gneuner2@comcast.net> - 2014-03-01 13:09 -0500
            Re: Best tools for writing an assembler? federation2005@netzero.com - 2014-03-26 17:57 -0700
              Re: Best tools for writing an assembler? federation2005@netzero.com - 2014-04-13 12:24 -0700
  Re: Best tools for writing an assembler? Sébastien Fricker <sebastien.fricker@gmail.com> - 2014-02-19 09:59 +0100
    Re: Best tools for writing an assembler? Robert A Duff <bobduff@shell01.TheWorld.com> - 2014-02-19 18:27 -0500
  Re: Best tools for writing an assembler? Patrik Túri <tpphysik@gmail.com> - 2014-02-20 17:15 -0800
    Re: Best tools for writing an assembler? Hans-Peter Diettrich <DrDiettrich1@aol.com> - 2014-02-21 12:09 +0100
      Re: Best tools for writing an assembler? glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-02-24 20:42 +0000
        Re: Best tools for writing an assembler? Ivan Godard <ivan@ootbcomp.com> - 2014-02-24 15:13 -0800
        Re: Best tools for writing an assembler? hu47121@usenet.kitty.sub.org (Hannah) - 2014-02-25 00:43 +0000
          Re: Best tools for writing an assembler? Walter Banks <walter@bytecraft.com> - 2014-02-27 14:14 -0500
        Re: Best tools for writing an assembler? Hans-Peter Diettrich <DrDiettrich1@aol.com> - 2014-02-25 04:23 +0100
    Re: Best tools for writing an assembler? glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-02-24 20:35 +0000

csiph-web