+ Reply to Thread
Page 1 of 2
1 2 LastLast
Results 1 to 10 of 19

Thread: parser for c language help me

  1. #1
    Newbie ~bleach~ is an unknown quantity at this point
    Join Date
    May 2008
    Posts
    15

    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 01:45 PM. Reason: add code tags

  2. #2
    Super Moderator WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther's Avatar
    Join Date
    Jul 2006
    Age
    36
    Posts
    11,673
    Blog Entries
    57

    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.
    CodeCall Blog | CodeCall Wiki | Shareware
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  3. #3
    MeTh0Dz is a name known to all MeTh0Dz is a name known to all MeTh0Dz is a name known to all MeTh0Dz is a name known to all MeTh0Dz is a name known to all MeTh0Dz is a name known to all
    Join Date
    May 2008
    Posts
    475

    Re: parser for c language help me

    Indentation wouldn't hurt either....

  4. #4
    Newbie ~bleach~ is an unknown quantity at this point
    Join Date
    May 2008
    Posts
    15

    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

  5. #5
    MeTh0Dz is a name known to all MeTh0Dz is a name known to all MeTh0Dz is a name known to all MeTh0Dz is a name known to all MeTh0Dz is a name known to all MeTh0Dz is a name known to all
    Join Date
    May 2008
    Posts
    475

    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.

  6. #6
    Newbie ~bleach~ is an unknown quantity at this point
    Join Date
    May 2008
    Posts
    15

    Re: parser for c language help me

    yes and i want it like parser compiler

  7. #7
    MeTh0Dz is a name known to all MeTh0Dz is a name known to all MeTh0Dz is a name known to all MeTh0Dz is a name known to all MeTh0Dz is a name known to all MeTh0Dz is a name known to all
    Join Date
    May 2008
    Posts
    475

    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.

  8. #8
    Newbie ~bleach~ is an unknown quantity at this point
    Join Date
    May 2008
    Posts
    15

    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

  9. #9
    MeTh0Dz is a name known to all MeTh0Dz is a name known to all MeTh0Dz is a name known to all MeTh0Dz is a name known to all MeTh0Dz is a name known to all MeTh0Dz is a name known to all
    Join Date
    May 2008
    Posts
    475

    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.

  10. #10
    Newbie ~bleach~ is an unknown quantity at this point
    Join Date
    May 2008
    Posts
    15

    Re: parser for c language help me

    ok thank you

+ Reply to Thread
Page 1 of 2
1 2 LastLast

Thread Information

Users Browsing this Thread

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

     

Similar Threads

  1. new C-like programming language
    By kenna in forum Software Development Tools
    Replies: 14
    Last Post: 09-03-2008, 02:34 PM
  2. TTCN3, The testing language
    By MrJack in forum General Programming
    Replies: 1
    Last Post: 01-19-2008, 09:48 AM
  3. What language is best to learn for message boards?
    By Fr0st2k in forum Website Design
    Replies: 4
    Last Post: 11-11-2007, 10:31 AM
  4. Language... Games.
    By trivia in forum General Programming
    Replies: 11
    Last Post: 10-27-2007, 09:48 AM
  5. What language to Learn?
    By mevets in forum General Programming
    Replies: 20
    Last Post: 12-20-2006, 09:04 AM

Bookmarks

Bookmarks

     
        Algorithms and Data Structures

        Java tutorials

        Algorithms Forum

Posting Permissions

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