Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!ncar!hsdndev!spdcc!iecc!compilers-sender From: bart@cs.uoregon.edu (Barton Christopher Massey) Newsgroups: comp.compilers Subject: Re: 8051 assembler Keywords: 8051, assembler, design, lex Message-ID: <1991Mar19.221827.16858@cs.uoregon.edu> Date: 19 Mar 91 22:18:27 GMT References: <3502@polari.UUCP> Sender: compilers-sender@iecc.cambridge.ma.us Reply-To: bart@cs.uoregon.edu (Barton Christopher Massey) Organization: Department of Computer Science, University of Oregon Lines: 35 Approved: compilers@iecc.cambridge.ma.us In article <3502@polari.UUCP> mzenier@polari.UUCP (Mark Zenier) writes: ... > But not Lex or Flex. The implementation of include files at the > yacc grammar level caused a such a messy conflict with the lookahead > in both Flex and Decus Lex, that I ended up rewriting the the lexical > analyzer by hand. Lex source isn't portable, especially if you > play with the input() macro. Hmm. The Motorola 56000 family assembly language has the interesting property that label addresses may be used in preprocessor expressions(!). In spite of this, I recently completed a 56K assembler written using LEX and YACC -- it's actually compatible with LEX or FLEX, and YACC, BISON, or BYACC (obviously, I tend to use FLEX and BYACC, but it needed to be portable to some weird environments, such as Stanford's V OS). It required some ifdefs, but other than that, the lexer was actually quite straightforward. I had no serious trouble modifying the input routines to switch between raw input and input from preprocessor output buffers. It meant that the lexer only looked ahead a line at a time, but that's about the best one can do anyhow, I think... Pushing information back through the *parser*, on the other hand, was a real nightmare, and still isn't quite right. Unfortunately, 56K expression syntax is non-trivial, and having a machine-generated operand parser was a real win. Anyhow, although I sympathise with the above-quoted paragraph, I strongly recommend using a FLEX lexer for an assembler -- my experience was much more positive. Bart Massey bart@cs.uoregon.edu -- Send compilers articles to compilers@iecc.cambridge.ma.us or {ima | spdcc | world}!iecc!compilers. Meta-mail to compilers-request.