How to implement type checking/conversion ?

"Floris 'Tamama' van Gog" <>
24 Sep 1999 22:59:54 -0400

          From comp.compilers

Related articles
How to implement type checking/conversion ? (Floris 'Tamama' van Gog) (1999-09-24)
| List of all articles for this month |

From: "Floris 'Tamama' van Gog" <>
Newsgroups: comp.compilers
Date: 24 Sep 1999 22:59:54 -0400
Organization: InfoThuis BV
Keywords: code, practice, question


I am currently making a small compiler that handles a subset of C
(don't ask me why.. i still have to figure that one out.. good
practice or something :-).

I have come to the part that it can generate correct assembly-like
code, (without registers though (stack-based temporary variables)),
however this is not type-checked. It is probably not that hard to make
a HUGE switch statement or something to check all possible l-values
and r-values, however i was hoping someone would know an better/more
structured way that would also allow it to grow as new types get

The parsing/code generation is done by the compiler itself (no
lex/yacc), and type-information is stored with every variable.

I guess my big problem is the global/detailed implementation design of
type-correction (the checking itself can be done by comparing 2
pointers to the type-information.. so that's not that hard). I'm
really stuck on this. I already had to redo most of the
parser/generator 'x' times to many (rewriting the basic stack machine
including instructions after you got most of the important peep-hole
optimisations ready does that) to just go dig in to write the code,
and not think of future things.

I have a testrun (so you could see what it generates) online @ If anyone can help me
see the light, i would appreciate it very much.

Floris v. Gog

Post a followup to this message

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