Re: type definitions

bear@sonic.net
23 May 2003 01:37:36 -0400

          From comp.compilers

Related articles
type definitions hibbits@cme.nist.gov (Justin Hibbits) (2003-05-18)
Re: type definitions bear@sonic.net (2003-05-23)
Re: type definitions hibbits@cme.nist.gov (Justin Hibbits) (2003-05-24)
Re: type definitions cfc@world.std.com (Chris F Clark) (2003-05-29)
| List of all articles for this month |
From: bear@sonic.net
Newsgroups: comp.compilers
Date: 23 May 2003 01:37:36 -0400
Organization: ...disorganized...
References: 03-05-151
Keywords: types
Posted-Date: 23 May 2003 01:37:36 EDT

Justin Hibbits wrote:


> I'm working on a compiler library, and extensions to yacc to allow
> people to easily write language definitions, and build compilers with
> very little C code in the definition/grammar. But, I'm stuck, and
> can't figure out how to cleanly represent type definitions using a
> yacc-like syntax, so that one only has to write "set_type( TYPE_NAME )"
> in order to set the type, and perform sanity checking (making sure
> types don't conflict, types aren't specified more than allowed, etc).


> ...I want to make my compiler as source-language independant as
> possible...


"I'm afraid I don't have a solution for you, but I admire the
problem." In this case, I'm reasonably sure a good solution exists,
but the problem may be more complex than you're giving it credit for.


Have you considered the many languages where it is values that have
types rather than variables? In scheme/lisp/most functional languages,
a value of any type may be assigned to any variable. Or languages
like Python, where the variables have type unions (Where each variable
has a set of types and may be assigned only values of those types)?
Or even languages like FORTH-1, where variables don't even exist?
Everything is done with values on the stack and strongly-typed
functions.


Bear


Post a followup to this message

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