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 == '"' && state == 2) { state = -1; } 43 else if (l == '"' && state == -1) { state = 2; } 44 else if (l == s.line_ending && state == 2) 45 { 46 if (blc.length > 0) 47 arg.outType = arg.outType ~ blc; 48 49 state = 0; 50 if (fname == "mod") 51 { 52 if (s.use_mod) 53 s.toplevel_header = kyle_vararg!(string).kyle_convert_argument(0, arg); 54 } 55 else if (fname in s.deles) 56 { 57 s.deles[fname](arg, s); 58 } 59 60 blc = ""; 61 arg = new kyle_arguments(); 62 } 63 else if (l == s.comment_op && state >= 0) 64 { 65 state = 6; 66 } 67 else if (l == s.comment_break && state == 6) 68 { 69 blc = ""; 70 state = 0; 71 continue; 72 } 73 else if (l == '\n' && state == 0) 74 continue; 75 76 else if (l == s.line_ending && state == 1) 77 { 78 s.err = true; 79 s.errmsg = ("unexpected token '#', maybe `;' was needed?"); 80 } 81 else 82 { 83 blc = blc ~ l; 84 } 85 } 86 }