YACC Program to Identify Function Declaration Syntax
Yacc program to identify function declaration syntax and semantics using regular expressions
Lex Program:
%{
#include<stdio.h>
#include "y.tab.h"
%}
%%
void|int|float|char return BUILTIN;
, return COMMA;
; return SC;
n return NL;
( return LP;
) return RP;
[a-zA-Z0-9]* return ID;
%%
YACC Program:
%{
#include<stdio.h>
#include "y.tab.h"
%}
%token COMMA ID BUILTIN SC NL RP LP
%%
var:datatype varlist LP FUNCT RP SC NL {printf("VAlid declaration");}
|
datatype: BUILTIN;
|
varlist: ID;
|
FUNCT: FUNCT COMMA ID|FUNCT COMMA BUILTIN|BUILTIN|ID;
%%
void yyerror(const char *str){printf("error");}
int yywrap(){return 1;}
main(){yyparse();}
Recent Comments