This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Newbie to creating front ends to gcc


Right now I'm trying to understand that tree code.

I think I need a simple example of how to create a tree. How would I eg
create tree for this function?

int foofunc(int x)
{
  return 7+x-atoi("54"); 
}

something like:

int
yyparse(YYPARSE_PARAM_ARG)
     YYPARSE_PARAM_DECL
{
  tree Tfuncname = get_identifier('foofunc'); /* Is this symbol exported
now? */
	
  tree Tconstant7 = build_int_2(7,0);
  tree Tfuncres = makenode(INTEGER_TYPE);
  tree Tassign build1(MODIFY_EXPR, TFuncres, Tconstant7);
  tree Tfunction = build(FUNCTION_DECL);
  /* etc */
}

..well, that was as far as I came. And that is probably wrong. Could
someone please point me in the right direction?

(The final version of my program will of course parse a file...but I'm
not that far yet.)

I'm running GCC 2.95.3 at the moment as that is what goes with DJGPP.

Thanks in advance for your help!

// David


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]