Re: Best tools for writing an assembler?

=?ISO-8859-1?Q?S=E9bastien_Fricker?= <sebastien.fricker@gmail.com>
Mon, 24 Feb 2014 07:32:37 +0100

          From comp.compilers

Related articles
[6 earlier articles]
Re: Best tools for writing an assembler? bobduff@shell01.TheWorld.com (Robert A Duff) (2014-02-19)
Re: Best tools for writing an assembler? tpphysik@gmail.com (=?ISO-8859-1?Q?Patrik_T=FAri?=) (2014-02-20)
Re: Best tools for writing an assembler? sebastien.fricker@gmail.com (=?ISO-8859-1?Q?S=E9bastien_Fricker?=) (2014-02-21)
Re: Best tools for writing an assembler? DrDiettrich1@aol.com (Hans-Peter Diettrich) (2014-02-21)
Re: Best tools for writing an assembler? bc@freeuk.com (BartC) (2014-02-22)
Re: Best tools for writing an assembler? noitalmost@cox.net (noitalmost) (2014-02-23)
Re: Best tools for writing an assembler? sebastien.fricker@gmail.com (=?ISO-8859-1?Q?S=E9bastien_Fricker?=) (2014-02-24)
Re: Best tools for writing an assembler? gah@ugcs.caltech.edu (glen herrmannsfeldt) (2014-02-24)
Re: Best tools for writing an assembler? gah@ugcs.caltech.edu (glen herrmannsfeldt) (2014-02-24)
Re: Best tools for writing an assembler? lkrupp@pssw.com (Louis Krupp) (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? 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)
[9 later articles]
| List of all articles for this month |

From: =?ISO-8859-1?Q?S=E9bastien_Fricker?= <sebastien.fricker@gmail.com>
Newsgroups: comp.compilers
Date: Mon, 24 Feb 2014 07:32:37 +0100
Organization: Guest of ProXad - France
References: 14-02-018 14-02-021 14-02-023 14-02-030
Keywords: assembler, tools, comment
Posted-Date: 24 Feb 2014 16:31:27 EST

On 23/02/2014 17:22, noitalmost wrote:
>
> I wouldn't bother with any generation tools like flex or bison, unless
> you want to gain experience with those tools for some other project.
> Since it's your own architecture, which has no native tools, you'll be
> cross-compiling so speed of the assembler won't matter. It'll be a
> long time before you write a program for your architecture that'll
> take longer than a second to compile, even if you use Perl. So the
> language you use should be the one you know best. My bias is toward
> C++, but it really won't matter in your case.
>
> I think that by hand-writing your own scanner and parser, you'll get
> to know your assembly syntax better. And unless you have something
> really strange, simple recursive descent will work fine for the
> parser.
>


Sorry, but even if Flex/Bison are difficult to setup, writing a parser
by hand is not a good way to work.
Tools like Flex/Bison give several advantages that you cannot cover by
writing a parser by hand:
  1) They are able to manage complex rules which would need many lines of
code. For example, parsing an integer consists only of matching the
regular expression pattern "[0-9]+". It is simple and more readable than
writing directly its C++ code.
  2) The generated code is optimized at a level different to what the
compiler does. For example, if in your keyword you have "visual" and
"virtual", the generated code will first match "vi" and then "rtual" or
"sual". Of course writing such optimization by hand is practically not
possible.
  3) Flex/Bison are performing some error analysis which permits detect
unused rules, unreachable states, ... All this checks are not existing
for hand written parser. That's mean that your test suite need to handle
such kind of non detected errors.
  4) Inserting a new keyword/extending a syntax of an existing parser is
more safe. In fact, due to all checks make by the parser generator, if
the code compiles without bison/flex warnings you can be sure that your
new syntax extension does not collide with the existing one. In other
words, you did not program a regression my extending your syntax.


In other words, saying that writing parser by hand is better is the same
as saying "why using object oriented programming? I can do the same in C
with struct!" Yes, but the result is less readable, the compiler does
does less verifications.
[Yacc or bison provides the pleasant assurance that the langauge your
program parses is exactly the one in the grammar, and not some
superset due to missing error checks. -John]


Post a followup to this message

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