Thread: Compiler design and implementation: token parsing

  1. #1
    Unregistered
    Guest

    Compiler design and implementation: token parsing

    So how should I start a program....

    Is it

    void main,

    or void main(void)??

  2. #2
    Registered User sean345's Avatar
    Join Date
    Mar 2002
    Posts
    346
    This has some parsing information I needed once.

    http://www.cprogramming.com/cboard/s...hlight=parsing

    - Sean
    If cities were built like software is built, the first woodpecker to come along would level civilization.
    Black Frog Studios

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897


    -Prelude
    My best code is written with the delete key.

  4. #4
    Registered User bljonk's Avatar
    Join Date
    Oct 2001
    Posts
    70
    int main(int argc,char *argv[])
    {return 0;
    }

    int main(void)
    {return 0;
    }

    void main(int argc,char *argv[])
    {
    }

    void main(void)
    {
    }

    as you please! depending of what u wanna do:
    Ünicode¬>world = 10.0£

  5. #5
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    It's void main() btw. And in anticipation of the next question, here's how you do it:
    Code:
    main(void){int(c)=6,_c=1,c_=32;o:c>0?printf("%*c%0*c\n",c--,c_,_c,'0'):exit(0),_c+=2;goto o;}
    -Prelude
    My best code is written with the delete key.

  6. #6
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    And what, pray tell, does that exactly do, fairest Prelude?
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  7. #7
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Originally posted by Prelude
    It's void main() btw. And in anticipation of the next question, here's how you do it:
    Code:
    main(void){int(c)=6,_c=1,c_=32;o:c>0?printf("%*c%0*c\n",c--,c_,_c,'0'):exit(0),_c+=2;goto o;}
    -Prelude
    Nice triange man! neat code too. Figure that one out later....! When my brain is awake more
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  8. #8
    www.entropysink.com
    Join Date
    Feb 2002
    Posts
    603
    Originally posted by Prelude


    -Prelude
    ....at least somebody understood. Go on, did you realise before or after you looked at it???

    Unregistered.

    BTW, nice photo!!!

    http://www.geocities.com/Area51/Cave...st/walker.html
    Last edited by RobR; 04-29-2002 at 02:40 PM.
    Visit entropysink.com - It's what your PC is made for!

  9. #9
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >did you realise before or after
    Before since it used my exact wording from the GD board.

    >Nice triange man! neat code too. Figure that one out later....!
    You should see the code I use to answer that question on IRC. Obfuscation like that can cause your brain to explode.

    -Prelude
    My best code is written with the delete key.

  10. #10
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Code:
    sh(int it){if (it>1 && printf("%s",it-70?it&1?"*":" ":(it=0,"\n"))) sh(it>>1);}
    main(int it){char *b="b~bb~~ ~b~~~FbbvvBb<HbHBBF~~jj~~ H~H~~FbbbbBJ<HbHBBFbbbb~R Hb~~B";
    	while(it=*b++) sh(it);
    }
    I stake no claim to coding this one... only adapting it, and even that burnt a good few brain cells ;-)
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  11. #11
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    Not bad. Recursion is fun.
    Code:
    x=6,_x=7,x_=7;main_(x,_x)
    {return(x>0?x_--,main_(x-
    printf("%c",_x),_x):x_);}
    main(){x>0?main_(main_(x,
    32),42),x_+=_x+=1,printf
    ("%c",'\n'),--x,main():0;}
    -Prelude
    My best code is written with the delete key.

  12. #12
    Comment your source code! Lynux-Penguin's Avatar
    Join Date
    Apr 2002
    Posts
    533
    HELP!! I CANNOT BELIEVE WHAT I AM SEEING

    Code:
    #include <myheaderfile.h>
    #define IF_I_NEED_CONSTANTS    1
    
    int main(int argc, char* argv[]) // GOOD!! no void here please
    {
      //CODE HERE
     return 0;  //return with no errors, or set it to return 1; to return with errors
    }
    NO void main.
    void main is ANSI Incorrect
    and ANSI is currently in charge of ANSI C

    -Luke
    Last edited by Lynux-Penguin; 04-29-2002 at 05:43 PM.
    Asking the right question is sometimes more important than knowing the answer.
    Please read the FAQ
    C Reference Card (A MUST!)
    Pointers and Memory
    The Essentials
    CString lib

  13. #13
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    One of the ones I liked best from the Obfucated C contests was a maze genrator who's source code was itself a maze.

    Quzah.
    Hope is the first step on the road to disappointment.

  14. #14
    Comment your source code! Lynux-Penguin's Avatar
    Join Date
    Apr 2002
    Posts
    533
    Had some code here, decided that it was just a waste of time.

    Anyway there was some code for this code on pi
    REALLY REALLY UGLY LOOKING!
    Obfuscate C all the way!
    Last edited by Lynux-Penguin; 04-29-2002 at 06:06 PM.
    Asking the right question is sometimes more important than knowing the answer.
    Please read the FAQ
    C Reference Card (A MUST!)
    Pointers and Memory
    The Essentials
    CString lib

  15. #15
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Originally posted by Prelude
    Not bad. Recursion is fun.
    Code:
    x=6,_x=7,x_=7;main_(x,_x)
    {return(x>0?x_--,main_(x-
    printf("%c",_x),_x):x_);}
    main(){x>0?main_(main_(x,
    32),42),x_+=_x+=1,printf
    ("%c",'\n'),--x,main():0;}
    -Prelude
    Do you write any of these yourself? If so, please stop it; my head hurts
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed