www.digitalmars.com         C & C++   DMDScript  

D.gnu - DMD parser hooked up

reply "Ben Hinkle" <bhinkle4 juno.com> writes:
After messing with the lexer I took a deep breath and got the DMD parser
hooked up and started transforming trees from DMD data structures to GCC
data structures. I've done enough to get "hello world" back (for now that is
my baseline - don't break things so much that "hello world" stops
compiling).

Basically I got the OpenD code and updated it from DMD.36 to DMD .78 (yeah,
I know, Walter released .79 today), hooked it up to the G++ front-end and
started plugging in the pieces to translate back and forth. So the parsing
and three semantic phases of the DMD src now run before it is turned over to
GCC. It should be fairly possible to make good progress filling in these
pieces until it gets hard again.

If anyone wants to try it out for themselves you can get the tarball from
the last link at
http://home.comcast.net/~benhinkle/index.html

I've only tried it on Linux and compiling "hello world".

-Ben

ps. Walter, could you remove the extra closing parenthesis on line 175 of
dmd/src/dmd/module.c?
 (((unsigned char *)p)[3] << 24));
Jan 22 2004
next sibling parent reply Andy Friesen <andy ikagames.com> writes:
Ben Hinkle wrote:
 After messing with the lexer I took a deep breath and got the DMD parser
 hooked up and started transforming trees from DMD data structures to GCC
 data structures. I've done enough to get "hello world" back (for now that is
 my baseline - don't break things so much that "hello world" stops
 compiling).

Simply amazing. I took one look at the GCC documentation, and my brain exploded more or less instantly. Well done! -- andy
Jan 22 2004
parent reply "Ben Hinkle" <bhinkle4 juno.com> writes:
"Andy Friesen" <andy ikagames.com> wrote in message
news:buq0u5$15vk$1 digitaldaemon.com...
 Ben Hinkle wrote:
 After messing with the lexer I took a deep breath and got the DMD parser
 hooked up and started transforming trees from DMD data structures to GCC
 data structures. I've done enough to get "hello world" back (for now


 my baseline - don't break things so much that "hello world" stops
 compiling).

Simply amazing. I took one look at the GCC documentation, and my brain exploded more or less instantly. Well done! -- andy

Glad you like it, though I don't understand 3/4 of the GCC internals either. That's why the G++ code is so useful - I can just call their function "finish_expr_stmt", for instance, instead of writing one myself. Probably at some point finish_expr_stmt will have to change but for now I just want to have a compiler than runs. It's too demoralizing to work on something that doesn't actually run. The main file to fiddle around with, if you want to take a look, is d-parse.c since it has all the routines that take D things and calls the G++ equivalents. -Ben
Jan 23 2004
parent reply Stephan Wienczny <wienczny web.de> writes:
Ben Hinkle wrote:
 "Andy Friesen" <andy ikagames.com> wrote in message
 news:buq0u5$15vk$1 digitaldaemon.com...
 
Ben Hinkle wrote:

After messing with the lexer I took a deep breath and got the DMD parser
hooked up and started transforming trees from DMD data structures to GCC
data structures. I've done enough to get "hello world" back (for now


that is
my baseline - don't break things so much that "hello world" stops
compiling).

Simply amazing. I took one look at the GCC documentation, and my brain exploded more or less instantly. Well done! -- andy

Glad you like it, though I don't understand 3/4 of the GCC internals either. That's why the G++ code is so useful - I can just call their function "finish_expr_stmt", for instance, instead of writing one myself. Probably at some point finish_expr_stmt will have to change but for now I just want to have a compiler than runs. It's too demoralizing to work on something that doesn't actually run. The main file to fiddle around with, if you want to take a look, is d-parse.c since it has all the routines that take D things and calls the G++ equivalents. -Ben

Stephan
Jan 23 2004
parent "Ben Hinkle" <bhinkle4 juno.com> writes:
try http://home.comcast.net/~benhinkle/gdmd.tar.gz

 Could you u/l it to a website?

 Stephan

