Thread overview
hello world compiled
Jan 02, 2004
Ben Hinkle
Jan 02, 2004
Ilya Minkov
Jan 03, 2004
Stephan Wienczny
Jan 04, 2004
Ben Hinkle
Jan 04, 2004
Walter
Jan 04, 2004
Ben Hinkle
Jan 04, 2004
Walter
January 02, 2004
Since it's the new year and we all have a few days off I figure'd I'd try to see just how bad it would be to modify the C++ front end to compile D.

After one day of search/replace cxx (and cp and tons of other stuff) with
dmd and one parser change to recognize "extern (C)" (in parse.y and the
wonderfully named file "spew.c") I got hello world to compile and run
(linked with libstc++):

extern (C) void printf(char*, ...);
extern (C) int main(int argc, char**argv)
{
    printf("hello world.\n");
    return 0;
}

[/home/bhinkle/d/gcc/build]845 %
../gcc-3.3.2/configure --enable-languages=c,dmd
[snip]
[/home/bhinkle/d/gcc/build]846 % make bootstrap
[snip]
[/home/bhinkle/d/gcc/build]847 % cd gcc
[/home/bhinkle/d/gcc/build/gcc]848 % gdmd
/home/bhinkle/hello.d -L. -L/home/bhinkle
[/home/bhinkle/d/gcc/build/gcc]849 % a.out
hello world.

Now my goal (something that would actually require work) is to get phobos compiled. It doesn't look like there are any templates in there so templates will wait. I figure I'll run into a brick wall at some point but what the heck.

Anyway, I'm not sure how far I'll get but happy new year.

-Ben



January 02, 2004
Ben Hinkle wrote:
> Since it's the new year and we all have a few days off I figure'd I'd try to
> see just how bad it would be to modify the C++ front end to compile D.
> 
> After one day of search/replace cxx (and cp and tons of other stuff) with
> dmd and one parser change to recognize "extern (C)" (in parse.y and the
> wonderfully named file "spew.c") I got hello world to compile and run
> (linked with libstc++):

Woohoo! So you're giving it a try another way around! You shall need a lot of good luck in rewriting the C++ front-end, if this really is what you intend to do...

I was not going to dig within G++ until i understand and can dump DMD... But i had realized a while ago that i shall for a long while have time for neither. I'm sorry.

Good luck and happy new year.

-eye

January 03, 2004
Ben Hinkle wrote:
> Since it's the new year and we all have a few days off I figure'd I'd try to
> see just how bad it would be to modify the C++ front end to compile D.
> 
> After one day of search/replace cxx (and cp and tons of other stuff) with
> dmd and one parser change to recognize "extern (C)" (in parse.y and the
> wonderfully named file "spew.c") I got hello world to compile and run
> (linked with libstc++):
> 
> extern (C) void printf(char*, ...);
> extern (C) int main(int argc, char**argv)
> {
>     printf("hello world.\n");
>     return 0;
> }
> 
> [/home/bhinkle/d/gcc/build]845 %
> ../gcc-3.3.2/configure --enable-languages=c,dmd
> [snip]
> [/home/bhinkle/d/gcc/build]846 % make bootstrap
> [snip]
> [/home/bhinkle/d/gcc/build]847 % cd gcc
> [/home/bhinkle/d/gcc/build/gcc]848 % gdmd
> /home/bhinkle/hello.d -L. -L/home/bhinkle
> [/home/bhinkle/d/gcc/build/gcc]849 % a.out
> hello world.
> 
> Now my goal (something that would actually require work) is to get phobos
> compiled. It doesn't look like there are any templates in there so templates
> will wait. I figure I'll run into a brick wall at some point but what the
> heck.
> 
> Anyway, I'm not sure how far I'll get but happy new year.
> 
> -Ben
> 
> 
> 
You did not use the 3.4 branch?!?
Do you have a website?
Sourceforge project etc?

Stephan
January 04, 2004
"Ben Hinkle" <bhinkle4@juno.com> wrote in message news:bt3thn$2i0a$1@digitaldaemon.com...
> Since it's the new year and we all have a few days off I figure'd I'd try
to
> see just how bad it would be to modify the C++ front end to compile D.

That is an interesting approach. It just might work!

> Now my goal (something that would actually require work) is to get phobos compiled. It doesn't look like there are any templates in there so
templates
> will wait. I figure I'll run into a brick wall at some point but what the heck.

D templates are easy - it's entirely handled within the front-end.


January 04, 2004
> You did not use the 3.4 branch?!?

umm. whoops. I just got the latest release a few weeks ago or so. I'll check it out.

> Do you have a website?
> Sourceforge project etc?

if I actually get anywhere with it

>
> Stephan



January 04, 2004
"Walter" <walter@digitalmars.com> wrote in message news:bt7qeh$294u$2@digitaldaemon.com...
>
> "Ben Hinkle" <bhinkle4@juno.com> wrote in message news:bt3thn$2i0a$1@digitaldaemon.com...
> > Since it's the new year and we all have a few days off I figure'd I'd
try
> to
> > see just how bad it would be to modify the C++ front end to compile D.
>
> That is an interesting approach. It just might work!

I added alias and uchar, ushort and friends with no problem but my next goal was dynamic arrays and that has been harder. I haven't figured out enough about the G++ front end to make any real progress on that. It turns out the C notion of arrays is pretty hard-wired into gcc. Also I started ripping out the preprocessor but that caused havoc in the parse and lex code (and that lovely spew.c). Right now I'm looking at plugging in your lexer since it has the least dependencies on anything else and is *much* simpler than the G++ cpp-based lexer. I'm starting to think my approach will end up as a rather extensive transplant of certain G++ chunks with the DMD equivalents.

> > Now my goal (something that would actually require work) is to get
phobos
> > compiled. It doesn't look like there are any templates in there so
> templates
> > will wait. I figure I'll run into a brick wall at some point but what
the
> > heck.
>
> D templates are easy - it's entirely handled within the front-end.

easy, eh?  Don't get my hopes up ;-)




January 04, 2004
"Ben Hinkle" <bhinkle4@juno.com> wrote in message news:bt84h2$2n84$1@digitaldaemon.com...
> Also I started ripping out
> the preprocessor but that caused havoc in the parse and lex code (and that
> lovely spew.c).

spew, gotta love it!

> Right now I'm looking at plugging in your lexer since it has
> the least dependencies on anything else and is *much* simpler than the G++
> cpp-based lexer.

I had the advantage here because whenever the D lexer started looking complicated, I simplified the language. Suggest simplifying the C++ language to make scanning easier, and one's compiler cajones get questioned <g>.

> > D templates are easy - it's entirely handled within the front-end.
> easy, eh?  Don't get my hopes up ;-)

Once you get the rest of the DMD front end in, it should be easy!