Académique Documents
Professionnel Documents
Culture Documents
YOUNES ADRAOUI
Exercice1
Exercice 2
%{
#include <stdio.h>
int prev_space = 1;
%}
%%
[[:space:]]+ {
if (!prev_space) {
printf(" ");
prev_space = 1;
[[:alpha:]]+ {
printf("%s", yytext);
prev_space = 0;
%%
int main(int argc, char *argv[]) {
yylex();
fclose(yyin);
return 0;
Exercise 3
%{
#include <string.h>
%}
%%
[[:alpha:]]+ {
if (strlen(yytext) < 4) {
%%
yylex();
return 0;
}
%{
%}
%%
[[:alpha:]]+ {
if (yyleng < 4) {
%%
yylex();
return 0;
%{
%}
%%
[[:alpha:]]{1,3} {
%%
int main(int argc, char *argv[]) {
yylex();
return 0;
Execice 2
%{
#include <stdio.h>
int prev_space = 1;
%}
%%
[[:space:]]+ {
if (!prev_space) {
printf(" ");
prev_space = 1;
[[:alpha:]]+ {
printf("%s", yytext);
prev_space = 0;
%%
yylex();
fclose(yyin);
return 0;
%{
#include <string.h>
#include <stdio.h>
#include <stdbool.h>
int max_length = 0;
char min_word[100];
char max_word[100];
return false;
return true;
%}
%%
[[:alpha:]]+ {
min_length = yyleng;
strcpy(min_word, yytext);
max_length = yyleng;
strcpy(max_word, yytext);
if (is_palindrome(yytext)) {
%%
yylex();
fclose(yyin);
return 0;