C
cr88192
Harald van D?k said:<OT, I guess>
You're right, this isn't the best group for that, but you might like the
comp.compilers newsgroup for it.
</OT>
sadly, it is moderated and filled with people obsessing on parsers...
as a result, had mostly been hanging around alt.lang.asm and comp.lang.misc.
here seems to be mostly a place for newbs to ask questions...
OT, basic description of effort:
now, my parser, well, it is a big mass of hand-written C code, not much to
say about that (I suspect most people with any interest in compiler or
interpreter writing, maybe run into the problem of syntax, or get some crude
interpreter or translator working, and die off after this point).
parser is uniteresting, hard-coded recusive-descent...
now, IMO, the parser is the easy part...
the compilation process, type handling, and code generation. IMO, this is
where most of the work seems to reside (note, I compile all the way down to
machine code using purely my own code).
currently the thing is about 30 kloc, but a lot is still incomplete.
note that it is a multi-stage compiler (currently 5 major stages, with some
of these stages making multiple passes).
I am aiming for calling-convention level compatibility with gcc.
in general, it is designed for run-time compilation and linking (so that it
can operate similarly to a script language), but also have full (and direct)
access to the OS and host app.
at present it can also load object files and static libraries (GNU-ar
format), and can output object files, albeit for all these presently only
PE/COFF is supported (what little I have run it on linux, it is restricted
to what can be done with libdl).
another eventual goal is to allow its use for tasks along the lines of
'eval' (dynamically compiling and running small pieces of code, such as
single expressions), self-writing programs, ...
other possible eventual features:
reflection, ...
compiler extensions for high-level features (garbage collection, dynamic
types, lexical varaibles, closures, ...).
as noted, given a C core these would be less nice than in a true script
language (and totally craping all over the purity of C), but it could still
be worthwhile (well, probably still far less horrid than Objective-C, more
like what would happen if C, JavaScript, Self, ... collided, and more
keeping in line with the basic style and aesthetic of the C family...).
as is usual, probably requiring a special header, 'variant.h', which would
enable all this bizareness (and probably "#error" if used in something like
gcc...).
note:
this is really only my first statically-typed language, me previously
writing dynamically typed script languages (the final of which using JIT and
type inference, I had figured maybe it wouldn't be too huge of a leap from
one to another, but have been regularly underestimating things).
well, it was less easy than could be hoped, good 4+ solid months of coding
getting this beast written, internally, a very different thing than the
script language...
however, the framework should be able to handle both styles absent too much
additional effort (far less than writing the damn thing).
or something...