|constatnt initialization firstname.lastname@example.org (2003-12-03)|
|Re: constatnt initialization email@example.com (2003-12-08)|
|Re: constatnt initialization firstname.lastname@example.org (Clint Olsen) (2003-12-13)|
|Re: constatnt initialization email@example.com (Nick Roberts) (2003-12-13)|
|Re: constatnt initialization firstname.lastname@example.org (Joachim Durchholz) (2003-12-14)|
|From:||Nick Roberts <email@example.com>|
|Date:||13 Dec 2003 21:03:40 -0500|
|Posted-Date:||13 Dec 2003 21:03:40 EST|
Attila Csosz wrote:
> I'm working a VHDL (hardware description language)
> compiler/interpreter. The language has a complex type system (like
> There are constant initialziation in format
> constant name: type := expression;
> My question: how to check that this can be assigned? I generate
> pseudo-code. The "type" can complex: like multidimensional arrays
> containing records. Can you draft me how do it?
I'm answering in case nobody else does. I may not be the best person
to answer your question, but I'll do my best. But I've got a few
What is your compiler/interpreter going to do? Is is going to simulate
circuits? What is the context of the project (is it your job)? In
which programming language are you implementing this
> I have the book Aho/Sethi/Ulmann: Compilers. Can you suggest me
> algorithms in this book for it or in the internet or other good
This is one of the 'canonical' compiler books, by all accounts, yet it
is one that I do not have! Nevertheless, I would imagine that if it
has a chapter on 'symbol tables' or something like (the main data
structures a typical compiler has inside it), this will be very
relevant to your question.
I am not an expert on VHDL -- although as it happens I am an expert on
Ada (its sibling language) -- but I gather that (unlike Ada) VHDL is a
'weakly typed' language: variables and expressions are considered to
'type match' if they are 'structurally identical' (rather than having
the same named type).
Assuming I'm right about this, I suggest you need to invent an
encoding of some kind that represents the structure of any variable or
expression. Probably this encoding will need to distinguish between
different major kinds of type (integer, float, array). If it is an
array, it will need to encode how many dimensions there are, and for
each dimension what the bounds are, in addition to the type of the
elements of the array.
For situations, such as an assignment (constant or not), where you
need to compare types, you compare these encodings. In essence, if the
encodings are the same, the types are the same.
Best of luck,
Return to the
Search the comp.compilers archives again.