@@ -25,7 +25,7 @@ const PREC = {
2525 BIT_OR : 6 , // |
2626 BIT_XOR : 7 , // ^
2727 BIT_AND : 8 , // &
28- EQUALITY : 9 , // == !=
28+ EQUALITY : 9 , // == != <>
2929 GENERIC : 10 ,
3030 REL : 10 , // < <= > >= instanceof
3131 SHIFT : 11 , // << >> >>>
@@ -75,6 +75,7 @@ module.exports = grammar({
7575 [ $ . field_access , $ . method_invocation , $ . expression ] ,
7676 [ $ . map_initializer , $ . array_initializer ] ,
7777 [ $ . function_name , $ . count_expression ] ,
78+ [ $ . switch_label , $ . primary_expression ] ,
7879 ] ,
7980
8081 rules : {
@@ -104,17 +105,13 @@ module.exports = grammar({
104105 dml_expression : ( $ ) =>
105106 prec . right (
106107 choice (
107- seq ( $ . dml_type , $ . primary_expression ) ,
108+ seq ( $ . dml_type , $ . expression ) ,
108109 seq (
109110 alias ( ci ( "upsert" ) , $ . dml_type ) ,
110- $ . primary_expression ,
111+ $ . expression ,
111112 optional ( $ . _unannotated_type )
112113 ) ,
113- seq (
114- alias ( ci ( "merge" ) , $ . dml_type ) ,
115- $ . primary_expression ,
116- $ . identifier // TODO: should be primary_expression
117- )
114+ seq ( alias ( ci ( "merge" ) , $ . dml_type ) , $ . expression , " " , $ . expression )
118115 )
119116 ) ,
120117 dml_type : ( $ ) =>
@@ -164,6 +161,7 @@ module.exports = grammar({
164161 [ "==" , PREC . EQUALITY ] ,
165162 [ "===" , PREC . EQUALITY ] ,
166163 [ "!=" , PREC . EQUALITY ] ,
164+ [ "<>" , PREC . EQUALITY ] ,
167165 [ "!==" , PREC . EQUALITY ] ,
168166 [ "&&" , PREC . AND ] ,
169167 [ "||" , PREC . OR ] ,
@@ -360,8 +358,11 @@ module.exports = grammar({
360358 seq (
361359 ci ( "when" ) ,
362360 choice (
363- commaJoined1 ( seq ( optional ( $ . _unannotated_type ) , $ . identifier ) ) ,
364- commaJoined1 ( $ . _literal ) ,
361+ // SObject type var syntax
362+ prec . right (
363+ commaJoined1 ( seq ( optional ( $ . _unannotated_type ) , $ . identifier ) )
364+ ) ,
365+ commaJoined1 ( $ . expression ) ,
365366 ci ( "else" )
366367 )
367368 ) ,
@@ -774,8 +775,6 @@ module.exports = grammar({
774775 _simple_type : ( $ ) =>
775776 choice (
776777 $ . void_type ,
777- $ . integral_type ,
778- $ . floating_point_type ,
779778 $ . boolean_type ,
780779 alias ( $ . identifier , $ . type_identifier ) ,
781780 $ . scoped_type_identifier ,
@@ -814,10 +813,6 @@ module.exports = grammar({
814813 field ( "dimensions" , $ . dimensions )
815814 ) ,
816815
817- integral_type : ( $ ) => choice ( "byte" , "short" , "int" , "long" , "char" ) ,
818-
819- floating_point_type : ( $ ) => choice ( "float" , "double" ) ,
820-
821816 boolean_type : ( $ ) => "boolean" ,
822817
823818 _method_header : ( $ ) =>
@@ -929,6 +924,6 @@ module.exports = grammar({
929924 )
930925 ) ,
931926
932- string_literal : ( $ ) => / ' ( \\ [ n N r R t T b B f F " ' _ % \\ ] | [ ^ \\ ' ] ) * ' / ,
927+ string_literal : ( $ ) => / ' ( \\ [ n N r R t T b B f F u U " ' _ % \\ ] | [ ^ \\ ' ] ) * ' / ,
933928 } ,
934929} ) ;
0 commit comments