Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   parser for c language help me (http://www.go4expert.com/forums/parser-c-language-help-t10912/)

~bleach~ 30May2008 00:22

parser for c language help me
 
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();
}



All times are GMT +5.5. The time now is 23:32.