1 module exec; 2 3 import std.stdio; 4 5 // contains the stuff for like the language.. 6 7 import kobj; 8 import cv; 9 import std.string; 10 import std.algorithm; 11 import va; 12 13 void kyle_execute(kyle_state s) 14 { 15 int state = 0; 16 string blc; 17 string fname; 18 kyle_arguments arg = new kyle_arguments(); 19 foreach (char l; s.supplied_code) 20 { 21 if (s.err) 22 break; 23 if (l == '#' && state == 0) 24 { 25 state = 1; 26 blc = ""; 27 } 28 else if (l == ' ' && state == 1) 29 { 30 state = 2; 31 fname = strip(blc); 32 blc = ""; 33 } 34 else if (l == ' ' && state == 2) 35 { 36 if (blc.length > 0) 37 { 38 arg.outType = arg.outType ~ blc; 39 blc = ""; 40 } 41 } 42 else if (l == s.line_ending && state == 2) 43 { 44 if (blc.length > 0) 45 arg.outType = arg.outType ~ blc; 46 47 state = 0; 48 if (fname == "mod") 49 { 50 if (s.use_mod) 51 s.toplevel_header = kyle_vararg!(string).kyle_convert_argument(0, arg); 52 } 53 else if (fname in s.deles) 54 { 55 s.deles[fname](arg, s); 56 } 57 58 blc = ""; 59 arg = new kyle_arguments(); 60 } 61 else if (l == s.comment_op && state >= 0) 62 { 63 state = 6; 64 } 65 else if (l == s.comment_break && state == 6) 66 { 67 blc = ""; 68 state = 0; 69 continue; 70 } 71 else if (l == '\n' && state == 0) 72 continue; 73 74 else if (l == s.line_ending && state == 1) 75 { 76 s.err = true; 77 s.errmsg = ("unexpected token '#', maybe `;' was needed?"); 78 } 79 else 80 { 81 blc = blc ~ l; 82 } 83 } 84 }