@@ -26,52 +26,14 @@ lexer grammar SparkSqlLexer;
26
26
*/
27
27
public has_unclosed_bracketed_comment = false ;
28
28
29
- /* *
30
- * Verify whether current token is a valid decimal token (which contains dot).
31
- * Returns true if the character that follows the token is not a digit or letter or underscore.
32
- *
33
- * For example:
34
- * For char stream "2.3", "2." is not a valid decimal token, because it is followed by digit '3'.
35
- * For char stream "2.3_", "2.3" is not a valid decimal token, because it is followed by '_'.
36
- * For char stream "2.3W", "2.3" is not a valid decimal token, because it is followed by 'W'.
37
- * For char stream "12.0D 34.E2+0.12 " 12.0D is a valid decimal token because it is followed
38
- * by a space. 34.E2 is a valid decimal token because it is followed by symbol '+'
39
- * which is not a digit or letter or underscore.
40
- */
41
- public isValidDecimal() {
42
- const nextChar = _input.LA(1 );
43
- if (nextChar >= ' A' && nextChar <= ' Z' || nextChar >= ' 0' && nextChar <= ' 9' ||
44
- nextChar == ' _' ) {
45
- return false ;
46
- } else {
47
- return true ;
48
- }
49
- }
50
-
51
- /* *
52
- * This method will be called when we see '/*' and try to match it as a bracketed comment.
53
- * If the next character is '+', it should be parsed as hint later, and we cannot match
54
- * it as a bracketed comment.
55
- *
56
- * Returns true if the next character is '+'.
57
- */
58
- public isHint() {
59
- const nextChar = _input.LA(1 );
60
- if (nextChar == ' +' ) {
61
- return true ;
62
- } else {
63
- return false ;
64
- }
65
- }
66
-
67
29
/* *
68
30
* This method will be called when the character stream ends and try to find out the
69
31
* unclosed bracketed comment.
70
32
* If the method be called, it means the end of the entire character stream match,
71
33
* and we set the flag and fail later.
72
34
*/
73
35
public markUnclosedComment() {
74
- has_unclosed_bracketed_comment = true ;
36
+ this. has_unclosed_bracketed_comment = true ;
75
37
}
76
38
}
77
39
@@ -488,26 +450,26 @@ INTEGER_VALUE
488
450
489
451
EXPONENT_VALUE
490
452
: DIGIT + EXPONENT
491
- | DECIMAL_DIGITS EXPONENT {isValidDecimal()} ?
453
+ | DECIMAL_DIGITS EXPONENT
492
454
;
493
455
494
456
DECIMAL_VALUE
495
- : DECIMAL_DIGITS {isValidDecimal()} ?
457
+ : DECIMAL_DIGITS
496
458
;
497
459
498
460
FLOAT_LITERAL
499
461
: DIGIT + EXPONENT ? ' F'
500
- | DECIMAL_DIGITS EXPONENT ? ' F' {isValidDecimal()} ?
462
+ | DECIMAL_DIGITS EXPONENT ? ' F'
501
463
;
502
464
503
465
DOUBLE_LITERAL
504
466
: DIGIT + EXPONENT ? ' D'
505
- | DECIMAL_DIGITS EXPONENT ? ' D' {isValidDecimal()} ?
467
+ | DECIMAL_DIGITS EXPONENT ? ' D'
506
468
;
507
469
508
470
BIGDECIMAL_LITERAL
509
471
: DIGIT + EXPONENT ? ' BD'
510
- | DECIMAL_DIGITS EXPONENT ? ' BD' {isValidDecimal()} ?
472
+ | DECIMAL_DIGITS EXPONENT ? ' BD'
511
473
;
512
474
513
475
IDENTIFIER
@@ -540,7 +502,7 @@ SIMPLE_COMMENT
540
502
;
541
503
542
504
BRACKETED_COMMENT
543
- : ' /*' {!isHint()} ? ( BRACKETED_COMMENT | . )*? (' */' | {markUnclosedComment();} EOF ) -> channel(HIDDEN )
505
+ : ' /*' ( BRACKETED_COMMENT | . )*? (' */' | {this. markUnclosedComment();} EOF ) -> channel(HIDDEN )
544
506
;
545
507
546
508
WS
0 commit comments