Yacc
Yacc
Subject Presentation on
YACC
YACC (Yet Another Compiler Compiler) is a powerful tool used in compiler design. Let’s delve into what YACC is
and how it fits into the world of language processing:
1.What is YACC?
• YACC is an LALR (1) (LookAhead, Left-to-right, Rightmost derivation producer with 1 lookahead
token) parser generator.
• It generates a bottom-up parser for a grammar-based language.
• Essentially, YACC helps create the syntactic analyzer (parser) for a language based on a given grammar.
%%
Lines : Lines S '\n' { printf("OK \n"); }
| S '\n’
| error '\n' {yyerror("Error: reenter last line:");
yyerrok; };
S : '(' S ')’
| '[' S ']’
| /* empty */ ;
%%
#include "lex.yy.c"
void yyerror(char * s)
/* yacc error handler */
{
fprintf (stderr, "%s\n", s);
}
int main(void)
{
return yyparse();
}
This command converts the file translate.y into a C file
y.tab.c.
THANK YOU…….