@@ -115,16 +115,16 @@ type name = [
115
115
]
116
116
117
117
type qualified_info = {
118
- name_last : (ident * type_arguments option );
119
- name_middle : qualifier option;
118
+ name_last : (ident * type_arguments nullable );
119
+ ? name_middle : qualifier option;
120
120
(* ::, Ruby, C++, also '`' abuse for PolyVariant in OCaml *)
121
- name_top : tok option;
121
+ ? name_top : tok option;
122
122
name_info : id_info;
123
123
}
124
124
125
125
type qualifier = [
126
126
(* Java/C++/Rust *)
127
- | QDots of (ident * type_arguments option ) list
127
+ | QDots of (ident * type_arguments nullable ) list
128
128
(* Ruby/Lua *)
129
129
| QExpr of (expr * tok)
130
130
]
@@ -135,9 +135,9 @@ type qualifier = [
135
135
136
136
(* EXPERIMENTAL *)
137
137
type id_info = {
138
- id_resolved: resolved_name option; (* variable tagger (naming) *)
139
- id_type: type_ option; (* type checker (typing) *)
140
- id_svalue: svalue option; (* constant propagation *)
138
+ ? id_resolved: resolved_name option; (* variable tagger (naming) *)
139
+ ? id_type: type_ option; (* type checker (typing) *)
140
+ ? id_svalue: svalue option; (* constant propagation *)
141
141
}
142
142
143
143
(*****************************************************************************)
@@ -195,8 +195,12 @@ type expr = [
195
195
(* in Js ArrayAccess is also abused to perform DotAccess (..., FDynamic) *)
196
196
| ArrayAccess of (expr * expr bracket)
197
197
198
- | SliceAccess of (expr *
199
- (expr option (* lower *) * expr option (* upper *) * expr option (* step *)) bracket)
198
+ | SliceAccess of (
199
+ expr
200
+ * (expr nullable (* lower *)
201
+ * expr nullable (* upper *)
202
+ * expr nullable (* step *)) bracket
203
+ )
200
204
201
205
(* very special value *)
202
206
| Lambda of function_definition
@@ -206,7 +210,7 @@ type expr = [
206
210
(* a.k.a ternary expression, or regular if in OCaml *)
207
211
| Conditional of (expr * expr * expr)
208
212
209
- | Yield of (tok * expr option * bool) (* 'from' for Python *)
213
+ | Yield of (tok * expr nullable * bool) (* 'from' for Python *)
210
214
| Await of (tok * expr)
211
215
212
216
| Cast of (type_ * expr)
@@ -232,9 +236,10 @@ type literal = [
232
236
(* the numbers are an option because OCaml numbers (e.g., 63bits int)
233
237
* may not be able to represent all numbers.
234
238
*)
235
- | Int of int option wrap_ | Float of float option wrap_
236
- | Char of string wrap_ | String of string wrap_
237
- | Regexp of (string wrap_ bracket (* // *) * string wrap_ option (* modifiers *))
239
+ | Int of int nullable wrap_ | Float of float nullable wrap_
240
+ | Char of string wrap_ | String of string wrap_
241
+ | Regexp of (string wrap_ bracket (* // *)
242
+ * string wrap_ nullable (* modifiers *))
238
243
| Atom of (tok * string wrap_) (* Ruby *)
239
244
| Unit of tok (* a.k.a Void *) | Null of tok | Undefined of tok (* JS *)
240
245
| Imag of string wrap_ (* Go, Python *) | Ratio of string wrap_ (* Ruby *)
@@ -397,7 +402,7 @@ type xml_attr_value = expr
397
402
type xml_body = [
398
403
| XmlText of string wrap_
399
404
(* this can be None when people abuse {} to put comments in it *)
400
- | XmlExpr of expr option bracket
405
+ | XmlExpr of expr nullable bracket
401
406
| XmlXml of xml
402
407
]
403
408
@@ -426,27 +431,30 @@ type stmt = [
426
431
427
432
| Block of stmt list bracket (* can be fake {} in Python where use layout *)
428
433
429
- | If of (tok (* 'if' or 'elif' *) * condition * stmt * stmt option )
430
- | While of (tok * condition * stmt)
434
+ | If of (tok (* 'if' or 'elif' *) * condition * stmt * stmt nullable )
435
+ | While of (tok * condition * stmt)
431
436
432
- | Return of (tok * expr option * sc)
437
+ | Return of (tok * expr nullable * sc)
433
438
434
439
| DoWhile of (tok * stmt * expr)
435
440
| For of (tok (* 'for', 'foreach'*) * for_header * stmt)
436
441
437
442
(* The expr can be None for Go and Ruby. *)
438
- | Switch of (tok (* 'switch' or also 'select' in Go *) * condition option *
439
- case_and_body list)
443
+ | Switch of (tok (* 'switch' or also 'select' in Go *)
444
+ * condition nullable
445
+ * case_and_body list)
440
446
441
447
| Continue of (tok * label_ident * sc)
442
- | Break of (tok * label_ident * sc)
448
+ | Break of (tok * label_ident * sc)
443
449
444
450
| Label of (label * stmt)
445
451
| Goto of (tok * label)
446
452
447
453
| Throw of (tok (* 'raise' in OCaml, 'throw' in Java/PHP *) * expr * sc)
448
- | Try of (tok * stmt * catch list * finally option)
449
- | WithUsingResource of (tok (* 'with' in Python, 'using' in C# *) * stmt list * stmt)
454
+ | Try of (tok * stmt * catch list * finally nullable)
455
+ | WithUsingResource of (tok (* 'with' in Python, 'using' in C# *)
456
+ * stmt list
457
+ * stmt)
450
458
| Assert of (tok * arguments * sc)
451
459
452
460
| DefStmt of definition
@@ -494,8 +502,8 @@ type label_ident = [
494
502
495
503
type for_header = [
496
504
| ForClassic of (for_var_or_expr list (* init *) *
497
- expr option (* cond *) *
498
- expr option ) (* next *)
505
+ expr nullable (* cond *) *
506
+ expr nullable ) (* next *)
499
507
| ForEach of for_each
500
508
(* Scala *)
501
509
| MultiForEach of multi_for_each list
@@ -568,7 +576,7 @@ type type_ = [
568
576
| TyFun of (parameter list * type_ (* return type *))
569
577
570
578
(* a special case of TApply, also a special case of TPointer *)
571
- | TyArray of ((* const_expr *) expr option bracket * type_)
579
+ | TyArray of ((* const_expr *) expr nullable bracket * type_)
572
580
| TyTuple of type_ list bracket
573
581
574
582
| TyVar of ident (* type variable in polymorphic types (not a typedef) *)
@@ -589,7 +597,8 @@ type type_ = [
589
597
* Most record types are defined via a TypeDef and are then referenced
590
598
* via a TyName. Here we have flexible record types (a.k.a. rows in OCaml).
591
599
*)
592
- | TyRecordAnon of (class_kind wrap_ (* 'struct/shape', fake in other *)* field list bracket)
600
+ | TyRecordAnon of (class_kind wrap_ (* 'struct/shape', fake in other *)
601
+ * field list bracket)
593
602
594
603
(* For languages such as Python which abuse expr to represent types.*)
595
604
| TyExpr of expr
@@ -601,8 +610,10 @@ type type_arguments = type_argument list bracket
601
610
type type_argument = [
602
611
| TA of type_
603
612
(* Java only *)
604
- | TAWildcard of (tok (* '?' *) *
605
- (bool wrap_ (* extends|super, true=super *) * type_) option)
613
+ | TAWildcard of (
614
+ tok (* '?' *)
615
+ * (bool wrap_ (* extends|super, true=super *) * type_) nullable
616
+ )
606
617
(* C++/Rust (Rust restrict expr to literals and ConstBlock) *)
607
618
| TAExpr of expr
608
619
| OtherTypeArg of (todo_kind * any list)
@@ -728,9 +739,9 @@ type type_parameter_classic = {
728
739
(* upper type bounds (must-be-a-subtype-of) *)
729
740
tp_bounds : type_ list;
730
741
(* for Rust/C++. Similar to parameter_classic, but with type here. *)
731
- tp_default : type_ option ;
742
+ tp_default : type_ nullable ;
732
743
(* declaration-site variance (Kotlin/Hack/Scala) *)
733
- tp_variance : variance wrap_ option ;
744
+ tp_variance : variance wrap_ nullable ;
734
745
}
735
746
736
747
(* TODO bracket *)
@@ -751,7 +762,7 @@ type variance = [
751
762
type function_definition = {
752
763
fkind: function_kind wrap_;
753
764
fparams: parameters;
754
- frettype: type_ option ; (* return type *)
765
+ frettype: type_ nullable ; (* return type *)
755
766
fbody: function_body;
756
767
}
757
768
@@ -780,9 +791,9 @@ type parameter = [
780
791
781
792
782
793
type parameter_classic = {
783
- pname: ident option ;
784
- ptype: type_ option ;
785
- pdefault: expr option ;
794
+ pname: ident nullable ;
795
+ ptype: type_ nullable ;
796
+ pdefault: expr nullable ;
786
797
787
798
pattrs: attribute list;
788
799
@@ -809,8 +820,8 @@ type function_body = [
809
820
*)
810
821
811
822
type variable_definition = {
812
- vinit: expr option;
813
- vtype: type_ option;
823
+ ? vinit: expr option;
824
+ ? vtype: type_ option;
814
825
}
815
826
816
827
(* ------------------------------------------------------------------------- *)
@@ -847,7 +858,7 @@ type or_type_element = [
847
858
(* OCaml *)
848
859
| OrConstructor of (ident * type_ list)
849
860
(* C *)
850
- | OrEnum of (ident * expr option )
861
+ | OrEnum of (ident * expr nullable )
851
862
(* Java? *)
852
863
| OrUnion of (ident * type_)
853
864
@@ -898,16 +909,16 @@ type class_kind = [
898
909
* can be defined in the class header via cparams and then this class
899
910
* header can call its parent constructor using those cparams).
900
911
*)
901
- type class_parent = (type_ * arguments option )
912
+ type class_parent = (type_ * arguments nullable )
902
913
903
914
(* ------------------------------------------------------------------------- *)
904
915
(* Enum entry *)
905
916
(* ------------------------------------------------------------------------- *)
906
917
(* for EnumClass, complex enums-as-classes in Java/Kotlin/Scala? *)
907
918
type enum_entry_definition = {
908
919
(* the enum identifier is in the corresponding entity *)
909
- ee_args : arguments option ;
910
- ee_body : field list bracket option ;
920
+ ee_args : arguments nullable ;
921
+ ee_body : field list bracket nullable ;
911
922
}
912
923
913
924
(* ------------------------------------------------------------------------- *)
@@ -920,7 +931,7 @@ type module_definition = {
920
931
921
932
type module_definition_kind = [
922
933
| ModuleAlias of dotted_ident
923
- | ModuleStruct of (dotted_ident option * item list)
934
+ | ModuleStruct of (dotted_ident nullable * item list)
924
935
925
936
| OtherModule of (todo_kind * any list)
926
937
]
@@ -940,10 +951,13 @@ type macro_definition = {
940
951
(*****************************************************************************)
941
952
942
953
type directive = [
943
- | ImportFrom of (tok (* 'import'/'from' for Python, 'include' for C *) *
944
- module_name * (ident * alias option (* as name alias *)) list)
954
+ | ImportFrom of (
955
+ tok (* 'import'/'from' for Python, 'include' for C *)
956
+ * module_name
957
+ * (ident * alias nullable (* as name alias *)) list
958
+ )
945
959
946
- | ImportAs of (tok * module_name * alias option ) (* as name *)
960
+ | ImportAs of (tok * module_name * alias nullable ) (* as name *)
947
961
| ImportAll of (tok * module_name * tok) (* '.' in Go, '*' in Java/Python *)
948
962
949
963
(* packages are different from modules in that multiple files can reuse
0 commit comments