1 module la;
2 
3 // load array
4 
5 import ho;
6 import hst;
7 import std.stdio;
8 import hcb;
9 import he;
10 import std.string;
11 import stat;
12 import he;
13 import exutil;
14 import hchars;
15 
16 void handy_parse_result(handy_state s, string arr)
17 {
18     auto state = hand_parse_state.idle;
19     string bf = "";
20     foreach (char l; arr)
21     {
22         if (l == '[' && state == hand_parse_state.idle)
23         {
24             state = hand_parse_state.collecting;
25         }
26         else if (handy_contains(s, l))
27         {
28             if (handy_excl_status(s, l) == handy_charstate.stringlike && state == hand_parse_state
29                 .collecting)
30             {
31                 state = hand_parse_state.ignorant;
32             }
33             else if (handy_excl_status(s, l) == handy_charstate.stringlike && state == hand_parse_state
34                 .ignorant)
35             {
36                 state = hand_parse_state.collecting;
37             }
38         }
39 
40         else if (l == ',' && state == hand_parse_state.collecting)
41         {
42             s.result = s.result ~ strip(bf);
43             if (s.allow_cb)
44                 handy_run_callback(s, strip(bf));
45 
46             bf = "";
47         }
48 
49         else if (l == ']' && state == hand_parse_state.collecting)
50         {
51             if (bf.length > 0)
52             {
53                 s.result = s.result ~ strip(bf);
54                 if (s.allow_cb)
55                     handy_run_callback(s, strip(bf));
56             }
57             bf = "";
58 
59             state = hand_parse_state.dead;
60 
61         }
62         else if (l == ']' && state != hand_parse_state.collecting)
63         {
64             throw new HandyBadToken("]");
65         }
66         else if (l == '[' && state == hand_parse_state.dead)
67         {
68             throw new HandyNonMultipleException("Multiple array instances are not allowed.");
69         }
70         else
71         {
72             bf = bf ~ l;
73         }
74 
75     }
76 }