@@ -551,8 +551,10 @@ tokenize([$: | String] = Original, Line, Column, Scope, Tokens) ->
551
551
NewScope = maybe_warn_for_ambiguous_bang_before_equals (atom , Unencoded , Rest , Line , Column , Scope ),
552
552
Token = {atom , {Line , Column , nil }, Atom },
553
553
tokenize (Rest , Line , Column + 1 + Length , NewScope , [Token | Tokens ]);
554
- empty ->
554
+ empty when Scope # elixir_tokenizer . cursor_completion == false ->
555
555
unexpected_token (Original , Line , Column , Scope , Tokens );
556
+ empty ->
557
+ tokenize ([], Line , Column , Scope , Tokens );
556
558
{error , Reason } ->
557
559
error (Reason , Original , Scope , Tokens )
558
560
end ;
@@ -565,17 +567,24 @@ tokenize([H | T], Line, Column, Scope, Tokens) when ?is_digit(H) ->
565
567
case tokenize_number (T , [H ], 1 , false ) of
566
568
{error , Reason , Original } ->
567
569
error ({Line , Column , Reason , Original }, T , Scope , Tokens );
568
- {[I | _ ], _Number , Original , _Length } when ? is_upcase (I ); ? is_downcase (I ); I == $_ ->
569
- Msg =
570
- io_lib :format (
571
- " invalid character ~ts after number ~ts . If you intended to write a number, "
572
- " make sure to add the proper punctuation character after the number (space, comma, etc). "
573
- " If you meant to write an identifier, note that identifiers in Elixir cannot start with numbers. "
574
- " Unexpected token: " ,
575
- [[I ], Original ]
576
- ),
577
-
578
- error ({Line , Column , Msg , [I ]}, T , Scope , Tokens );
570
+ {[I | Rest ], Number , Original , _Length } when ? is_upcase (I ); ? is_downcase (I ); I == $_ ->
571
+ if
572
+ Number == 0 , (I =:= $x ) orelse (I =:= $o ) orelse (I =:= $b ), Rest == [],
573
+ Scope # elixir_tokenizer .cursor_completion /= false ->
574
+ tokenize ([], Line , Column , Scope , Tokens );
575
+
576
+ true ->
577
+ Msg =
578
+ io_lib :format (
579
+ " invalid character ~ts after number ~ts . If you intended to write a number, "
580
+ " make sure to add the proper punctuation character after the number (space, comma, etc). "
581
+ " If you meant to write an identifier, note that identifiers in Elixir cannot start with numbers. "
582
+ " Unexpected token: " ,
583
+ [[I ], Original ]
584
+ ),
585
+
586
+ error ({Line , Column , Msg , [I ]}, T , Scope , Tokens )
587
+ end ;
579
588
{Rest , Number , Original , Length } when is_integer (Number ) ->
580
589
Token = {int , {Line , Column , Number }, Original },
581
590
tokenize (Rest , Line , Column + Length , Scope , [Token | Tokens ]);
@@ -679,9 +688,16 @@ tokenize(String, Line, Column, Scope, Tokens) ->
679
688
{keyword , Atom , Type , Rest , Length } ->
680
689
tokenize_keyword (Type , Rest , Line , Column , Atom , Length , Scope , Tokens );
681
690
682
- empty ->
691
+ empty when Scope # elixir_tokenizer . cursor_completion == false ->
683
692
unexpected_token (String , Line , Column , Scope , Tokens );
684
693
694
+ empty ->
695
+ case String of
696
+ [$~ , L ] when ? is_upcase (L ); ? is_downcase (L ) -> tokenize ([], Line , Column , Scope , Tokens );
697
+ [$~ ] -> tokenize ([], Line , Column , Scope , Tokens );
698
+ _ -> unexpected_token (String , Line , Column , Scope , Tokens )
699
+ end ;
700
+
685
701
{error , Reason } ->
686
702
error (Reason , String , Scope , Tokens )
687
703
end .
0 commit comments