1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
|
class clang4_java
{
int pos ;
int line ;
private static byte _clang_actions [] = { 0, 1, 0, 1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 2, 0, 2, 2, 1, 0, 2, 3, 1, 2, 3, 2, 2, 4, 1, 2, 4, 2, 2, 5, 1, 2, 5, 2, 2, 6, 1, 2, 6, 2, 2, 7, 1, 2, 7, 2, 2, 8, 1, 2, 8, 2, 3, 3, 1, 0, 3, 4, 1, 0, 3, 5, 1, 0, 3, 6, 1, 0, 3, 7, 1, 0, 3, 8, 1, 0, 0 , };
private static short _clang_key_offsets [] = { 0, 0, 5, 10, 13, 17, 22, 25, 27, 33, 36, 56, 76, 96, 117, 138, 157, 176, 196, 0 , };
private static char _clang_trans_keys [] = { 10, 34, 92, 0, 255, 10, 39, 92, 0, 255, 10, 0, 255, 10, 33, 0, 255, 10, 33, 47, 0, 255, 10, 0, 255, 48, 57, 48, 57, 65, 70, 97, 102, 10, 0, 255, 10, 34, 39, 47, 48, 95, 33, 46, 49, 57, 58, 64, 65, 90, 91, 96, 97, 122, 123, 126, 10, 34, 39, 47, 48, 95, 33, 46, 49, 57, 58, 64, 65, 90, 91, 96, 97, 122, 123, 126, 10, 34, 39, 47, 48, 95, 33, 46, 49, 57, 58, 64, 65, 90, 91, 96, 97, 122, 123, 126, 10, 33, 34, 39, 47, 48, 95, 35, 46, 49, 57, 58, 64, 65, 90, 91, 96, 97, 122, 123, 126, 10, 34, 39, 46, 47, 95, 120, 33, 45, 48, 57, 58, 64, 65, 90, 91, 96, 97, 122, 123, 126, 10, 34, 39, 47, 95, 33, 46, 48, 57, 58, 64, 65, 90, 91, 96, 97, 122, 123, 126, 10, 34, 39, 47, 95, 33, 46, 48, 57, 58, 64, 65, 90, 91, 96, 97, 122, 123, 126, 10, 34, 39, 46, 47, 95, 33, 45, 48, 57, 58, 64, 65, 90, 91, 96, 97, 122, 123, 126, 10, 34, 39, 47, 95, 33, 46, 48, 57, 58, 64, 65, 70, 71, 90, 91, 96, 97, 102, 103, 122, 123, 126, 0, };
private static byte _clang_single_lengths [] = { 0, 3, 3, 1, 2, 3, 1, 0, 0, 1, 6, 6, 6, 7, 7, 5, 5, 6, 5, 0 , };
private static byte _clang_range_lengths [] = { 0, 1, 1, 1, 1, 1, 1, 1, 3, 1, 7, 7, 7, 7, 7, 7, 7, 7, 9, 0 , };
private static short _clang_index_offsets [] = { 0, 0, 5, 10, 13, 17, 22, 25, 27, 31, 34, 48, 62, 76, 91, 106, 119, 132, 146, 0 , };
private static byte _clang_trans_cond_spaces [] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0 , };
private static short _clang_trans_offsets [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 0 , };
private static byte _clang_trans_lengths [] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 , };
private static byte _clang_cond_keys [] = { 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, 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, 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, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 , };
private static byte _clang_cond_targs [] = { 1, 12, 9, 1, 0, 2, 12, 3, 2, 0, 2, 2, 0, 4, 5, 4, 0, 4, 5, 10, 4, 0, 10, 6, 0, 15, 0, 18, 18, 18, 0, 1, 1, 0, 10, 1, 2, 13, 14, 16, 11, 17, 11, 16, 11, 16, 11, 10, 10, 1, 2, 13, 14, 16, 11, 17, 11, 16, 11, 16, 11, 10, 10, 1, 2, 13, 14, 16, 11, 17, 11, 16, 11, 16, 11, 10, 10, 4, 1, 2, 6, 14, 16, 11, 17, 11, 16, 11, 16, 11, 10, 10, 1, 2, 7, 13, 16, 8, 11, 17, 11, 16, 11, 16, 11, 10, 10, 1, 2, 13, 16, 11, 15, 11, 16, 11, 16, 11, 10, 10, 1, 2, 13, 16, 11, 16, 11, 16, 11, 16, 11, 10, 10, 1, 2, 7, 13, 16, 11, 17, 11, 16, 11, 16, 11, 10, 10, 1, 2, 13, 16, 11, 18, 11, 18, 16, 11, 18, 16, 11, 10, 0 , };
private static byte _clang_cond_actions [] = { 19, 0, 0, 1, 0, 19, 0, 0, 1, 0, 19, 1, 0, 5, 0, 0, 0, 5, 0, 0, 0, 0, 5, 0, 0, 1, 0, 22, 22, 22, 0, 19, 1, 0, 5, 3, 3, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 0, 58, 55, 55, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 17, 34, 31, 31, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 9, 58, 0, 55, 55, 0, 81, 81, 81, 81, 81, 81, 81, 81, 81, 17, 46, 43, 43, 1, 73, 73, 0, 73, 1, 73, 73, 73, 73, 73, 13, 40, 37, 37, 69, 69, 69, 1, 69, 69, 69, 69, 69, 11, 28, 25, 25, 61, 1, 61, 1, 61, 1, 61, 1, 61, 7, 46, 43, 43, 1, 73, 73, 73, 1, 73, 73, 73, 73, 73, 13, 52, 49, 49, 77, 77, 77, 1, 77, 1, 77, 77, 1, 77, 77, 15, 0 , };
private static byte _clang_eof_actions [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 9, 17, 13, 11, 7, 13, 15, 0 , };
private static byte _clang_nfa_targs [] = { 0, 0 , };
private static byte _clang_nfa_offsets [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 , };
private static byte _clang_nfa_push_actions [] = { 0, 0 , };
private static byte _clang_nfa_pop_trans [] = { 0, 0 , };
private static int clang_start = 10;
private static int clang_first_final = 10;
private static int clang_error = 0;
private static int clang_en_main = 10;
int cs;
void init()
{
pos = 0;
line = 1;
{
cs = (int)clang_start;
}
}
void exec( char data[], int len )
{
char buffer [] = new char[1024];
int blen = 0;
int p = 0;
int pe = len;
int eof = len;
String _s;
{
int _klen;
int _trans = 0;
int _cond = 0;
int _acts;
int _nacts;
int _keys;
int _ckeys;
int _cpc;
int _goto_targ = 0;
_goto: while ( true ) {
switch ( _goto_targ ) {
case 0:
if ( p == pe )
{
_goto_targ = 5;
if (true)
continue _goto;
}
if ( cs == 0 )
{
_goto_targ = 6;
if (true)
continue _goto;
}
case 1:
_keys = _clang_key_offsets[cs] ;
_trans = (int )_clang_index_offsets[cs];
_klen = (int)_clang_single_lengths[cs];
if ( _klen > 0 )
{
int _lower;
int _mid;
int _upper;
_lower = _keys;
_upper = _keys + _klen - 1;
while ( true )
{
if ( _upper < _lower )
break;
_mid = _lower + ((_upper-_lower) >> 1);
if ( ( data[p ]) < _clang_trans_keys[_mid ] )
_upper = _mid - 1;
else if ( ( data[p ]) > _clang_trans_keys[_mid ] )
_lower = _mid + 1;
else
{
_trans += (int )(_mid - _keys);
{
_goto_targ = 2;
if (true)
continue _goto;
}
}
}
_keys += _klen;
_trans += (int )_klen;
}
_klen = (int)_clang_range_lengths[cs];
if ( _klen > 0 )
{
int _lower;
int _mid;
int _upper;
_lower = _keys;
_upper = _keys + (_klen<<1) - 2;
while ( true )
{
if ( _upper < _lower )
break;
_mid = _lower + (((_upper-_lower) >> 1) & ~1);
if ( ( data[p ]) < _clang_trans_keys[_mid ] )
_upper = _mid - 2;
else if ( ( data[p ]) > _clang_trans_keys[_mid + 1 ] )
_lower = _mid + 2;
else
{
_trans += (int )((_mid - _keys)>>1);
{
_goto_targ = 2;
if (true)
continue _goto;
}
}
}
_trans += (int )_klen;
}
case 2:
_ckeys = _clang_trans_offsets[_trans] ;
_klen = (int)_clang_trans_lengths[_trans];
_cond = (int )_clang_trans_offsets[_trans];
_cpc = 0;
{
int _lower;
int _mid;
int _upper;
_lower = _ckeys;
_upper = _ckeys + _klen - 1;
while ( true )
{
if ( _upper < _lower )
break;
_mid = _lower + ((_upper-_lower) >> 1);
if ( _cpc < (int)_clang_cond_keys[_mid ] )
_upper = _mid - 1;
else if ( _cpc > (int)_clang_cond_keys[_mid ] )
_lower = _mid + 1;
else
{
_cond += (int )(_mid - _ckeys);
{
_goto_targ = 3;
if (true)
continue _goto;
}
}
}
cs = 0;
{
_goto_targ = 4;
if (true)
continue _goto;
}
}
case 3:
cs = (int)_clang_cond_targs[_cond];
if ( _clang_cond_actions[_cond] == 0 )
{
_goto_targ = 4;
if (true)
continue _goto;
}
_acts = _clang_cond_actions[_cond] ;
_nacts = (int )_clang_actions[_acts ];
_acts += 1;
while ( _nacts > 0 )
{
switch ( _clang_actions[_acts ] ) {
case 0 :
{
buffer[blen] = (( data[p ]));
blen += 1;
}
break;
case 1 :
{
blen = 0;
}
break;
case 2 :
{
line = line + 1;
}
break;
case 3 :
{
System.out.print( "ident(" );
System.out.print( line );
System.out.print( "," );
System.out.print( blen );
System.out.print( "): " );
System.out.print( new String( buffer, 0, blen ) );
System.out.print( "\n" );
}
break;
case 4 :
{
System.out.print( "literal(" );
System.out.print( line );
System.out.print( "," );
System.out.print( blen );
System.out.print( "): " );
System.out.print( new String( buffer, 0, blen ) );
System.out.print( "\n" );
}
break;
case 5 :
{
System.out.print( "float(" );
System.out.print( line );
System.out.print( "," );
System.out.print( blen );
System.out.print( "): " );
System.out.print( new String( buffer, 0, blen ) );
System.out.print( "\n" );
}
break;
case 6 :
{
System.out.print( "int(" );
System.out.print( line );
System.out.print( "," );
System.out.print( blen );
System.out.print( "): " );
System.out.print( new String( buffer, 0, blen ) );
System.out.print( "\n" );
}
break;
case 7 :
{
System.out.print( "hex(" );
System.out.print( line );
System.out.print( "," );
System.out.print( blen );
System.out.print( "): " );
System.out.print( new String( buffer, 0, blen ) );
System.out.print( "\n" );
}
break;
case 8 :
{
System.out.print( "symbol(" );
System.out.print( line );
System.out.print( "," );
System.out.print( blen );
System.out.print( "): " );
System.out.print( new String( buffer, 0, blen ) );
System.out.print( "\n" );
}
break;
}
_nacts -= 1;
_acts += 1;
}
case 4:
if ( cs == 0 )
{
_goto_targ = 6;
if (true)
continue _goto;
}
p += 1;
if ( p != pe )
{
_goto_targ = 1;
if (true)
continue _goto;
}
case 5:
{
}
if ( p == eof )
{
int __acts;
int __nacts;
__acts = _clang_eof_actions[cs] ;
__nacts = (int )_clang_actions[__acts ];
__acts += 1;
while ( __nacts > 0 )
{
switch ( _clang_actions[__acts ] ) {
case 3 :
{
System.out.print( "ident(" );
System.out.print( line );
System.out.print( "," );
System.out.print( blen );
System.out.print( "): " );
System.out.print( new String( buffer, 0, blen ) );
System.out.print( "\n" );
}
break;
case 4 :
{
System.out.print( "literal(" );
System.out.print( line );
System.out.print( "," );
System.out.print( blen );
System.out.print( "): " );
System.out.print( new String( buffer, 0, blen ) );
System.out.print( "\n" );
}
break;
case 5 :
{
System.out.print( "float(" );
System.out.print( line );
System.out.print( "," );
System.out.print( blen );
System.out.print( "): " );
System.out.print( new String( buffer, 0, blen ) );
System.out.print( "\n" );
}
break;
case 6 :
{
System.out.print( "int(" );
System.out.print( line );
System.out.print( "," );
System.out.print( blen );
System.out.print( "): " );
System.out.print( new String( buffer, 0, blen ) );
System.out.print( "\n" );
}
break;
case 7 :
{
System.out.print( "hex(" );
System.out.print( line );
System.out.print( "," );
System.out.print( blen );
System.out.print( "): " );
System.out.print( new String( buffer, 0, blen ) );
System.out.print( "\n" );
}
break;
case 8 :
{
System.out.print( "symbol(" );
System.out.print( line );
System.out.print( "," );
System.out.print( blen );
System.out.print( "): " );
System.out.print( new String( buffer, 0, blen ) );
System.out.print( "\n" );
}
break;
}
__nacts -= 1;
__acts += 1;
}
}
case 6:
{
}
}
break;
}
}
}
void finish( )
{
if ( cs >= clang_first_final )
System.out.println( "ACCEPT" );
else
System.out.println( "FAIL" );
}
static final String inp[] = {
"999 0xaAFF99 99.99 /!\n!/ 'lksdj' //\n\"\n\nliteral\n\n\n\"0x00aba foobardd.ddsf 0x0.9\n",
"wordwithnum00asdf\n000wordfollowsnum,makes new symbol\n\nfinishing early /! unfinished ...\n",
};
static final int inplen = 2;
public static void main (String[] args)
{
clang4_java machine = new clang4_java();
for ( int i = 0; i < inplen; i++ ) {
machine.init();
machine.exec( inp[i].toCharArray(), inp[i].length() );
machine.finish();
}
}
}
|