View Javadoc

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