Flex program to check use of the function yyterminate()

Flex program to check use of the function yyterminate()

This flex program is to check use of yyterminate() function. The yyterminate() function ends the execution of the program as soon as it is called. Check the output below to get a clearer picture.

Program

%{
/* Implementation of yyterminate() */
#undef yywrap
#define yywrap() 1

%}

%%

[a-z]+ {
	printf("\nlowercase word = ");
	ECHO;
	printf("\nStart of yyteminate()");
	yyterminate();
	printf("\nEnd of yyterminate");
}

[a-zA-Z]+ {
	printf("\nmixed word = " );
	ECHO;
}

%%

main()
{
	yylex();
}

Output

Share Me!