1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

parser for c language help me

Discussion in 'C' started by ~bleach~, May 29, 2008.

  1. ~bleach~

    ~bleach~ New Member

    Joined:
    May 29, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    parser for c language help me

    --------------------------------------------------------------------------------

    i want parser in language


    i have grammer is that

    SS->AAaBBb

    AA->a|b

    BB->aAA

    this a letter for language a ,b



    Code:
    int lexan()
    {
    int lookahead;
    
    lookahead=getchar();
    
    return t;
    }
    int match(int t)
    {
    if(lookahead==t)
    lookahead=lexan();
    else error();
    return lookahead;
    }
    void error()
    {
    printf(" error syntax");
    }
    void SS()
    {
    AA();
    if(lookahead=='a')
    match('a');
    else error();
    BB();
    if(lookahead=='b')
    match('b');
    else error();
    }
    
    void AA()
    {
    if(lookahead=='a')
    match('a');
    else error();
    
    if(lookahead=='b')
    match('b');
    else error();
    
    }
    void BB()
    {
    if(lookahead=='a')
    match('a');
    else error();
    AA();
    }
     
    Last edited by a moderator: May 30, 2008

Share This Page