Re: Assembler using Lex/Yacc

russell kym horsell <>
5 Dec 2005 02:53:36 -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: russell kym horsell <>
Newsgroups: comp.compilers
Date: 5 Dec 2005 02:53:36 -0500
Organization: Central Iowa (Model) Railroad, Plano, TX, USA
References: 05-12-009
Keywords: assembler, design
Posted-Date: 05 Dec 2005 02:53:36 EST

Sanky <> wrote:
> 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


I've written several of both (incl some full-blown ones generating proprietary
multi-seg relocatable binaries) and there seems no good reason -- apart from
lethargy and pride -- not to use the tools.

I don't know what you mean by "tough" to design assembler syntax. ;-)

The only overhead I'd imagine is the learning curve. A rec descent
parser requires almost 0 learning. Getting yacc and lex to do same
requires knowing how to handle end-of-lines (i.e. whatever
record-oriented processing is required for your assembler -- usually
getting the listing right!), etc.

Post a followup to this message

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