Jan 23 2004
prev sibling next sibling parent Ilya Minkov <minkov cs.tum.edu> writes:
Wooooohoooo!

Thanks a lot for your efforts! I will join you in about 3-4 weeks!

-eye

Ben Hinkle wrote:
 After messing with the lexer I took a deep breath and got the DMD parser
 hooked up and started transforming trees from DMD data structures to GCC
 data structures. I've done enough to get "hello world" back (for now that is
 my baseline - don't break things so much that "hello world" stops
 compiling).
 
 Basically I got the OpenD code and updated it from DMD.36 to DMD .78 (yeah,
 I know, Walter released .79 today), hooked it up to the G++ front-end and
 started plugging in the pieces to translate back and forth. So the parsing
 and three semantic phases of the DMD src now run before it is turned over to
 GCC. It should be fairly possible to make good progress filling in these
 pieces until it gets hard again.
 
 If anyone wants to try it out for themselves you can get the tarball from
 the last link at
 http://home.comcast.net/~benhinkle/index.html
 
 I've only tried it on Linux and compiling "hello world".
 
 -Ben
 
 ps. Walter, could you remove the extra closing parenthesis on line 175 of
 dmd/src/dmd/module.c?
  (((unsigned char *)p)[3] << 24));
 
 

Jan 23 2004
prev sibling next sibling parent reply resistor mac.com writes:
Awesome!  I'm compiling it now on my Mac OS X box.  We'll see how it turns
out...

Only problem I've had thus far is that libstdc++ only seems to exist on OS X as
a static library.  Do 
I need to change anything to get it to work as such?

Thanks again,

Owen

In article <bupadt$16o$1 digitaldaemon.com>, Ben Hinkle says...
After messing with the lexer I took a deep breath and got the DMD parser
hooked up and started transforming trees from DMD data structures to GCC
data structures. I've done enough to get "hello world" back (for now that is
my baseline - don't break things so much that "hello world" stops
compiling).

Basically I got the OpenD code and updated it from DMD.36 to DMD .78 (yeah,
I know, Walter released .79 today), hooked it up to the G++ front-end and
started plugging in the pieces to translate back and forth. So the parsing
and three semantic phases of the DMD src now run before it is turned over to
GCC. It should be fairly possible to make good progress filling in these
pieces until it gets hard again.

If anyone wants to try it out for themselves you can get the tarball from
the last link at
http://home.comcast.net/~benhinkle/index.html

I've only tried it on Linux and compiling "hello world".

-Ben

ps. Walter, could you remove the extra closing parenthesis on line 175 of
dmd/src/dmd/module.c?
 (((unsigned char *)p)[3] << 24));

Jan 23 2004
parent reply resistor mac.com writes:
Well, no luck with that.  It failed with these errors.  Anything you can suggest
to fix it?

stage1/xgcc -Bstage1/ -B/usr/local/powerpc-apple-darwin7.2.0/bin/ -c   -g -O2
-DIN_GCC   -W 
-Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -pedantic
-Wno-long-long 
-Werror -Werror -fno-common   -DHAVE_CONFIG_H    -I. -Id -I../../gcc3/gcc
-I../../gcc3/gcc/d 
-I../../gcc3/gcc/../include -I../intl ../../gcc3/gcc/d/call.c -o d/call.o
In file included from ../../gcc3/gcc/d/call.c:35:
./../gcc3/gcc/d/d-tree.h:1020: warning: bit-field 'is_lang_type_class' type
invalid in ISO C
./../gcc3/gcc/d/d-tree.h:1022: warning: bit-field 'has_type_conversion' type
invalid in ISO C
./../gcc3/gcc/d/d-tree.h:1023: warning: bit-field 'has_init_ref' type invalid
in ISO C
./../gcc3/gcc/d/d-tree.h:1024: warning: bit-field 'has_default_ctor' type
invalid in ISO C
./../gcc3/gcc/d/d-tree.h:1025: warning: bit-field 'uses_multiple_inheritance'
type invalid in ISO C
./../gcc3/gcc/d/d-tree.h:1026: warning: bit-field 'const_needs_init' type
invalid in ISO C
./../gcc3/gcc/d/d-tree.h:1027: warning: bit-field 'ref_needs_init' type invalid
in ISO C
./../gcc3/gcc/d/d-tree.h:1028: warning: bit-field 'has_const_assign_ref' type
invalid in ISO C
gnumake[2]: *** [d/call.o] Error 1
gnumake[1]: *** [stage2_build] Error 2
gnumake: *** [bootstrap] Error 2

