[Ilugc] Tokenizer in python

  • From: balachandarlinks@xxxxxxxxx (Balachandar)
  • Date: Mon Jan 11 12:13:57 2010

Hi guys,
   I want to parse a "C source code file" using python.I want to separate each
and every string in the c file to process in python.

For example,
  #include<stdio.h>
  int main()
  {
     int i=0;
     for(i=0;i<10;i++)
     {
       printf("i = %d",i);
     }
     return(0);
  }

Then i want to tokenize this file like this.

#include<stdio.h>
int,main,(,),{,int,i,=,0,;,for,(,i,=,0,i,<,10 ....( Like that i want to parse
the entire file)

I am new to python.I tried split command.But it can split by using separator.So
i cant exactly tokenize the file as i like.Guys i am really in need of doing
this.Waiting for your replies.
             Thank you.

-with regards,
  Balachandar.K.M < LOVE WITH LINUX >
  http://infoqueue.wordpress.com


Other related posts: