@@ -69,6 +69,7 @@ pub(crate) enum TokenKind {
69
69
Number ,
70
70
Placeholder ,
71
71
Word ,
72
+ Join ,
72
73
}
73
74
74
75
#[ derive( Debug , Clone ) ]
@@ -379,6 +380,7 @@ fn get_reserved_word_token<'a>(
379
380
alt ( (
380
381
get_top_level_reserved_token ( last_reserved_top_level_token) ,
381
382
get_newline_reserved_token ( last_reserved_token) ,
383
+ get_join_token ( ) ,
382
384
get_top_level_reserved_token_no_indent,
383
385
get_plain_reserved_token,
384
386
) )
@@ -497,16 +499,11 @@ fn get_top_level_reserved_token<'a>(
497
499
}
498
500
}
499
501
500
- fn get_newline_reserved_token < ' a > (
501
- last_reserved_token : Option < Token < ' a > > ,
502
- ) -> impl Parser < & ' a str , Token < ' a > , ContextError > {
502
+ fn get_join_token < ' a > ( ) -> impl Parser < & ' a str , Token < ' a > , ContextError > {
503
503
move |input : & mut & ' a str | {
504
504
let uc_input: String = get_uc_words ( input, 3 ) ;
505
505
let mut uc_input = uc_input. as_str ( ) ;
506
506
507
- // We have to break up the alternatives into multiple subsets
508
- // to avoid exceeding the alt() 21 element limit.
509
-
510
507
// Standard SQL joins
511
508
let standard_joins = alt ( (
512
509
terminated ( "JOIN" , end_of_word) ,
@@ -544,6 +541,37 @@ fn get_newline_reserved_token<'a>(
544
541
terminated ( "GLOBAL FULL JOIN" , end_of_word) ,
545
542
) ) ;
546
543
544
+ // Combine all parsers
545
+ let result: PResult < & str > =
546
+ alt ( ( standard_joins, specific_joins, special_joins) ) . parse_next ( & mut uc_input) ;
547
+
548
+ if let Ok ( token) = result {
549
+ let final_word = token. split ( ' ' ) . last ( ) . unwrap ( ) ;
550
+ let input_end_pos =
551
+ input. to_ascii_uppercase ( ) . find ( final_word) . unwrap ( ) + final_word. len ( ) ;
552
+ let token = input. next_slice ( input_end_pos) ;
553
+ let kind = TokenKind :: Join ;
554
+ Ok ( Token {
555
+ kind,
556
+ value : token,
557
+ key : None ,
558
+ } )
559
+ } else {
560
+ Err ( ErrMode :: from_error_kind ( input, ErrorKind :: Alt ) )
561
+ }
562
+ }
563
+ }
564
+
565
+ fn get_newline_reserved_token < ' a > (
566
+ last_reserved_token : Option < Token < ' a > > ,
567
+ ) -> impl Parser < & ' a str , Token < ' a > , ContextError > {
568
+ move |input : & mut & ' a str | {
569
+ let uc_input: String = get_uc_words ( input, 3 ) ;
570
+ let mut uc_input = uc_input. as_str ( ) ;
571
+
572
+ // We have to break up the alternatives into multiple subsets
573
+ // to avoid exceeding the alt() 21 element limit.
574
+
547
575
// Legacy and logical operators
548
576
let operators = alt ( (
549
577
terminated ( "CROSS APPLY" , end_of_word) ,
@@ -565,14 +593,7 @@ fn get_newline_reserved_token<'a>(
565
593
) ) ;
566
594
567
595
// Combine all parsers
568
- let result: PResult < & str > = alt ( (
569
- standard_joins,
570
- specific_joins,
571
- special_joins,
572
- operators,
573
- alter_table_actions,
574
- ) )
575
- . parse_next ( & mut uc_input) ;
596
+ let result: PResult < & str > = alt ( ( operators, alter_table_actions) ) . parse_next ( & mut uc_input) ;
576
597
577
598
if let Ok ( token) = result {
578
599
let final_word = token. split ( ' ' ) . last ( ) . unwrap ( ) ;
0 commit comments