In article <bus9vc$1v9b$1 digitaldaemon.com>, resistor mac.com says...
Awesome!  I'm compiling it now on my Mac OS X box.  We'll see how it turns
out...

Only problem I've had thus far is that libstdc++ only seems to exist on OS X as
a static library.  Do 
I need to change anything to get it to work as such?

Thanks again,

Owen

Jan 23 2004
parent "Ben Hinkle" <bhinkle4 juno.com> writes:
Googling for the error gives these thread:

http://gcc.gnu.org/ml/gcc/2003-04/msg00102.html

http://gcc.gnu.org/ml/gcc-patches/2003-04/msg00175.html

It seems like the second one has a solution as a patch file. If you feel
like experimenting try using different C compilers for bootstrapping or
maybe strip out the -pendantic flag or something.
Good luck,
-Ben

<resistor mac.com> wrote in message news:busk3q$2f5k$1 digitaldaemon.com...
 Well, no luck with that.  It failed with these errors.  Anything you can

 to fix it?

2
 -DIN_GCC   -W
 -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -pedantic
 -Wno-long-long
 -Werror -Werror -fno-common   -DHAVE_CONFIG_H    -I. -Id -I../../gcc3/gcc
 -I../../gcc3/gcc/d
 -I../../gcc3/gcc/../include -I../intl ../../gcc3/gcc/d/call.c -o d/call.o
 In file included from ../../gcc3/gcc/d/call.c:35:
 ./../gcc3/gcc/d/d-tree.h:1020: warning: bit-field 'is_lang_type_class'

 invalid in ISO C
 ./../gcc3/gcc/d/d-tree.h:1022: warning: bit-field 'has_type_conversion'

 invalid in ISO C
 ./../gcc3/gcc/d/d-tree.h:1023: warning: bit-field 'has_init_ref' type

 in ISO C
 ./../gcc3/gcc/d/d-tree.h:1024: warning: bit-field 'has_default_ctor' type
 invalid in ISO C
 ./../gcc3/gcc/d/d-tree.h:1025: warning: bit-field

 type invalid in ISO C
 ./../gcc3/gcc/d/d-tree.h:1026: warning: bit-field 'const_needs_init' type
 invalid in ISO C
 ./../gcc3/gcc/d/d-tree.h:1027: warning: bit-field 'ref_needs_init' type

 in ISO C
 ./../gcc3/gcc/d/d-tree.h:1028: warning: bit-field 'has_const_assign_ref'

 invalid in ISO C
 gnumake[2]: *** [d/call.o] Error 1
 gnumake[1]: *** [stage2_build] Error 2
 gnumake: *** [bootstrap] Error 2

 In article <bus9vc$1v9b$1 digitaldaemon.com>, resistor mac.com says...
Awesome!  I'm compiling it now on my Mac OS X box.  We'll see how it


out...

Only problem I've had thus far is that libstdc++ only seems to exist on


a static library.  Do
I need to change anything to get it to work as such?

Thanks again,

Owen


Jan 23 2004
prev sibling next sibling parent "Walter" <walter digitalmars.com> writes:
"Ben Hinkle" <bhinkle4 juno.com> wrote in message
news:bupadt$16o$1 digitaldaemon.com...
 After messing with the lexer I took a deep breath and got the DMD parser
 hooked up and started transforming trees from DMD data structures to GCC
 data structures. I've done enough to get "hello world" back (for now that

 my baseline - don't break things so much that "hello world" stops
 compiling).

