Re: Compiler Design. (Tim Channon)
3 Jun 1998 01:56: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: (Tim Channon)
Newsgroups: comp.compilers
Date: 3 Jun 1998 01:56:05 -0400
Organization: Compilers Central
References: 98-05-058 98-05-098 98-05-126 98-05-141
Keywords: design, assembler

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

>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.

I've used a variation on this to decode T4 facsimile data using the T4
decode table to preload a trie, at compile or runtime. This looks a
bit like a simple interpreter and could be greatly enhanced.

It was implemented as a Patricia trie, where the codes to be decoded
are fed into the trie together with action funtions, which decorate
all the leaves, so there are no cracks, ie. error handling.
Real data is then fed in via simple loop where the trie lookups
callback the function to execute. As a side effect out trots decoded
data. I store auxillary data in the trie and that is where the
function addresses sit.
I was surprised that it ran quite fast.

It will also work with plain text. Being a dynamic self organising
trie it would be trivial to modify the trie during operation, brain
damage excepted... rather you than me!

This particular trie is a fair alternative to hashing for symbol

It was one of my exercises in madness. Seemed a good thing at the

Post a followup to this message

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