Using Lex to scan a processor specific Assembly Language

mprestonsnead@yahoo.com (msnead)
20 Dec 2000 17:22:44 -0500

          From comp.compilers

Related articles
Using Lex to scan a processor specific Assembly Language mprestonsnead@yahoo.com (2000-12-20)
Re: Using Lex to scan a processor specific Assembly Language joachim_d@gmx.de (Joachim Durchholz) (2000-12-21)
| List of all articles for this month |

From: mprestonsnead@yahoo.com (msnead)
Newsgroups: comp.compilers
Date: 20 Dec 2000 17:22:44 -0500
Organization: Compilers Central
Keywords: assembler, question
Posted-Date: 20 Dec 2000 17:22:43 EST

Hi,


I am in the process of writing a scanner that scans an assembly
language that was written for a specific processor. This language is
very old, and the current assembler has some issues that need to be
reworked.


I am having trouble figuring out how to scan for comments in the file.
A comment can start with a star, which is easy enough, "*"[^\n]*


But text in the fourth column of the file is also considered a
comment. And this type of comment does not start with any kind of
special character like the '*'. Here is an example:


label Operator op1,op2 Comment


So I am really confused about how to throw away this type of comment
for the yacc parser. How can I write a regular expression to catch a
comment that is not associated with a '*' or something.
[Basically, you can't. I suspect you can use start states and some
whitespace counting hackery to switch into a state after the operands
that swallows up the rest of the line. -John]



Post a followup to this message

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