Great!
 ps. Walter, could you remove the extra closing parenthesis on line 175 of
 dmd/src/dmd/module.c?
  (((unsigned char *)p)[3] << 24));

Done.
Jan 24 2004
prev sibling parent reply resistor mac.com writes:
Well, I eventually gave up on getting it to build on my Mac OS X box.  But I DID
get it to run on my 
P4 Linux box. YAY!  Keep up the great work man!

Owen Anderson

In article <bupadt$16o$1 digitaldaemon.com>, Ben Hinkle says...
After messing with the lexer I took a deep breath and got the DMD parser
hooked up and started transforming trees from DMD data structures to GCC
data structures. I've done enough to get "hello world" back (for now that is
my baseline - don't break things so much that "hello world" stops
compiling).

Basically I got the OpenD code and updated it from DMD.36 to DMD .78 (yeah,
I know, Walter released .79 today), hooked it up to the G++ front-end and
started plugging in the pieces to translate back and forth. So the parsing
and three semantic phases of the DMD src now run before it is turned over to
GCC. It should be fairly possible to make good progress filling in these
pieces until it gets hard again.

If anyone wants to try it out for themselves you can get the tarball from
the last link at
http://home.comcast.net/~benhinkle/index.html

I've only tried it on Linux and compiling "hello world".

-Ben

ps. Walter, could you remove the extra closing parenthesis on line 175 of
dmd/src/dmd/module.c?
 (((unsigned char *)p)[3] << 24));

Jan 31 2004
parent reply "Ben Hinkle" <bhinkle4 juno.com> writes:
<resistor mac.com> wrote in message news:bvhqnc$pf2$1 digitaldaemon.com...
 Well, I eventually gave up on getting it to build on my Mac OS X box.  But

 get it to run on my P4 Linux box.

I, too, tried it on a Mac OS X box to no avail. I wasn't getting the error you got but it was complaining like mad about other things. Plus there are chunks of the DMD source that don't compile on anything other than Win32 or Linux. I took a quick shot on a Sun Solaris, too, (Blade something or other) but didn't get much further than on the Mac. I'll try again in a while.
 YAY!  Keep up the great work man!

 Owen Anderson

Thanks for the encouragement and for trying it out in such an early state. -Ben
Jan 31 2004
next sibling parent reply resistor mac.com writes:
I'm giving it another try now on both boxes with your updated code.  BTW, you're
missing a 
#include "lexer.h" in dmd/id.c.  As far as I can tell at least.

I shall keep trying on OS X building.  I'm determined to be to first person to
compile a working D 
on a non-X86 processor! I'll race you!

Owen

In article <bvhvct$10gu$1 digitaldaemon.com>, Ben Hinkle says...
<resistor mac.com> wrote in message news:bvhqnc$pf2$1 digitaldaemon.com...
 Well, I eventually gave up on getting it to build on my Mac OS X box.  But

 get it to run on my P4 Linux box.

I, too, tried it on a Mac OS X box to no avail. I wasn't getting the error you got but it was complaining like mad about other things. Plus there are chunks of the DMD source that don't compile on anything other than Win32 or Linux. I took a quick shot on a Sun Solaris, too, (Blade something or other) but didn't get much further than on the Mac. I'll try again in a while.
 YAY!  Keep up the great work man!

 Owen Anderson

Thanks for the encouragement and for trying it out in such an early state. -Ben

Jan 31 2004
parent reply resistor mac.com writes:
Alright, the P4 finished and seems to work just fine.  It compiles both of your
Hello programs 
perfectly, though it does produce a great deal of output to STDOUT.  I take it
that's normal?

The OS X box is still compiling (yes, it's a really really old G4, so this could
take a while).

Thanks again for your work,
Owen

In article <bvi0k3$12aa$1 digitaldaemon.com>, resistor mac.com says...
I'm giving it another try now on both boxes with your updated code.  BTW, you're
missing a 
#include "lexer.h" in dmd/id.c.  As far as I can tell at least.

