1 module xp;
2 
3 // Expressions.
4 
5 import xps;
6 import ec;
7 import st;
8 
9 import std.typecons : tuple, Tuple;
10 import std.stdio;
11 import std.string;
12 import std.algorithm;
13 
14 // This functions returns two values.
15 Tuple!(string[], kyle_expr_type) kyle_each_side(string Full)
16 {
17     state C = state.idle;
18     kyle_expr_type t;
19     string b;
20     string[] g;
21 
22     foreach (char s; Full)
23     {
24         if (s == '=' && C == state.idle)
25         {
26             if (b.length > 0)
27             {
28                 C = state.collecting;
29                 g = g ~ strip(b);
30                 b = "";
31             }
32         }
33         else if (s == '=' && C == state.collecting)
34         {
35             if (b.length > 0)
36             {
37 
38                 t = kyle_expr_type.compareTo;
39                 b = "";
40             }
41             C = state.idle;
42         }
43         else
44         {
45             b = b ~ s;
46         }
47     }
48 
49 
50     if (b.length > 0 && t == kyle_expr_type.compareTo)
51         g = g ~ strip(b);
52 
53     if (g.length == 1) /*suspicious*/
54     t = kyle_expr_type.review;
55 
56     if (C == state.collecting)
57     {
58         throw new KyleAssignOpError("Assignments are not allowed in if blocks.");
59     }
60 
61     return tuple(g, t);
62 }