gcc c grammar
Hello, my name is Eduardo Cruz. I am an studen.t of Computer Science at the State University of Maringa, in Brazil. One of our teachers gave us a work in wich we are supposed to modify the c language to support some parallel programming stuff. I want to modify the gcc c frontend to support these features. I thought gcc used bison as a syntax analyser, but when I saw the gcc c-parser source code I realized that it didn't use bison. I read in the gcc mailist that gcc now has a recursive descent parser. Do you have any document that contains the grammar implemented in gcc c-parser? If you have, can you send it? It would be easier to make the proprer changes in the grammar if I have this document, because I won't have to understand the grammar reading the source code. Thank you very much for your atention
Re: GCC C FRONT END EXPLANATION
hey, could you guys explain me something? in c-parser.c in c_parser_direct_declarator, when a function name is being parsed, this if: if (c_parser_next_token_is (parser, CPP_OPEN_PAREN)) is true, and inside this if: c_parser_consume_token (parser); attrs = c_parser_attributes (parser); so it consumes the token "(", and then calls c_parser_attributes to check the parameters of the function but in c_parser_attributes this is made in the beggining of the loop: c_parser_consume_token (parser); if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) { parser->lex_untranslated_string = false; return attrs; } I don't understand, after the consumed token "(" there will be a variable type right? why it consumed the token without checking it? and why does it require the token "(" ? aren't we inside the function parameters list? that's all for a while thanks 2009/3/20 Dave Korn : > Guilherme Puglia wrote: > >> But thanks to everybody. >> I'll read the gcc docs in the source code! > > > The C parser starts in gcc/c-parser.c. There are a bunch of lexing routines > at the top, then you'll see a whole bunch of c_parser_X routines which > handle the individual grammar constructs. Each one has a commnent at the top > describing the syntax elements it parses and referring to the paragraph of the > C standard where they're defined. (If you don't have a copy of the C standard > handy, google "n1256.pdf"). Good luck! > > cheers, > DaveK > >
lookup_name
does the function lookup_name distinguish the identifier between different contexts? for example void func1() { int foo; } void func2() { int foo; } if I call lookup_name with the foo ident-tree while parsing these functions, will it return different decl-tree nodes? thanks
Re: lookup_name
> I assume you mean the function in the C frontend, in c-decl.c. thats correct! thanks a lot! 2009/4/7 Ian Lance Taylor : > Eduardo Cruz writes: > >> does the function lookup_name distinguish the identifier between >> different contexts? > > I assume you mean the function in the C frontend, in c-decl.c. That > function looks up the name in the current scope, so, yes, it will return > different DECL nodes when appropriate. > > Ian >