embulk 0.8.26-java → 0.8.27-java

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,62 @@
1
+ /* IMPORTANT: must compile with JFlex 1.4, JFlex 1.4.3 seems buggy with look-ahead */
2
+
3
+ package org.embulk.spi.time.lexer;
4
+
5
+ import org.embulk.spi.time.StrptimeToken;
6
+
7
+ %%
8
+ %public
9
+ %class StrptimeLexer
10
+ //%debug
11
+ %unicode
12
+ %type org.embulk.spi.time.StrptimeToken
13
+ %{
14
+ StringBuilder stringBuf = new StringBuilder();
15
+
16
+ public StrptimeToken rawString() {
17
+ String str = stringBuf.toString();
18
+ stringBuf.setLength(0);
19
+ return StrptimeToken.str(str);
20
+ }
21
+
22
+ public StrptimeToken directive(char c) {
23
+ StrptimeToken token;
24
+ if (c == 'z') {
25
+ int colons = yylength()-1; // can only be colons except the 'z'
26
+ return StrptimeToken.zoneOffsetColons(colons);
27
+ } else if ((token = StrptimeToken.format(c)) != null) {
28
+ return token;
29
+ } else {
30
+ return StrptimeToken.special(c);
31
+ }
32
+ }
33
+ %}
34
+
35
+ Flags = [-_0#\^]+
36
+ Width = [1-9][0-9]*
37
+
38
+ // See RubyDateFormatter.main to generate this
39
+ // Chars are sorted by | ruby -e 'p STDIN.each_char.sort{|a,b|a.casecmp(b).tap{|c|break a<=>b if c==0}}.join'
40
+ Conversion = [\+AaBbCcDdeFGgHhIjkLlMmNnPpQRrSsTtUuVvWwXxYyZz] | {IgnoredModifier} | {Zone}
41
+ // From MRI strftime.c
42
+ IgnoredModifier = E[CcXxYy] | O[deHIMmSUuVWwy]
43
+ Zone = :{1,3} z
44
+
45
+ SimpleDirective = "%"
46
+ LiteralPercent = "%%"
47
+ Unknown = .|\n
48
+
49
+ %xstate CONVERSION
50
+
51
+ %%
52
+
53
+ <YYINITIAL> {
54
+ {LiteralPercent} { return StrptimeToken.str("%"); }
55
+ {SimpleDirective} / {Conversion} { yybegin(CONVERSION); }
56
+ }
57
+
58
+ <CONVERSION> {Conversion} { yybegin(YYINITIAL); return directive(yycharat(yylength()-1)); }
59
+
60
+ /* fallback */
61
+ {Unknown} / [^%] { stringBuf.append(yycharat(0)); }
62
+ {Unknown} { stringBuf.append(yycharat(0)); return rawString(); }
@@ -0,0 +1,577 @@
1
+ /* The following code was generated by JFlex 1.4 on 5/6/17 4:40 AM */
2
+
3
+ /* IMPORTANT: must compile with JFlex 1.4, JFlex 1.4.3 seems buggy with look-ahead */
4
+
5
+ package org.embulk.spi.time.lexer;
6
+
7
+ import org.embulk.spi.time.StrptimeToken;
8
+
9
+
10
+ /**
11
+ * This class is a scanner generated by
12
+ * <a href="http://www.jflex.de/">JFlex</a> 1.4
13
+ * on 5/6/17 4:40 AM from the specification file
14
+ * <tt>embulk-jruby-strptime/src/main/java/org/embulk/spi/time/lexer/StrptimeLexer.flex</tt>
15
+ */
16
+ public class StrptimeLexer {
17
+
18
+ /** This character denotes the end of file */
19
+ public static final int YYEOF = -1;
20
+
21
+ /** initial size of the lookahead buffer */
22
+ private static final int ZZ_BUFFERSIZE = 16384;
23
+
24
+ /** lexical states */
25
+ public static final int CONVERSION = 1;
26
+ public static final int YYINITIAL = 0;
27
+
28
+ /**
29
+ * Translates characters to character classes
30
+ */
31
+ private static final String ZZ_CMAP_PACKED =
32
+ "\12\0\1\0\30\0\1\0\1\0\1\11\5\0\1\1\1\0\1\0"+
33
+ "\2\0\1\0\11\0\1\7\6\0\2\1\1\3\1\1\1\2\2\1"+
34
+ "\2\5\2\0\1\1\1\5\1\1\1\4\3\1\1\5\1\1\3\5"+
35
+ "\2\3\1\1\3\0\2\0\1\0\2\1\1\3\2\5\1\0\2\1"+
36
+ "\1\0\3\1\1\5\1\1\1\0\1\1\1\0\3\1\1\5\1\1"+
37
+ "\1\5\1\3\1\6\1\10\uff85\0";
38
+
39
+ /**
40
+ * Translates characters to character classes
41
+ */
42
+ private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED);
43
+
44
+ /**
45
+ * Translates DFA states to action switch labels.
46
+ */
47
+ private static final int [] ZZ_ACTION = zzUnpackAction();
48
+
49
+ private static final String ZZ_ACTION_PACKED_0 =
50
+ "\2\0\2\1\1\2\3\0\1\3\1\4\3\3\1\5"+
51
+ "\4\0";
52
+
53
+ private static int [] zzUnpackAction() {
54
+ int [] result = new int[18];
55
+ int offset = 0;
56
+ offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
57
+ return result;
58
+ }
59
+
60
+ private static int zzUnpackAction(String packed, int offset, int [] result) {
61
+ int i = 0; /* index in packed string */
62
+ int j = offset; /* index in unpacked array */
63
+ int l = packed.length();
64
+ while (i < l) {
65
+ int count = packed.charAt(i++);
66
+ int value = packed.charAt(i++);
67
+ do result[j++] = value; while (--count > 0);
68
+ }
69
+ return j;
70
+ }
71
+
72
+
73
+ /**
74
+ * Translates a state to a row index in the transition table
75
+ */
76
+ private static final int [] ZZ_ROWMAP = zzUnpackRowMap();
77
+
78
+ private static final String ZZ_ROWMAP_PACKED_0 =
79
+ "\0\0\0\12\0\24\0\36\0\50\0\62\0\74\0\106"+
80
+ "\0\50\0\50\0\120\0\132\0\144\0\50\0\156\0\170"+
81
+ "\0\202\0\214";
82
+
83
+ private static int [] zzUnpackRowMap() {
84
+ int [] result = new int[18];
85
+ int offset = 0;
86
+ offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
87
+ return result;
88
+ }
89
+
90
+ private static int zzUnpackRowMap(String packed, int offset, int [] result) {
91
+ int i = 0; /* index in packed string */
92
+ int j = offset; /* index in unpacked array */
93
+ int l = packed.length();
94
+ while (i < l) {
95
+ int high = packed.charAt(i++) << 16;
96
+ result[j++] = high | packed.charAt(i++);
97
+ }
98
+ return j;
99
+ }
100
+
101
+ /**
102
+ * The transition table of the DFA
103
+ */
104
+ private static final int [] ZZ_TRANS = zzUnpackTrans();
105
+
106
+ private static final String ZZ_TRANS_PACKED_0 =
107
+ "\11\3\1\4\1\0\1\5\1\6\1\5\1\7\2\5"+
108
+ "\1\10\1\5\1\0\11\11\1\0\1\11\1\12\1\13"+
109
+ "\1\12\1\14\2\12\1\15\1\12\1\16\15\0\1\5"+
110
+ "\2\0\1\5\10\0\2\5\12\0\1\17\1\5\4\0"+
111
+ "\1\12\2\0\1\12\10\0\2\12\12\0\1\20\1\12"+
112
+ "\10\0\1\21\1\5\10\0\1\22\1\12\11\0\1\5"+
113
+ "\11\0\1\12\1\0";
114
+
115
+ private static int [] zzUnpackTrans() {
116
+ int [] result = new int[150];
117
+ int offset = 0;
118
+ offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result);
119
+ return result;
120
+ }
121
+
122
+ private static int zzUnpackTrans(String packed, int offset, int [] result) {
123
+ int i = 0; /* index in packed string */
124
+ int j = offset; /* index in unpacked array */
125
+ int l = packed.length();
126
+ while (i < l) {
127
+ int count = packed.charAt(i++);
128
+ int value = packed.charAt(i++);
129
+ value--;
130
+ do result[j++] = value; while (--count > 0);
131
+ }
132
+ return j;
133
+ }
134
+
135
+
136
+ /* error codes */
137
+ private static final int ZZ_UNKNOWN_ERROR = 0;
138
+ private static final int ZZ_NO_MATCH = 1;
139
+ private static final int ZZ_PUSHBACK_2BIG = 2;
140
+
141
+ /* error messages for the codes above */
142
+ private static final String ZZ_ERROR_MSG[] = {
143
+ "Unkown internal scanner error",
144
+ "Error: could not match input",
145
+ "Error: pushback value was too large"
146
+ };
147
+
148
+ /**
149
+ * ZZ_ATTRIBUTE[aState] contains the attributes of state <code>aState</code>
150
+ */
151
+ private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();
152
+
153
+ private static final String ZZ_ATTRIBUTE_PACKED_0 =
154
+ "\2\0\2\3\1\11\3\0\2\15\3\5\1\11\4\0";
155
+
156
+ private static int [] zzUnpackAttribute() {
157
+ int [] result = new int[18];
158
+ int offset = 0;
159
+ offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
160
+ return result;
161
+ }
162
+
163
+ private static int zzUnpackAttribute(String packed, int offset, int [] result) {
164
+ int i = 0; /* index in packed string */
165
+ int j = offset; /* index in unpacked array */
166
+ int l = packed.length();
167
+ while (i < l) {
168
+ int count = packed.charAt(i++);
169
+ int value = packed.charAt(i++);
170
+ do result[j++] = value; while (--count > 0);
171
+ }
172
+ return j;
173
+ }
174
+
175
+ /** the input device */
176
+ private java.io.Reader zzReader;
177
+
178
+ /** the current state of the DFA */
179
+ private int zzState;
180
+
181
+ /** the current lexical state */
182
+ private int zzLexicalState = YYINITIAL;
183
+
184
+ /** this buffer contains the current text to be matched and is
185
+ the source of the yytext() string */
186
+ private char zzBuffer[] = new char[ZZ_BUFFERSIZE];
187
+
188
+ /** the textposition at the last accepting state */
189
+ private int zzMarkedPos;
190
+
191
+ /** the textposition at the last state to be included in yytext */
192
+ private int zzPushbackPos;
193
+
194
+ /** the current text position in the buffer */
195
+ private int zzCurrentPos;
196
+
197
+ /** startRead marks the beginning of the yytext() string in the buffer */
198
+ private int zzStartRead;
199
+
200
+ /** endRead marks the last character in the buffer, that has been read
201
+ from input */
202
+ private int zzEndRead;
203
+
204
+ /** number of newlines encountered up to the start of the matched text */
205
+ private int yyline;
206
+
207
+ /** the number of characters up to the start of the matched text */
208
+ private int yychar;
209
+
210
+ /**
211
+ * the number of characters from the last newline up to the start of the
212
+ * matched text
213
+ */
214
+ private int yycolumn;
215
+
216
+ /**
217
+ * zzAtBOL == true <=> the scanner is currently at the beginning of a line
218
+ */
219
+ private boolean zzAtBOL = true;
220
+
221
+ /** zzAtEOF == true <=> the scanner is at the EOF */
222
+ private boolean zzAtEOF;
223
+
224
+ /* user code: */
225
+ StringBuilder stringBuf = new StringBuilder();
226
+
227
+ public StrptimeToken rawString() {
228
+ String str = stringBuf.toString();
229
+ stringBuf.setLength(0);
230
+ return StrptimeToken.str(str);
231
+ }
232
+
233
+ public StrptimeToken directive(char c) {
234
+ StrptimeToken token;
235
+ if (c == 'z') {
236
+ int colons = yylength()-1; // can only be colons except the 'z'
237
+ return StrptimeToken.zoneOffsetColons(colons);
238
+ } else if ((token = StrptimeToken.format(c)) != null) {
239
+ return token;
240
+ } else {
241
+ return StrptimeToken.special(c);
242
+ }
243
+ }
244
+
245
+
246
+ /**
247
+ * Creates a new scanner
248
+ * There is also a java.io.InputStream version of this constructor.
249
+ *
250
+ * @param in the java.io.Reader to read input from.
251
+ */
252
+ public StrptimeLexer(java.io.Reader in) {
253
+ this.zzReader = in;
254
+ }
255
+
256
+ /**
257
+ * Creates a new scanner.
258
+ * There is also java.io.Reader version of this constructor.
259
+ *
260
+ * @param in the java.io.Inputstream to read input from.
261
+ */
262
+ public StrptimeLexer(java.io.InputStream in) {
263
+ this(new java.io.InputStreamReader(in));
264
+ }
265
+
266
+ /**
267
+ * Unpacks the compressed character translation table.
268
+ *
269
+ * @param packed the packed character translation table
270
+ * @return the unpacked character translation table
271
+ */
272
+ private static char [] zzUnpackCMap(String packed) {
273
+ char [] map = new char[0x10000];
274
+ int i = 0; /* index in packed string */
275
+ int j = 0; /* index in unpacked array */
276
+ while (i < 110) {
277
+ int count = packed.charAt(i++);
278
+ char value = packed.charAt(i++);
279
+ do map[j++] = value; while (--count > 0);
280
+ }
281
+ return map;
282
+ }
283
+
284
+
285
+ /**
286
+ * Refills the input buffer.
287
+ *
288
+ * @return <code>false</code>, iff there was new input.
289
+ *
290
+ * @exception java.io.IOException if any I/O-Error occurs
291
+ */
292
+ private boolean zzRefill() throws java.io.IOException {
293
+
294
+ /* first: make room (if you can) */
295
+ if (zzStartRead > 0) {
296
+ System.arraycopy(zzBuffer, zzStartRead,
297
+ zzBuffer, 0,
298
+ zzEndRead-zzStartRead);
299
+
300
+ /* translate stored positions */
301
+ zzEndRead-= zzStartRead;
302
+ zzCurrentPos-= zzStartRead;
303
+ zzMarkedPos-= zzStartRead;
304
+ zzPushbackPos-= zzStartRead;
305
+ zzStartRead = 0;
306
+ }
307
+
308
+ /* is the buffer big enough? */
309
+ if (zzCurrentPos >= zzBuffer.length) {
310
+ /* if not: blow it up */
311
+ char newBuffer[] = new char[zzCurrentPos*2];
312
+ System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length);
313
+ zzBuffer = newBuffer;
314
+ }
315
+
316
+ /* finally: fill the buffer with new input */
317
+ int numRead = zzReader.read(zzBuffer, zzEndRead,
318
+ zzBuffer.length-zzEndRead);
319
+
320
+ if (numRead < 0) {
321
+ return true;
322
+ }
323
+ else {
324
+ zzEndRead+= numRead;
325
+ return false;
326
+ }
327
+ }
328
+
329
+
330
+ /**
331
+ * Closes the input stream.
332
+ */
333
+ public final void yyclose() throws java.io.IOException {
334
+ zzAtEOF = true; /* indicate end of file */
335
+ zzEndRead = zzStartRead; /* invalidate buffer */
336
+
337
+ if (zzReader != null)
338
+ zzReader.close();
339
+ }
340
+
341
+
342
+ /**
343
+ * Resets the scanner to read from a new input stream.
344
+ * Does not close the old reader.
345
+ *
346
+ * All internal variables are reset, the old input stream
347
+ * <b>cannot</b> be reused (internal buffer is discarded and lost).
348
+ * Lexical state is set to <tt>ZZ_INITIAL</tt>.
349
+ *
350
+ * @param reader the new input stream
351
+ */
352
+ public final void yyreset(java.io.Reader reader) {
353
+ zzReader = reader;
354
+ zzAtBOL = true;
355
+ zzAtEOF = false;
356
+ zzEndRead = zzStartRead = 0;
357
+ zzCurrentPos = zzMarkedPos = zzPushbackPos = 0;
358
+ yyline = yychar = yycolumn = 0;
359
+ zzLexicalState = YYINITIAL;
360
+ }
361
+
362
+
363
+ /**
364
+ * Returns the current lexical state.
365
+ */
366
+ public final int yystate() {
367
+ return zzLexicalState;
368
+ }
369
+
370
+
371
+ /**
372
+ * Enters a new lexical state
373
+ *
374
+ * @param newState the new lexical state
375
+ */
376
+ public final void yybegin(int newState) {
377
+ zzLexicalState = newState;
378
+ }
379
+
380
+
381
+ /**
382
+ * Returns the text matched by the current regular expression.
383
+ */
384
+ public final String yytext() {
385
+ return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead );
386
+ }
387
+
388
+
389
+ /**
390
+ * Returns the character at position <tt>pos</tt> from the
391
+ * matched text.
392
+ *
393
+ * It is equivalent to yytext().charAt(pos), but faster
394
+ *
395
+ * @param pos the position of the character to fetch.
396
+ * A value from 0 to yylength()-1.
397
+ *
398
+ * @return the character at position pos
399
+ */
400
+ public final char yycharat(int pos) {
401
+ return zzBuffer[zzStartRead+pos];
402
+ }
403
+
404
+
405
+ /**
406
+ * Returns the length of the matched text region.
407
+ */
408
+ public final int yylength() {
409
+ return zzMarkedPos-zzStartRead;
410
+ }
411
+
412
+
413
+ /**
414
+ * Reports an error that occured while scanning.
415
+ *
416
+ * In a wellformed scanner (no or only correct usage of
417
+ * yypushback(int) and a match-all fallback rule) this method
418
+ * will only be called with things that "Can't Possibly Happen".
419
+ * If this method is called, something is seriously wrong
420
+ * (e.g. a JFlex bug producing a faulty scanner etc.).
421
+ *
422
+ * Usual syntax/scanner level error handling should be done
423
+ * in error fallback rules.
424
+ *
425
+ * @param errorCode the code of the errormessage to display
426
+ */
427
+ private void zzScanError(int errorCode) {
428
+ String message;
429
+ try {
430
+ message = ZZ_ERROR_MSG[errorCode];
431
+ }
432
+ catch (ArrayIndexOutOfBoundsException e) {
433
+ message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
434
+ }
435
+
436
+ throw new Error(message);
437
+ }
438
+
439
+
440
+ /**
441
+ * Pushes the specified amount of characters back into the input stream.
442
+ *
443
+ * They will be read again by then next call of the scanning method
444
+ *
445
+ * @param number the number of characters to be read again.
446
+ * This number must not be greater than yylength()!
447
+ */
448
+ public void yypushback(int number) {
449
+ if ( number > yylength() )
450
+ zzScanError(ZZ_PUSHBACK_2BIG);
451
+
452
+ zzMarkedPos -= number;
453
+ }
454
+
455
+
456
+ /**
457
+ * Resumes scanning until the next regular expression is matched,
458
+ * the end of input is encountered or an I/O-Error occurs.
459
+ *
460
+ * @return the next token
461
+ * @exception java.io.IOException if any I/O-Error occurs
462
+ */
463
+ public org.embulk.spi.time.StrptimeToken yylex() throws java.io.IOException {
464
+ int zzInput;
465
+ int zzAction;
466
+
467
+ // cached fields:
468
+ int zzCurrentPosL;
469
+ int zzMarkedPosL;
470
+ int zzEndReadL = zzEndRead;
471
+ char [] zzBufferL = zzBuffer;
472
+ char [] zzCMapL = ZZ_CMAP;
473
+
474
+ int [] zzTransL = ZZ_TRANS;
475
+ int [] zzRowMapL = ZZ_ROWMAP;
476
+ int [] zzAttrL = ZZ_ATTRIBUTE;
477
+ int zzPushbackPosL = zzPushbackPos = -1;
478
+ boolean zzWasPushback;
479
+
480
+ while (true) {
481
+ zzMarkedPosL = zzMarkedPos;
482
+
483
+ zzAction = -1;
484
+
485
+ zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
486
+
487
+ zzState = zzLexicalState;
488
+
489
+ zzWasPushback = false;
490
+
491
+ zzForAction: {
492
+ while (true) {
493
+
494
+ if (zzCurrentPosL < zzEndReadL)
495
+ zzInput = zzBufferL[zzCurrentPosL++];
496
+ else if (zzAtEOF) {
497
+ zzInput = YYEOF;
498
+ break zzForAction;
499
+ }
500
+ else {
501
+ // store back cached positions
502
+ zzCurrentPos = zzCurrentPosL;
503
+ zzMarkedPos = zzMarkedPosL;
504
+ zzPushbackPos = zzPushbackPosL;
505
+ boolean eof = zzRefill();
506
+ // get translated positions and possibly new buffer
507
+ zzCurrentPosL = zzCurrentPos;
508
+ zzMarkedPosL = zzMarkedPos;
509
+ zzBufferL = zzBuffer;
510
+ zzEndReadL = zzEndRead;
511
+ zzPushbackPosL = zzPushbackPos;
512
+ if (eof) {
513
+ zzInput = YYEOF;
514
+ break zzForAction;
515
+ }
516
+ else {
517
+ zzInput = zzBufferL[zzCurrentPosL++];
518
+ }
519
+ }
520
+ int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ];
521
+ if (zzNext == -1) break zzForAction;
522
+ zzState = zzNext;
523
+
524
+ int zzAttributes = zzAttrL[zzState];
525
+ if ( (zzAttributes & 2) == 2 )
526
+ zzPushbackPosL = zzCurrentPosL;
527
+
528
+ if ( (zzAttributes & 1) == 1 ) {
529
+ zzWasPushback = (zzAttributes & 4) == 4;
530
+ zzAction = zzState;
531
+ zzMarkedPosL = zzCurrentPosL;
532
+ if ( (zzAttributes & 8) == 8 ) break zzForAction;
533
+ }
534
+
535
+ }
536
+ }
537
+
538
+ // store back cached position
539
+ zzMarkedPos = zzMarkedPosL;
540
+ if (zzWasPushback)
541
+ zzMarkedPos = zzPushbackPosL;
542
+
543
+ switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
544
+ case 2:
545
+ { yybegin(YYINITIAL); return directive(yycharat(yylength()-1));
546
+ }
547
+ case 6: break;
548
+ case 3:
549
+ { stringBuf.append(yycharat(0));
550
+ }
551
+ case 7: break;
552
+ case 5:
553
+ { return StrptimeToken.str("%");
554
+ }
555
+ case 8: break;
556
+ case 1:
557
+ { stringBuf.append(yycharat(0)); return rawString();
558
+ }
559
+ case 9: break;
560
+ case 4:
561
+ { yybegin(CONVERSION);
562
+ }
563
+ case 10: break;
564
+ default:
565
+ if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
566
+ zzAtEOF = true;
567
+ return null;
568
+ }
569
+ else {
570
+ zzScanError(ZZ_NO_MATCH);
571
+ }
572
+ }
573
+ }
574
+ }
575
+
576
+
577
+ }