Advertisement
nich1616

objc to c converter in c

Jan 16th, 2014
2,515
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Vala 1.91 KB | None | 0 0
  1. public class compiler{
  2.     string filename = "main.m";
  3.     string[] functions;
  4.     string text;
  5.  
  6.     char[] letters;
  7.     int length;
  8.  
  9.     public compiler()
  10.     {
  11.         FileUtils.get_contents (filename, out text);
  12.     }
  13.    
  14.     char[] string_to_char_array(string str) {
  15.         char[] char_array = new char[str.length];
  16.  
  17.         for (int i = 0; i < str.length; i++){
  18.         char_array[i] = (char)str.get_char(str.index_of_nth_char(i));
  19.         }
  20.  
  21.         return char_array;
  22.     }
  23.     void doit ()
  24.     {
  25.         stdout.printf("1");
  26.         char[] char_array = string_to_char_array(text);
  27.         stdout.printf("2");
  28.         for (int i=0; i < char_array.length; i++) {
  29.             //stdout.printf("-");
  30.             //stdout.printf("%c", char_array[i]);
  31.             //stdout.printf("-");
  32.             if(char_array[i] == (char)"-")
  33.             {
  34.                 stdout.printf("4");
  35.                 if(char_array[i + 1] == (char)" ")
  36.                 {
  37.                 stdout.printf("5");
  38.                     if(char_array[i + 2] == (char)"(")
  39.                     {
  40.                     stdout.printf("6");
  41.                     //int a = i + 2;
  42.                     //functions += assemble(char_array, a, get_howlong(char_array, a));
  43.                     bool quit = false;
  44.                     int index = i + 2;
  45.                     int start = index;
  46.                     string finale_string;
  47.  
  48.                     stdout.printf("7");
  49.                     while (quit == false)
  50.                     {
  51.                         stdout.printf("8");
  52.                         if(char_array[index] == (char)")")
  53.                         {
  54.                             stdout.printf("9");
  55.                             quit = true;
  56.                             length = index - start;
  57.                         }
  58.                         else
  59.                         {
  60.                             stdout.printf("10");
  61.                             index++;
  62.                         }
  63.                     }
  64.  
  65.                     stdout.printf("11");
  66.                     for(var k = i + 2; k < length; k++)
  67.                     {
  68.                         stdout.printf("12-");
  69.                         letters += char_array[k];
  70.                     }
  71.                     stdout.printf("13");
  72.                     finale_string = (string)letters;
  73.                     functions += finale_string;
  74.                     stdout.printf("14");
  75.  
  76.                     //end
  77.                     }
  78.                 }
  79.             }
  80.         }
  81.         for(var a = 0; a < functions.length; a++)
  82.         {
  83.             stdout.printf("%s\n + hey", functions[a]);
  84.         }
  85.     }
  86.     static int main (string[] args) {
  87.         compiler _compiler = new compiler();
  88.         _compiler.doit();
  89.         return 0;
  90.     }
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement