c++ Syntax

Started by
4 comments, last by Lars W. 22 years, 3 months ago
Hi Does anybody know a site where i can find Information about the Syntax of C++. i need it to write a c++ parser, and there for i need a very detailed description (Best would be in EBNF). I espacially need the syntax of functions. There is more then just "return_type name(args){}" there is that calling convention stuff and all the different ways to write a function. There must be something somewhere but i couldn''t find anything on the net detailed enough. Thanks in advance. Lars
--------> http://www.larswolter.de <---------
Advertisement
do a search on "www.google.com" for "c++ lexical". you''re sure to get at least 1 hundred hits. i am currently coding a c compiler for the PS2, but i didn''t find much of it useful. i am using the "c primer" book and "cl (MS VC++ c compiler" as my guide.

To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.
To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.
http://www.cs.man.ac.uk/~pjj/bnf/c_syntax.k_r
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
I would imagine that a few dollars expenditure on the C++ standard would probably be helpful.
char a[99999],*p=a;int main(int c,char**V){char*v=c>0?1[V]:(char*)V;if(c>=0)for(;*v&&93!=*v;){62==*v&&++p||60==*v&&--p||43==*v&&++*p||45==*v&&--*p||44==*v&&(*p=getchar())||46==*v&&putchar(*p)||91==*v&&(*p&&main(0,(char**)(--v+2))||(v=(char*)main(-1,(char**)++v)-1));++v;}else for(c=1;c;c+=(91==*v)-(93==*v),++v);return(int)v;}  /*** drpizza@battleaxe.net ***/
You could always get the source for g++. g++ uses bison for parsing, and a bison file is almost pure BNF anyway...

Fantastic doctrines (like Christianity or Islam or Marxism or Microsoft-bashing) require unanimity of belief. One dissenter casts doubt on the creed of millions. Thus the fear and hate; thus the torture chamber, the iron stake, the gallows, the labor camp, the psychiatric ward - Edward Abbey
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
Thanks a lot guys!

especially the tip with the g++ is very interesting.
Just looked into the File and the advantage is, that nothing can be missing.
It also inspires me to make my parsing algorithm a little more dynamic.

Lars
--------> http://www.larswolter.de <---------

This topic is closed to new replies.

Advertisement