Exmples of lex programs

Tuesday, 1 April 2014

12. Lex program to put every line in parenthesis

The program puts every line in parenthesis.
For example

I am going
We are going

appears

{I am going}
{We are going}

Here is the code :

%{
   
%}
%%
[a-z A-Z]+ {printf("{%s}",yytext);}
%%

main()
{
extern FILE *yyin;
yyin=fopen("new","r");
yylex();
}

Posted by amrutansu at 09:41
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

About Me

amrutansu
View my complete profile

Blog Archive

  • ▼  2014 (15)
    • ▼  April (15)
      • 15. Lex program to count number of spaces in the file
      • 14. Lex program to remove every word that start wi...
      • 13.Lex program to print every words in parenthesis
      • 12. Lex program to put every line in parenthesis
      • 11. Lex program to remove all newline characters
      • 10.Lex program to print every lines in a file with...
      • 9. Lex program to view file contents with double l...
      • 8. Lex program to extract email IDs from a file
      • 7. Lex program to count the number of vowels in a ...
      • 6.Lex program to print words in a file that starts...
      • 5. Lex program to print the words in a file that d...
      • 4. Lex program to check whether an year is a leap...
      • 3. Lex program to search a word in a file
      • 2.Lex program to check perfect numbers
      • 1.To check whether the given number in the file is...
Simple theme. Powered by Blogger.