Closed Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: parser for c language help me

  1. #1
    ~bleach~ is offline Newbie
    Join Date
    May 2008
    Posts
    15
    Rep Power
    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 WingedPanther; 05-29-2008 at 11:45 AM. Reason: add code tags

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Jul 2006
    Posts
    16,475
    Blog Entries
    75
    Rep Power
    143

    Re: parser for c language help me

    I'm not clear on what you're asking for here.

    Also, please use code tags with your code.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  4. #3
    Join Date
    May 2008
    Posts
    2,126
    Blog Entries
    1
    Rep Power
    33

    Re: parser for c language help me

    Indentation wouldn't hurt either....

  5. #4
    ~bleach~ is offline Newbie
    Join Date
    May 2008
    Posts
    15
    Rep Power
    0

    Re: parser for c language help me

    if we have word is ababab

    this is currect language

    but if we have langauge absddss

    this not belong to our language

    if any word exept letter a and b is currect other is faluse

    i want function for this

  6. #5
    Join Date
    May 2008
    Posts
    2,126
    Blog Entries
    1
    Rep Power
    33

    Re: parser for c language help me

    So you want a function to read a string of text and then check to see if there is any character besides an a or b in it?

    If so that won't be hard to do at all, just check the character/memory at each location in the string.

  7. #6
    ~bleach~ is offline Newbie
    Join Date
    May 2008
    Posts
    15
    Rep Power
    0

    Re: parser for c language help me

    yes and i want it like parser compiler

  8. #7
    Join Date
    May 2008
    Posts
    2,126
    Blog Entries
    1
    Rep Power
    33

    Re: parser for c language help me

    What do you mean? Parsing is a part of a compiler, but it's not a compiler. All that parsing is, is taking a group of characters and analyzing them, then acting on them based on your algorithm or whatever.

  9. #8
    ~bleach~ is offline Newbie
    Join Date
    May 2008
    Posts
    15
    Rep Power
    0

    Re: parser for c language help me

    yes part of it let see we have function s have laguae ab

    we want parse if we enter aaaaaaaabbba

    it's right language

    but if we enter aaaaabaaad

    it's not belong to our language

  10. #9
    Join Date
    May 2008
    Posts
    2,126
    Blog Entries
    1
    Rep Power
    33

    Re: parser for c language help me

    Okay......... I understand that you want to parse a line of text.... But its not like your building a compiler. Just a second and I'll make a sample function.

  11. #10
    ~bleach~ is offline Newbie
    Join Date
    May 2008
    Posts
    15
    Rep Power
    0

    Re: parser for c language help me

    ok thank you

Closed Thread
Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Need help with php dom parser
    By thatsme in forum PHP Development
    Replies: 1
    Last Post: 07-18-2011, 05:00 AM
  2. Irc Parser
    By Warrior in forum Member Software/Projects
    Replies: 2
    Last Post: 07-07-2010, 10:27 AM
  3. help with cfg parser!
    By ASDF_guy in forum The Lounge
    Replies: 1
    Last Post: 05-08-2009, 09:06 AM
  4. XML Parser
    By John_L in forum Perl
    Replies: 1
    Last Post: 05-13-2008, 05:22 PM
  5. Help in SLR parser
    By vithasekar in forum C and C++
    Replies: 3
    Last Post: 02-14-2007, 11:50 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts