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(); }


LinkBack URL
About LinkBacks




Reply With Quote




Bookmarks
Algorithms and Data Structures
Java tutorials
Algorithms Forum