/* Write a Lex program that implements the Caesar cipher: it replaces every letter
with the one three letters after in in alphabetical order, wrapping around at Z.
e.g. a is replaced by d, b by e, and so on z by c. */
%%
[a-z] {char cipher_char = yytext[0];
cipher_char += 3;
if (cipher_char> 'z') cipher_char -= ('z'+1- 'a');
printf ("%c" ,cipher_char );
}
[A-Z] { char cipher_char = yytext[0] ;
cipher_char += 3;
if (cipher_char> 'Z') cipher_char -= ('Z'+1- 'A');
printf("%c",cipher_char);
}
%%
/*Output of this program*/
Is there is not use of transition function?
ReplyDelete