Re: Assembler in Lex/Yacc



Sanky <spamtrap@xxxxxxxxxx> wrote:
> Hi there,
>
> I was working on an assembler for X64 architecture. I was wondering
> what are the tradeoffs in designing an assembler using lex or re2c and
> yacc? Why is that handwritten assemblers are more popular than those
> developed using lex/yacc? Developing a grammar is the toughest part,
> but once you have a grammar ready, I think the rest of the routines are
> pretty strightforward? Is it that code generated by Lex/Yacc is not as
> efficient?

Developing grammar with bison is an easy part. The tough part is semantic
processing. For example to files in gas responsible for reading the
input file are about 7000 lines, while the rest is about 32000 lines
(not counting libraries). Moreover, the part reading input is doing
both lexing/parsing and some semantic processing. In other words parsing
assembler instructions is easy, but the assembler have to do much more.

Once the grammar is ready writing recursive descent parser require only
little more work than using bison, but my experience was that developing
grammar with bison is much easier than writing recursive parser without
grammar.

--
Waldek Hebisch
hebisch@xxxxxxxxxxxxxxxx

.



Relevant Pages

  • Re: HLA
    ... It could be added to almost any C compiler without problems... ... I don't think you'll find an x86 assembler with a syntax closer to C's than HLA. ... extensions can be added to the ISO C LALRgrammar without any ...
    (alt.lang.asm)
  • Re: BethTool ?
    ... a "grammar") supplied as part of the input file. ... You want a MASM syntax assembler, ...
    (alt.lang.asm)
  • Re: YACC grammar for 8085 assembler.
    ... I am looking for a YACC grammar for 8085 assembler. ... where I see a grammar helping is in expression parsing. ... parsing of the address expressions, ...
    (comp.compilers)
  • Re: Assembler in Lex/Yacc
    ... > I was working on an assembler for X64 architecture. ... HLA v1.x, as a prototype, was written with Flex and Bison. ... "compile-time" language (i.e., macros, conditional assembly, and stuff ... The grammar for a *typical* assembler is usually quite ...
    (comp.lang.asm.x86)
  • Re: Nasm genesis
    ... >> Only a dement like you, who writes his shit in Flex, Bison ... >> and C, who is unable write any Assembler, and unable to ... >> holy ursurpated reputation, you want to sell yourself as ... > This is why Betov is so jealous of the reputation of Randy Hyde because ...
    (alt.lang.asm)