Professional Documents
Culture Documents
CD PR 9
CD PR 9
Program:
%{
#include <stdio.h>
#include <stdlib.h>
int temp_count = 1;
%}
DIGIT [0-9]
IDENTIFIER [a-zA-Z_][a-zA-Z0-9_]*
WS [ \t\n]+
%%
%%
int yywrap(void) {
int main() {
char input_buffer[1024];
temp_count = 1;
yy_scan_string(input_buffer);
yylex();
return 0;
Output:
mgm14@MGM14 ~ % cd Desktop
t1 = g
t2 = t1 + t0
t3 = j
Invalid input: =
t4 = s
t1 = 2
t2 = t1 + t0
t3 = 12
Invalid input: =
t4 = 7