I shall keep trying on OS X building.  I'm determined to be to first person to
compile a working D 
on a non-X86 processor! I'll race you!

Owen

Jan 31 2004
next sibling parent "Ben Hinkle" <bhinkle4 juno.com> writes:
<resistor mac.com> wrote in message news:bvi1i6$1496$1 digitaldaemon.com...
 Alright, the P4 finished and seems to work just fine.  It compiles both of

 Hello programs
 perfectly, though it does produce a great deal of output to STDOUT.  I

 that's normal?

Yeah. I left in all of my debugging printf's this time. Eventually those will get ripped out. They are useful for now when things go wrong since the compiler seg-v's if anything gets a little out of place.
 The OS X box is still compiling (yes, it's a really really old G4, so this

 take a while).

 Thanks again for your work,
 Owen

 In article <bvi0k3$12aa$1 digitaldaemon.com>, resistor mac.com says...
I'm giving it another try now on both boxes with your updated code.  BTW,


missing a
#include "lexer.h" in dmd/id.c.  As far as I can tell at least.

I shall keep trying on OS X building.  I'm determined to be to first


compile a working D
on a non-X86 processor! I'll race you!

Owen


Feb 01 2004
prev sibling parent reply resistor mac.com writes:
The OS X box is still compiling (yes, it's a really really old G4, so this could
take a while).

Well, that didn't work. I've tried compilingit against both a GCC 3.4 snapshot and against Apple's modified GCC 3.3 code. The 3.4 snapshot fails when trying to link cc1d together, while Apple's code fails with really odd errors about things not being defined that are defined. The upshot is that I suspect it shall have to wait until Apple's GCC moves to 3.4. Owen
Feb 01 2004
parent "Ben Hinkle" <bhinkle4 juno.com> writes:
You can download a weekly snapshot of the GCC-3.4 source from
http://gcc.gnu.org/mirrors.html
I am working from the snapshot gcc-3.4-20040107.tar.bz2

-Ben

<resistor mac.com> wrote in message news:bvjqqd$v23$1 digitaldaemon.com...
The OS X box is still compiling (yes, it's a really really old G4, so


take a while).

Well, that didn't work. I've tried compilingit against both a GCC 3.4

 and against Apple's
 modified GCC 3.3 code.  The 3.4 snapshot fails when trying to link cc1d
 together, while Apple's
 code fails with really odd errors about things not being defined that are
 defined.

 The upshot is that I suspect it shall have to wait until Apple's GCC moves

 3.4.

 Owen

Feb 01 2004
prev sibling parent reply "Walter" <walter digitalmars.com> writes:
"Ben Hinkle" <bhinkle4 juno.com> wrote in message
news:bvhvct$10gu$1 digitaldaemon.com...
 Plus there are
 chunks of the DMD source that don't compile on anything other than Win32

 Linux.

Let me know about such problems so I can make the source better!
Feb 01 2004
parent reply resistor mac.com writes:
I ran into a few places where #if's only defined scenarios for Win32 and Linux.
I solved that pretty easily though.

Also, I'm waiting for my SourceForge Compile Farm account to be activated, and
then I'll try compiling this on all kinds of other systems.

Owen

In article <bvks2n$2nnf$1 digitaldaemon.com>, Walter says...
"Ben Hinkle" <bhinkle4 juno.com> wrote in message
news:bvhvct$10gu$1 digitaldaemon.com...
 Plus there are
 chunks of the DMD source that don't compile on anything other than Win32

 Linux.

Let me know about such problems so I can make the source better!

Feb 02 2004
parent "Walter" <walter digitalmars.com> writes:
<resistor mac.com> wrote in message news:bvlnpd$14bp$1 digitaldaemon.com...
 I ran into a few places where #if's only defined scenarios for Win32 and

 I solved that pretty easily though.

That's deliberate, as any other system will need to have some attention there. Once that is done, send me the fixes and I'll fold them in.
Feb 02 2004