Skip to main content
GameDev.net gamedev.net
🔒 Locked

c++ Syntax

Started by Lars W. Dec 25, 2001 at 10:23 PM 4 replies 500+ views
Original Post
Lars W.
Lars W.
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
jenova
jenova
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.
DrPizza
DrPizza
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 ***/
Arild Fines
Arild Fines
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]
Lars W.
Lars W.
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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.