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 s1;
21     string[] g;
22     string s2;
23 
24     foreach (char s; Full)
25     {
26         if (s == '=' && C == state.idle)
27         {
28             if (b.length > 0)
29             {
30                 C = state.collecting;
31                 g = g ~ strip(b);
32                 b = "";
33             }
34         }
35         else if (s == '=' && C == state.collecting)
36         {
37             if (b.length > 0)
38             {
39 
40                 t = kyle_expr_type.compareTo;
41                 g = g ~ strip(b);
42                 b = "";
43             }
44             C = state.idle;
45         }
46         else
47         {
48             b = b ~ s;
49         }
50     }
51     if (b.length > 0 && t == kyle_expr_type.compareTo)
52         g = g ~ strip(b);
53 
54     if (C == state.collecting)
55     {
56         throw new KyleAssignOpError("Assignments are not allowed in if blocks.");
57     }
58 
59     return tuple(g, t);
60 }