View Javadoc

1   /**
2    * Copyright (c) 2008-2011, http://www.snakeyaml.org
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  // line 1 "RagelMachine.rl"
18  package org.yaml.snakeyaml.resolver;
19  
20  //Source for Ragel 6.3
21  
22  /**
23   * Generated by Ragel 6.3 (http://www.complang.org/ragel/)
24   * 
25   * @see http://www.complang.org/ragel/
26   */
27  public class RagelMachine {
28  
29      // line 15 "RagelMachine.java"
30      private static byte[] init__snakeyaml_actions_0() {
31          return new byte[] { 0, 1, 0, 1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6 };
32      }
33  
34      private static final byte _snakeyaml_actions[] = init__snakeyaml_actions_0();
35  
36      private static short[] init__snakeyaml_key_offsets_0() {
37          return new short[] { 0, 0, 20, 24, 28, 30, 32, 34, 35, 36, 37, 42, 46, 50, 52, 56, 59, 66,
38                  70, 74, 80, 82, 83, 84, 85, 87, 90, 92, 98, 102, 105, 106, 108, 110, 111, 113, 115,
39                  120, 122, 124, 126, 130, 132, 133, 135, 141, 147, 152, 157, 158, 160, 161, 162,
40                  163, 164, 165, 166, 170, 171, 172, 173, 174, 178, 179, 180, 182, 183, 184, 186,
41                  187, 188, 189, 191, 193, 194, 195, 195, 200, 202, 202, 211, 218, 224, 227, 234,
42                  239, 243, 245, 250, 253, 254, 263, 270, 277, 285, 291, 294, 295, 295, 302, 306,
43                  311, 316, 321, 327, 327, 327 };
44      }
45  
46      private static final short _snakeyaml_key_offsets[] = init__snakeyaml_key_offsets_0();
47  
48      private static char[] init__snakeyaml_trans_keys_0() {
49          return new char[] { 32, 43, 45, 46, 48, 60, 61, 70, 78, 79, 84, 89, 102, 110, 111, 116,
50                  121, 126, 49, 57, 46, 48, 49, 57, 73, 105, 48, 57, 43, 45, 48, 57, 78, 110, 70,
51                  102, 110, 46, 58, 95, 48, 57, 48, 53, 54, 57, 46, 58, 48, 57, 46, 58, 46, 95, 48,
52                  57, 95, 48, 49, 95, 48, 57, 65, 70, 97, 102, 48, 53, 54, 57, 48, 53, 54, 57, 73,
53                  78, 105, 110, 48, 57, 65, 97, 78, 97, 110, 48, 57, 45, 48, 57, 48, 57, 9, 32, 84,
54                  116, 48, 57, 9, 32, 48, 57, 58, 48, 57, 58, 48, 57, 48, 57, 58, 48, 57, 48, 57, 9,
55                  32, 43, 45, 90, 48, 57, 48, 57, 48, 57, 9, 32, 84, 116, 48, 57, 45, 48, 57, 9, 32,
56                  84, 116, 48, 57, 45, 46, 58, 95, 48, 57, 46, 58, 95, 48, 57, 46, 58, 95, 48, 57,
57                  60, 65, 97, 76, 83, 69, 108, 115, 101, 79, 85, 111, 117, 76, 76, 108, 108, 70, 78,
58                  102, 110, 70, 102, 82, 114, 85, 117, 69, 101, 83, 115, 97, 111, 117, 102, 110, 114,
59                  101, 69, 95, 101, 48, 57, 48, 57, 46, 58, 95, 98, 120, 48, 55, 56, 57, 46, 58, 95,
60                  48, 55, 56, 57, 46, 95, 48, 55, 56, 57, 95, 48, 49, 95, 48, 57, 65, 70, 97, 102,
61                  46, 58, 95, 48, 57, 46, 58, 48, 57, 46, 58, 46, 58, 95, 48, 57, 58, 48, 57, 58, 46,
62                  58, 95, 98, 120, 48, 55, 56, 57, 46, 58, 95, 48, 55, 56, 57, 46, 58, 95, 48, 55,
63                  56, 57, 45, 46, 58, 95, 48, 55, 56, 57, 9, 32, 43, 45, 46, 90, 58, 48, 57, 58, 9,
64                  32, 43, 45, 90, 48, 57, 9, 32, 84, 116, 46, 58, 95, 48, 57, 46, 58, 95, 48, 57, 46,
65                  58, 95, 48, 57, 45, 46, 58, 95, 48, 57, 0 };
66      }
67  
68      private static final char _snakeyaml_trans_keys[] = init__snakeyaml_trans_keys_0();
69  
70      private static byte[] init__snakeyaml_single_lengths_0() {
71          return new byte[] { 0, 18, 2, 2, 2, 0, 2, 1, 1, 1, 3, 0, 2, 2, 2, 1, 1, 0, 0, 4, 2, 1, 1,
72                  1, 0, 1, 0, 4, 2, 1, 1, 0, 0, 1, 0, 0, 5, 0, 0, 0, 4, 0, 1, 0, 4, 4, 3, 3, 1, 2, 1,
73                  1, 1, 1, 1, 1, 4, 1, 1, 1, 1, 4, 1, 1, 2, 1, 1, 2, 1, 1, 1, 2, 2, 1, 1, 0, 3, 0, 0,
74                  5, 3, 2, 1, 1, 3, 2, 2, 3, 1, 1, 5, 3, 3, 4, 6, 1, 1, 0, 5, 4, 3, 3, 3, 4, 0, 0, 0 };
75      }
76  
77      private static final byte _snakeyaml_single_lengths[] = init__snakeyaml_single_lengths_0();
78  
79      private static byte[] init__snakeyaml_range_lengths_0() {
80          return new byte[] { 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 2, 1, 0, 1, 1, 3, 2, 2, 1, 0, 0, 0, 0,
81                  1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0,
82                  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 2,
83                  2, 2, 1, 3, 1, 1, 0, 1, 1, 0, 2, 2, 2, 2, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0 };
84      }
85  
86      private static final byte _snakeyaml_range_lengths[] = init__snakeyaml_range_lengths_0();
87  
88      private static short[] init__snakeyaml_index_offsets_0() {
89          return new short[] { 0, 0, 20, 24, 28, 31, 33, 36, 38, 40, 42, 47, 50, 54, 57, 61, 64, 69,
90                  72, 75, 81, 84, 86, 88, 90, 92, 95, 97, 103, 107, 110, 112, 114, 116, 118, 120,
91                  122, 128, 130, 132, 134, 139, 141, 143, 145, 151, 157, 162, 167, 169, 172, 174,
92                  176, 178, 180, 182, 184, 189, 191, 193, 195, 197, 202, 204, 206, 209, 211, 213,
93                  216, 218, 220, 222, 225, 228, 230, 232, 233, 238, 240, 241, 249, 255, 260, 263,
94                  268, 273, 277, 280, 285, 288, 290, 298, 304, 310, 317, 324, 327, 329, 330, 337,
95                  342, 347, 352, 357, 363, 364, 365 };
96      }
97  
98      private static final short _snakeyaml_index_offsets[] = init__snakeyaml_index_offsets_0();
99  
100     private static byte[] init__snakeyaml_indicies_0() {
101         return new byte[] { 0, 2, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 5, 1, 18,
102                 19, 20, 1, 22, 23, 21, 1, 24, 24, 1, 25, 1, 26, 27, 1, 28, 1, 28, 1, 27, 1, 21, 30,
103                 31, 29, 1, 32, 33, 1, 25, 30, 33, 1, 25, 30, 1, 21, 31, 31, 1, 34, 34, 1, 35, 35,
104                 35, 35, 1, 36, 37, 1, 38, 39, 1, 22, 40, 23, 41, 21, 1, 42, 42, 1, 28, 1, 43, 1,
105                 28, 1, 44, 1, 45, 46, 1, 47, 1, 48, 48, 50, 50, 49, 1, 48, 48, 51, 1, 53, 52, 1,
106                 53, 1, 54, 1, 55, 1, 56, 1, 57, 1, 58, 1, 59, 59, 60, 60, 61, 1, 62, 1, 63, 1, 61,
107                 1, 48, 48, 50, 50, 1, 51, 1, 64, 1, 65, 1, 48, 48, 50, 50, 66, 1, 67, 21, 30, 31,
108                 29, 1, 21, 30, 31, 68, 1, 21, 30, 31, 69, 1, 70, 1, 71, 72, 1, 73, 1, 74, 1, 75, 1,
109                 76, 1, 77, 1, 75, 1, 75, 78, 75, 79, 1, 80, 1, 0, 1, 81, 1, 0, 1, 82, 75, 83, 75,
110                 1, 75, 1, 75, 1, 84, 85, 1, 74, 1, 77, 1, 86, 87, 1, 75, 1, 75, 1, 72, 1, 75, 79,
111                 1, 83, 75, 1, 85, 1, 87, 1, 1, 88, 21, 88, 21, 1, 25, 1, 1, 21, 30, 90, 91, 92, 89,
112                 29, 1, 21, 30, 90, 89, 29, 1, 21, 90, 90, 31, 1, 34, 34, 1, 35, 35, 35, 35, 1, 21,
113                 93, 94, 20, 1, 25, 93, 37, 1, 25, 93, 1, 21, 95, 94, 94, 1, 95, 39, 1, 95, 1, 21,
114                 30, 90, 91, 92, 96, 97, 1, 21, 30, 90, 98, 69, 1, 21, 30, 90, 99, 68, 1, 67, 21,
115                 30, 90, 89, 29, 1, 59, 59, 60, 60, 100, 61, 1, 102, 101, 1, 102, 1, 1, 59, 59, 60,
116                 60, 61, 100, 1, 48, 48, 50, 50, 1, 21, 93, 94, 103, 1, 21, 93, 94, 104, 1, 21, 93,
117                 94, 105, 1, 67, 21, 93, 94, 20, 1, 1, 1, 1, 0 };
118     }
119 
120     private static final byte _snakeyaml_indicies[] = init__snakeyaml_indicies_0();
121 
122     private static byte[] init__snakeyaml_trans_targs_0() {
123         return new byte[] { 75, 0, 2, 19, 90, 100, 48, 105, 49, 56, 61, 64, 67, 70, 71, 72, 73, 74,
124                 3, 79, 84, 76, 6, 9, 5, 77, 7, 8, 78, 10, 11, 14, 12, 13, 82, 83, 85, 86, 88, 89,
125                 20, 22, 21, 23, 25, 26, 42, 27, 28, 40, 41, 29, 30, 31, 32, 33, 34, 35, 94, 36, 37,
126                 97, 95, 39, 43, 44, 99, 24, 45, 46, 104, 50, 53, 51, 52, 106, 54, 55, 57, 59, 58,
127                 60, 62, 63, 65, 66, 68, 69, 4, 80, 81, 15, 16, 17, 87, 18, 91, 47, 92, 93, 98, 96,
128                 38, 101, 102, 103 };
129     }
130 
131     private static final byte _snakeyaml_trans_targs[] = init__snakeyaml_trans_targs_0();
132 
133     // private static byte[] init__snakeyaml_trans_actions_0() {
134     // return new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
135     // 0, 0, 0, 0, 0, 0,
136     // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
137     // 0, 0, 0, 0,
138     // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
139     // 0, 0, 0, 0,
140     // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
141     // 0, 0 };
142     // }
143 
144     // private static final byte _snakeyaml_trans_actions[] =
145     // init__snakeyaml_trans_actions_0();
146 
147     private static byte[] init__snakeyaml_eof_actions_0() {
148         return new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
149                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
150                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 11, 11, 11,
151                 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 13, 13, 13, 13, 13, 13, 9, 9, 9, 9, 3,
152                 7, 1 };
153     }
154 
155     private static final byte _snakeyaml_eof_actions[] = init__snakeyaml_eof_actions_0();
156 
157     static final int snakeyaml_start = 1;
158     static final int snakeyaml_error = 0;
159 
160     static final int snakeyaml_en_main = 1;
161 
162     // line 53 "RagelMachine.rl"
163 
164     public String scan(String scalar) {
165         if (scalar == null) {
166             throw new NullPointerException("Scalar must be provided.");
167         }
168         String tag = null;
169         int cs = 0;
170         int p = 0;
171         int pe = scalar.length();
172         int eof = pe;
173         char[] data;
174         if (pe == 0) {
175             // NULL value
176             data = new char[] { '~' };
177             pe = 1;
178             eof = 1;
179         } else {
180             data = scalar.toCharArray();
181         }
182 
183         // line 257 "RagelMachine.java"
184         {
185             cs = snakeyaml_start;
186         }
187 
188         // line 262 "RagelMachine.java"
189         {
190             int _klen;
191             int _trans = 0;
192             int _keys;
193             int _goto_targ = 0;
194 
195             _goto: while (true) {
196                 switch (_goto_targ) {
197                 case 0:
198                     if (p == pe) {
199                         _goto_targ = 4;
200                         continue _goto;
201                     }
202                     if (cs == 0) {
203                         _goto_targ = 5;
204                         continue _goto;
205                     }
206                 case 1:
207                     _match: do {
208                         _keys = _snakeyaml_key_offsets[cs];
209                         _trans = _snakeyaml_index_offsets[cs];
210                         _klen = _snakeyaml_single_lengths[cs];
211                         if (_klen > 0) {
212                             int _lower = _keys;
213                             int _mid;
214                             int _upper = _keys + _klen - 1;
215                             while (true) {
216                                 if (_upper < _lower)
217                                     break;
218 
219                                 _mid = _lower + ((_upper - _lower) >> 1);
220                                 if (data[p] < _snakeyaml_trans_keys[_mid])
221                                     _upper = _mid - 1;
222                                 else if (data[p] > _snakeyaml_trans_keys[_mid])
223                                     _lower = _mid + 1;
224                                 else {
225                                     _trans += (_mid - _keys);
226                                     break _match;
227                                 }
228                             }
229                             _keys += _klen;
230                             _trans += _klen;
231                         }
232 
233                         _klen = _snakeyaml_range_lengths[cs];
234                         if (_klen > 0) {
235                             int _lower = _keys;
236                             int _mid;
237                             int _upper = _keys + (_klen << 1) - 2;
238                             while (true) {
239                                 if (_upper < _lower)
240                                     break;
241 
242                                 _mid = _lower + (((_upper - _lower) >> 1) & ~1);
243                                 if (data[p] < _snakeyaml_trans_keys[_mid])
244                                     _upper = _mid - 2;
245                                 else if (data[p] > _snakeyaml_trans_keys[_mid + 1])
246                                     _lower = _mid + 2;
247                                 else {
248                                     _trans += ((_mid - _keys) >> 1);
249                                     break _match;
250                                 }
251                             }
252                             _trans += _klen;
253                         }
254                     } while (false);
255 
256                     _trans = _snakeyaml_indicies[_trans];
257                     cs = _snakeyaml_trans_targs[_trans];
258 
259                 case 2:
260                     if (cs == 0) {
261                         _goto_targ = 5;
262                         continue _goto;
263                     }
264                     if (++p != pe) {
265                         _goto_targ = 1;
266                         continue _goto;
267                     }
268                 case 4:
269                     if (p == eof) {
270                         int __acts = _snakeyaml_eof_actions[cs];
271                         int __nacts = (int) _snakeyaml_actions[__acts++];
272                         while (__nacts-- > 0) {
273                             switch (_snakeyaml_actions[__acts++]) {
274                             case 0:
275                                 // line 14 "RagelMachine.rl"
276                             {
277                                 tag = "tag:yaml.org,2002:bool";
278                             }
279                                 break;
280                             case 1:
281                                 // line 15 "RagelMachine.rl"
282                             {
283                                 tag = "tag:yaml.org,2002:merge";
284                             }
285                                 break;
286                             case 2:
287                                 // line 16 "RagelMachine.rl"
288                             {
289                                 tag = "tag:yaml.org,2002:null";
290                             }
291                                 break;
292                             case 3:
293                                 // line 17 "RagelMachine.rl"
294                             {
295                                 tag = "tag:yaml.org,2002:value";
296                             }
297                                 break;
298                             case 4:
299                                 // line 18 "RagelMachine.rl"
300                             {
301                                 tag = "tag:yaml.org,2002:int";
302                             }
303                                 break;
304                             case 5:
305                                 // line 19 "RagelMachine.rl"
306                             {
307                                 tag = "tag:yaml.org,2002:float";
308                             }
309                                 break;
310                             case 6:
311                                 // line 20 "RagelMachine.rl"
312                             {
313                                 tag = "tag:yaml.org,2002:timestamp";
314                             }
315                                 break;
316                             // line 377 "RagelMachine.java"
317                             }
318                         }
319                     }
320 
321                 case 5:
322                 }
323                 break;
324             }
325         }
326         // line 77 "RagelMachine.rl"
327 
328         return tag;
329     }
330 }