Re: Assembler in Lex/Yacc
- From: Waldek Hebisch <spamtrap@xxxxxxxxxx>
- Date: Sun, 4 Dec 2005 16:45:38 +0000 (UTC)
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
.
- References:
- Assembler in Lex/Yacc
- From: Sanky
- Assembler in Lex/Yacc
- Prev by Date: varargs in C (AMD64 architecture)
- Next by Date: Re: varargs in C (AMD64 architecture)
- Previous by thread: Re: Assembler in Lex/Yacc
- Next by thread: Embedded x86 ASM
- Index(es):
Relevant Pages
|