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
I'm not clear on what you're asking for here.
Also, please use code tags with your code.
Indentation wouldn't hurt either....
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
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.
yes and i want it like parser compiler
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.
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
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.
ok thank you
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks