Assembler using Lex/Yacc

"Sanky" <>
3 Dec 2005 16:23:19 -0500

          From comp.compilers

Related articles
Assembler using Lex/Yacc (Sanky) (2005-12-03)
Re: Assembler using Lex/Yacc (russell kym horsell) (2005-12-05)
| List of all articles for this month |

From: "Sanky" <>
Newsgroups: comp.compilers
Date: 3 Dec 2005 16:23:19 -0500
Keywords: assembler, question, comment
Posted-Date: 03 Dec 2005 16:23:18 EST

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
YASM does get close, but again it resorts to hand written code at some

Is it that Lex/Yacc is an overkill or is that Lex/Yacc are not the
right tools? I'm new to compiler and assembler design, and would be
helpful if anyone can guide.

[Lex and yacc only automate the front end of a compiler, not the code generator.
The main reasons I've seen that people don't use them is that they're overkill
for the very simple syntax of most assemblers, or that the assembler syntax is
an ancient hack that can't be changed for compatibility reasons and isn't
amenable to what lex and yacc do. I've written assemblers with lex and yacc,
works fine so long as you can define the syntax so that it's not too context
dependent. -John]

Post a followup to this message

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