Re: Compiler Design.

"Torbjorn Drevin" <>
30 May 1998 11:58:05 -0400

          From comp.compilers

Related articles
Compiler Deisgn. (Matthew Webb) (1998-05-12)
Re: Compiler Deisgn. (Kirk Abbott) (1998-05-15)
Re: Compiler Deisgn. (1998-05-27)
Re: Compiler Design. (Torbjorn Drevin) (1998-05-30)
Re: Compiler Design. (1998-06-03)
| List of all articles for this month |

From: "Torbjorn Drevin" <>
Newsgroups: comp.compilers
Date: 30 May 1998 11:58:05 -0400
Organization: Algonet/Tninet
References: 98-05-058 98-05-098 98-05-126
Keywords: design

Anton Ertl wrote in message 98-05-126...
>Matthew Webb wrote:
>>> My diassembler/assembler are bassically just one massive case statment
>>> the bytes or text strings. The look identical but the reversed.
>>> Can anyone give another structure other than a case statment please?

One can use a table with data and function pointers instead of a large
case-statement. The function pointers can point to a specific
"actionfunction", if needed. If the opcode in a specific record does not
need to have an "action function", then it should contain NULL. I have used
this technique both in an assembler, and when I wrote a printer emulator, to
parse incoming esc-sequences. When the scanner has collected a token it
searches in the table for the token. If found, it looks at the data in the
record, and makes a jump to the "action function" if the pointer != NULL.

Torbjorn Drevin, /


Post a followup to this message

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