diff --git a/analysis/vendor/dune b/analysis/vendor/dune index e125ef55f..2064349dd 100644 --- a/analysis/vendor/dune +++ b/analysis/vendor/dune @@ -1 +1 @@ -(dirs ext ml res_syntax json) +(dirs ext ml res_syntax json js_parser) diff --git a/analysis/vendor/ext/ext_path.ml b/analysis/vendor/ext/ext_path.ml index 9ad999077..31bbe47a6 100644 --- a/analysis/vendor/ext/ext_path.ml +++ b/analysis/vendor/ext/ext_path.ml @@ -1,5 +1,5 @@ (* Copyright (C) 2017 Hongbo Zhang, Authors of ReScript - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -17,7 +17,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) @@ -43,18 +43,18 @@ let split_by_sep_per_os : string -> string list = (** example {[ - "/bb/mbigc/mbig2899/bgit/bucklescript/jscomp/stdlib/external/pervasives.cmj" - "/bb/mbigc/mbig2899/bgit/bucklescript/jscomp/stdlib/ocaml_array.ml" + "/bb/mbigc/mbig2899/bgit/rescript/jscomp/stdlib/external/pervasives.cmj" + "/bb/mbigc/mbig2899/bgit/rescript/jscomp/stdlib/ocaml_array.ml" ]} The other way {[ - "/bb/mbigc/mbig2899/bgit/bucklescript/jscomp/stdlib/ocaml_array.ml" - "/bb/mbigc/mbig2899/bgit/bucklescript/jscomp/stdlib/external/pervasives.cmj" + "/bb/mbigc/mbig2899/bgit/rescript/jscomp/stdlib/ocaml_array.ml" + "/bb/mbigc/mbig2899/bgit/rescript/jscomp/stdlib/external/pervasives.cmj" ]} {[ - "/bb/mbigc/mbig2899/bgit/bucklescript/jscomp/stdlib//ocaml_array.ml" + "/bb/mbigc/mbig2899/bgit/rescript/jscomp/stdlib//ocaml_array.ml" ]} {[ /a/b @@ -117,7 +117,7 @@ let ( // ) x y = split_aux "//ghosg//ghsogh/";; - : string * string list = ("/", ["ghosg"; "ghsogh"]) ]} - Note that + Note that {[ Filename.dirname "/a/" = "/" Filename.dirname "/a/b/" = Filename.dirname "/a/b" = "/a" @@ -132,7 +132,7 @@ let ( // ) x y = basename "" = "." dirname "" = "." dirname "" = "." - ]} + ]} *) let split_aux p = let rec go p acc = @@ -149,11 +149,11 @@ let split_aux p = go p [] -(** +(** TODO: optimization - if [from] and [to] resolve to the same path, a zero-length string is returned + if [from] and [to] resolve to the same path, a zero-length string is returned - This function is useed in [es6-global] and + This function is useed in [es6-global] and [amdjs-global] format and tailored for `rollup` *) let rel_normalized_absolute_path ~from to_ = @@ -261,14 +261,17 @@ let concat dirname filename = let check_suffix_case = Ext_string.ends_with (* Input must be absolute directory *) -let rec find_root_filename ~cwd filename = - if Sys.file_exists (Filename.concat cwd filename) then cwd +let rec find_root_filename ~cwd filenames = + let file_exists = Ext_list.exists filenames (fun filename -> + Sys.file_exists (Filename.concat cwd filename)) + in + if file_exists then cwd else let cwd' = Filename.dirname cwd in if String.length cwd' < String.length cwd then - find_root_filename ~cwd:cwd' filename - else Ext_fmt.failwithf ~loc:__LOC__ "%s not found from %s" filename cwd + find_root_filename ~cwd:cwd' filenames + else Ext_fmt.failwithf ~loc:__LOC__ "%s not found from %s" (List.hd filenames) cwd -let find_package_json_dir cwd = find_root_filename ~cwd Literals.bsconfig_json +let find_config_dir cwd = find_root_filename ~cwd [Literals.rescript_json; Literals.bsconfig_json] -let package_dir = lazy (find_package_json_dir (Lazy.force cwd)) +let package_dir = lazy (find_config_dir (Lazy.force cwd)) diff --git a/analysis/vendor/ext/ext_path.mli b/analysis/vendor/ext/ext_path.mli index 76e6e209c..6a9905688 100644 --- a/analysis/vendor/ext/ext_path.mli +++ b/analysis/vendor/ext/ext_path.mli @@ -1,5 +1,5 @@ (* Copyright (C) 2017 Authors of ReScript - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -17,7 +17,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) @@ -25,11 +25,11 @@ type t val simple_convert_node_path_to_os_path : string -> string -(** Js_output is node style, which means +(** Js_output is node style, which means separator is only '/' - if the path contains 'node_modules', - [node_relative_path] will discard its prefix and + if the path contains 'node_modules', + [node_relative_path] will discard its prefix and just treat it as a library instead *) @@ -50,14 +50,14 @@ val combine : string -> string -> string val node_rebase_file : from:string -> to_:string -> string -> string val rel_normalized_absolute_path : from:string -> string -> string -(** +(** TODO: could be highly optimized - if [from] and [to] resolve to the same path, a zero-length string is returned + if [from] and [to] resolve to the same path, a zero-length string is returned Given that two paths are directory - A typical use case is + A typical use case is {[ - Filename.concat + Filename.concat (rel_normalized_absolute_path cwd (Filename.dirname a)) (Filename.basename a) ]} @@ -69,7 +69,7 @@ val absolute_cwd_path : string -> string val concat : string -> string -> string (** [concat dirname filename] - The same as {!Filename.concat} except a tiny optimization + The same as {!Filename.concat} except a tiny optimization for current directory simplification *) diff --git a/analysis/vendor/ext/js_reserved_map.ml b/analysis/vendor/ext/js_reserved_map.ml index 9b6ccbfcd..21cef5b3b 100644 --- a/analysis/vendor/ext/js_reserved_map.ml +++ b/analysis/vendor/ext/js_reserved_map.ml @@ -26,9 +26,15 @@ let sorted_keywords = [| "AbortController"; "AbortSignal"; + "AbstractRange"; "ActiveXObject"; + "AggregateError"; "AnalyserNode"; + "Animation"; + "AnimationEffect"; "AnimationEvent"; + "AnimationPlaybackEvent"; + "AnimationTimeline"; "Array"; "ArrayBuffer"; "Atomics"; @@ -37,6 +43,7 @@ let sorted_keywords = [| "AudioBuffer"; "AudioBufferSourceNode"; "AudioContext"; + "AudioData"; "AudioDestinationNode"; "AudioListener"; "AudioNode"; @@ -44,10 +51,13 @@ let sorted_keywords = [| "AudioParamMap"; "AudioProcessingEvent"; "AudioScheduledSourceNode"; + "AudioSinkInfo"; "AudioWorkletNode"; + "BackgroundFetchManager"; + "BackgroundFetchRecord"; + "BackgroundFetchRegistration"; "BarProp"; "BaseAudioContext"; - "BatteryManager"; "BeforeInstallPromptEvent"; "BeforeUnloadEvent"; "BigInt"; @@ -59,18 +69,27 @@ let sorted_keywords = [| "BluetoothUUID"; "Boolean"; "BroadcastChannel"; + "BrowserCaptureMediaStreamTrack"; "Buffer"; + "Bun"; "ByteLengthQueuingStrategy"; "CDATASection"; "CSS"; + "CSSAnimation"; "CSSConditionRule"; + "CSSContainerRule"; + "CSSCounterStyleRule"; "CSSFontFaceRule"; + "CSSFontPaletteValuesRule"; "CSSGroupingRule"; "CSSImageValue"; "CSSImportRule"; "CSSKeyframeRule"; "CSSKeyframesRule"; "CSSKeywordValue"; + "CSSLayerBlockRule"; + "CSSLayerStatementRule"; + "CSSMathClamp"; "CSSMathInvert"; "CSSMathMax"; "CSSMathMin"; @@ -86,6 +105,7 @@ let sorted_keywords = [| "CSSPageRule"; "CSSPerspective"; "CSSPositionValue"; + "CSSPropertyRule"; "CSSRotate"; "CSSRule"; "CSSRuleList"; @@ -100,6 +120,7 @@ let sorted_keywords = [| "CSSSupportsRule"; "CSSTransformComponent"; "CSSTransformValue"; + "CSSTransition"; "CSSTranslate"; "CSSUnitValue"; "CSSUnparsedValue"; @@ -115,13 +136,16 @@ let sorted_keywords = [| "CloseEvent"; "Comment"; "CompositionEvent"; + "CompressionStream"; "ConstantSourceNode"; + "ContentVisibilityAutoStateChangeEvent"; "ConvolverNode"; "CountQueuingStrategy"; + "CropTarget"; "Crypto"; - "CryptoKey"; "CustomElementRegistry"; "CustomEvent"; + "CustomStateSet"; "DOMError"; "DOMException"; "DOMImplementation"; @@ -142,37 +166,51 @@ let sorted_keywords = [| "DataTransferItemList"; "DataView"; "Date"; + "DecompressionStream"; "DelayNode"; - "DeviceMotionEvent"; - "DeviceOrientationEvent"; + "DelegatedInkTrailPresenter"; "Document"; "DocumentFragment"; + "DocumentPictureInPictureEvent"; + "DocumentTimeline"; "DocumentType"; "DragEvent"; "DynamicsCompressorNode"; "Element"; - "EnterPictureInPictureEvent"; + "ElementInternals"; + "EncodedAudioChunk"; + "EncodedVideoChunk"; "Error"; "ErrorEvent"; "EvalError"; "Event"; + "EventCounts"; "EventSource"; "EventTarget"; + "External"; + "FeaturePolicy"; "File"; "FileList"; "FileReader"; + "FinalizationRegistry"; "Float32Array"; "Float64Array"; "FocusEvent"; "FontFace"; "FontFaceSetLoadEvent"; "FormData"; + "FormDataEvent"; + "FragmentDirective"; "Function"; "GainNode"; "Gamepad"; "GamepadButton"; "GamepadEvent"; "GamepadHapticActuator"; + "Geolocation"; + "GeolocationCoordinates"; + "GeolocationPosition"; + "GeolocationPositionError"; "HTMLAllCollection"; "HTMLAnchorElement"; "HTMLAreaElement"; @@ -183,7 +221,6 @@ let sorted_keywords = [| "HTMLButtonElement"; "HTMLCanvasElement"; "HTMLCollection"; - "HTMLContentElement"; "HTMLDListElement"; "HTMLDataElement"; "HTMLDataListElement"; @@ -232,7 +269,6 @@ let sorted_keywords = [| "HTMLQuoteElement"; "HTMLScriptElement"; "HTMLSelectElement"; - "HTMLShadowElement"; "HTMLSlotElement"; "HTMLSourceElement"; "HTMLSpanElement"; @@ -253,6 +289,8 @@ let sorted_keywords = [| "HTMLVideoElement"; "HashChangeEvent"; "Headers"; + "Highlight"; + "HighlightRegistry"; "History"; "IDBCursor"; "IDBCursorWithValue"; @@ -272,7 +310,10 @@ let sorted_keywords = [| "ImageBitmapRenderingContext"; "ImageCapture"; "ImageData"; + "ImageTrack"; + "ImageTrackList"; "Infinity"; + "Ink"; "InputDeviceCapabilities"; "InputDeviceInfo"; "InputEvent"; @@ -284,36 +325,36 @@ let sorted_keywords = [| "Intl"; "JSON"; "KeyboardEvent"; + "KeyframeEffect"; + "LargestContentfulPaint"; + "LaunchParams"; + "LaunchQueue"; + "LayoutShift"; + "LayoutShiftAttribution"; "Location"; - "MIDIAccess"; - "MIDIConnectionEvent"; - "MIDIInput"; - "MIDIInputMap"; - "MIDIMessageEvent"; - "MIDIOutput"; - "MIDIOutputMap"; - "MIDIPort"; "Map"; "Math"; + "MathMLElement"; "MediaCapabilities"; - "MediaCapabilitiesInfo"; - "MediaDeviceInfo"; - "MediaDevices"; "MediaElementAudioSourceNode"; "MediaEncryptedEvent"; "MediaError"; "MediaList"; + "MediaMetadata"; "MediaQueryList"; "MediaQueryListEvent"; "MediaRecorder"; - "MediaSettingsRange"; + "MediaSession"; "MediaSource"; + "MediaSourceHandle"; "MediaStream"; "MediaStreamAudioDestinationNode"; "MediaStreamAudioSourceNode"; "MediaStreamEvent"; "MediaStreamTrack"; "MediaStreamTrackEvent"; + "MediaStreamTrackGenerator"; + "MediaStreamTrackProcessor"; "MessageChannel"; "MessageEvent"; "MessagePort"; @@ -325,7 +366,14 @@ let sorted_keywords = [| "MutationRecord"; "NaN"; "NamedNodeMap"; + "NavigateEvent"; + "Navigation"; + "NavigationCurrentEntryChangeEvent"; + "NavigationDestination"; + "NavigationHistoryEntry"; + "NavigationTransition"; "Navigator"; + "NavigatorUAData"; "NetworkInformation"; "Node"; "NodeFilter"; @@ -344,11 +392,12 @@ let sorted_keywords = [| "PageTransitionEvent"; "PannerNode"; "Path2D"; - "PaymentInstruments"; "PaymentManager"; "PaymentRequestUpdateEvent"; "Performance"; + "PerformanceElementTiming"; "PerformanceEntry"; + "PerformanceEventTiming"; "PerformanceLongTaskTiming"; "PerformanceMark"; "PerformanceMeasure"; @@ -360,16 +409,18 @@ let sorted_keywords = [| "PerformanceResourceTiming"; "PerformanceServerTiming"; "PerformanceTiming"; + "PeriodicSyncManager"; "PeriodicWave"; "PermissionStatus"; "Permissions"; - "PhotoCapabilities"; + "PictureInPictureEvent"; "PictureInPictureWindow"; "Plugin"; "PluginArray"; "PointerEvent"; "PopStateEvent"; "ProcessingInstruction"; + "Profiler"; "ProgressEvent"; "Promise"; "PromiseRejectionEvent"; @@ -382,20 +433,32 @@ let sorted_keywords = [| "RTCDTMFToneChangeEvent"; "RTCDataChannel"; "RTCDataChannelEvent"; + "RTCDtlsTransport"; + "RTCEncodedAudioFrame"; + "RTCEncodedVideoFrame"; + "RTCError"; + "RTCErrorEvent"; "RTCIceCandidate"; + "RTCIceTransport"; "RTCPeerConnection"; + "RTCPeerConnectionIceErrorEvent"; "RTCPeerConnectionIceEvent"; - "RTCRtpContributingSource"; "RTCRtpReceiver"; "RTCRtpSender"; "RTCRtpTransceiver"; + "RTCSctpTransport"; "RTCSessionDescription"; "RTCStatsReport"; "RTCTrackEvent"; "RadioNodeList"; "Range"; "RangeError"; + "ReadableByteStreamController"; "ReadableStream"; + "ReadableStreamBYOBReader"; + "ReadableStreamBYOBRequest"; + "ReadableStreamDefaultController"; + "ReadableStreamDefaultReader"; "ReferenceError"; "Reflect"; "RegExp"; @@ -404,6 +467,7 @@ let sorted_keywords = [| "Request"; "ResizeObserver"; "ResizeObserverEntry"; + "ResizeObserverSize"; "Response"; "SVGAElement"; "SVGAngle"; @@ -428,7 +492,6 @@ let sorted_keywords = [| "SVGComponentTransferFunctionElement"; "SVGDefsElement"; "SVGDescElement"; - "SVGDiscardElement"; "SVGElement"; "SVGEllipseElement"; "SVGFEBlendElement"; @@ -503,14 +566,16 @@ let sorted_keywords = [| "SVGUnitTypes"; "SVGUseElement"; "SVGViewElement"; + "Scheduler"; + "Scheduling"; "Screen"; "ScreenOrientation"; "ScriptProcessorNode"; + "ScrollTimeline"; "SecurityPolicyViolationEvent"; "Selection"; "Set"; "ShadowRoot"; - "SharedArrayBuffer"; "SharedWorker"; "SourceBuffer"; "SourceBufferList"; @@ -526,11 +591,14 @@ let sorted_keywords = [| "StylePropertyMapReadOnly"; "StyleSheet"; "StyleSheetList"; - "SubtleCrypto"; + "SubmitEvent"; "Symbol"; "SyncManager"; "SyntaxError"; "TaskAttributionTiming"; + "TaskController"; + "TaskPriorityChangeEvent"; + "TaskSignal"; "Text"; "TextDecoder"; "TextDecoderStream"; @@ -543,17 +611,25 @@ let sorted_keywords = [| "TextTrackCueList"; "TextTrackList"; "TimeRanges"; + "ToggleEvent"; "Touch"; "TouchEvent"; "TouchList"; "TrackEvent"; "TransformStream"; + "TransformStreamDefaultController"; "TransitionEvent"; "TreeWalker"; + "TrustedHTML"; + "TrustedScript"; + "TrustedScriptURL"; + "TrustedTypePolicy"; + "TrustedTypePolicyFactory"; "TypeError"; "UIEvent"; "URIError"; "URL"; + "URLPattern"; "URLSearchParams"; "Uint16Array"; "Uint32Array"; @@ -562,9 +638,17 @@ let sorted_keywords = [| "UserActivation"; "VTTCue"; "ValidityState"; + "VideoColorSpace"; + "VideoFrame"; + "VideoPlaybackQuality"; + "ViewTimeline"; + "ViewTransition"; + "VirtualKeyboardGeometryChangeEvent"; + "VisibilityStateEntry"; "VisualViewport"; "WaveShaperNode"; "WeakMap"; + "WeakRef"; "WeakSet"; "WebAssembly"; "WebGL2RenderingContext"; @@ -589,8 +673,12 @@ let sorted_keywords = [| "WebSocket"; "WheelEvent"; "Window"; + "WindowControlsOverlay"; + "WindowControlsOverlayGeometryChangeEvent"; "Worker"; "WritableStream"; + "WritableStreamDefaultController"; + "WritableStreamDefaultWriter"; "XDomainRequest"; "XMLDocument"; "XMLHttpRequest"; diff --git a/analysis/vendor/ext/literals.ml b/analysis/vendor/ext/literals.ml index 6810267cf..ed410ee8d 100644 --- a/analysis/vendor/ext/literals.ml +++ b/analysis/vendor/ext/literals.ml @@ -76,6 +76,8 @@ let package_json = "package.json" let bsconfig_json = "bsconfig.json" +let rescript_json = "rescript.json" + let build_ninja = "build.ninja" (* Name of the library file created for each external dependency. *) diff --git a/analysis/vendor/ext/warnings.ml b/analysis/vendor/ext/warnings.ml index ba237696e..a839f711f 100644 --- a/analysis/vendor/ext/warnings.ml +++ b/analysis/vendor/ext/warnings.ml @@ -26,6 +26,8 @@ type loc = { loc_ghost : bool; } +type topLevelUnitHelp = FunctionCall | Other + type t = | Comment_start (* 1 *) | Comment_not_end (* 2 *) @@ -83,7 +85,7 @@ type t = | Bs_unimplemented_primitive of string (* 106 *) | Bs_integer_literal_overflow (* 107 *) | Bs_uninterpreted_delimiters of string (* 108 *) - | Bs_toplevel_expression_unit (* 109 *) + | Bs_toplevel_expression_unit of (string * topLevelUnitHelp) option (* 109 *) (* If you remove a warning, leave a hole in the numbering. NEVER change the numbers of existing warnings. @@ -148,7 +150,7 @@ let number = function | Bs_unimplemented_primitive _ -> 106 | Bs_integer_literal_overflow -> 107 | Bs_uninterpreted_delimiters _ -> 108 - | Bs_toplevel_expression_unit -> 109 + | Bs_toplevel_expression_unit _ -> 109 let last_warning_number = 110 @@ -480,7 +482,7 @@ let message = function | Bs_polymorphic_comparison -> "Polymorphic comparison introduced (maybe unsafe)" | Bs_ffi_warning s -> "FFI warning: " ^ s - | Bs_derive_warning s -> "bs.deriving warning: " ^ s + | Bs_derive_warning s -> "@deriving warning: " ^ s | Bs_fragile_external s -> s ^ " : using an empty string as a shorthand to infer the external's name \ @@ -490,8 +492,23 @@ let message = function | Bs_integer_literal_overflow -> "Integer literal exceeds the range of representable integers of type int" | Bs_uninterpreted_delimiters s -> "Uninterpreted delimiters " ^ s - | Bs_toplevel_expression_unit -> - "Toplevel expression is expected to have unit type." + | Bs_toplevel_expression_unit help -> + Printf.sprintf "This%sis at the top level and is expected to return `unit`. But it's returning %s.\n\n In ReScript, anything at the top level must evaluate to `unit`. You can fix this by assigning the expression to a value, or piping it into the `ignore` function.%s" + (match help with + | Some (_, FunctionCall) -> " function call " + | _ -> " ") + + (match help with + | Some (returnType, _) -> Printf.sprintf "`%s`" returnType + | None -> "something that is not `unit`") + + (match help with + | Some (_, helpTyp) -> + let helpText = (match helpTyp with + | FunctionCall -> "yourFunctionCall()" + | Other -> "yourExpression") in + Printf.sprintf "\n\n Possible solutions:\n - Assigning to a value that is then ignored: `let _ = %s`\n - Piping into the built-in ignore function to ignore the result: `%s->ignore`" helpText helpText + | _ -> "") let sub_locs = function | Deprecated (_, def, use) -> diff --git a/analysis/vendor/ext/warnings.mli b/analysis/vendor/ext/warnings.mli index 4e36bc00e..d5d8445c2 100644 --- a/analysis/vendor/ext/warnings.mli +++ b/analysis/vendor/ext/warnings.mli @@ -19,6 +19,8 @@ type loc = { loc_ghost : bool; } +type topLevelUnitHelp = FunctionCall | Other + type t = | Comment_start (* 1 *) | Comment_not_end (* 2 *) @@ -76,7 +78,7 @@ type t = | Bs_unimplemented_primitive of string (* 106 *) | Bs_integer_literal_overflow (* 107 *) | Bs_uninterpreted_delimiters of string (* 108 *) - | Bs_toplevel_expression_unit (* 109 *) + | Bs_toplevel_expression_unit of (string * topLevelUnitHelp) option (* 109 *) val parse_options : bool -> string -> unit diff --git a/analysis/vendor/js_parser/.ocamlformat b/analysis/vendor/js_parser/.ocamlformat new file mode 100644 index 000000000..593b6a1ff --- /dev/null +++ b/analysis/vendor/js_parser/.ocamlformat @@ -0,0 +1 @@ +disable diff --git a/analysis/vendor/js_parser/comment_attachment.ml b/analysis/vendor/js_parser/comment_attachment.ml new file mode 100644 index 000000000..4866a4785 --- /dev/null +++ b/analysis/vendor/js_parser/comment_attachment.ml @@ -0,0 +1,779 @@ +(* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) + +module Ast = Flow_ast +open Flow_ast +open Parser_env + +let id = Flow_ast_mapper.id + +let map_loc = Flow_ast_mapper.map_loc + +let map_opt = Flow_ast_mapper.map_opt + +let id_list_last (map : 'a -> 'a) (lst : 'a list) : 'a list = + match List.rev lst with + | [] -> lst + | hd :: tl -> + let hd' = map hd in + if hd == hd' then + lst + else + List.rev (hd' :: tl) + +(* Mapper that removes all trailing comments that appear after a given position in an AST node *) +class ['loc] trailing_comments_remover ~after_pos = + object (this) + inherit ['loc] Flow_ast_mapper.mapper + + method! syntax comments = + let open Syntax in + let { trailing; _ } = comments in + let trailing' = + List.filter (fun (loc, _) -> Loc.(pos_cmp loc.start after_pos < 0)) trailing + in + if List.length trailing = List.length trailing' then + comments + else + { comments with trailing = trailing' } + + method! array _loc expr = + let open Ast.Expression.Array in + let { comments; _ } = expr in + id this#syntax_opt comments expr (fun comments' -> { expr with comments = comments' }) + + method! array_type t = + let open Ast.Type.Array in + let { comments; _ } = t in + id this#syntax_opt comments t (fun comments' -> { t with comments = comments' }) + + method! assignment _loc expr = + let open Ast.Expression.Assignment in + let { right; comments; _ } = expr in + let right' = this#expression right in + let comments' = this#syntax_opt comments in + if right == right' && comments == comments' then + expr + else + { expr with right = right'; comments = comments' } + + method! binary _loc expr = + let open Ast.Expression.Binary in + let { right; comments; _ } = expr in + let right' = this#expression right in + let comments' = this#syntax_opt comments in + if right == right' && comments == comments' then + expr + else + { expr with right = right'; comments = comments' } + + method! block _loc stmt = + let open Ast.Statement.Block in + let { comments; _ } = stmt in + id this#syntax_opt comments stmt (fun comments' -> { stmt with comments = comments' }) + + method! call _annot expr = + let open Ast.Expression.Call in + let { arguments; comments; _ } = expr in + let arguments' = this#call_arguments arguments in + let comments' = this#syntax_opt comments in + if arguments == arguments' && comments == comments' then + expr + else + { expr with arguments = arguments'; comments = comments' } + + method! call_arguments arg_list = + let open Ast.Expression.ArgList in + let (loc, { arguments; comments }) = arg_list in + id this#syntax_opt comments arg_list (fun comments' -> + (loc, { arguments; comments = comments' }) + ) + + method! call_type_args targs = + let open Ast.Expression.CallTypeArgs in + let (loc, { arguments; comments }) = targs in + id this#syntax_opt comments targs (fun comments' -> (loc, { arguments; comments = comments' })) + + method! class_ _loc cls = + let open Ast.Class in + let { body; comments; _ } = cls in + let body' = this#class_body body in + let comments' = this#syntax_opt comments in + if body == body' && comments == comments' then + cls + else + { cls with body = body'; comments = comments' } + + method! class_body body = + let open Ast.Class.Body in + let (loc, { body = _body; comments }) = body in + id this#syntax_opt comments body (fun comments' -> + (loc, { body = _body; comments = comments' }) + ) + + method! class_extends _loc extends = + let open Ast.Class.Extends in + let { expr; targs; _ } = extends in + if targs = None then + id this#expression expr extends (fun expr' -> { extends with expr = expr' }) + else + id (map_opt this#type_args) targs extends (fun targs' -> { extends with targs = targs' }) + + method! class_implements implements = + let open Ast.Class.Implements in + let (loc, { interfaces; comments }) = implements in + id (id_list_last this#class_implements_interface) interfaces implements (fun interfaces' -> + (loc, { interfaces = interfaces'; comments }) + ) + + method! class_implements_interface interface = + let open Ast.Class.Implements.Interface in + let (loc, { id = id_; targs }) = interface in + if targs = None then + id this#identifier id_ interface (fun id' -> (loc, { id = id'; targs })) + else + id (map_opt this#type_args) targs interface (fun targs' -> + (loc, { id = id_; targs = targs' }) + ) + + method! computed_key key = + let open Ast.ComputedKey in + let (loc, { expression; comments }) = key in + id this#syntax_opt comments key (fun comments' -> (loc, { expression; comments = comments' })) + + method! conditional _loc expr = + let open Ast.Expression.Conditional in + let { alternate; comments; _ } = expr in + let alternate' = this#expression alternate in + let comments' = this#syntax_opt comments in + if alternate == alternate' && comments == comments' then + expr + else + { expr with alternate = alternate'; comments = comments' } + + method! function_ _loc func = + let open Ast.Function in + let { body; comments; _ } = func in + let body' = this#function_body_any body in + let comments' = this#syntax_opt comments in + if body == body' && comments == comments' then + func + else + { func with body = body'; comments = comments' } + + method! function_params (loc, params) = + let open Ast.Function.Params in + let { comments; _ } = params in + id this#syntax_opt comments (loc, params) (fun comments' -> + (loc, { params with comments = comments' }) + ) + + method! function_type _loc func = + let open Ast.Type.Function in + let { return; comments; _ } = func in + let return' = this#type_ return in + let comments' = this#syntax_opt comments in + if return == return' && comments == comments' then + func + else + { func with return = return'; comments = comments' } + + method! generic_identifier_type git = + let open Ast.Type.Generic.Identifier in + match git with + | Unqualified i -> id this#identifier i git (fun i -> Unqualified i) + | Qualified (loc, ({ id; _ } as qualified)) -> + let id' = this#identifier id in + if id == id' then + git + else + Qualified (loc, { qualified with id = id' }) + + method! import _loc expr = + let open Ast.Expression.Import in + let { comments; _ } = expr in + id this#syntax_opt comments expr (fun comments' -> { expr with comments = comments' }) + + method! interface_type _loc t = + let open Ast.Type.Interface in + let { body; comments; _ } = t in + let body' = map_loc this#object_type body in + let comments' = this#syntax_opt comments in + if body == body' && comments == comments' then + t + else + { t with body = body'; comments = comments' } + + method! intersection_type _loc t = + let { Ast.Type.Intersection.types = (t0, t1, ts); comments } = t in + let (t1', ts') = + match ts with + | [] -> (this#type_ t1, []) + | _ -> (t1, id_list_last this#type_ ts) + in + let comments' = this#syntax_opt comments in + if t1 == t1' && ts == ts' && comments == comments' then + t + else + { Ast.Type.Intersection.types = (t0, t1', ts'); comments = comments' } + + method! jsx_element _loc elem = + let open Ast.JSX in + let { comments; _ } = elem in + id this#syntax_opt comments elem (fun comments' -> { elem with comments = comments' }) + + method! jsx_fragment _loc frag = + let open Ast.JSX in + let { frag_comments = comments; _ } = frag in + id this#syntax_opt comments frag (fun comments' -> { frag with frag_comments = comments' }) + + method! logical _loc expr = + let open Ast.Expression.Logical in + let { right; comments; _ } = expr in + let right' = this#expression right in + let comments' = this#syntax_opt comments in + if right == right' && comments == comments' then + expr + else + { expr with right = right'; comments = comments' } + + method! new_ _loc expr = + let open Ast.Expression.New in + let { callee; targs; arguments; comments } = expr in + let comments' = this#syntax_opt comments in + match (targs, arguments) with + (* new Callee() *) + | (_, Some _) -> + let arguments' = map_opt this#call_arguments arguments in + if arguments == arguments' && comments == comments' then + expr + else + { expr with arguments = arguments'; comments = comments' } + (* new Callee *) + | (Some _, _) -> + let targs' = map_opt this#call_type_args targs in + if targs == targs' && comments == comments' then + expr + else + { expr with targs = targs'; comments = comments' } + (* new Callee *) + | (None, None) -> + let callee' = this#expression callee in + if callee == callee' && comments == comments' then + expr + else + { expr with callee = callee'; comments = comments' } + + method! member _loc expr = + let open Ast.Expression.Member in + let { property; comments; _ } = expr in + let property' = this#member_property property in + let comments' = this#syntax_opt comments in + if property == property' && comments == comments' then + expr + else + { expr with property = property'; comments = comments' } + + method! object_ _loc expr = + let open Ast.Expression.Object in + let { comments; _ } = expr in + id this#syntax_opt comments expr (fun comments' -> { expr with comments = comments' }) + + method! object_type _loc obj = + let open Ast.Type.Object in + let { comments; _ } = obj in + id this#syntax_opt comments obj (fun comments' -> { obj with comments = comments' }) + + method! predicate pred = + let open Ast.Type.Predicate in + let (loc, { kind; comments }) = pred in + id this#syntax_opt comments pred (fun comments' -> (loc, { kind; comments = comments' })) + + method! sequence _loc expr = + let open Ast.Expression.Sequence in + let { expressions; comments } = expr in + let expressions' = id_list_last this#expression expressions in + let comments' = this#syntax_opt comments in + if expressions == expressions' && comments == comments' then + expr + else + { expressions = expressions'; comments = comments' } + + method! template_literal _loc expr = + let open Ast.Expression.TemplateLiteral in + let { comments; _ } = expr in + id this#syntax_opt comments expr (fun comments' -> { expr with comments = comments' }) + + method! tuple_type t = + let open Ast.Type.Tuple in + let { comments; _ } = t in + id this#syntax_opt comments t (fun comments' -> { t with comments = comments' }) + + method! type_cast _loc expr = + let open Ast.Expression.TypeCast in + let { comments; _ } = expr in + id this#syntax_opt comments expr (fun comments' -> { expr with comments = comments' }) + + method! type_params tparams = + let open Ast.Type.TypeParams in + let (loc, { params; comments }) = tparams in + id this#syntax_opt comments tparams (fun comments' -> (loc, { params; comments = comments' })) + + method! union_type _loc t = + let { Ast.Type.Union.types = (t0, t1, ts); comments } = t in + let (t1', ts') = + match ts with + | [] -> (this#type_ t1, []) + | _ -> (t1, id_list_last this#type_ ts) + in + let comments' = this#syntax_opt comments in + if t1 == t1' && ts == ts' && comments == comments' then + t + else + { Ast.Type.Union.types = (t0, t1', ts'); comments = comments' } + + method! variable_declarator ~kind decl = + let open Ast.Statement.VariableDeclaration.Declarator in + let (loc, { id = ident; init }) = decl in + match init with + | None -> + id (this#variable_declarator_pattern ~kind) ident decl (fun ident' -> + (loc, { id = ident'; init }) + ) + | Some init -> + id this#expression init decl (fun init' -> (loc, { id = ident; init = Some init' })) + end + +type trailing_and_remover_result = { + trailing: Loc.t Comment.t list; + remove_trailing: 'a. 'a -> (Loc.t trailing_comments_remover -> 'a -> 'a) -> 'a; +} + +(* Returns a remover function which removes comments beginning after the previous token. + No trailing comments are returned, since all comments since the last loc should be removed. *) +let trailing_and_remover_after_last_loc : Parser_env.env -> trailing_and_remover_result = + fun env -> + let open Loc in + let remover = + match Parser_env.last_loc env with + | None -> None + | Some _ when not (Peek.has_eaten_comments env) -> None + | Some last_loc -> + Parser_env.consume_comments_until env last_loc._end; + let remover = new trailing_comments_remover ~after_pos:last_loc._end in + Some remover + in + { + trailing = []; + remove_trailing = + (fun node f -> + match remover with + | None -> node + | Some remover -> f remover node); + } + +(* Consumes and returns comments on the same line as the previous token. Also returns a remover + function which can be used to remove comments beginning after the previous token's line. *) +let trailing_and_remover_after_last_line : Parser_env.env -> trailing_and_remover_result = + fun env -> + let open Loc in + let (trailing, remover) = + match Parser_env.last_loc env with + | None -> ([], None) + | Some _ when not (Peek.has_eaten_comments env) -> (Eat.comments_until_next_line env, None) + | Some last_loc -> + Parser_env.consume_comments_until env last_loc._end; + let trailing = Eat.comments_until_next_line env in + let next_line_start = { line = last_loc._end.line + 1; column = 0 } in + let remover = new trailing_comments_remover ~after_pos:next_line_start in + (trailing, Some remover) + in + { + trailing; + remove_trailing = + (fun node f -> + match remover with + | None -> node + | Some remover -> f remover node); + } + +let trailing_and_remover : Parser_env.env -> trailing_and_remover_result = + fun env -> + if Peek.is_line_terminator env then + trailing_and_remover_after_last_line env + else + trailing_and_remover_after_last_loc env + +let id_remove_trailing env id = + let { remove_trailing; _ } = trailing_and_remover env in + remove_trailing id (fun remover id -> remover#identifier id) + +let expression_remove_trailing env expr = + let { remove_trailing; _ } = trailing_and_remover env in + remove_trailing expr (fun remover expr -> remover#expression expr) + +let block_remove_trailing env block = + let { remove_trailing; _ } = trailing_and_remover env in + remove_trailing block (fun remover (loc, str) -> (loc, remover#block loc str)) + +let type_params_remove_trailing env tparams = + match tparams with + | None -> None + | Some tparams -> + let { remove_trailing; _ } = trailing_and_remover env in + Some (remove_trailing tparams (fun remover tparams -> remover#type_params tparams)) + +let type_remove_trailing env ty = + let { remove_trailing; _ } = trailing_and_remover env in + remove_trailing ty (fun remover ty -> remover#type_ ty) + +let type_annotation_hint_remove_trailing env annot = + let { remove_trailing; _ } = trailing_and_remover env in + remove_trailing annot (fun remover annot -> remover#type_annotation_hint annot) + +let function_params_remove_trailing env params = + let { remove_trailing; _ } = trailing_and_remover env in + remove_trailing params (fun remover params -> remover#function_params params) + +let predicate_remove_trailing env pred = + match pred with + | None -> None + | Some pred -> + let { remove_trailing; _ } = trailing_and_remover env in + Some (remove_trailing pred (fun remover pred -> remover#predicate pred)) + +let object_key_remove_trailing env key = + let { remove_trailing; _ } = trailing_and_remover env in + remove_trailing key (fun remover key -> remover#object_key key) + +let generic_type_remove_trailing env ty = + let { remove_trailing; _ } = trailing_and_remover env in + remove_trailing ty (fun remover ty -> map_loc remover#generic_type ty) + +let generic_type_list_remove_trailing env extends = + let { remove_trailing; _ } = trailing_and_remover env in + remove_trailing extends (fun remover extends -> + id_list_last (map_loc remover#generic_type) extends + ) + +let class_implements_remove_trailing env implements = + let { remove_trailing; _ } = trailing_and_remover env in + remove_trailing implements (fun remover impl -> remover#class_implements impl) + +let string_literal_remove_trailing env str = + let { remove_trailing; _ } = trailing_and_remover env in + remove_trailing str (fun remover (loc, str) -> (loc, remover#string_literal_type loc str)) + +let statement_add_comments + ((loc, stmt) : (Loc.t, Loc.t) Statement.t) (comments : (Loc.t, unit) Syntax.t option) : + (Loc.t, Loc.t) Statement.t = + let open Statement in + let merge_comments inner = Flow_ast_utils.merge_comments ~inner ~outer:comments in + let merge_comments_with_internal inner = + Flow_ast_utils.merge_comments_with_internal ~inner ~outer:comments + in + ( loc, + match stmt with + | Block ({ Block.comments; _ } as s) -> + Block { s with Block.comments = merge_comments_with_internal comments } + | Break ({ Break.comments; _ } as s) -> + Break { s with Break.comments = merge_comments comments } + | ClassDeclaration ({ Class.comments; _ } as s) -> + ClassDeclaration { s with Class.comments = merge_comments comments } + | Continue ({ Continue.comments; _ } as s) -> + Continue { s with Continue.comments = merge_comments comments } + | Debugger { Debugger.comments } -> Debugger { Debugger.comments = merge_comments comments } + | DeclareClass ({ DeclareClass.comments; _ } as s) -> + DeclareClass { s with DeclareClass.comments = merge_comments comments } + | DeclareExportDeclaration ({ DeclareExportDeclaration.comments; _ } as s) -> + DeclareExportDeclaration + { s with DeclareExportDeclaration.comments = merge_comments comments } + | DeclareFunction ({ DeclareFunction.comments; _ } as s) -> + DeclareFunction { s with DeclareFunction.comments = merge_comments comments } + | DeclareInterface ({ Interface.comments; _ } as s) -> + DeclareInterface { s with Interface.comments = merge_comments comments } + | DeclareModule ({ DeclareModule.comments; _ } as s) -> + DeclareModule { s with DeclareModule.comments = merge_comments comments } + | DeclareModuleExports ({ DeclareModuleExports.comments; _ } as s) -> + DeclareModuleExports { s with DeclareModuleExports.comments = merge_comments comments } + | DeclareTypeAlias ({ TypeAlias.comments; _ } as s) -> + DeclareTypeAlias { s with TypeAlias.comments = merge_comments comments } + | DeclareOpaqueType ({ OpaqueType.comments; _ } as s) -> + DeclareOpaqueType { s with OpaqueType.comments = merge_comments comments } + | DeclareVariable ({ DeclareVariable.comments; _ } as s) -> + DeclareVariable { s with DeclareVariable.comments = merge_comments comments } + | DoWhile ({ DoWhile.comments; _ } as s) -> + DoWhile { s with DoWhile.comments = merge_comments comments } + | Empty { Empty.comments } -> Empty { Empty.comments = merge_comments comments } + | EnumDeclaration ({ EnumDeclaration.comments; _ } as s) -> + EnumDeclaration { s with EnumDeclaration.comments = merge_comments comments } + | ExportDefaultDeclaration ({ ExportDefaultDeclaration.comments; _ } as s) -> + ExportDefaultDeclaration + { s with ExportDefaultDeclaration.comments = merge_comments comments } + | ExportNamedDeclaration ({ ExportNamedDeclaration.comments; _ } as s) -> + ExportNamedDeclaration { s with ExportNamedDeclaration.comments = merge_comments comments } + | Expression ({ Expression.comments; _ } as s) -> + Expression { s with Expression.comments = merge_comments comments } + | For ({ For.comments; _ } as s) -> For { s with For.comments = merge_comments comments } + | ForIn ({ ForIn.comments; _ } as s) -> + ForIn { s with ForIn.comments = merge_comments comments } + | ForOf ({ ForOf.comments; _ } as s) -> + ForOf { s with ForOf.comments = merge_comments comments } + | FunctionDeclaration ({ Function.comments; _ } as s) -> + FunctionDeclaration { s with Function.comments = merge_comments comments } + | If ({ If.comments; _ } as s) -> If { s with If.comments = merge_comments comments } + | ImportDeclaration ({ ImportDeclaration.comments; _ } as s) -> + ImportDeclaration { s with ImportDeclaration.comments = merge_comments comments } + | InterfaceDeclaration ({ Interface.comments; _ } as s) -> + InterfaceDeclaration { s with Interface.comments = merge_comments comments } + | Labeled ({ Labeled.comments; _ } as s) -> + Labeled { s with Labeled.comments = merge_comments comments } + | Return ({ Return.comments; _ } as s) -> + Return { s with Return.comments = merge_comments comments } + | Switch ({ Switch.comments; _ } as s) -> + Switch { s with Switch.comments = merge_comments comments } + | Throw ({ Throw.comments; _ } as s) -> + Throw { s with Throw.comments = merge_comments comments } + | Try ({ Try.comments; _ } as s) -> Try { s with Try.comments = merge_comments comments } + | TypeAlias ({ TypeAlias.comments; _ } as s) -> + TypeAlias { s with TypeAlias.comments = merge_comments comments } + | OpaqueType ({ OpaqueType.comments; _ } as s) -> + OpaqueType { s with OpaqueType.comments = merge_comments comments } + | VariableDeclaration ({ VariableDeclaration.comments; _ } as s) -> + VariableDeclaration { s with VariableDeclaration.comments = merge_comments comments } + | While ({ While.comments; _ } as s) -> + While { s with While.comments = merge_comments comments } + | With ({ With.comments; _ } as s) -> With { s with With.comments = merge_comments comments } + ) + +(* Collects the first leading and last trailing comment on an AST node or its children. + The first leading comment is the first attached comment that begins before the given node's loc, + and the last trailing comment is the last attached comment that begins after the given node's loc. *) +class ['loc] comment_bounds_collector ~loc = + object (this) + inherit ['loc] Flow_ast_mapper.mapper + + val mutable first_leading = None + + val mutable last_trailing = None + + method comment_bounds = (first_leading, last_trailing) + + method collect_comments : 'internal. ('loc, 'internal) Syntax.t -> unit = + function + | { Syntax.leading; trailing; _ } -> + List.iter this#visit_leading_comment leading; + List.iter this#visit_trailing_comment trailing + + method collect_comments_opt = + function + | None -> () + | Some comments -> this#collect_comments comments + + method visit_leading_comment ((comment_loc, _) as comment) = + let open Loc in + match first_leading with + | None -> if pos_cmp comment_loc.start loc.start < 0 then first_leading <- Some comment + | Some (current_first_loc, _) -> + if pos_cmp comment_loc.start current_first_loc.start < 0 then first_leading <- Some comment + + method visit_trailing_comment ((comment_loc, _) as comment) = + let open Loc in + match last_trailing with + | None -> if pos_cmp comment_loc.start loc._end >= 0 then last_trailing <- Some comment + | Some (current_last_loc, _) -> + if pos_cmp current_last_loc.start comment_loc.start < 0 then last_trailing <- Some comment + + method! syntax comments = + this#collect_comments comments; + comments + + method! block _loc block = + let { Statement.Block.comments; _ } = block in + this#collect_comments_opt comments; + block + end + +(* Given an AST node and a function to collect all its comments, return the first leading + and last trailing comment on the node. *) +let comment_bounds loc node f = + let collector = new comment_bounds_collector ~loc in + ignore (f collector node); + collector#comment_bounds + +(* Expand node's loc to include its attached comments *) +let expand_loc_with_comment_bounds loc (first_leading, last_trailing) = + let open Loc in + let start = + match first_leading with + | None -> loc + | Some (first_leading_loc, _) -> first_leading_loc + in + let _end = + match last_trailing with + | None -> loc + | Some (last_trailing_loc, _) -> last_trailing_loc + in + btwn start _end + +(* Remove the trailing comment bound if it is a line comment *) +let comment_bounds_without_trailing_line_comment (leading, trailing) = + match trailing with + | Some (_, { Ast.Comment.kind = Ast.Comment.Line; _ }) -> (leading, None) + | _ -> (leading, trailing) + +let collect_without_trailing_line_comment collector = + comment_bounds_without_trailing_line_comment collector#comment_bounds + +(* Return the first leading and last trailing comment of a statement *) +let statement_comment_bounds ((loc, _) as stmt : (Loc.t, Loc.t) Statement.t) : + Loc.t Comment.t option * Loc.t Comment.t option = + let collector = new comment_bounds_collector ~loc in + ignore (collector#statement stmt); + collector#comment_bounds + +let expression_comment_bounds ((loc, _) as expr) = + let collector = new comment_bounds_collector ~loc in + ignore (collector#expression expr); + collector#comment_bounds + +let type_comment_bounds ((loc, _) as ty) = + let collector = new comment_bounds_collector ~loc in + ignore (collector#type_ ty); + collector#comment_bounds + +let block_comment_bounds (loc, block) = + let collector = new comment_bounds_collector ~loc in + ignore (collector#block loc block); + collector#comment_bounds + +let object_property_comment_bounds property = + let open Ast.Expression.Object in + let collector = + match property with + | Property ((loc, _) as p) -> + let collector = new comment_bounds_collector ~loc in + ignore (collector#object_property p); + collector + | SpreadProperty ((loc, _) as p) -> + let collector = new comment_bounds_collector ~loc in + ignore (collector#spread_property p); + collector + in + collect_without_trailing_line_comment collector + +let object_type_property_comment_bounds property = + let open Ast.Type.Object in + let collector = + match property with + | Property ((loc, _) as p) -> + let collector = new comment_bounds_collector ~loc in + ignore (collector#object_property_type p); + collector + | SpreadProperty ((loc, _) as p) -> + let collector = new comment_bounds_collector ~loc in + ignore (collector#object_spread_property_type p); + collector + | Indexer ((loc, _) as p) -> + let collector = new comment_bounds_collector ~loc in + ignore (collector#object_indexer_property_type p); + collector + | InternalSlot ((loc, _) as p) -> + let collector = new comment_bounds_collector ~loc in + ignore (collector#object_internal_slot_property_type p); + collector + | CallProperty ((loc, _) as p) -> + let collector = new comment_bounds_collector ~loc in + ignore (collector#object_call_property_type p); + collector + in + collect_without_trailing_line_comment collector + +let object_pattern_property_comment_bounds loc property = + let collector = new comment_bounds_collector ~loc in + ignore (collector#pattern_object_p property); + collect_without_trailing_line_comment collector + +let switch_case_comment_bounds (loc, case) = + let collector = new comment_bounds_collector ~loc in + ignore (collector#switch_case (loc, case)); + collector#comment_bounds + +let function_param_comment_bounds (loc, param) = + let collector = new comment_bounds_collector ~loc in + ignore (collector#function_param (loc, param)); + collect_without_trailing_line_comment collector + +let function_rest_param_comment_bounds (loc, param) = + let collector = new comment_bounds_collector ~loc in + ignore (collector#function_rest_param (loc, param)); + collect_without_trailing_line_comment collector + +let function_this_param_comment_bounds (loc, param) = + let collector = new comment_bounds_collector ~loc in + ignore (collector#function_this_param (loc, param)); + collect_without_trailing_line_comment collector + +let function_type_param_comment_bounds (loc, param) = + let collector = new comment_bounds_collector ~loc in + ignore (collector#function_param_type (loc, param)); + collect_without_trailing_line_comment collector + +let function_type_rest_param_comment_bounds (loc, param) = + let collector = new comment_bounds_collector ~loc in + ignore (collector#function_rest_param_type (loc, param)); + collect_without_trailing_line_comment collector + +let function_type_this_param_comment_bounds (loc, param) = + let collector = new comment_bounds_collector ~loc in + ignore (collector#function_this_param_type (loc, param)); + collect_without_trailing_line_comment collector + +let array_element_comment_bounds loc element = + let collector = new comment_bounds_collector ~loc in + ignore (collector#array_element element); + collect_without_trailing_line_comment collector + +let array_pattern_element_comment_bounds loc element = + let collector = new comment_bounds_collector ~loc in + ignore (collector#pattern_array_e element); + collect_without_trailing_line_comment collector + +let expression_or_spread_comment_bounds loc expr_or_spread = + let collector = new comment_bounds_collector ~loc in + ignore (collector#expression_or_spread expr_or_spread); + collect_without_trailing_line_comment collector + +let call_type_arg_comment_bounds loc arg = + let collector = new comment_bounds_collector ~loc in + ignore (collector#call_type_arg arg); + collect_without_trailing_line_comment collector + +let type_param_comment_bounds (loc, param) = + let collector = new comment_bounds_collector ~loc in + ignore (collector#type_param (loc, param)); + collect_without_trailing_line_comment collector + +let function_body_comment_bounds body = + let loc = + match body with + | Ast.Function.BodyBlock (loc, _) -> loc + | Ast.Function.BodyExpression (loc, _) -> loc + in + let collector = new comment_bounds_collector ~loc in + ignore (collector#function_body_any body); + collector#comment_bounds + +let if_alternate_statement_comment_bounds loc alternate = + let collector = new comment_bounds_collector ~loc in + ignore (collector#if_alternate_statement loc alternate); + collector#comment_bounds + +let member_property_comment_bounds loc property = + let collector = new comment_bounds_collector ~loc in + ignore (collector#member_property property); + collector#comment_bounds diff --git a/analysis/vendor/js_parser/declaration_parser.ml b/analysis/vendor/js_parser/declaration_parser.ml new file mode 100644 index 000000000..ef9f983ac --- /dev/null +++ b/analysis/vendor/js_parser/declaration_parser.ml @@ -0,0 +1,432 @@ +(* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) + +module Ast = Flow_ast +open Token +open Parser_common +open Parser_env +open Flow_ast +open Comment_attachment + +module type DECLARATION = sig + val async : env -> bool * Loc.t Comment.t list + + val generator : env -> bool * Loc.t Comment.t list + + val variance : env -> bool -> bool -> Loc.t Variance.t option + + val function_params : await:bool -> yield:bool -> env -> (Loc.t, Loc.t) Ast.Function.Params.t + + val function_body : + env -> + async:bool -> + generator:bool -> + expression:bool -> + simple_params:bool -> + (Loc.t, Loc.t) Function.body * bool + + val strict_post_check : + env -> + contains_use_strict:bool -> + (Loc.t, Loc.t) Identifier.t option -> + (Loc.t, Loc.t) Ast.Function.Params.t -> + unit + + val let_ : + env -> + (Loc.t, Loc.t) Statement.VariableDeclaration.Declarator.t list + * Loc.t Ast.Comment.t list + * (Loc.t * Parse_error.t) list + + val const : + env -> + (Loc.t, Loc.t) Statement.VariableDeclaration.Declarator.t list + * Loc.t Ast.Comment.t list + * (Loc.t * Parse_error.t) list + + val var : + env -> + (Loc.t, Loc.t) Statement.VariableDeclaration.Declarator.t list + * Loc.t Ast.Comment.t list + * (Loc.t * Parse_error.t) list + + val _function : env -> (Loc.t, Loc.t) Statement.t + + val enum_declaration : env -> (Loc.t, Loc.t) Statement.t +end + +module Declaration (Parse : Parser_common.PARSER) (Type : Type_parser.TYPE) : DECLARATION = struct + module Enum = Enum_parser.Enum (Parse) + + let check_param = + let rec pattern ((env, _) as check_env) (loc, p) = + Pattern.( + match p with + | Object o -> _object check_env o + | Array arr -> _array check_env arr + | Identifier id -> identifier_pattern check_env id + | Expression _ -> + error_at env (loc, Parse_error.ExpectedPatternFoundExpression); + check_env + ) + and _object check_env o = List.fold_left object_property check_env o.Pattern.Object.properties + and object_property check_env = + let open Pattern.Object in + function + | Property (_, property) -> + Property.( + let check_env = + match property.key with + | Identifier id -> identifier_no_dupe_check check_env id + | _ -> check_env + in + pattern check_env property.pattern + ) + | RestElement (_, { Pattern.RestElement.argument; comments = _ }) -> + pattern check_env argument + and _array check_env arr = List.fold_left array_element check_env arr.Pattern.Array.elements + and array_element check_env = + let open Pattern.Array in + function + | Hole _ -> check_env + | Element (_, { Element.argument; default = _ }) -> pattern check_env argument + | RestElement (_, { Pattern.RestElement.argument; comments = _ }) -> + pattern check_env argument + and identifier_pattern check_env { Pattern.Identifier.name = id; _ } = identifier check_env id + and identifier (env, param_names) ((loc, { Identifier.name; comments = _ }) as id) = + if SSet.mem name param_names then error_at env (loc, Parse_error.StrictParamDupe); + let (env, param_names) = identifier_no_dupe_check (env, param_names) id in + (env, SSet.add name param_names) + and identifier_no_dupe_check (env, param_names) (loc, { Identifier.name; comments = _ }) = + if is_restricted name then strict_error_at env (loc, Parse_error.StrictParamName); + if is_future_reserved name || is_strict_reserved name then + strict_error_at env (loc, Parse_error.StrictReservedWord); + (env, param_names) + in + pattern + + let strict_post_check env ~contains_use_strict id params = + let strict_mode = Parser_env.in_strict_mode env in + let simple = is_simple_parameter_list params in + let (_, { Ast.Function.Params.params; rest; this_ = _; comments = _ }) = params in + (* If we were already in strict mode and therefore already threw strict + errors, we want to do these checks outside of strict mode. If we + were in non-strict mode but the function contains "use strict", then + we want to do these checks in strict mode *) + let env = + if strict_mode then + with_strict false env + else + with_strict contains_use_strict env + in + if contains_use_strict || strict_mode || not simple then ( + (match id with + | Some (loc, { Identifier.name; comments = _ }) -> + if is_restricted name then strict_error_at env (loc, Parse_error.StrictFunctionName); + if is_future_reserved name || is_strict_reserved name then + strict_error_at env (loc, Parse_error.StrictReservedWord) + | None -> ()); + let acc = + List.fold_left + (fun acc (_, { Function.Param.argument; default = _ }) -> check_param acc argument) + (env, SSet.empty) + params + in + match rest with + | Some (_, { Function.RestParam.argument; comments = _ }) -> ignore (check_param acc argument) + | None -> () + ) + + let function_params = + let rec param = + with_loc (fun env -> + if Peek.token env = T_THIS then error env Parse_error.ThisParamMustBeFirst; + let argument = Parse.pattern env Parse_error.StrictParamName in + let default = + if Peek.token env = T_ASSIGN then ( + Expect.token env T_ASSIGN; + Some (Parse.assignment env) + ) else + None + in + { Function.Param.argument; default } + ) + and param_list env acc = + match Peek.token env with + | (T_EOF | T_RPAREN | T_ELLIPSIS) as t -> + let rest = + if t = T_ELLIPSIS then + let leading = Peek.comments env in + let (loc, id) = + with_loc + (fun env -> + Expect.token env T_ELLIPSIS; + Parse.pattern env Parse_error.StrictParamName) + env + in + Some + ( loc, + { + Function.RestParam.argument = id; + comments = Flow_ast_utils.mk_comments_opt ~leading (); + } + ) + else + None + in + if Peek.token env <> T_RPAREN then error env Parse_error.ParameterAfterRestParameter; + (List.rev acc, rest) + | _ -> + let the_param = param env in + if Peek.token env <> T_RPAREN then Expect.token env T_COMMA; + param_list env (the_param :: acc) + in + let this_param_annotation env = + if should_parse_types env && Peek.token env = T_THIS then ( + let leading = Peek.comments env in + let (this_loc, this_param) = + with_loc + (fun env -> + Expect.token env T_THIS; + if Peek.token env <> T_COLON then begin + error env Parse_error.ThisParamAnnotationRequired; + None + end else + Some (Type.annotation env)) + env + in + match this_param with + | None -> None + | Some annot -> + if Peek.token env = T_COMMA then Eat.token env; + Some + ( this_loc, + { + Ast.Function.ThisParam.annot; + comments = Flow_ast_utils.mk_comments_opt ~leading (); + } + ) + ) else + None + in + fun ~await ~yield -> + with_loc (fun env -> + let env = + env + |> with_allow_await await + |> with_allow_yield yield + |> with_in_formal_parameters true + in + let leading = Peek.comments env in + Expect.token env T_LPAREN; + let this_ = this_param_annotation env in + let (params, rest) = param_list env [] in + let internal = Peek.comments env in + Expect.token env T_RPAREN; + let trailing = Eat.trailing_comments env in + { + Ast.Function.Params.params; + rest; + comments = Flow_ast_utils.mk_comments_with_internal_opt ~leading ~trailing ~internal (); + this_; + } + ) + + let function_body env ~async ~generator ~expression ~simple_params = + let env = enter_function env ~async ~generator ~simple_params in + let (body_block, contains_use_strict) = Parse.function_block_body env ~expression in + (Function.BodyBlock body_block, contains_use_strict) + + let variance env is_async is_generator = + let loc = Peek.loc env in + let variance = + match Peek.token env with + | T_PLUS -> + let leading = Peek.comments env in + Eat.token env; + Some + ( loc, + { Variance.kind = Variance.Plus; comments = Flow_ast_utils.mk_comments_opt ~leading () } + ) + | T_MINUS -> + let leading = Peek.comments env in + Eat.token env; + Some + ( loc, + { + Variance.kind = Variance.Minus; + comments = Flow_ast_utils.mk_comments_opt ~leading (); + } + ) + | _ -> None + in + match variance with + | Some (loc, _) when is_async || is_generator -> + error_at env (loc, Parse_error.UnexpectedVariance); + None + | _ -> variance + + let generator env = + if Peek.token env = T_MULT then ( + let leading = Peek.comments env in + Eat.token env; + (true, leading) + ) else + (false, []) + + (* Returns true and consumes a token if the token is `async` and the token after it is on + the same line (see https://tc39.github.io/ecma262/#sec-async-function-definitions) *) + let async env = + if Peek.token env = T_ASYNC && not (Peek.ith_is_line_terminator ~i:1 env) then + let leading = Peek.comments env in + let () = Eat.token env in + (true, leading) + else + (false, []) + + let _function = + with_loc (fun env -> + let (async, leading_async) = async env in + let (sig_loc, (generator, tparams, id, params, return, predicate, leading)) = + with_loc + (fun env -> + let leading_function = Peek.comments env in + Expect.token env T_FUNCTION; + let (generator, leading_generator) = generator env in + let leading = List.concat [leading_async; leading_function; leading_generator] in + let (tparams, id) = + match (in_export_default env, Peek.token env) with + | (true, T_LPAREN) -> (None, None) + | (true, T_LESS_THAN) -> + let tparams = type_params_remove_trailing env (Type.type_params env) in + let id = + if Peek.token env = T_LPAREN then + None + else + let id = + id_remove_trailing + env + (Parse.identifier ~restricted_error:Parse_error.StrictFunctionName env) + in + Some id + in + (tparams, id) + | _ -> + let id = + if Peek.is_identifier env then + id_remove_trailing + env + (Parse.identifier ~restricted_error:Parse_error.StrictFunctionName env) + else ( + (* don't consume the identifier here like Parse.identifier does. *) + error_nameless_declaration env "function"; + (Peek.loc env, { Identifier.name = ""; comments = None }) + ) + in + let tparams = type_params_remove_trailing env (Type.type_params env) in + (tparams, Some id) + in + let params = + let params = function_params ~await:async ~yield:generator env in + if Peek.token env = T_COLON then + params + else + function_params_remove_trailing env params + in + let (return, predicate) = Type.annotation_and_predicate_opt env in + let (return, predicate) = + match predicate with + | None -> (type_annotation_hint_remove_trailing env return, predicate) + | Some _ -> (return, predicate_remove_trailing env predicate) + in + (generator, tparams, id, params, return, predicate, leading)) + env + in + let simple_params = is_simple_parameter_list params in + let (body, contains_use_strict) = + function_body env ~async ~generator ~expression:false ~simple_params + in + strict_post_check env ~contains_use_strict id params; + Statement.FunctionDeclaration + { + Function.id; + params; + body; + generator; + async; + predicate; + return; + tparams; + sig_loc; + comments = Flow_ast_utils.mk_comments_opt ~leading (); + } + ) + + let variable_declaration_list = + let variable_declaration env = + let (loc, (decl, err)) = + with_loc + (fun env -> + let id = Parse.pattern env Parse_error.StrictVarName in + let (init, err) = + if Eat.maybe env T_ASSIGN then + (Some (Parse.assignment env), None) + else + match id with + | (_, Ast.Pattern.Identifier _) -> (None, None) + | (loc, _) -> (None, Some (loc, Parse_error.NoUninitializedDestructuring)) + in + (Ast.Statement.VariableDeclaration.Declarator.{ id; init }, err)) + env + in + ((loc, decl), err) + in + let rec helper env decls errs = + let (decl, err) = variable_declaration env in + let decls = decl :: decls in + let errs = + match err with + | Some x -> x :: errs + | None -> errs + in + if Eat.maybe env T_COMMA then + helper env decls errs + else + (List.rev decls, List.rev errs) + in + (fun env -> helper env [] []) + + let declarations token env = + let leading = Peek.comments env in + Expect.token env token; + let (declarations, errs) = variable_declaration_list env in + (declarations, leading, errs) + + let var = declarations T_VAR + + let const env = + let env = env |> with_no_let true in + let (declarations, leading_comments, errs) = declarations T_CONST env in + (* Make sure all consts defined are initialized *) + let errs = + List.fold_left + (fun errs decl -> + match decl with + | (loc, { Statement.VariableDeclaration.Declarator.init = None; _ }) -> + (loc, Parse_error.NoUninitializedConst) :: errs + | _ -> errs) + errs + declarations + in + (declarations, leading_comments, List.rev errs) + + let let_ env = + let env = env |> with_no_let true in + declarations T_LET env + + let enum_declaration = Enum.declaration +end diff --git a/analysis/vendor/js_parser/dune b/analysis/vendor/js_parser/dune new file mode 100644 index 000000000..a783f2d65 --- /dev/null +++ b/analysis/vendor/js_parser/dune @@ -0,0 +1,5 @@ +(library + (name js_parser) + (wrapped false) + (flags + (:standard -w +a-4-44-48-50-70))) diff --git a/analysis/vendor/js_parser/enum_common.ml b/analysis/vendor/js_parser/enum_common.ml new file mode 100644 index 000000000..45b52ee74 --- /dev/null +++ b/analysis/vendor/js_parser/enum_common.ml @@ -0,0 +1,24 @@ +(* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) +open Primitive_deriving +type explicit_type = + | Boolean + | Number + | String + | Symbol +[@@deriving_inline compare] +let _ = fun (_ : explicit_type) -> () +let compare_explicit_type = + (Ppx_compare_lib.polymorphic_compare : explicit_type -> + explicit_type -> int) +let _ = compare_explicit_type +[@@@end] +let string_of_explicit_type = function + | Boolean -> "boolean" + | Number -> "number" + | String -> "string" + | Symbol -> "symbol" diff --git a/analysis/vendor/js_parser/enum_parser.ml b/analysis/vendor/js_parser/enum_parser.ml new file mode 100644 index 000000000..e5eb0272e --- /dev/null +++ b/analysis/vendor/js_parser/enum_parser.ml @@ -0,0 +1,435 @@ +(* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) + +open Flow_ast +open Parser_common +open Parser_env +open Token + +module Enum (Parse : Parser_common.PARSER) : sig + val declaration : env -> (Loc.t, Loc.t) Statement.t +end = struct + open Flow_ast.Statement.EnumDeclaration + + type members = { + boolean_members: (Loc.t BooleanLiteral.t, Loc.t) InitializedMember.t list; + number_members: (Loc.t NumberLiteral.t, Loc.t) InitializedMember.t list; + string_members: (Loc.t StringLiteral.t, Loc.t) InitializedMember.t list; + defaulted_members: Loc.t DefaultedMember.t list; + } + + type acc = { + members: members; + seen_names: SSet.t; + has_unknown_members: bool; + internal_comments: Loc.t Comment.t list; + } + + type init = + | NoInit + | InvalidInit of Loc.t + | BooleanInit of Loc.t * Loc.t BooleanLiteral.t + | NumberInit of Loc.t * Loc.t NumberLiteral.t + | StringInit of Loc.t * Loc.t StringLiteral.t + + let empty_members = + { boolean_members = []; number_members = []; string_members = []; defaulted_members = [] } + + let empty_acc = + { + members = empty_members; + seen_names = SSet.empty; + has_unknown_members = false; + internal_comments = []; + } + + let end_of_member_init env = + match Peek.token env with + | T_SEMICOLON + | T_COMMA + | T_RCURLY -> + true + | _ -> false + + let member_init env = + let loc = Peek.loc env in + let leading = Peek.comments env in + match Peek.token env with + | T_NUMBER { kind; raw } -> + let value = Parse.number env kind raw in + let trailing = Eat.trailing_comments env in + if end_of_member_init env then + NumberInit + ( loc, + { + NumberLiteral.value; + raw; + comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing (); + } + ) + else + InvalidInit loc + | T_STRING (loc, value, raw, octal) -> + if octal then strict_error env Parse_error.StrictOctalLiteral; + Eat.token env; + let trailing = Eat.trailing_comments env in + if end_of_member_init env then + StringInit + ( loc, + { + StringLiteral.value; + raw; + comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing (); + } + ) + else + InvalidInit loc + | (T_TRUE | T_FALSE) as token -> + Eat.token env; + let trailing = Eat.trailing_comments env in + if end_of_member_init env then + BooleanInit + ( loc, + { + BooleanLiteral.value = token = T_TRUE; + comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing (); + } + ) + else + InvalidInit loc + | _ -> + Eat.token env; + InvalidInit loc + + let member_raw = + with_loc (fun env -> + let id = identifier_name env in + let init = + match Peek.token env with + | T_ASSIGN -> + Expect.token env T_ASSIGN; + member_init env + | T_COLON -> + let (_, { Identifier.name = member_name; _ }) = id in + error env (Parse_error.EnumInvalidInitializerSeparator { member_name }); + Expect.token env T_COLON; + member_init env + | _ -> NoInit + in + (id, init) + ) + + let check_explicit_type_mismatch env ~enum_name ~explicit_type ~member_name literal_type loc = + match explicit_type with + | Some enum_type when enum_type <> literal_type -> + error_at + env + (loc, Parse_error.EnumInvalidMemberInitializer { enum_name; explicit_type; member_name }) + | _ -> () + + let is_a_to_z c = c >= 'a' && c <= 'z' + + let enum_member ~enum_name ~explicit_type acc env = + let { members; seen_names; _ } = acc in + let (member_loc, (id, init)) = member_raw env in + let (id_loc, { Identifier.name = member_name; _ }) = id in + (* if we parsed an empty name, something has gone wrong and we should abort analysis *) + if member_name = "" then + acc + else ( + if is_a_to_z @@ member_name.[0] then + error_at env (id_loc, Parse_error.EnumInvalidMemberName { enum_name; member_name }); + if SSet.mem member_name seen_names then + error_at env (id_loc, Parse_error.EnumDuplicateMemberName { enum_name; member_name }); + let acc = { acc with seen_names = SSet.add member_name seen_names } in + let check_explicit_type_mismatch = + check_explicit_type_mismatch env ~enum_name ~explicit_type ~member_name + in + match init with + | BooleanInit (loc, value) -> + check_explicit_type_mismatch Enum_common.Boolean loc; + let member = (member_loc, { InitializedMember.id; init = (loc, value) }) in + { acc with members = { members with boolean_members = member :: members.boolean_members } } + | NumberInit (loc, value) -> + check_explicit_type_mismatch Enum_common.Number loc; + let member = (member_loc, { InitializedMember.id; init = (loc, value) }) in + { acc with members = { members with number_members = member :: members.number_members } } + | StringInit (loc, value) -> + check_explicit_type_mismatch Enum_common.String loc; + let member = (member_loc, { InitializedMember.id; init = (loc, value) }) in + { acc with members = { members with string_members = member :: members.string_members } } + | InvalidInit loc -> + error_at + env + (loc, Parse_error.EnumInvalidMemberInitializer { enum_name; explicit_type; member_name }); + acc + | NoInit -> + begin + match explicit_type with + | Some Enum_common.Boolean -> + error_at + env + (member_loc, Parse_error.EnumBooleanMemberNotInitialized { enum_name; member_name }); + acc + | Some Enum_common.Number -> + error_at + env + (member_loc, Parse_error.EnumNumberMemberNotInitialized { enum_name; member_name }); + acc + | Some Enum_common.String + | Some Enum_common.Symbol + | None -> + let member = (member_loc, { DefaultedMember.id }) in + { + acc with + members = { members with defaulted_members = member :: members.defaulted_members }; + } + end + ) + + let rec enum_members ~enum_name ~explicit_type acc env = + match Peek.token env with + | T_RCURLY + | T_EOF -> + ( { + boolean_members = List.rev acc.members.boolean_members; + number_members = List.rev acc.members.number_members; + string_members = List.rev acc.members.string_members; + defaulted_members = List.rev acc.members.defaulted_members; + }, + acc.has_unknown_members, + acc.internal_comments + ) + | T_ELLIPSIS -> + let loc = Peek.loc env in + (* Internal comments may appear before the ellipsis *) + let internal_comments = Peek.comments env in + Eat.token env; + (match Peek.token env with + | T_RCURLY + | T_EOF -> + () + | T_COMMA -> + Expect.token env T_COMMA; + let trailing_comma = + match Peek.token env with + | T_RCURLY + | T_EOF -> + true + | _ -> false + in + error_at env (loc, Parse_error.EnumInvalidEllipsis { trailing_comma }) + | _ -> error_at env (loc, Parse_error.EnumInvalidEllipsis { trailing_comma = false })); + enum_members + ~enum_name + ~explicit_type + { acc with has_unknown_members = true; internal_comments } + env + | _ -> + let acc = enum_member ~enum_name ~explicit_type acc env in + (match Peek.token env with + | T_RCURLY + | T_EOF -> + () + | T_SEMICOLON -> + error env Parse_error.EnumInvalidMemberSeparator; + Expect.token env T_SEMICOLON + | _ -> Expect.token env T_COMMA); + enum_members ~enum_name ~explicit_type acc env + + let string_body + ~env ~enum_name ~is_explicit ~has_unknown_members string_members defaulted_members comments = + let initialized_len = List.length string_members in + let defaulted_len = List.length defaulted_members in + let defaulted_body () = + StringBody + { + StringBody.members = StringBody.Defaulted defaulted_members; + explicit_type = is_explicit; + has_unknown_members; + comments; + } + in + let initialized_body () = + StringBody + { + StringBody.members = StringBody.Initialized string_members; + explicit_type = is_explicit; + has_unknown_members; + comments; + } + in + match (initialized_len, defaulted_len) with + | (0, 0) + | (0, _) -> + defaulted_body () + | (_, 0) -> initialized_body () + | _ when defaulted_len > initialized_len -> + List.iter + (fun (loc, _) -> + error_at env (loc, Parse_error.EnumStringMemberInconsistentlyInitailized { enum_name })) + string_members; + defaulted_body () + | _ -> + List.iter + (fun (loc, _) -> + error_at env (loc, Parse_error.EnumStringMemberInconsistentlyInitailized { enum_name })) + defaulted_members; + initialized_body () + + let parse_explicit_type ~enum_name env = + if Eat.maybe env T_OF then ( + Eat.push_lex_mode env Lex_mode.TYPE; + let result = + match Peek.token env with + | T_BOOLEAN_TYPE BOOLEAN -> Some Enum_common.Boolean + | T_NUMBER_TYPE -> Some Enum_common.Number + | T_STRING_TYPE -> Some Enum_common.String + | T_SYMBOL_TYPE -> Some Enum_common.Symbol + | T_IDENTIFIER { value; _ } -> + let supplied_type = Some value in + error env (Parse_error.EnumInvalidExplicitType { enum_name; supplied_type }); + None + | _ -> + error env (Parse_error.EnumInvalidExplicitType { enum_name; supplied_type = None }); + None + in + Eat.token env; + Eat.pop_lex_mode env; + result + ) else + None + + let enum_body ~enum_name ~name_loc = + with_loc (fun env -> + let explicit_type = parse_explicit_type ~enum_name env in + let leading = + if explicit_type <> None then + Peek.comments env + else + [] + in + Expect.token env T_LCURLY; + let (members, has_unknown_members, internal) = + enum_members ~enum_name ~explicit_type empty_acc env + in + let internal = internal @ Peek.comments env in + Expect.token env T_RCURLY; + let trailing = + match Peek.token env with + | T_EOF + | T_RCURLY -> + Eat.trailing_comments env + | _ when Peek.is_line_terminator env -> Eat.comments_until_next_line env + | _ -> [] + in + let comments = + Flow_ast_utils.mk_comments_with_internal_opt ~leading ~trailing ~internal () + in + let body = + match explicit_type with + | Some Enum_common.Boolean -> + BooleanBody + { + BooleanBody.members = members.boolean_members; + explicit_type = true; + has_unknown_members; + comments; + } + | Some Enum_common.Number -> + NumberBody + { + NumberBody.members = members.number_members; + explicit_type = true; + has_unknown_members; + comments; + } + | Some Enum_common.String -> + string_body + ~env + ~enum_name + ~is_explicit:true + ~has_unknown_members + members.string_members + members.defaulted_members + comments + | Some Enum_common.Symbol -> + SymbolBody + { SymbolBody.members = members.defaulted_members; has_unknown_members; comments } + | None -> + let bools_len = List.length members.boolean_members in + let nums_len = List.length members.number_members in + let strs_len = List.length members.string_members in + let defaulted_len = List.length members.defaulted_members in + let empty () = + StringBody + { + StringBody.members = StringBody.Defaulted []; + explicit_type = false; + has_unknown_members; + comments; + } + in + begin + match (bools_len, nums_len, strs_len, defaulted_len) with + | (0, 0, 0, 0) -> empty () + | (0, 0, _, _) -> + string_body + ~env + ~enum_name + ~is_explicit:false + ~has_unknown_members + members.string_members + members.defaulted_members + comments + | (_, 0, 0, _) when bools_len >= defaulted_len -> + List.iter + (fun (loc, { DefaultedMember.id = (_, { Identifier.name = member_name; _ }) }) -> + error_at + env + (loc, Parse_error.EnumBooleanMemberNotInitialized { enum_name; member_name })) + members.defaulted_members; + BooleanBody + { + BooleanBody.members = members.boolean_members; + explicit_type = false; + has_unknown_members; + comments; + } + | (0, _, 0, _) when nums_len >= defaulted_len -> + List.iter + (fun (loc, { DefaultedMember.id = (_, { Identifier.name = member_name; _ }) }) -> + error_at + env + (loc, Parse_error.EnumNumberMemberNotInitialized { enum_name; member_name })) + members.defaulted_members; + NumberBody + { + NumberBody.members = members.number_members; + explicit_type = false; + has_unknown_members; + comments; + } + | _ -> + error_at env (name_loc, Parse_error.EnumInconsistentMemberValues { enum_name }); + empty () + end + in + body + ) + + let declaration = + with_loc (fun env -> + let leading = Peek.comments env in + Expect.token env T_ENUM; + let id = Parse.identifier env in + let (name_loc, { Identifier.name = enum_name; _ }) = id in + let body = enum_body ~enum_name ~name_loc env in + let comments = Flow_ast_utils.mk_comments_opt ~leading () in + Statement.EnumDeclaration { id; body; comments } + ) +end diff --git a/analysis/vendor/js_parser/expression_parser.ml b/analysis/vendor/js_parser/expression_parser.ml new file mode 100644 index 000000000..f35eda727 --- /dev/null +++ b/analysis/vendor/js_parser/expression_parser.ml @@ -0,0 +1,1734 @@ +(* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) + +module Ast = Flow_ast +open Token +open Parser_env +open Flow_ast +open Parser_common +open Comment_attachment + +module type EXPRESSION = sig + val assignment : env -> (Loc.t, Loc.t) Expression.t + + val assignment_cover : env -> pattern_cover + + val conditional : env -> (Loc.t, Loc.t) Expression.t + + val is_assignable_lhs : (Loc.t, Loc.t) Expression.t -> bool + + val left_hand_side : env -> (Loc.t, Loc.t) Expression.t + + val number : env -> number_type -> string -> float + + val sequence : + env -> start_loc:Loc.t -> (Loc.t, Loc.t) Expression.t list -> (Loc.t, Loc.t) Expression.t +end + +module Expression + (Parse : PARSER) + (Type : Type_parser.TYPE) + (Declaration : Declaration_parser.DECLARATION) + (Pattern_cover : Pattern_cover.COVER) : EXPRESSION = struct + type op_precedence = + | Left_assoc of int + | Right_assoc of int + + type group_cover = + | Group_expr of (Loc.t, Loc.t) Expression.t + | Group_typecast of (Loc.t, Loc.t) Expression.TypeCast.t + + let is_tighter a b = + let a_prec = + match a with + | Left_assoc x -> x + | Right_assoc x -> x - 1 + in + let b_prec = + match b with + | Left_assoc x -> x + | Right_assoc x -> x + in + a_prec >= b_prec + + let is_assignable_lhs = + let open Expression in + function + | ( _, + MetaProperty + { + MetaProperty.meta = (_, { Identifier.name = "new"; comments = _ }); + property = (_, { Identifier.name = "target"; comments = _ }); + comments = _; + } + ) -> + false + | ( _, + MetaProperty + { + MetaProperty.meta = (_, { Identifier.name = "import"; comments = _ }); + property = (_, { Identifier.name = "meta"; comments = _ }); + comments = _; + } + ) -> + false + (* #sec-static-semantics-static-semantics-isvalidsimpleassignmenttarget *) + | (_, Array _) + | (_, Identifier _) + | (_, Member _) + | (_, MetaProperty _) + | (_, Object _) -> + true + | (_, ArrowFunction _) + | (_, Assignment _) + | (_, Binary _) + | (_, Call _) + | (_, Class _) + | (_, Comprehension _) + | (_, Conditional _) + | (_, Function _) + | (_, Generator _) + | (_, Import _) + | (_, JSXElement _) + | (_, JSXFragment _) + | (_, Literal _) + | (_, Logical _) + | (_, New _) + | (_, OptionalCall _) + | (_, OptionalMember _) + | (_, Sequence _) + | (_, Super _) + | (_, TaggedTemplate _) + | (_, TemplateLiteral _) + | (_, This _) + | (_, TypeCast _) + | (_, Unary _) + | (_, Update _) + | (_, Yield _) -> + false + + let as_expression = Pattern_cover.as_expression + + let as_pattern = Pattern_cover.as_pattern + + (* AssignmentExpression : + * [+Yield] YieldExpression + * ConditionalExpression + * LeftHandSideExpression = AssignmentExpression + * LeftHandSideExpression AssignmentOperator AssignmentExpression + * ArrowFunctionFunction + * + * Originally we were parsing this without backtracking, but + * ArrowFunctionExpression got too tricky. Oh well. + *) + let rec assignment_cover = + let assignment_but_not_arrow_function_cover env = + let start_loc = Peek.loc env in + let expr_or_pattern = conditional_cover env in + match assignment_op env with + | Some operator -> + let expr = + with_loc + ~start_loc + (fun env -> + let left = as_pattern env expr_or_pattern in + let right = assignment env in + Expression.(Assignment { Assignment.operator; left; right; comments = None })) + env + in + Cover_expr expr + | _ -> expr_or_pattern + in + let error_callback _ = function + (* Don't rollback on these errors. *) + | Parse_error.StrictReservedWord -> () + (* Everything else causes a rollback *) + | _ -> raise Try.Rollback + (* So we may or may not be parsing the first part of an arrow function + * (the part before the =>). We might end up parsing that whole thing or + * we might end up parsing only part of it and thinking we're done. We + * need to look at the next token to figure out if we really parsed an + * assignment expression or if this is just the beginning of an arrow + * function *) + in + let try_assignment_but_not_arrow_function env = + let env = env |> with_error_callback error_callback in + let ret = assignment_but_not_arrow_function_cover env in + match Peek.token env with + | T_ARROW -> + (* x => 123 *) + raise Try.Rollback + | T_COLON + when match last_token env with + | Some T_RPAREN -> true + | _ -> false -> + (* (x): number => 123 *) + raise Try.Rollback + (* async x => 123 -- and we've already parsed async as an identifier + * expression *) + | _ when Peek.is_identifier env -> + begin + match ret with + | Cover_expr (_, Expression.Identifier (_, { Identifier.name = "async"; comments = _ })) + when not (Peek.is_line_terminator env) -> + raise Try.Rollback + | _ -> ret + end + | _ -> ret + in + fun env -> + match (Peek.token env, Peek.is_identifier env) with + | (T_YIELD, _) when allow_yield env -> Cover_expr (yield env) + | ((T_LPAREN as t), _) + | ((T_LESS_THAN as t), _) + | ((T_THIS as t), _) + | (t, true) -> + (* Ok, we don't know if this is going to be an arrow function or a + * regular assignment expression. Let's first try to parse it as an + * assignment expression. If that fails we'll try an arrow function. + * Unless it begins with `async <` in which case we first try parsing + * it as an arrow function, and then an assignment expression. + *) + let (initial, secondary) = + if t = T_ASYNC && should_parse_types env && Peek.ith_token ~i:1 env = T_LESS_THAN then + (try_arrow_function, try_assignment_but_not_arrow_function) + else + (try_assignment_but_not_arrow_function, try_arrow_function) + in + (match Try.to_parse env initial with + | Try.ParsedSuccessfully expr -> expr + | Try.FailedToParse -> + (match Try.to_parse env secondary with + | Try.ParsedSuccessfully expr -> expr + | Try.FailedToParse -> + (* Well shoot. It doesn't parse cleanly as a normal + * expression or as an arrow_function. Let's treat it as a + * normal assignment expression gone wrong *) + assignment_but_not_arrow_function_cover env)) + | _ -> assignment_but_not_arrow_function_cover env + + and assignment env = as_expression env (assignment_cover env) + + and yield env = + with_loc + (fun env -> + if in_formal_parameters env then error env Parse_error.YieldInFormalParameters; + let leading = Peek.comments env in + let start_loc = Peek.loc env in + Expect.token env T_YIELD; + let end_loc = Peek.loc env in + let (argument, delegate) = + if Peek.is_implicit_semicolon env then + (None, false) + else + let delegate = Eat.maybe env T_MULT in + let has_argument = + match Peek.token env with + | T_SEMICOLON + | T_RBRACKET + | T_RCURLY + | T_RPAREN + | T_COLON + | T_COMMA -> + false + | _ -> true + in + let argument = + if delegate || has_argument then + Some (assignment env) + else + None + in + (argument, delegate) + in + let trailing = + match argument with + | None -> Eat.trailing_comments env + | Some _ -> [] + in + let open Expression in + Yield + Yield. + { + argument; + delegate; + comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing (); + result_out = Loc.btwn start_loc end_loc; + } + ) + env + + and is_lhs = + let open Expression in + function + | ( _, + MetaProperty + { + MetaProperty.meta = (_, { Identifier.name = "new"; comments = _ }); + property = (_, { Identifier.name = "target"; comments = _ }); + comments = _; + } + ) -> + false + | ( _, + MetaProperty + { + MetaProperty.meta = (_, { Identifier.name = "import"; comments = _ }); + property = (_, { Identifier.name = "meta"; comments = _ }); + comments = _; + } + ) -> + false + (* #sec-static-semantics-static-semantics-isvalidsimpleassignmenttarget *) + | (_, Identifier _) + | (_, Member _) + | (_, MetaProperty _) -> + true + | (_, Array _) + | (_, ArrowFunction _) + | (_, Assignment _) + | (_, Binary _) + | (_, Call _) + | (_, Class _) + | (_, Comprehension _) + | (_, Conditional _) + | (_, Function _) + | (_, Generator _) + | (_, Import _) + | (_, JSXElement _) + | (_, JSXFragment _) + | (_, Literal _) + | (_, Logical _) + | (_, New _) + | (_, Object _) + | (_, OptionalCall _) + | (_, OptionalMember _) + | (_, Sequence _) + | (_, Super _) + | (_, TaggedTemplate _) + | (_, TemplateLiteral _) + | (_, This _) + | (_, TypeCast _) + | (_, Unary _) + | (_, Update _) + | (_, Yield _) -> + false + + and assignment_op env = + let op = + let open Expression.Assignment in + match Peek.token env with + | T_RSHIFT3_ASSIGN -> Some (Some RShift3Assign) + | T_RSHIFT_ASSIGN -> Some (Some RShiftAssign) + | T_LSHIFT_ASSIGN -> Some (Some LShiftAssign) + | T_BIT_XOR_ASSIGN -> Some (Some BitXorAssign) + | T_BIT_OR_ASSIGN -> Some (Some BitOrAssign) + | T_BIT_AND_ASSIGN -> Some (Some BitAndAssign) + | T_MOD_ASSIGN -> Some (Some ModAssign) + | T_DIV_ASSIGN -> Some (Some DivAssign) + | T_MULT_ASSIGN -> Some (Some MultAssign) + | T_EXP_ASSIGN -> Some (Some ExpAssign) + | T_MINUS_ASSIGN -> Some (Some MinusAssign) + | T_PLUS_ASSIGN -> Some (Some PlusAssign) + | T_NULLISH_ASSIGN -> Some (Some NullishAssign) + | T_AND_ASSIGN -> Some (Some AndAssign) + | T_OR_ASSIGN -> Some (Some OrAssign) + | T_ASSIGN -> Some None + | _ -> None + in + if op <> None then Eat.token env; + op + + (* ConditionalExpression : + * LogicalExpression + * LogicalExpression ? AssignmentExpression : AssignmentExpression + *) + and conditional_cover env = + let start_loc = Peek.loc env in + let expr = logical_cover env in + if Peek.token env = T_PLING then ( + Eat.token env; + + (* no_in is ignored for the consequent *) + let env' = env |> with_no_in false in + let consequent = assignment env' in + Expect.token env T_COLON; + let (loc, alternate) = with_loc ~start_loc assignment env in + Cover_expr + ( loc, + let open Expression in + Conditional + { Conditional.test = as_expression env expr; consequent; alternate; comments = None } + ) + ) else + expr + + and conditional env = as_expression env (conditional_cover env) + + (* + * LogicalANDExpression : + * BinaryExpression + * LogicalANDExpression && BitwiseORExpression + * + * LogicalORExpression : + * LogicalANDExpression + * LogicalORExpression || LogicalANDExpression + * LogicalORExpression ?? LogicalANDExpression + * + * LogicalExpression : + * LogicalORExpression + *) + and logical_cover = + let open Expression in + let make_logical env left right operator loc = + let left = as_expression env left in + let right = as_expression env right in + Cover_expr (loc, Logical { Logical.operator; left; right; comments = None }) + in + let rec logical_and env left lloc = + match Peek.token env with + | T_AND -> + Eat.token env; + let (rloc, right) = with_loc binary_cover env in + let loc = Loc.btwn lloc rloc in + let left = make_logical env left right Logical.And loc in + (* `a && b ?? c` is an error, but to recover, try to parse it like `(a && b) ?? c`. *) + let (loc, left) = coalesce ~allowed:false env left loc in + logical_and env left loc + | _ -> (lloc, left) + and logical_or env left lloc = + match Peek.token env with + | T_OR -> + Eat.token env; + let (rloc, right) = with_loc binary_cover env in + let (rloc, right) = logical_and env right rloc in + let loc = Loc.btwn lloc rloc in + let left = make_logical env left right Logical.Or loc in + (* `a || b ?? c` is an error, but to recover, try to parse it like `(a || b) ?? c`. *) + let (loc, left) = coalesce ~allowed:false env left loc in + logical_or env left loc + | _ -> (lloc, left) + and coalesce ~allowed env left lloc = + match Peek.token env with + | T_PLING_PLING -> + if not allowed then error env (Parse_error.NullishCoalescingUnexpectedLogical "??"); + + Expect.token env T_PLING_PLING; + let (rloc, right) = with_loc binary_cover env in + let (rloc, right) = + match Peek.token env with + | (T_AND | T_OR) as t -> + (* `a ?? b || c` is an error. To recover, treat it like `a ?? (b || c)`. *) + error env (Parse_error.NullishCoalescingUnexpectedLogical (Token.value_of_token t)); + let (rloc, right) = logical_and env right rloc in + logical_or env right rloc + | _ -> (rloc, right) + in + let loc = Loc.btwn lloc rloc in + coalesce ~allowed:true env (make_logical env left right Logical.NullishCoalesce loc) loc + | _ -> (lloc, left) + in + fun env -> + let (loc, left) = with_loc binary_cover env in + let (_, left) = + match Peek.token env with + | T_PLING_PLING -> coalesce ~allowed:true env left loc + | _ -> + let (loc, left) = logical_and env left loc in + logical_or env left loc + in + left + + and binary_cover = + let binary_op env = + let ret = + let open Expression.Binary in + match Peek.token env with + (* Most BinaryExpression operators are left associative *) + (* Lowest pri *) + | T_BIT_OR -> Some (BitOr, Left_assoc 2) + | T_BIT_XOR -> Some (Xor, Left_assoc 3) + | T_BIT_AND -> Some (BitAnd, Left_assoc 4) + | T_EQUAL -> Some (Equal, Left_assoc 5) + | T_STRICT_EQUAL -> Some (StrictEqual, Left_assoc 5) + | T_NOT_EQUAL -> Some (NotEqual, Left_assoc 5) + | T_STRICT_NOT_EQUAL -> Some (StrictNotEqual, Left_assoc 5) + | T_LESS_THAN -> Some (LessThan, Left_assoc 6) + | T_LESS_THAN_EQUAL -> Some (LessThanEqual, Left_assoc 6) + | T_GREATER_THAN -> Some (GreaterThan, Left_assoc 6) + | T_GREATER_THAN_EQUAL -> Some (GreaterThanEqual, Left_assoc 6) + | T_IN -> + if no_in env then + None + else + Some (In, Left_assoc 6) + | T_INSTANCEOF -> Some (Instanceof, Left_assoc 6) + | T_LSHIFT -> Some (LShift, Left_assoc 7) + | T_RSHIFT -> Some (RShift, Left_assoc 7) + | T_RSHIFT3 -> Some (RShift3, Left_assoc 7) + | T_PLUS -> Some (Plus, Left_assoc 8) + | T_MINUS -> Some (Minus, Left_assoc 8) + | T_MULT -> Some (Mult, Left_assoc 9) + | T_DIV -> Some (Div, Left_assoc 9) + | T_MOD -> Some (Mod, Left_assoc 9) + | T_EXP -> Some (Exp, Right_assoc 10) + (* Highest priority *) + | _ -> None + in + if ret <> None then Eat.token env; + ret + in + let make_binary left right operator loc = + (loc, Expression.(Binary Binary.{ operator; left; right; comments = None })) + in + let rec add_to_stack right (rop, rpri) rloc = function + | (left, (lop, lpri), lloc) :: rest when is_tighter lpri rpri -> + let loc = Loc.btwn lloc rloc in + let right = make_binary left right lop loc in + add_to_stack right (rop, rpri) loc rest + | stack -> (right, (rop, rpri), rloc) :: stack + in + let rec collapse_stack right rloc = function + | [] -> right + | (left, (lop, _), lloc) :: rest -> + let loc = Loc.btwn lloc rloc in + collapse_stack (make_binary left right lop loc) loc rest + in + let rec helper env stack = + let (right_loc, (is_unary, right)) = + with_loc + (fun env -> + let is_unary = peek_unary_op env <> None in + let right = unary_cover (env |> with_no_in false) in + (is_unary, right)) + env + in + ( if Peek.token env = T_LESS_THAN then + match right with + | Cover_expr (_, Expression.JSXElement _) -> error env Parse_error.AdjacentJSXElements + | _ -> () + ); + match (stack, binary_op env) with + | ([], None) -> right + | (_, None) -> + let right = as_expression env right in + Cover_expr (collapse_stack right right_loc stack) + | (_, Some (rop, rpri)) -> + if is_unary && rop = Expression.Binary.Exp then + error_at env (right_loc, Parse_error.InvalidLHSInExponentiation); + let right = as_expression env right in + helper env (add_to_stack right (rop, rpri) right_loc stack) + in + (fun env -> helper env []) + + and peek_unary_op env = + let open Expression.Unary in + match Peek.token env with + | T_NOT -> Some Not + | T_BIT_NOT -> Some BitNot + | T_PLUS -> Some Plus + | T_MINUS -> Some Minus + | T_TYPEOF -> Some Typeof + | T_VOID -> Some Void + | T_DELETE -> Some Delete + (* If we are in a unary expression context, and within an async function, + * assume that a use of "await" is intended as a keyword, not an ordinary + * identifier. This is a little bit inconsistent, since it can be used as + * an identifier in other contexts (such as a variable name), but it's how + * Babel does it. *) + | T_AWAIT when allow_await env -> Some Await + | _ -> None + + and unary_cover env = + let start_loc = Peek.loc env in + let leading = Peek.comments env in + let op = peek_unary_op env in + match op with + | None -> + let op = + let open Expression.Update in + match Peek.token env with + | T_INCR -> Some Increment + | T_DECR -> Some Decrement + | _ -> None + in + (match op with + | None -> postfix_cover env + | Some operator -> + Eat.token env; + let (loc, argument) = with_loc ~start_loc unary env in + if not (is_lhs argument) then error_at env (fst argument, Parse_error.InvalidLHSInAssignment); + (match argument with + | (_, Expression.Identifier (_, { Identifier.name; comments = _ })) when is_restricted name + -> + strict_error env Parse_error.StrictLHSPrefix + | _ -> ()); + Cover_expr + ( loc, + Expression.( + Update + { + Update.operator; + prefix = true; + argument; + comments = Flow_ast_utils.mk_comments_opt ~leading (); + } + ) + )) + | Some operator -> + Eat.token env; + let (loc, argument) = with_loc ~start_loc unary env in + let open Expression in + (match (operator, argument) with + | (Unary.Delete, (_, Identifier _)) -> strict_error_at env (loc, Parse_error.StrictDelete) + | (Unary.Delete, (_, Member member)) -> + begin + match member.Ast.Expression.Member.property with + | Ast.Expression.Member.PropertyPrivateName _ -> + error_at env (loc, Parse_error.PrivateDelete) + | _ -> () + end + | _ -> ()); + Cover_expr + ( loc, + let open Expression in + Unary { Unary.operator; argument; comments = Flow_ast_utils.mk_comments_opt ~leading () } + ) + + and unary env = as_expression env (unary_cover env) + + and postfix_cover env = + let argument = left_hand_side_cover env in + (* No line terminator allowed before operator *) + if Peek.is_line_terminator env then + argument + else + let op = + let open Expression.Update in + match Peek.token env with + | T_INCR -> Some Increment + | T_DECR -> Some Decrement + | _ -> None + in + match op with + | None -> argument + | Some operator -> + let argument = as_expression env argument in + if not (is_lhs argument) then error_at env (fst argument, Parse_error.InvalidLHSInAssignment); + (match argument with + | (_, Expression.Identifier (_, { Identifier.name; comments = _ })) when is_restricted name + -> + strict_error env Parse_error.StrictLHSPostfix + | _ -> ()); + let end_loc = Peek.loc env in + Eat.token env; + let trailing = Eat.trailing_comments env in + let loc = Loc.btwn (fst argument) end_loc in + Cover_expr + ( loc, + Expression.( + Update + { + Update.operator; + prefix = false; + argument; + comments = Flow_ast_utils.mk_comments_opt ~trailing (); + } + ) + ) + + and left_hand_side_cover env = + let start_loc = Peek.loc env in + let allow_new = not (no_new env) in + let env = with_no_new false env in + let expr = + match Peek.token env with + | T_NEW when allow_new -> Cover_expr (new_expression env) + | T_IMPORT -> Cover_expr (import env) + | T_SUPER -> Cover_expr (super env) + | _ when Peek.is_function env -> Cover_expr (_function env) + | _ -> primary_cover env + in + call_cover env start_loc expr + + and left_hand_side env = as_expression env (left_hand_side_cover env) + + and super env = + let (allowed, call_allowed) = + match allow_super env with + | No_super -> (false, false) + | Super_prop -> (true, false) + | Super_prop_or_call -> (true, true) + in + let loc = Peek.loc env in + let leading = Peek.comments env in + Expect.token env T_SUPER; + let trailing = Eat.trailing_comments env in + let super = + ( loc, + Expression.Super + { Expression.Super.comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing () } + ) + in + match Peek.token env with + | T_PERIOD + | T_LBRACKET -> + let super = + if not allowed then ( + error_at env (loc, Parse_error.UnexpectedSuper); + (loc, Expression.Identifier (Flow_ast_utils.ident_of_source (loc, "super"))) + ) else + super + in + call ~allow_optional_chain:false env loc super + | T_LPAREN -> + let super = + if not call_allowed then ( + error_at env (loc, Parse_error.UnexpectedSuperCall); + (loc, Expression.Identifier (Flow_ast_utils.ident_of_source (loc, "super"))) + ) else + super + in + call ~allow_optional_chain:false env loc super + | _ -> + if not allowed then + error_at env (loc, Parse_error.UnexpectedSuper) + else + error_unexpected ~expected:"either a call or access of `super`" env; + super + + and import env = + with_loc + (fun env -> + let leading = Peek.comments env in + let start_loc = Peek.loc env in + Expect.token env T_IMPORT; + if Eat.maybe env T_PERIOD then ( + (* import.meta *) + let import_ident = Flow_ast_utils.ident_of_source (start_loc, "import") in + let meta_loc = Peek.loc env in + Expect.identifier env "meta"; + let meta_ident = Flow_ast_utils.ident_of_source (meta_loc, "meta") in + let trailing = Eat.trailing_comments env in + Expression.MetaProperty + { + Expression.MetaProperty.meta = import_ident; + property = meta_ident; + comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing (); + } + ) else + let leading_arg = Peek.comments env in + Expect.token env T_LPAREN; + let argument = add_comments (assignment (with_no_in false env)) ~leading:leading_arg in + Expect.token env T_RPAREN; + let trailing = Eat.trailing_comments env in + Expression.Import + { + Expression.Import.argument; + comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing (); + }) + env + + and call_cover ?(allow_optional_chain = true) ?(in_optional_chain = false) env start_loc left = + let left = member_cover ~allow_optional_chain ~in_optional_chain env start_loc left in + let optional = + match last_token env with + | Some T_PLING_PERIOD -> true + | _ -> false + in + let left_to_callee env = + let { remove_trailing; _ } = trailing_and_remover env in + remove_trailing (as_expression env left) (fun remover left -> remover#expression left) + in + let arguments ?targs env callee = + let (args_loc, arguments) = arguments env in + let loc = Loc.btwn start_loc args_loc in + let call = + { Expression.Call.callee; targs; arguments = (args_loc, arguments); comments = None } + in + let call = + if optional || in_optional_chain then + let open Expression in + OptionalCall { OptionalCall.call; optional; filtered_out = loc } + else + Expression.Call call + in + let in_optional_chain = in_optional_chain || optional in + call_cover ~allow_optional_chain ~in_optional_chain env start_loc (Cover_expr (loc, call)) + in + if no_call env then + left + else + match Peek.token env with + | T_LPAREN -> arguments env (left_to_callee env) + | T_LSHIFT + | T_LESS_THAN + when should_parse_types env -> + (* If we are parsing types, then f(e) is a function call with a + type application. If we aren't, it's a nested binary expression. *) + let error_callback _ _ = raise Try.Rollback in + let env = env |> with_error_callback error_callback in + (* Parameterized call syntax is ambiguous, so we fall back to + standard parsing if it fails. *) + Try.or_else env ~fallback:left (fun env -> + let callee = left_to_callee env in + let targs = call_type_args env in + arguments ?targs env callee + ) + | _ -> left + + and call ?(allow_optional_chain = true) env start_loc left = + as_expression env (call_cover ~allow_optional_chain env start_loc (Cover_expr left)) + + and new_expression env = + with_loc + (fun env -> + let start_loc = Peek.loc env in + let leading = Peek.comments env in + Expect.token env T_NEW; + + if in_function env && Peek.token env = T_PERIOD then ( + let trailing = Eat.trailing_comments env in + Eat.token env; + let meta = + Flow_ast_utils.ident_of_source + (start_loc, "new") + ?comments:(Flow_ast_utils.mk_comments_opt ~leading ~trailing ()) + in + match Peek.token env with + | T_IDENTIFIER { raw = "target"; _ } -> + let property = Parse.identifier env in + Expression.(MetaProperty MetaProperty.{ meta; property; comments = None }) + | _ -> + error_unexpected ~expected:"the identifier `target`" env; + Eat.token env; + + (* skip unknown identifier *) + Expression.Identifier meta + (* return `new` identifier *) + ) else + let callee_loc = Peek.loc env in + let expr = + match Peek.token env with + | T_NEW -> new_expression env + | T_SUPER -> super (env |> with_no_call true) + | _ when Peek.is_function env -> _function env + | _ -> primary env + in + let callee = + member ~allow_optional_chain:false (env |> with_no_call true) callee_loc expr + in + (* You can do something like + * new raw`42` + *) + let callee = + let callee = + match Peek.token env with + | T_TEMPLATE_PART part -> tagged_template env callee_loc callee part + | _ -> callee + in + (* Remove trailing comments if the callee is followed by args or type args *) + if Peek.token env = T_LPAREN || (should_parse_types env && Peek.token env = T_LESS_THAN) + then + let { remove_trailing; _ } = trailing_and_remover env in + remove_trailing callee (fun remover callee -> remover#expression callee) + else + callee + in + let targs = + (* If we are parsing types, then new C(e) is a constructor with a + type application. If we aren't, it's a nested binary expression. *) + if should_parse_types env then + (* Parameterized call syntax is ambiguous, so we fall back to + standard parsing if it fails. *) + let error_callback _ _ = raise Try.Rollback in + let env = env |> with_error_callback error_callback in + Try.or_else env ~fallback:None call_type_args + else + None + in + let arguments = + match Peek.token env with + | T_LPAREN -> Some (arguments env) + | _ -> None + in + let comments = Flow_ast_utils.mk_comments_opt ~leading () in + Expression.(New New.{ callee; targs; arguments; comments })) + env + + and call_type_args = + let args = + let rec args_helper env acc = + match Peek.token env with + | T_EOF + | T_GREATER_THAN -> + List.rev acc + | _ -> + let t = + match Peek.token env with + | T_IDENTIFIER { value = "_"; _ } -> + let loc = Peek.loc env in + let leading = Peek.comments env in + Expect.identifier env "_"; + let trailing = Eat.trailing_comments env in + Expression.CallTypeArg.Implicit + ( loc, + { + Expression.CallTypeArg.Implicit.comments = + Flow_ast_utils.mk_comments_opt ~leading ~trailing (); + } + ) + | _ -> Expression.CallTypeArg.Explicit (Type._type env) + in + let acc = t :: acc in + if Peek.token env <> T_GREATER_THAN then Expect.token env T_COMMA; + args_helper env acc + in + fun env -> + let leading = Peek.comments env in + Expect.token env T_LESS_THAN; + let arguments = args_helper env [] in + let internal = Peek.comments env in + Expect.token env T_GREATER_THAN; + let trailing = + if Peek.token env = T_LPAREN then + let { trailing; _ } = trailing_and_remover env in + trailing + else + Eat.trailing_comments env + in + { + Expression.CallTypeArgs.arguments; + comments = Flow_ast_utils.mk_comments_with_internal_opt ~leading ~trailing ~internal (); + } + in + fun env -> + Eat.push_lex_mode env Lex_mode.TYPE; + let node = + if Peek.token env = T_LESS_THAN then + Some (with_loc args env) + else + None + in + Eat.pop_lex_mode env; + node + + and arguments = + let spread_element env = + let leading = Peek.comments env in + Expect.token env T_ELLIPSIS; + let argument = assignment env in + Expression.SpreadElement.{ argument; comments = Flow_ast_utils.mk_comments_opt ~leading () } + in + let argument env = + match Peek.token env with + | T_ELLIPSIS -> Expression.Spread (with_loc spread_element env) + | _ -> Expression.Expression (assignment env) + in + let rec arguments' env acc = + match Peek.token env with + | T_EOF + | T_RPAREN -> + List.rev acc + | _ -> + let acc = argument env :: acc in + if Peek.token env <> T_RPAREN then Expect.token env T_COMMA; + arguments' env acc + in + fun env -> + with_loc + (fun env -> + let leading = Peek.comments env in + Expect.token env T_LPAREN; + let args = arguments' env [] in + let internal = Peek.comments env in + Expect.token env T_RPAREN; + let trailing = Eat.trailing_comments env in + { + Expression.ArgList.arguments = args; + comments = Flow_ast_utils.mk_comments_with_internal_opt ~leading ~trailing ~internal (); + }) + env + + and member_cover = + let dynamic + ?(allow_optional_chain = true) + ?(in_optional_chain = false) + ?(optional = false) + env + start_loc + left = + let expr = Parse.expression (env |> with_no_call false) in + let last_loc = Peek.loc env in + Expect.token env T_RBRACKET; + let trailing = Eat.trailing_comments env in + let loc = Loc.btwn start_loc last_loc in + let member = + { + Expression.Member._object = as_expression env left; + property = Expression.Member.PropertyExpression expr; + comments = Flow_ast_utils.mk_comments_opt ~trailing (); + } + in + + let member = + if in_optional_chain then + let open Expression in + OptionalMember { OptionalMember.member; optional; filtered_out = loc } + else + Expression.Member member + in + call_cover ~allow_optional_chain ~in_optional_chain env start_loc (Cover_expr (loc, member)) + in + let static + ?(allow_optional_chain = true) + ?(in_optional_chain = false) + ?(optional = false) + env + start_loc + left = + let open Expression.Member in + let (id_loc, property) = + match Peek.token env with + | T_POUND -> + let ((id_loc, { Ast.PrivateName.name; _ }) as id) = private_identifier env in + add_used_private env name id_loc; + (id_loc, PropertyPrivateName id) + | _ -> + let ((id_loc, _) as id) = identifier_name env in + (id_loc, PropertyIdentifier id) + in + let loc = Loc.btwn start_loc id_loc in + (* super.PrivateName is a syntax error *) + begin + match (left, property) with + | (Cover_expr (_, Ast.Expression.Super _), PropertyPrivateName _) -> + error_at env (loc, Parse_error.SuperPrivate) + | _ -> () + end; + let member = + Expression.Member.{ _object = as_expression env left; property; comments = None } + in + let member = + if in_optional_chain then + let open Expression in + OptionalMember { OptionalMember.member; optional; filtered_out = loc } + else + Expression.Member member + in + call_cover ~allow_optional_chain ~in_optional_chain env start_loc (Cover_expr (loc, member)) + in + fun ?(allow_optional_chain = true) ?(in_optional_chain = false) env start_loc left -> + match Peek.token env with + | T_PLING_PERIOD -> + if not allow_optional_chain then error env Parse_error.OptionalChainNew; + + Expect.token env T_PLING_PERIOD; + begin + match Peek.token env with + | T_TEMPLATE_PART _ -> + error env Parse_error.OptionalChainTemplate; + left + | T_LPAREN -> left + | T_LESS_THAN when should_parse_types env -> left + | T_LBRACKET -> + Eat.token env; + dynamic ~allow_optional_chain ~in_optional_chain:true ~optional:true env start_loc left + | _ -> + static ~allow_optional_chain ~in_optional_chain:true ~optional:true env start_loc left + end + | T_LBRACKET -> + Eat.token env; + dynamic ~allow_optional_chain ~in_optional_chain env start_loc left + | T_PERIOD -> + Eat.token env; + static ~allow_optional_chain ~in_optional_chain env start_loc left + | T_TEMPLATE_PART part -> + if in_optional_chain then error env Parse_error.OptionalChainTemplate; + + let expr = tagged_template env start_loc (as_expression env left) part in + call_cover ~allow_optional_chain:false env start_loc (Cover_expr expr) + | _ -> left + + and member ?(allow_optional_chain = true) env start_loc left = + as_expression env (member_cover ~allow_optional_chain env start_loc (Cover_expr left)) + + and _function env = + with_loc + (fun env -> + let (async, leading_async) = Declaration.async env in + let (sig_loc, (id, params, generator, predicate, return, tparams, leading)) = + with_loc + (fun env -> + let leading_function = Peek.comments env in + Expect.token env T_FUNCTION; + let (generator, leading_generator) = Declaration.generator env in + let leading = List.concat [leading_async; leading_function; leading_generator] in + (* `await` is a keyword in async functions: + - proposal-async-iteration/#prod-AsyncGeneratorExpression + - #prod-AsyncFunctionExpression *) + let await = async in + (* `yield` is a keyword in generator functions: + - proposal-async-iteration/#prod-AsyncGeneratorExpression + - #prod-GeneratorExpression *) + let yield = generator in + let (id, tparams) = + if Peek.token env = T_LPAREN then + (None, None) + else + let id = + match Peek.token env with + | T_LESS_THAN -> None + | _ -> + let env = env |> with_allow_await await |> with_allow_yield yield in + let id = + id_remove_trailing + env + (Parse.identifier ~restricted_error:Parse_error.StrictFunctionName env) + in + Some id + in + let tparams = type_params_remove_trailing env (Type.type_params env) in + (id, tparams) + in + (* #sec-function-definitions-static-semantics-early-errors *) + let env = env |> with_allow_super No_super in + let params = + let params = Declaration.function_params ~await ~yield env in + if Peek.token env = T_COLON then + params + else + function_params_remove_trailing env params + in + let (return, predicate) = Type.annotation_and_predicate_opt env in + let (return, predicate) = + match predicate with + | None -> (type_annotation_hint_remove_trailing env return, predicate) + | Some _ -> (return, predicate_remove_trailing env predicate) + in + (id, params, generator, predicate, return, tparams, leading)) + env + in + let simple_params = is_simple_parameter_list params in + let (body, contains_use_strict) = + Declaration.function_body env ~async ~generator ~expression:true ~simple_params + in + Declaration.strict_post_check env ~contains_use_strict id params; + Expression.Function + { + Function.id; + params; + body; + generator; + async; + predicate; + return; + tparams; + sig_loc; + comments = Flow_ast_utils.mk_comments_opt ~leading (); + }) + env + + and number env kind raw = + let value = + match kind with + | LEGACY_OCTAL -> + strict_error env Parse_error.StrictOctalLiteral; + begin + try Int64.to_float (Int64.of_string ("0o" ^ raw)) with + | Failure _ -> failwith ("Invalid legacy octal " ^ raw) + end + | LEGACY_NON_OCTAL -> + strict_error env Parse_error.StrictNonOctalLiteral; + begin + try float_of_string raw with + | Failure _ -> failwith ("Invalid number " ^ raw) + end + | BINARY + | OCTAL -> + begin + try Int64.to_float (Int64.of_string raw) with + | Failure _ -> failwith ("Invalid binary/octal " ^ raw) + end + | NORMAL -> + begin + try float_of_string raw with + | Failure _ -> failwith ("Invalid number " ^ raw) + end + in + Expect.token env (T_NUMBER { kind; raw }); + value + + and bigint_strip_n raw = + let size = String.length raw in + let str = + if size != 0 && raw.[size - 1] == 'n' then + String.sub raw 0 (size - 1) + else + raw + in + str + + and bigint env kind raw = + let postraw = bigint_strip_n raw in + let value = Int64.of_string_opt postraw in + Expect.token env (T_BIGINT { kind; raw }); + value + + and primary_cover env = + let loc = Peek.loc env in + let leading = Peek.comments env in + match Peek.token env with + | T_THIS -> + Eat.token env; + let trailing = Eat.trailing_comments env in + Cover_expr + ( loc, + Expression.This + { Expression.This.comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing () } + ) + | T_NUMBER { kind; raw } -> + let value = Literal.Number (number env kind raw) in + let trailing = Eat.trailing_comments env in + Cover_expr + ( loc, + let open Expression in + Literal + { Literal.value; raw; comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing () } + ) + | T_BIGINT { kind; raw } -> + let value = Literal.BigInt (bigint env kind raw) in + let trailing = Eat.trailing_comments env in + Cover_expr + ( loc, + let open Expression in + Literal + { Literal.value; raw; comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing () } + ) + | T_STRING (loc, value, raw, octal) -> + if octal then strict_error env Parse_error.StrictOctalLiteral; + Eat.token env; + let value = Literal.String value in + let trailing = Eat.trailing_comments env in + Cover_expr + ( loc, + Expression.Literal + { Literal.value; raw; comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing () } + ) + | (T_TRUE | T_FALSE) as token -> + Eat.token env; + let truthy = token = T_TRUE in + let raw = + if truthy then + "true" + else + "false" + in + let value = Literal.Boolean truthy in + let trailing = Eat.trailing_comments env in + Cover_expr + ( loc, + Expression.Literal + { Literal.value; raw; comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing () } + ) + | T_NULL -> + Eat.token env; + let raw = "null" in + let value = Literal.Null in + let trailing = Eat.trailing_comments env in + Cover_expr + ( loc, + Expression.Literal + { Literal.value; raw; comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing () } + ) + | T_LPAREN -> Cover_expr (group env) + | T_LCURLY -> + let (loc, obj, errs) = Parse.object_initializer env in + Cover_patt ((loc, Expression.Object obj), errs) + | T_LBRACKET -> + let (loc, (arr, errs)) = with_loc array_initializer env in + Cover_patt ((loc, Expression.Array arr), errs) + | T_DIV + | T_DIV_ASSIGN -> + Cover_expr (regexp env) + | T_LESS_THAN -> + let (loc, expression) = + match Parse.jsx_element_or_fragment env with + | (loc, `Element e) -> (loc, Expression.JSXElement e) + | (loc, `Fragment f) -> (loc, Expression.JSXFragment f) + in + Cover_expr (loc, expression) + | T_TEMPLATE_PART part -> + let (loc, template) = template_literal env part in + Cover_expr (loc, Expression.TemplateLiteral template) + | T_CLASS -> Cover_expr (Parse.class_expression env) + | _ when Peek.is_identifier env -> + let id = Parse.identifier env in + Cover_expr (fst id, Expression.Identifier id) + | t -> + error_unexpected env; + + (* Let's get rid of the bad token *) + begin + match t with + | T_ERROR _ -> Eat.token env + | _ -> () + end; + + (* Really no idea how to recover from this. I suppose a null + * expression is as good as anything *) + let value = Literal.Null in + let raw = "null" in + let trailing = [] in + Cover_expr + ( loc, + let open Expression in + Literal + { Literal.value; raw; comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing () } + ) + + and primary env = as_expression env (primary_cover env) + + and template_literal = + let rec template_parts env quasis expressions = + let expr = Parse.expression env in + let expressions = expr :: expressions in + match Peek.token env with + | T_RCURLY -> + Eat.push_lex_mode env Lex_mode.TEMPLATE; + let (loc, part, is_tail) = + match Peek.token env with + | T_TEMPLATE_PART (loc, { cooked; raw; _ }, tail) -> + let open Ast.Expression.TemplateLiteral in + Eat.token env; + (loc, { Element.value = { Element.cooked; raw }; tail }, tail) + | _ -> assert false + in + Eat.pop_lex_mode env; + let quasis = (loc, part) :: quasis in + if is_tail then + (loc, List.rev quasis, List.rev expressions) + else + template_parts env quasis expressions + | _ -> + (* Malformed template *) + error_unexpected ~expected:"a template literal part" env; + let imaginary_quasi = + ( fst expr, + { + Expression.TemplateLiteral.Element.value = + { Expression.TemplateLiteral.Element.raw = ""; cooked = "" }; + tail = true; + } + ) + in + (fst expr, List.rev (imaginary_quasi :: quasis), List.rev expressions) + in + fun env ((start_loc, { cooked; raw; _ }, is_tail) as part) -> + let leading = Peek.comments env in + Expect.token env (T_TEMPLATE_PART part); + let (end_loc, quasis, expressions) = + let head = + ( start_loc, + { + Ast.Expression.TemplateLiteral.Element.value = + { Ast.Expression.TemplateLiteral.Element.cooked; raw }; + tail = is_tail; + } + ) + in + + if is_tail then + (start_loc, [head], []) + else + template_parts env [head] [] + in + let trailing = Eat.trailing_comments env in + let loc = Loc.btwn start_loc end_loc in + ( loc, + { + Expression.TemplateLiteral.quasis; + expressions; + comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing (); + } + ) + + and tagged_template env start_loc tag part = + let tag = expression_remove_trailing env tag in + let quasi = template_literal env part in + ( Loc.btwn start_loc (fst quasi), + Expression.(TaggedTemplate TaggedTemplate.{ tag; quasi; comments = None }) + ) + + and group env = + let leading = Peek.comments env in + let (loc, cover) = + with_loc + (fun env -> + Expect.token env T_LPAREN; + let expr_start_loc = Peek.loc env in + let expression = assignment env in + let ret = + match Peek.token env with + | T_COLON -> + let annot = Type.annotation env in + Group_typecast Expression.TypeCast.{ expression; annot; comments = None } + | T_COMMA -> Group_expr (sequence env ~start_loc:expr_start_loc [expression]) + | _ -> Group_expr expression + in + Expect.token env T_RPAREN; + ret) + env + in + let trailing = Eat.trailing_comments env in + let ret = + match cover with + | Group_expr expr -> expr + | Group_typecast cast -> (loc, Expression.TypeCast cast) + in + add_comments ret ~leading ~trailing + + and add_comments ?(leading = []) ?(trailing = []) (loc, expression) = + let merge_comments inner = + Flow_ast_utils.merge_comments + ~inner + ~outer:(Flow_ast_utils.mk_comments_opt ~leading ~trailing ()) + in + let merge_comments_with_internal inner = + Flow_ast_utils.merge_comments_with_internal + ~inner + ~outer:(Flow_ast_utils.mk_comments_opt ~leading ~trailing ()) + in + let open Expression in + ( loc, + match expression with + | Array ({ Array.comments; _ } as e) -> + Array { e with Array.comments = merge_comments_with_internal comments } + | ArrowFunction ({ Function.comments; _ } as e) -> + ArrowFunction { e with Function.comments = merge_comments comments } + | Assignment ({ Assignment.comments; _ } as e) -> + Assignment { e with Assignment.comments = merge_comments comments } + | Binary ({ Binary.comments; _ } as e) -> + Binary { e with Binary.comments = merge_comments comments } + | Call ({ Call.comments; _ } as e) -> Call { e with Call.comments = merge_comments comments } + | Class ({ Class.comments; _ } as e) -> + Class { e with Class.comments = merge_comments comments } + | Conditional ({ Conditional.comments; _ } as e) -> + Conditional { e with Conditional.comments = merge_comments comments } + | Function ({ Function.comments; _ } as e) -> + Function { e with Function.comments = merge_comments comments } + | Identifier (loc, ({ Identifier.comments; _ } as e)) -> + Identifier (loc, { e with Identifier.comments = merge_comments comments }) + | Import ({ Import.comments; _ } as e) -> + Import { e with Import.comments = merge_comments comments } + | JSXElement ({ JSX.comments; _ } as e) -> + JSXElement { e with JSX.comments = merge_comments comments } + | JSXFragment ({ JSX.frag_comments; _ } as e) -> + JSXFragment { e with JSX.frag_comments = merge_comments frag_comments } + | Literal ({ Literal.comments; _ } as e) -> + Literal { e with Literal.comments = merge_comments comments } + | Logical ({ Logical.comments; _ } as e) -> + Logical { e with Logical.comments = merge_comments comments } + | Member ({ Member.comments; _ } as e) -> + Member { e with Member.comments = merge_comments comments } + | MetaProperty ({ MetaProperty.comments; _ } as e) -> + MetaProperty { e with MetaProperty.comments = merge_comments comments } + | New ({ New.comments; _ } as e) -> New { e with New.comments = merge_comments comments } + | Object ({ Object.comments; _ } as e) -> + Object { e with Object.comments = merge_comments_with_internal comments } + | OptionalCall ({ OptionalCall.call = { Call.comments; _ } as call; _ } as optional_call) -> + OptionalCall + { + optional_call with + OptionalCall.call = { call with Call.comments = merge_comments comments }; + } + | OptionalMember + ({ OptionalMember.member = { Member.comments; _ } as member; _ } as optional_member) -> + OptionalMember + { + optional_member with + OptionalMember.member = { member with Member.comments = merge_comments comments }; + } + | Sequence ({ Sequence.comments; _ } as e) -> + Sequence { e with Sequence.comments = merge_comments comments } + | Super { Super.comments; _ } -> Super { Super.comments = merge_comments comments } + | TaggedTemplate ({ TaggedTemplate.comments; _ } as e) -> + TaggedTemplate { e with TaggedTemplate.comments = merge_comments comments } + | TemplateLiteral ({ TemplateLiteral.comments; _ } as e) -> + TemplateLiteral { e with TemplateLiteral.comments = merge_comments comments } + | This { This.comments; _ } -> This { This.comments = merge_comments comments } + | TypeCast ({ TypeCast.comments; _ } as e) -> + TypeCast { e with TypeCast.comments = merge_comments comments } + | Unary ({ Unary.comments; _ } as e) -> + Unary { e with Unary.comments = merge_comments comments } + | Update ({ Update.comments; _ } as e) -> + Update { e with Update.comments = merge_comments comments } + | Yield ({ Yield.comments; _ } as e) -> + Yield { e with Yield.comments = merge_comments comments } + (* TODO: Delete once all expressions support comment attachment *) + | _ -> expression + ) + + and array_initializer = + let rec elements env (acc, errs) = + match Peek.token env with + | T_EOF + | T_RBRACKET -> + (List.rev acc, Pattern_cover.rev_errors errs) + | T_COMMA -> + let loc = Peek.loc env in + Eat.token env; + elements env (Expression.Array.Hole loc :: acc, errs) + | T_ELLIPSIS -> + let leading = Peek.comments env in + let (loc, (argument, new_errs)) = + with_loc + (fun env -> + Eat.token env; + match assignment_cover env with + | Cover_expr argument -> (argument, Pattern_cover.empty_errors) + | Cover_patt (argument, new_errs) -> (argument, new_errs)) + env + in + let elem = + Expression.( + Array.Spread + ( loc, + SpreadElement.{ argument; comments = Flow_ast_utils.mk_comments_opt ~leading () } + ) + ) + in + let is_last = Peek.token env = T_RBRACKET in + (* if this array is interpreted as a pattern, the spread becomes an AssignmentRestElement + which must be the last element. We can easily error about additional elements since + they will be in the element list, but a trailing elision, like `[...x,]`, is not part + of the AST. so, keep track of the error so we can raise it if this is a pattern. *) + let new_errs = + if (not is_last) && Peek.ith_token ~i:1 env = T_RBRACKET then + let if_patt = (loc, Parse_error.ElementAfterRestElement) :: new_errs.if_patt in + { new_errs with if_patt } + else + new_errs + in + if not is_last then Expect.token env T_COMMA; + let acc = elem :: acc in + let errs = Pattern_cover.rev_append_errors new_errs errs in + elements env (acc, errs) + | _ -> + let (elem, new_errs) = + match assignment_cover env with + | Cover_expr elem -> (elem, Pattern_cover.empty_errors) + | Cover_patt (elem, new_errs) -> (elem, new_errs) + in + if Peek.token env <> T_RBRACKET then Expect.token env T_COMMA; + let acc = Expression.Array.Expression elem :: acc in + let errs = Pattern_cover.rev_append_errors new_errs errs in + elements env (acc, errs) + in + fun env -> + let leading = Peek.comments env in + Expect.token env T_LBRACKET; + let (elems, errs) = elements env ([], Pattern_cover.empty_errors) in + let internal = Peek.comments env in + Expect.token env T_RBRACKET; + let trailing = Eat.trailing_comments env in + ( { + Ast.Expression.Array.elements = elems; + comments = Flow_ast_utils.mk_comments_with_internal_opt ~leading ~trailing ~internal (); + }, + errs + ) + + and regexp env = + Eat.push_lex_mode env Lex_mode.REGEXP; + let loc = Peek.loc env in + let leading = Peek.comments env in + let tkn = Peek.token env in + let (raw, pattern, raw_flags, trailing) = + match tkn with + | T_REGEXP (_, pattern, flags) -> + Eat.token env; + let trailing = Eat.trailing_comments env in + let raw = "/" ^ pattern ^ "/" ^ flags in + (raw, pattern, flags, trailing) + | _ -> + error_unexpected ~expected:"a regular expression" env; + ("", "", "", []) + in + Eat.pop_lex_mode env; + let filtered_flags = Buffer.create (String.length raw_flags) in + String.iter + (function + | ('d' | 'g' | 'i' | 'm' | 's' | 'u' | 'y') as c -> Buffer.add_char filtered_flags c + | _ -> ()) + raw_flags; + let flags = Buffer.contents filtered_flags in + if flags <> raw_flags then error env (Parse_error.InvalidRegExpFlags raw_flags); + let value = Literal.(RegExp { RegExp.pattern; flags }) in + ( loc, + let open Expression in + Literal + { Literal.value; raw; comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing () } + ) + + and try_arrow_function = + (* Certain errors (almost all errors) cause a rollback *) + let error_callback _ = + Parse_error.( + function + (* Don't rollback on these errors. *) + | StrictParamName + | StrictReservedWord + | ParameterAfterRestParameter + | NewlineBeforeArrow + | YieldInFormalParameters + | ThisParamBannedInArrowFunctions -> + () + (* Everything else causes a rollback *) + | _ -> raise Try.Rollback + ) + in + let concise_function_body env = + match Peek.token env with + | T_LCURLY -> + let (body_block, contains_use_strict) = Parse.function_block_body env ~expression:true in + (Function.BodyBlock body_block, contains_use_strict) + | _ -> + let expr = Parse.assignment env in + (Function.BodyExpression expr, false) + in + fun env -> + let env = env |> with_error_callback error_callback in + let start_loc = Peek.loc env in + (* a T_ASYNC could either be a parameter name or it could be indicating + * that it's an async function *) + let (async, leading) = + if Peek.ith_token ~i:1 env <> T_ARROW then + Declaration.async env + else + (false, []) + in + let (sig_loc, (tparams, params, return, predicate)) = + with_loc + (fun env -> + let tparams = type_params_remove_trailing env (Type.type_params env) in + (* Disallow all fancy features for identifier => body *) + if Peek.is_identifier env && tparams = None then + let ((loc, _) as name) = + Parse.identifier ~restricted_error:Parse_error.StrictParamName env + in + let param = + ( loc, + { + Ast.Function.Param.argument = + ( loc, + Pattern.Identifier + { + Pattern.Identifier.name; + annot = Ast.Type.Missing (Peek.loc_skip_lookahead env); + optional = false; + } + ); + default = None; + } + ) + in + ( tparams, + ( loc, + { + Ast.Function.Params.params = [param]; + rest = None; + comments = None; + this_ = None; + } + ), + Ast.Type.Missing Loc.{ loc with start = loc._end }, + None + ) + else + let params = + let yield = allow_yield env in + let await = allow_await env in + Declaration.function_params ~await ~yield env + in + (* There's an ambiguity if you use a function type as the return + * type for an arrow function. So we disallow anonymous function + * types in arrow function return types unless the function type is + * enclosed in parens *) + let (return, predicate) = + env |> with_no_anon_function_type true |> Type.annotation_and_predicate_opt + in + (tparams, params, return, predicate)) + env + in + (* It's hard to tell if an invalid expression was intended to be an + * arrow function before we see the =>. If there are no params, that + * implies "()" which is only ever found in arrow params. Similarly, + * rest params indicate arrow functions. Therefore, if we see a rest + * param or an empty param list then we can disable the rollback and + * instead generate errors as if we were parsing an arrow function *) + let env = + match params with + | (_, { Ast.Function.Params.params = _; rest = Some _; this_ = None; comments = _ }) + | (_, { Ast.Function.Params.params = []; rest = _; this_ = None; comments = _ }) -> + without_error_callback env + | _ -> env + in + + (* Disallow this param annotations in arrow functions *) + let params = + match params with + | (loc, ({ Ast.Function.Params.this_ = Some (this_loc, _); _ } as params)) -> + error_at env (this_loc, Parse_error.ThisParamBannedInArrowFunctions); + (loc, { params with Ast.Function.Params.this_ = None }) + | _ -> params + in + let simple_params = is_simple_parameter_list params in + + if Peek.is_line_terminator env && Peek.token env = T_ARROW then + error env Parse_error.NewlineBeforeArrow; + Expect.token env T_ARROW; + + (* Now we know for sure this is an arrow function *) + let env = without_error_callback env in + (* arrow functions can't be generators *) + let env = enter_function env ~async ~generator:false ~simple_params in + let (end_loc, (body, contains_use_strict)) = with_loc concise_function_body env in + Declaration.strict_post_check env ~contains_use_strict None params; + let loc = Loc.btwn start_loc end_loc in + Cover_expr + ( loc, + let open Expression in + ArrowFunction + { + Function.id = None; + params; + body; + async; + generator = false; + (* arrow functions cannot be generators *) + predicate; + return; + tparams; + sig_loc; + comments = Flow_ast_utils.mk_comments_opt ~leading (); + } + ) + + and sequence = + let rec helper acc env = + match Peek.token env with + | T_COMMA -> + Eat.token env; + let expr = assignment env in + helper (expr :: acc) env + | _ -> + let expressions = List.rev acc in + Expression.(Sequence Sequence.{ expressions; comments = None }) + in + (fun env ~start_loc acc -> with_loc ~start_loc (helper acc) env) +end diff --git a/analysis/vendor/js_parser/file_key.ml b/analysis/vendor/js_parser/file_key.ml new file mode 100644 index 000000000..2ee9176dc --- /dev/null +++ b/analysis/vendor/js_parser/file_key.ml @@ -0,0 +1,100 @@ +(* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) +open Primitive_deriving + +type t = + | LibFile of string + | SourceFile of string + | JsonFile of string + (* A resource that might get required, like .css, .jpg, etc. We don't parse + these, just check that they exist *) + | ResourceFile of string +[@@deriving_inline equal] +let _ = fun (_ : t) -> () +let equal = + (fun a__001_ -> + fun b__002_ -> + if Ppx_compare_lib.phys_equal a__001_ b__002_ + then true + else + (match (a__001_, b__002_) with + | (LibFile _a__003_, LibFile _b__004_) -> + equal_string _a__003_ _b__004_ + | (LibFile _, _) -> false + | (_, LibFile _) -> false + | (SourceFile _a__005_, SourceFile _b__006_) -> + equal_string _a__005_ _b__006_ + | (SourceFile _, _) -> false + | (_, SourceFile _) -> false + | (JsonFile _a__007_, JsonFile _b__008_) -> + equal_string _a__007_ _b__008_ + | (JsonFile _, _) -> false + | (_, JsonFile _) -> false + | (ResourceFile _a__009_, ResourceFile _b__010_) -> + equal_string _a__009_ _b__010_) : t -> t -> bool) +let _ = equal +[@@@end] +let to_string = function + | LibFile x + | SourceFile x + | JsonFile x + | ResourceFile x -> + x + +let to_path = function + | LibFile x + | SourceFile x + | JsonFile x + | ResourceFile x -> + Ok x + +let compare = + (* libs, then source and json files at the same priority since JSON files are + * basically source files. We don't actually read resource files so they come + * last *) + let order_of_filename = function + | LibFile _ -> 1 + | SourceFile _ -> 2 + | JsonFile _ -> 2 + | ResourceFile _ -> 3 + in + fun a b -> + let k = order_of_filename a - order_of_filename b in + if k <> 0 then + k + else + String.compare (to_string a) (to_string b) + +let compare_opt a b = + match (a, b) with + | (Some _, None) -> -1 + | (None, Some _) -> 1 + | (None, None) -> 0 + | (Some a, Some b) -> compare a b + +let is_lib_file = function + | LibFile _ -> true + | SourceFile _ -> false + | JsonFile _ -> false + | ResourceFile _ -> false + +let map f = function + | LibFile filename -> LibFile (f filename) + | SourceFile filename -> SourceFile (f filename) + | JsonFile filename -> JsonFile (f filename) + | ResourceFile filename -> ResourceFile (f filename) + +let exists f = function + | LibFile filename + | SourceFile filename + | JsonFile filename + | ResourceFile filename -> + f filename + +let check_suffix filename suffix = exists (fun fn -> Filename.check_suffix fn suffix) filename +let chop_suffix filename suffix = map (fun fn -> Filename.chop_suffix fn suffix) filename +let with_suffix filename suffix = map (fun fn -> fn ^ suffix) filename diff --git a/analysis/vendor/js_parser/flow_LICENSE b/analysis/vendor/js_parser/flow_LICENSE new file mode 100644 index 000000000..188fb2b0b --- /dev/null +++ b/analysis/vendor/js_parser/flow_LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2013-present, Facebook, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/analysis/vendor/js_parser/flow_ast.ml b/analysis/vendor/js_parser/flow_ast.ml new file mode 100644 index 000000000..628b21ce3 --- /dev/null +++ b/analysis/vendor/js_parser/flow_ast.ml @@ -0,0 +1,1754 @@ +(* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) + +module rec Syntax : sig + type ('M, 'internal) t = { + leading: 'M Comment.t list; + trailing: 'M Comment.t list; + internal: 'internal; + } +end = + Syntax + +and Identifier : sig + type ('M, 'T) t = 'T * 'M t' + + and 'M t' = { + name: string; + comments: ('M, unit) Syntax.t option; + } +end = + Identifier + +and PrivateName : sig + type 'M t = 'M * 'M t' + + and 'M t' = { + name: string; + comments: ('M, unit) Syntax.t option; + } +end = + PrivateName + +and Literal : sig + module RegExp : sig + type t = { + pattern: string; + flags: string; + } + end + + (* Literals also carry along their raw value *) + type 'M t = { + value: value; + raw: string; + comments: ('M, unit) Syntax.t option; + } + + and value = + | String of string + | Boolean of bool + | Null + | Number of float + | BigInt of int64 option + | RegExp of RegExp.t +end = + Literal + +and StringLiteral : sig + type 'M t = { + value: string; + raw: string; + comments: ('M, unit) Syntax.t option; + } +end = + StringLiteral + +and NumberLiteral : sig + type 'M t = { + value: float; + raw: string; + comments: ('M, unit) Syntax.t option; + } +end = + NumberLiteral + +and BigIntLiteral : sig + type 'M t = { + (* This will be None if we couldn't parse `raw`. That could be if the number is out of range or invalid (like a float) *) + value: int64 option; + raw: string; + comments: ('M, unit) Syntax.t option; + } +end = + BigIntLiteral + +and BooleanLiteral : sig + type 'M t = { + value: bool; + comments: ('M, unit) Syntax.t option; + } +end = + BooleanLiteral + +and Variance : sig + type 'M t = 'M * 'M t' + + and kind = + | Plus + | Minus + + and 'M t' = { + kind: kind; + comments: ('M, unit) Syntax.t option; + } +end = + Variance + +and ComputedKey : sig + type ('M, 'T) t = 'M * ('M, 'T) ComputedKey.t' + + and ('M, 'T) t' = { + expression: ('M, 'T) Expression.t; + comments: ('M, unit) Syntax.t option; + } +end = + ComputedKey + +and Type : sig + module Function : sig + module Param : sig + type ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) t' = { + name: ('M, 'T) Identifier.t option; + annot: ('M, 'T) Type.t; + optional: bool; + } + end + + module RestParam : sig + type ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) t' = { + argument: ('M, 'T) Param.t; + comments: ('M, unit) Syntax.t option; + } + end + + module ThisParam : sig + type ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) t' = { + annot: ('M, 'T) Type.annotation; + comments: ('M, unit) Syntax.t option; + } + end + + module Params : sig + type ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) t' = { + this_: ('M, 'T) ThisParam.t option; + params: ('M, 'T) Param.t list; + rest: ('M, 'T) RestParam.t option; + comments: ('M, 'M Comment.t list) Syntax.t option; + } + end + + type ('M, 'T) t = { + tparams: ('M, 'T) Type.TypeParams.t option; + params: ('M, 'T) Params.t; + return: ('M, 'T) Type.t; + comments: ('M, unit) Syntax.t option; + } + end + + module Generic : sig + module Identifier : sig + type ('M, 'T) t = + | Unqualified of ('M, 'T) Identifier.t + | Qualified of ('M, 'T) qualified + + and ('M, 'T) qualified = 'M * ('M, 'T) qualified' + + and ('M, 'T) qualified' = { + qualification: ('M, 'T) t; + id: ('M, 'T) Identifier.t; + } + end + + type ('M, 'T) t = { + id: ('M, 'T) Identifier.t; + targs: ('M, 'T) Type.TypeArgs.t option; + comments: ('M, unit) Syntax.t option; + } + end + + module IndexedAccess : sig + type ('M, 'T) t = { + _object: ('M, 'T) Type.t; + index: ('M, 'T) Type.t; + comments: ('M, unit) Syntax.t option; + } + end + + module OptionalIndexedAccess : sig + type ('M, 'T) t = { + indexed_access: ('M, 'T) IndexedAccess.t; + optional: bool; + } + end + + module Object : sig + module Property : sig + type ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) t' = { + key: ('M, 'T) Expression.Object.Property.key; + value: ('M, 'T) value; + optional: bool; + static: bool; + proto: bool; + _method: bool; + variance: 'M Variance.t option; + comments: ('M, unit) Syntax.t option; + } + + and ('M, 'T) value = + | Init of ('M, 'T) Type.t + | Get of ('M * ('M, 'T) Function.t) + | Set of ('M * ('M, 'T) Function.t) + end + + module SpreadProperty : sig + type ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) t' = { + argument: ('M, 'T) Type.t; + comments: ('M, unit) Syntax.t option; + } + end + + module Indexer : sig + type ('M, 'T) t' = { + id: ('M, 'M) Identifier.t option; + key: ('M, 'T) Type.t; + value: ('M, 'T) Type.t; + static: bool; + variance: 'M Variance.t option; + comments: ('M, unit) Syntax.t option; + } + + and ('M, 'T) t = 'M * ('M, 'T) t' + end + + module CallProperty : sig + type ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) t' = { + value: 'M * ('M, 'T) Function.t; + static: bool; + comments: ('M, unit) Syntax.t option; + } + end + + module InternalSlot : sig + type ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) t' = { + id: ('M, 'M) Identifier.t; + value: ('M, 'T) Type.t; + optional: bool; + static: bool; + _method: bool; + comments: ('M, unit) Syntax.t option; + } + end + + type ('M, 'T) t = { + exact: bool; + (* Inexact indicates the presence of ... in the object. It is more + * easily understood if exact is read as "explicitly exact" and "inexact" + * is read as "explicitly inexact". + * + * This confusion will go away when we get rid of the exact flag in favor + * of inexact as part of the work to make object types exact by default. + * *) + inexact: bool; + properties: ('M, 'T) property list; + comments: ('M, 'M Comment.t list) Syntax.t option; + } + + and ('M, 'T) property = + | Property of ('M, 'T) Property.t + | SpreadProperty of ('M, 'T) SpreadProperty.t + | Indexer of ('M, 'T) Indexer.t + | CallProperty of ('M, 'T) CallProperty.t + | InternalSlot of ('M, 'T) InternalSlot.t + end + + module Interface : sig + type ('M, 'T) t = { + body: 'M * ('M, 'T) Object.t; + extends: ('M * ('M, 'T) Generic.t) list; + comments: ('M, unit) Syntax.t option; + } + end + + module Nullable : sig + type ('M, 'T) t = { + argument: ('M, 'T) Type.t; + comments: ('M, unit) Syntax.t option; + } + end + + module Typeof : sig + module Target : sig + type ('M, 'T) t = + | Unqualified of ('M, 'T) Identifier.t + | Qualified of ('M, 'T) qualified + + and ('M, 'T) qualified' = { + qualification: ('M, 'T) t; + id: ('M, 'T) Identifier.t; + } + + and ('M, 'T) qualified = 'T * ('M, 'T) qualified' + end + + type ('M, 'T) t = { + argument: ('M, 'T) Target.t; + comments: ('M, unit) Syntax.t option; + } + end + + module Tuple : sig + type ('M, 'T) t = { + types: ('M, 'T) Type.t list; + comments: ('M, unit) Syntax.t option; + } + end + + module Array : sig + type ('M, 'T) t = { + argument: ('M, 'T) Type.t; + comments: ('M, unit) Syntax.t option; + } + end + + module Union : sig + type ('M, 'T) t = { + types: ('M, 'T) Type.t * ('M, 'T) Type.t * ('M, 'T) Type.t list; + comments: ('M, unit) Syntax.t option; + } + end + + module Intersection : sig + type ('M, 'T) t = { + types: ('M, 'T) Type.t * ('M, 'T) Type.t * ('M, 'T) Type.t list; + comments: ('M, unit) Syntax.t option; + } + end + + type ('M, 'T) t = 'T * ('M, 'T) t' + + (* Yes, we could add a little complexity here to show that Any and Void + * should never be declared nullable, but that check can happen later *) + and ('M, 'T) t' = + | Any of ('M, unit) Syntax.t option + | Mixed of ('M, unit) Syntax.t option + | Empty of ('M, unit) Syntax.t option + | Void of ('M, unit) Syntax.t option + | Null of ('M, unit) Syntax.t option + | Number of ('M, unit) Syntax.t option + | BigInt of ('M, unit) Syntax.t option + | String of ('M, unit) Syntax.t option + | Boolean of ('M, unit) Syntax.t option + | Symbol of ('M, unit) Syntax.t option + | Exists of ('M, unit) Syntax.t option + | Nullable of ('M, 'T) Nullable.t + | Function of ('M, 'T) Function.t + | Object of ('M, 'T) Object.t + | Interface of ('M, 'T) Interface.t + | Array of ('M, 'T) Array.t + | Generic of ('M, 'T) Generic.t + | IndexedAccess of ('M, 'T) IndexedAccess.t + | OptionalIndexedAccess of ('M, 'T) OptionalIndexedAccess.t + | Union of ('M, 'T) Union.t + | Intersection of ('M, 'T) Intersection.t + | Typeof of ('M, 'T) Typeof.t + | Tuple of ('M, 'T) Tuple.t + | StringLiteral of 'M StringLiteral.t + | NumberLiteral of 'M NumberLiteral.t + | BigIntLiteral of 'M BigIntLiteral.t + | BooleanLiteral of 'M BooleanLiteral.t + + (* Type.annotation is a concrete syntax node with a location that starts at + * the colon and ends after the type. For example, "var a: number", the + * identifier a would have a property annot which contains a + * Type.annotation with a location from column 6-14 *) + and ('M, 'T) annotation = 'M * ('M, 'T) t + + and ('M, 'T) annotation_or_hint = + | Missing of 'T + | Available of ('M, 'T) Type.annotation + + module TypeParam : sig + type ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) t' = { + name: ('M, 'M) Identifier.t; + bound: ('M, 'T) Type.annotation_or_hint; + variance: 'M Variance.t option; + default: ('M, 'T) Type.t option; + } + end + + module TypeParams : sig + type ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) t' = { + params: ('M, 'T) TypeParam.t list; + comments: ('M, 'M Comment.t list) Syntax.t option; + } + end + + module TypeArgs : sig + type ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) t' = { + arguments: ('M, 'T) Type.t list; + comments: ('M, 'M Comment.t list) Syntax.t option; + } + end + + module Predicate : sig + type ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) t' = { + kind: ('M, 'T) kind; + comments: ('M, unit) Syntax.t option; + } + + and ('M, 'T) kind = + | Declared of ('M, 'T) Expression.t + | Inferred + end +end = + Type + +and Statement : sig + module Block : sig + type ('M, 'T) t = { + body: ('M, 'T) Statement.t list; + comments: ('M, 'M Comment.t list) Syntax.t option; + } + end + + module If : sig + module Alternate : sig + type ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) t' = { + body: ('M, 'T) Statement.t; + comments: ('M, unit) Syntax.t option; + } + end + + type ('M, 'T) t = { + test: ('M, 'T) Expression.t; + consequent: ('M, 'T) Statement.t; + alternate: ('M, 'T) Alternate.t option; + comments: ('M, unit) Syntax.t option; + } + end + + module Labeled : sig + type ('M, 'T) t = { + label: ('M, 'M) Identifier.t; + body: ('M, 'T) Statement.t; + comments: ('M, unit) Syntax.t option; + } + end + + module Break : sig + type 'M t = { + label: ('M, 'M) Identifier.t option; + comments: ('M, unit) Syntax.t option; + } + end + + module Continue : sig + type 'M t = { + label: ('M, 'M) Identifier.t option; + comments: ('M, unit) Syntax.t option; + } + end + + module Debugger : sig + type 'M t = { comments: ('M, unit) Syntax.t option } + end + + module With : sig + type ('M, 'T) t = { + _object: ('M, 'T) Expression.t; + body: ('M, 'T) Statement.t; + comments: ('M, unit) Syntax.t option; + } + end + + module TypeAlias : sig + type ('M, 'T) t = { + id: ('M, 'T) Identifier.t; + tparams: ('M, 'T) Type.TypeParams.t option; + right: ('M, 'T) Type.t; + comments: ('M, unit) Syntax.t option; + } + end + + module OpaqueType : sig + type ('M, 'T) t = { + id: ('M, 'T) Identifier.t; + tparams: ('M, 'T) Type.TypeParams.t option; + impltype: ('M, 'T) Type.t option; + supertype: ('M, 'T) Type.t option; + comments: ('M, unit) Syntax.t option; + } + end + + module Switch : sig + module Case : sig + type ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) t' = { + test: ('M, 'T) Expression.t option; + consequent: ('M, 'T) Statement.t list; + comments: ('M, unit) Syntax.t option; + } + end + + type ('M, 'T) t = { + discriminant: ('M, 'T) Expression.t; + cases: ('M, 'T) Case.t list; + comments: ('M, unit) Syntax.t option; + exhaustive_out: 'T; + } + end + + module Return : sig + type ('M, 'T) t = { + argument: ('M, 'T) Expression.t option; + comments: ('M, unit) Syntax.t option; + return_out: 'T; + } + end + + module Throw : sig + type ('M, 'T) t = { + argument: ('M, 'T) Expression.t; + comments: ('M, unit) Syntax.t option; + } + end + + module Try : sig + module CatchClause : sig + type ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) t' = { + param: ('M, 'T) Pattern.t option; + body: 'M * ('M, 'T) Block.t; + comments: ('M, unit) Syntax.t option; + } + end + + type ('M, 'T) t = { + block: 'M * ('M, 'T) Block.t; + handler: ('M, 'T) CatchClause.t option; + finalizer: ('M * ('M, 'T) Block.t) option; + comments: ('M, unit) Syntax.t option; + } + end + + module VariableDeclaration : sig + module Declarator : sig + type ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) t' = { + id: ('M, 'T) Pattern.t; + init: ('M, 'T) Expression.t option; + } + end + + type ('M, 'T) t = { + declarations: ('M, 'T) Declarator.t list; + kind: kind; + comments: ('M, unit) Syntax.t option; + } + + and kind = + | Var + | Let + | Const + end + + module While : sig + type ('M, 'T) t = { + test: ('M, 'T) Expression.t; + body: ('M, 'T) Statement.t; + comments: ('M, unit) Syntax.t option; + } + end + + module DoWhile : sig + type ('M, 'T) t = { + body: ('M, 'T) Statement.t; + test: ('M, 'T) Expression.t; + comments: ('M, unit) Syntax.t option; + } + end + + module For : sig + type ('M, 'T) t = { + init: ('M, 'T) init option; + test: ('M, 'T) Expression.t option; + update: ('M, 'T) Expression.t option; + body: ('M, 'T) Statement.t; + comments: ('M, unit) Syntax.t option; + } + + and ('M, 'T) init = + | InitDeclaration of ('M * ('M, 'T) VariableDeclaration.t) + | InitExpression of ('M, 'T) Expression.t + end + + module ForIn : sig + type ('M, 'T) t = { + left: ('M, 'T) left; + right: ('M, 'T) Expression.t; + body: ('M, 'T) Statement.t; + each: bool; + comments: ('M, unit) Syntax.t option; + } + + and ('M, 'T) left = + | LeftDeclaration of ('M * ('M, 'T) VariableDeclaration.t) + | LeftPattern of ('M, 'T) Pattern.t + end + + module ForOf : sig + type ('M, 'T) t = { + left: ('M, 'T) left; + right: ('M, 'T) Expression.t; + body: ('M, 'T) Statement.t; + await: bool; + comments: ('M, unit) Syntax.t option; + } + + and ('M, 'T) left = + | LeftDeclaration of ('M * ('M, 'T) VariableDeclaration.t) + | LeftPattern of ('M, 'T) Pattern.t + end + + module EnumDeclaration : sig + module DefaultedMember : sig + type 'M t = 'M * 'M t' + and 'M t' = { id: ('M, 'M) Identifier.t } + end + + module InitializedMember : sig + type ('I, 'M) t = 'M * ('I, 'M) t' + + and ('I, 'M) t' = { + id: ('M, 'M) Identifier.t; + init: 'M * 'I; + } + end + + module BooleanBody : sig + type 'M t = { + members: ('M BooleanLiteral.t, 'M) InitializedMember.t list; + explicit_type: bool; + has_unknown_members: bool; + comments: ('M, 'M Comment.t list) Syntax.t option; + } + end + + module NumberBody : sig + type 'M t = { + members: ('M NumberLiteral.t, 'M) InitializedMember.t list; + explicit_type: bool; + has_unknown_members: bool; + comments: ('M, 'M Comment.t list) Syntax.t option; + } + end + + module StringBody : sig + type 'M t = { + members: ('M StringLiteral.t, 'M) members; + explicit_type: bool; + has_unknown_members: bool; + comments: ('M, 'M Comment.t list) Syntax.t option; + } + + and ('I, 'M) members = + | Defaulted of 'M DefaultedMember.t list + | Initialized of ('I, 'M) InitializedMember.t list + end + + module SymbolBody : sig + type 'M t = { + members: 'M DefaultedMember.t list; + has_unknown_members: bool; + comments: ('M, 'M Comment.t list) Syntax.t option; + } + end + + type ('M, 'T) t = { + id: ('M, 'T) Identifier.t; + body: 'M body; + comments: ('M, unit) Syntax.t option; + } + + and 'M body = 'M * 'M body' + + and 'M body' = + | BooleanBody of 'M BooleanBody.t + | NumberBody of 'M NumberBody.t + | StringBody of 'M StringBody.t + | SymbolBody of 'M SymbolBody.t + end + + module Interface : sig + type ('M, 'T) t = { + id: ('M, 'T) Identifier.t; + tparams: ('M, 'T) Type.TypeParams.t option; + extends: ('M * ('M, 'T) Type.Generic.t) list; + body: 'M * ('M, 'T) Type.Object.t; + comments: ('M, unit) Syntax.t option; + } + end + + module DeclareClass : sig + type ('M, 'T) t = { + id: ('M, 'T) Identifier.t; + tparams: ('M, 'T) Type.TypeParams.t option; + body: 'M * ('M, 'T) Type.Object.t; + extends: ('M * ('M, 'T) Type.Generic.t) option; + mixins: ('M * ('M, 'T) Type.Generic.t) list; + implements: ('M, 'T) Class.Implements.t option; + comments: ('M, unit) Syntax.t option; + } + end + + module DeclareVariable : sig + type ('M, 'T) t = { + id: ('M, 'T) Identifier.t; + annot: ('M, 'T) Type.annotation; + comments: ('M, unit) Syntax.t option; + } + end + + module DeclareFunction : sig + type ('M, 'T) t = { + id: ('M, 'T) Identifier.t; + annot: ('M, 'T) Type.annotation; + predicate: ('M, 'T) Type.Predicate.t option; + comments: ('M, unit) Syntax.t option; + } + end + + module DeclareModule : sig + type ('M, 'T) id = + | Identifier of ('M, 'T) Identifier.t + | Literal of ('T * 'M StringLiteral.t) + + and module_kind = + | CommonJS + | ES + + and ('M, 'T) t = { + id: ('M, 'T) id; + body: 'M * ('M, 'T) Block.t; + kind: module_kind; + comments: ('M, unit) Syntax.t option; + } + end + + module DeclareModuleExports : sig + type ('M, 'T) t = { + annot: ('M, 'T) Type.annotation; + comments: ('M, unit) Syntax.t option; + } + end + + module ExportNamedDeclaration : sig + module ExportSpecifier : sig + type 'M t = 'M * 'M t' + + and 'M t' = { + local: ('M, 'M) Identifier.t; + exported: ('M, 'M) Identifier.t option; + } + end + + module ExportBatchSpecifier : sig + type 'M t = 'M * ('M, 'M) Identifier.t option + end + + type ('M, 'T) t = { + declaration: ('M, 'T) Statement.t option; + specifiers: 'M specifier option; + source: ('M * 'M StringLiteral.t) option; + export_kind: Statement.export_kind; + comments: ('M, unit) Syntax.t option; + } + + and 'M specifier = + | ExportSpecifiers of 'M ExportSpecifier.t list + | ExportBatchSpecifier of 'M ExportBatchSpecifier.t + end + + module ExportDefaultDeclaration : sig + type ('M, 'T) t = { + default: 'M; + declaration: ('M, 'T) declaration; + comments: ('M, unit) Syntax.t option; + } + + and ('M, 'T) declaration = + | Declaration of ('M, 'T) Statement.t + | Expression of ('M, 'T) Expression.t + end + + module DeclareExportDeclaration : sig + type ('M, 'T) declaration = + (* declare export var *) + | Variable of ('M * ('M, 'T) DeclareVariable.t) + (* declare export function *) + | Function of ('M * ('M, 'T) DeclareFunction.t) + (* declare export class *) + | Class of ('M * ('M, 'T) DeclareClass.t) + (* declare export default [type] + * this corresponds to things like + * export default 1+1; *) + | DefaultType of ('M, 'T) Type.t + (* declare export type *) + | NamedType of ('M * ('M, 'T) TypeAlias.t) + (* declare export opaque type *) + | NamedOpaqueType of ('M * ('M, 'T) OpaqueType.t) + (* declare export interface *) + | Interface of ('M * ('M, 'T) Interface.t) + + and ('M, 'T) t = { + default: 'M option; + declaration: ('M, 'T) declaration option; + specifiers: 'M ExportNamedDeclaration.specifier option; + source: ('M * 'M StringLiteral.t) option; + comments: ('M, unit) Syntax.t option; + } + end + + module ImportDeclaration : sig + type import_kind = + | ImportType + | ImportTypeof + | ImportValue + + and ('M, 'T) specifier = + | ImportNamedSpecifiers of ('M, 'T) named_specifier list + | ImportNamespaceSpecifier of ('M * ('M, 'T) Identifier.t) + + and ('M, 'T) named_specifier = { + kind: import_kind option; + local: ('M, 'T) Identifier.t option; + remote: ('M, 'T) Identifier.t; + } + + and ('M, 'T) t = { + import_kind: import_kind; + source: 'T * 'M StringLiteral.t; + default: ('M, 'T) Identifier.t option; + specifiers: ('M, 'T) specifier option; + comments: ('M, unit) Syntax.t option; + } + end + + module Expression : sig + type ('M, 'T) t = { + expression: ('M, 'T) Expression.t; + directive: string option; + comments: ('M, unit) Syntax.t option; + } + end + + module Empty : sig + type 'M t = { comments: ('M, unit) Syntax.t option } + end + + type export_kind = + | ExportType + | ExportValue + + and ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) t' = + | Block of ('M, 'T) Block.t + | Break of 'M Break.t + | ClassDeclaration of ('M, 'T) Class.t + | Continue of 'M Continue.t + | Debugger of 'M Debugger.t + | DeclareClass of ('M, 'T) DeclareClass.t + | DeclareExportDeclaration of ('M, 'T) DeclareExportDeclaration.t + | DeclareFunction of ('M, 'T) DeclareFunction.t + | DeclareInterface of ('M, 'T) Interface.t + | DeclareModule of ('M, 'T) DeclareModule.t + | DeclareModuleExports of ('M, 'T) DeclareModuleExports.t + | DeclareTypeAlias of ('M, 'T) TypeAlias.t + | DeclareOpaqueType of ('M, 'T) OpaqueType.t + | DeclareVariable of ('M, 'T) DeclareVariable.t + | DoWhile of ('M, 'T) DoWhile.t + | Empty of 'M Empty.t + | EnumDeclaration of ('M, 'T) EnumDeclaration.t + | ExportDefaultDeclaration of ('M, 'T) ExportDefaultDeclaration.t + | ExportNamedDeclaration of ('M, 'T) ExportNamedDeclaration.t + | Expression of ('M, 'T) Expression.t + | For of ('M, 'T) For.t + | ForIn of ('M, 'T) ForIn.t + | ForOf of ('M, 'T) ForOf.t + | FunctionDeclaration of ('M, 'T) Function.t + | If of ('M, 'T) If.t + | ImportDeclaration of ('M, 'T) ImportDeclaration.t + | InterfaceDeclaration of ('M, 'T) Interface.t + | Labeled of ('M, 'T) Labeled.t + | Return of ('M, 'T) Return.t + | Switch of ('M, 'T) Switch.t + | Throw of ('M, 'T) Throw.t + | Try of ('M, 'T) Try.t + | TypeAlias of ('M, 'T) TypeAlias.t + | OpaqueType of ('M, 'T) OpaqueType.t + | VariableDeclaration of ('M, 'T) VariableDeclaration.t + | While of ('M, 'T) While.t + | With of ('M, 'T) With.t +end = + Statement + +and Expression : sig + module CallTypeArg : sig + module Implicit : sig + type ('M, 'T) t = 'T * 'M t' + and 'M t' = { comments: ('M, unit) Syntax.t option } + end + + type ('M, 'T) t = + | Explicit of ('M, 'T) Type.t + | Implicit of ('M, 'T) Implicit.t + end + + module CallTypeArgs : sig + type ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) t' = { + arguments: ('M, 'T) CallTypeArg.t list; + comments: ('M, 'M Comment.t list) Syntax.t option; + } + end + + module SpreadElement : sig + type ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) t' = { + argument: ('M, 'T) Expression.t; + comments: ('M, unit) Syntax.t option; + } + end + + module Array : sig + type ('M, 'T) element = + | Expression of ('M, 'T) Expression.t + | Spread of ('M, 'T) SpreadElement.t + | Hole of 'M + + type ('M, 'T) t = { + elements: ('M, 'T) element list; + comments: ('M, 'M Comment.t list) Syntax.t option; + } + end + + module TemplateLiteral : sig + module Element : sig + type value = { + raw: string; + cooked: string; + } + + and 'M t = 'M * t' + + and t' = { + value: value; + tail: bool; + } + end + + type ('M, 'T) t = { + quasis: 'M Element.t list; + expressions: ('M, 'T) Expression.t list; + comments: ('M, unit) Syntax.t option; + } + end + + module TaggedTemplate : sig + type ('M, 'T) t = { + tag: ('M, 'T) Expression.t; + quasi: 'M * ('M, 'T) TemplateLiteral.t; + comments: ('M, unit) Syntax.t option; + } + end + + module Object : sig + module Property : sig + type ('M, 'T) key = + | Literal of ('T * 'M Literal.t) + | Identifier of ('M, 'T) Identifier.t + | PrivateName of 'M PrivateName.t + | Computed of ('M, 'T) ComputedKey.t + + and ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) t' = + | Init of { + key: ('M, 'T) key; + value: ('M, 'T) Expression.t; + shorthand: bool; + } + | Method of { + key: ('M, 'T) key; + value: 'M * ('M, 'T) Function.t; + } + | Get of { + key: ('M, 'T) key; + value: 'M * ('M, 'T) Function.t; + comments: ('M, unit) Syntax.t option; + } + | Set of { + key: ('M, 'T) key; + value: 'M * ('M, 'T) Function.t; + comments: ('M, unit) Syntax.t option; + } + end + + module SpreadProperty : sig + type ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) t' = { + argument: ('M, 'T) Expression.t; + comments: ('M, unit) Syntax.t option; + } + end + + type ('M, 'T) property = + | Property of ('M, 'T) Property.t + | SpreadProperty of ('M, 'T) SpreadProperty.t + + and ('M, 'T) t = { + properties: ('M, 'T) property list; + comments: ('M, 'M Comment.t list) Syntax.t option; + } + end + + module Sequence : sig + type ('M, 'T) t = { + expressions: ('M, 'T) Expression.t list; + comments: ('M, unit) Syntax.t option; + } + end + + module Unary : sig + type operator = + | Minus + | Plus + | Not + | BitNot + | Typeof + | Void + | Delete + | Await + + and ('M, 'T) t = { + operator: operator; + argument: ('M, 'T) Expression.t; + comments: ('M, unit) Syntax.t option; + } + end + + module Binary : sig + type operator = + | Equal + | NotEqual + | StrictEqual + | StrictNotEqual + | LessThan + | LessThanEqual + | GreaterThan + | GreaterThanEqual + | LShift + | RShift + | RShift3 + | Plus + | Minus + | Mult + | Exp + | Div + | Mod + | BitOr + | Xor + | BitAnd + | In + | Instanceof + + and ('M, 'T) t = { + operator: operator; + left: ('M, 'T) Expression.t; + right: ('M, 'T) Expression.t; + comments: ('M, unit) Syntax.t option; + } + end + + module Assignment : sig + type operator = + | PlusAssign + | MinusAssign + | MultAssign + | ExpAssign + | DivAssign + | ModAssign + | LShiftAssign + | RShiftAssign + | RShift3Assign + | BitOrAssign + | BitXorAssign + | BitAndAssign + | NullishAssign + | AndAssign + | OrAssign + + and ('M, 'T) t = { + operator: operator option; + left: ('M, 'T) Pattern.t; + right: ('M, 'T) Expression.t; + comments: ('M, unit) Syntax.t option; + } + end + + module Update : sig + type operator = + | Increment + | Decrement + + and ('M, 'T) t = { + operator: operator; + argument: ('M, 'T) Expression.t; + prefix: bool; + comments: ('M, unit) Syntax.t option; + } + end + + module Logical : sig + type operator = + | Or + | And + | NullishCoalesce + + and ('M, 'T) t = { + operator: operator; + left: ('M, 'T) Expression.t; + right: ('M, 'T) Expression.t; + comments: ('M, unit) Syntax.t option; + } + end + + module Conditional : sig + type ('M, 'T) t = { + test: ('M, 'T) Expression.t; + consequent: ('M, 'T) Expression.t; + alternate: ('M, 'T) Expression.t; + comments: ('M, unit) Syntax.t option; + } + end + + type ('M, 'T) expression_or_spread = + | Expression of ('M, 'T) Expression.t + | Spread of ('M, 'T) SpreadElement.t + + module ArgList : sig + type ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) t' = { + arguments: ('M, 'T) expression_or_spread list; + comments: ('M, 'M Comment.t list) Syntax.t option; + } + end + + module New : sig + type ('M, 'T) t = { + callee: ('M, 'T) Expression.t; + targs: ('M, 'T) Expression.CallTypeArgs.t option; + arguments: ('M, 'T) ArgList.t option; + comments: ('M, unit) Syntax.t option; + } + end + + module Call : sig + type ('M, 'T) t = { + callee: ('M, 'T) Expression.t; + targs: ('M, 'T) Expression.CallTypeArgs.t option; + arguments: ('M, 'T) ArgList.t; + comments: ('M, unit) Syntax.t option; + } + end + + module OptionalCall : sig + type ('M, 'T) t = { + call: ('M, 'T) Call.t; + filtered_out: 'T; + optional: bool; + } + end + + module Member : sig + type ('M, 'T) property = + | PropertyIdentifier of ('M, 'T) Identifier.t + | PropertyPrivateName of 'M PrivateName.t + | PropertyExpression of ('M, 'T) Expression.t + + and ('M, 'T) t = { + _object: ('M, 'T) Expression.t; + property: ('M, 'T) property; + comments: ('M, unit) Syntax.t option; + } + end + + module OptionalMember : sig + type ('M, 'T) t = { + member: ('M, 'T) Member.t; + filtered_out: 'T; + optional: bool; + } + end + + module Yield : sig + type ('M, 'T) t = { + argument: ('M, 'T) Expression.t option; + comments: ('M, unit) Syntax.t option; + delegate: bool; + result_out: 'T; + } + end + + module Comprehension : sig + module Block : sig + type ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) t' = { + left: ('M, 'T) Pattern.t; + right: ('M, 'T) Expression.t; + each: bool; + } + end + + type ('M, 'T) t = { + blocks: ('M, 'T) Block.t list; + filter: ('M, 'T) Expression.t option; + } + end + + module Generator : sig + type ('M, 'T) t = { + blocks: ('M, 'T) Comprehension.Block.t list; + filter: ('M, 'T) Expression.t option; + } + end + + module TypeCast : sig + type ('M, 'T) t = { + expression: ('M, 'T) Expression.t; + annot: ('M, 'T) Type.annotation; + comments: ('M, unit) Syntax.t option; + } + end + + module MetaProperty : sig + type 'M t = { + meta: ('M, 'M) Identifier.t; + property: ('M, 'M) Identifier.t; + comments: ('M, unit) Syntax.t option; + } + end + + module This : sig + type 'M t = { comments: ('M, unit) Syntax.t option } + end + + module Super : sig + type 'M t = { comments: ('M, unit) Syntax.t option } + end + + module Import : sig + type ('M, 'T) t = { + argument: ('M, 'T) Expression.t; + comments: ('M, unit) Syntax.t option; + } + end + + type ('M, 'T) t = 'T * ('M, 'T) t' + + and ('M, 'T) t' = + | Array of ('M, 'T) Array.t + | ArrowFunction of ('M, 'T) Function.t + | Assignment of ('M, 'T) Assignment.t + | Binary of ('M, 'T) Binary.t + | Call of ('M, 'T) Call.t + | Class of ('M, 'T) Class.t + | Comprehension of ('M, 'T) Comprehension.t + | Conditional of ('M, 'T) Conditional.t + | Function of ('M, 'T) Function.t + | Generator of ('M, 'T) Generator.t + | Identifier of ('M, 'T) Identifier.t + | Import of ('M, 'T) Import.t + | JSXElement of ('M, 'T) JSX.element + | JSXFragment of ('M, 'T) JSX.fragment + | Literal of 'M Literal.t + | Logical of ('M, 'T) Logical.t + | Member of ('M, 'T) Member.t + | MetaProperty of 'M MetaProperty.t + | New of ('M, 'T) New.t + | Object of ('M, 'T) Object.t + | OptionalCall of ('M, 'T) OptionalCall.t + | OptionalMember of ('M, 'T) OptionalMember.t + | Sequence of ('M, 'T) Sequence.t + | Super of 'M Super.t + | TaggedTemplate of ('M, 'T) TaggedTemplate.t + | TemplateLiteral of ('M, 'T) TemplateLiteral.t + | This of 'M This.t + | TypeCast of ('M, 'T) TypeCast.t + | Unary of ('M, 'T) Unary.t + | Update of ('M, 'T) Update.t + | Yield of ('M, 'T) Yield.t +end = + Expression + +and JSX : sig + module Identifier : sig + type ('M, 'T) t = 'T * 'M t' + + and 'M t' = { + name: string; + comments: ('M, unit) Syntax.t option; + } + end + + module NamespacedName : sig + type ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) t' = { + namespace: ('M, 'T) Identifier.t; + name: ('M, 'T) Identifier.t; + } + end + + module ExpressionContainer : sig + type ('M, 'T) t = { + expression: ('M, 'T) expression; + comments: ('M, 'M Comment.t list) Syntax.t option; + } + + and ('M, 'T) expression = + | Expression of ('M, 'T) Expression.t + | EmptyExpression + end + + module Text : sig + type t = { + value: string; + raw: string; + } + end + + module Attribute : sig + type ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) name = + | Identifier of ('M, 'T) Identifier.t + | NamespacedName of ('M, 'T) NamespacedName.t + + and ('M, 'T) value = + | Literal of 'T * 'M Literal.t + | ExpressionContainer of 'T * ('M, 'T) ExpressionContainer.t + + and ('M, 'T) t' = { + name: ('M, 'T) name; + value: ('M, 'T) value option; + } + end + + module SpreadAttribute : sig + type ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) t' = { + argument: ('M, 'T) Expression.t; + comments: ('M, unit) Syntax.t option; + } + end + + module MemberExpression : sig + type ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) _object = + | Identifier of ('M, 'T) Identifier.t + | MemberExpression of ('M, 'T) t + + and ('M, 'T) t' = { + _object: ('M, 'T) _object; + property: ('M, 'T) Identifier.t; + } + end + + type ('M, 'T) name = + | Identifier of ('M, 'T) Identifier.t + | NamespacedName of ('M, 'T) NamespacedName.t + | MemberExpression of ('M, 'T) MemberExpression.t + + module Opening : sig + type ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) attribute = + | Attribute of ('M, 'T) Attribute.t + | SpreadAttribute of ('M, 'T) SpreadAttribute.t + + and ('M, 'T) t' = { + name: ('M, 'T) name; + self_closing: bool; + attributes: ('M, 'T) attribute list; + } + end + + module Closing : sig + type ('M, 'T) t = 'M * ('M, 'T) t' + and ('M, 'T) t' = { name: ('M, 'T) name } + end + + module SpreadChild : sig + type ('M, 'T) t = { + expression: ('M, 'T) Expression.t; + comments: ('M, unit) Syntax.t option; + } + end + + type ('M, 'T) child = 'M * ('M, 'T) child' + + and ('M, 'T) child' = + | Element of ('M, 'T) element + | Fragment of ('M, 'T) fragment + | ExpressionContainer of ('M, 'T) ExpressionContainer.t + | SpreadChild of ('M, 'T) SpreadChild.t + | Text of Text.t + + and ('M, 'T) element = { + opening_element: ('M, 'T) Opening.t; + closing_element: ('M, 'T) Closing.t option; + children: 'M * ('M, 'T) child list; + comments: ('M, unit) Syntax.t option; + } + + and ('M, 'T) fragment = { + frag_opening_element: 'M; + frag_closing_element: 'M; + frag_children: 'M * ('M, 'T) child list; + frag_comments: ('M, unit) Syntax.t option; + } +end = + JSX + +and Pattern : sig + module RestElement : sig + type ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) t' = { + argument: ('M, 'T) Pattern.t; + comments: ('M, unit) Syntax.t option; + } + end + + module Object : sig + module Property : sig + type ('M, 'T) key = + | Literal of ('M * 'M Literal.t) + | Identifier of ('M, 'T) Identifier.t + | Computed of ('M, 'T) ComputedKey.t + + and ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) t' = { + key: ('M, 'T) key; + pattern: ('M, 'T) Pattern.t; + default: ('M, 'T) Expression.t option; + shorthand: bool; + } + end + + type ('M, 'T) property = + | Property of ('M, 'T) Property.t + | RestElement of ('M, 'T) RestElement.t + + and ('M, 'T) t = { + properties: ('M, 'T) property list; + annot: ('M, 'T) Type.annotation_or_hint; + comments: ('M, 'M Comment.t list) Syntax.t option; + } + end + + module Array : sig + module Element : sig + type ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) t' = { + argument: ('M, 'T) Pattern.t; + default: ('M, 'T) Expression.t option; + } + end + + type ('M, 'T) element = + | Element of ('M, 'T) Element.t + | RestElement of ('M, 'T) RestElement.t + | Hole of 'M + + and ('M, 'T) t = { + elements: ('M, 'T) element list; + annot: ('M, 'T) Type.annotation_or_hint; + comments: ('M, 'M Comment.t list) Syntax.t option; + } + end + + module Identifier : sig + type ('M, 'T) t = { + name: ('M, 'T) Identifier.t; + annot: ('M, 'T) Type.annotation_or_hint; + optional: bool; + } + end + + type ('M, 'T) t = 'T * ('M, 'T) t' + + and ('M, 'T) t' = + | Object of ('M, 'T) Object.t + | Array of ('M, 'T) Array.t + | Identifier of ('M, 'T) Identifier.t + | Expression of ('M, 'T) Expression.t +end = + Pattern + +and Comment : sig + type 'M t = 'M * t' + + and kind = + | Block + | Line + + and t' = { + kind: kind; + text: string; + on_newline: bool; + } +end = + Comment + +and Class : sig + module Method : sig + type ('M, 'T) t = 'T * ('M, 'T) t' + + and kind = + | Constructor + | Method + | Get + | Set + + and ('M, 'T) t' = { + kind: kind; + key: ('M, 'T) Expression.Object.Property.key; + value: 'M * ('M, 'T) Function.t; + static: bool; + decorators: ('M, 'T) Class.Decorator.t list; + comments: ('M, unit) Syntax.t option; + } + end + + module Property : sig + type ('M, 'T) t = 'T * ('M, 'T) t' + + and ('M, 'T) t' = { + key: ('M, 'T) Expression.Object.Property.key; + value: ('M, 'T) value; + annot: ('M, 'T) Type.annotation_or_hint; + static: bool; + variance: 'M Variance.t option; + comments: ('M, unit) Syntax.t option; + } + + and ('M, 'T) value = + | Declared + | Uninitialized + | Initialized of ('M, 'T) Expression.t + end + + module PrivateField : sig + type ('M, 'T) t = 'T * ('M, 'T) t' + + and ('M, 'T) t' = { + key: 'M PrivateName.t; + value: ('M, 'T) Class.Property.value; + annot: ('M, 'T) Type.annotation_or_hint; + static: bool; + variance: 'M Variance.t option; + comments: ('M, unit) Syntax.t option; + } + end + + module Extends : sig + type ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) t' = { + expr: ('M, 'T) Expression.t; + targs: ('M, 'T) Type.TypeArgs.t option; + comments: ('M, unit) Syntax.t option; + } + end + + module Implements : sig + module Interface : sig + type ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) t' = { + id: ('M, 'T) Identifier.t; + targs: ('M, 'T) Type.TypeArgs.t option; + } + end + + type ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) t' = { + interfaces: ('M, 'T) Interface.t list; + comments: ('M, unit) Syntax.t option; + } + end + + module Body : sig + type ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) t' = { + body: ('M, 'T) element list; + comments: ('M, unit) Syntax.t option; + } + + and ('M, 'T) element = + | Method of ('M, 'T) Method.t + | Property of ('M, 'T) Property.t + | PrivateField of ('M, 'T) PrivateField.t + end + + module Decorator : sig + type ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) t' = { + expression: ('M, 'T) Expression.t; + comments: ('M, unit) Syntax.t option; + } + end + + type ('M, 'T) t = { + id: ('M, 'T) Identifier.t option; + body: ('M, 'T) Class.Body.t; + tparams: ('M, 'T) Type.TypeParams.t option; + extends: ('M, 'T) Extends.t option; + implements: ('M, 'T) Implements.t option; + class_decorators: ('M, 'T) Decorator.t list; + comments: ('M, unit) Syntax.t option; + } +end = + Class + +and Function : sig + module RestParam : sig + type ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) t' = { + argument: ('M, 'T) Pattern.t; + comments: ('M, unit) Syntax.t option; + } + end + + module Param : sig + type ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) t' = { + argument: ('M, 'T) Pattern.t; + default: ('M, 'T) Expression.t option; + } + end + + module ThisParam : sig + type ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) t' = { + annot: ('M, 'T) Type.annotation; + comments: ('M, unit) Syntax.t option; + } + end + + module Params : sig + type ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) t' = { + this_: ('M, 'T) ThisParam.t option; + params: ('M, 'T) Param.t list; + rest: ('M, 'T) RestParam.t option; + comments: ('M, 'M Comment.t list) Syntax.t option; + } + end + + type ('M, 'T) t = { + id: ('M, 'T) Identifier.t option; + params: ('M, 'T) Params.t; + body: ('M, 'T) body; + async: bool; + generator: bool; + predicate: ('M, 'T) Type.Predicate.t option; + return: ('M, 'T) Type.annotation_or_hint; + tparams: ('M, 'T) Type.TypeParams.t option; + comments: ('M, unit) Syntax.t option; + (* Location of the signature portion of a function, e.g. + * function foo(): void {} + * ^^^^^^^^^^^^^^^^^^^^ + *) + sig_loc: 'M; + } + + and ('M, 'T) body = + | BodyBlock of ('M * ('M, 'T) Statement.Block.t) + | BodyExpression of ('M, 'T) Expression.t +end = + Function + +and Program : sig + type ('M, 'T) t = 'M * ('M, 'T) t' + + and ('M, 'T) t' = { + statements: ('M, 'T) Statement.t list; + comments: ('M, unit) Syntax.t option; + all_comments: 'M Comment.t list; + } +end = + Program diff --git a/analysis/vendor/js_parser/flow_ast_mapper.ml b/analysis/vendor/js_parser/flow_ast_mapper.ml new file mode 100644 index 000000000..60050c7bf --- /dev/null +++ b/analysis/vendor/js_parser/flow_ast_mapper.ml @@ -0,0 +1,2681 @@ +(* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) + +module Ast = Flow_ast + +let map_opt : 'node. ('node -> 'node) -> 'node option -> 'node option = + fun map opt -> + match opt with + | Some item -> + let item' = map item in + if item == item' then + opt + else + Some item' + | None -> opt + +let id_loc : 'node 'a. ('loc -> 'node -> 'node) -> 'loc -> 'node -> 'a -> ('node -> 'a) -> 'a = + fun map loc item same diff -> + let item' = map loc item in + if item == item' then + same + else + diff item' + +let id : 'node 'a. ('node -> 'node) -> 'node -> 'a -> ('node -> 'a) -> 'a = + fun map item same diff -> + let item' = map item in + if item == item' then + same + else + diff item' + +let map_loc : 'node. ('loc -> 'node -> 'node) -> 'loc * 'node -> 'loc * 'node = + fun map same -> + let (loc, item) = same in + id_loc map loc item same (fun diff -> (loc, diff)) + +let map_loc_opt : 'node. ('loc -> 'node -> 'node) -> ('loc * 'node) option -> ('loc * 'node) option + = + fun map same -> + map_opt + (fun same -> + let (loc, item) = same in + id_loc map loc item same (fun diff -> (loc, diff))) + same + +let map_list map lst = + let (rev_lst, changed) = + List.fold_left + (fun (lst', changed) item -> + let item' = map item in + (item' :: lst', changed || item' != item)) + ([], false) + lst + in + if changed then + List.rev rev_lst + else + lst + +let map_list_multiple map lst = + let (rev_lst, changed) = + List.fold_left + (fun (lst', changed) item -> + match map item with + | [] -> (lst', true) + | [item'] -> (item' :: lst', changed || item != item') + | items' -> (List.rev_append items' lst', true)) + ([], false) + lst + in + if changed then + List.rev rev_lst + else + lst + +class ['loc] mapper = + object (this) + method program (program : ('loc, 'loc) Ast.Program.t) = + let open Ast.Program in + let (loc, { statements; comments; all_comments }) = program in + let statements' = this#toplevel_statement_list statements in + let comments' = this#syntax_opt comments in + let all_comments' = map_list this#comment all_comments in + if statements == statements' && comments == comments' && all_comments == all_comments' then + program + else + (loc, { statements = statements'; comments = comments'; all_comments = all_comments' }) + + method statement (stmt : ('loc, 'loc) Ast.Statement.t) = + let open Ast.Statement in + match stmt with + | (loc, Block block) -> id_loc this#block loc block stmt (fun block -> (loc, Block block)) + | (loc, Break break) -> id_loc this#break loc break stmt (fun break -> (loc, Break break)) + | (loc, ClassDeclaration cls) -> + id_loc this#class_declaration loc cls stmt (fun cls -> (loc, ClassDeclaration cls)) + | (loc, Continue cont) -> id_loc this#continue loc cont stmt (fun cont -> (loc, Continue cont)) + | (loc, Debugger dbg) -> id_loc this#debugger loc dbg stmt (fun dbg -> (loc, Debugger dbg)) + | (loc, DeclareClass stuff) -> + id_loc this#declare_class loc stuff stmt (fun stuff -> (loc, DeclareClass stuff)) + | (loc, DeclareExportDeclaration decl) -> + id_loc this#declare_export_declaration loc decl stmt (fun decl -> + (loc, DeclareExportDeclaration decl) + ) + | (loc, DeclareFunction stuff) -> + id_loc this#declare_function loc stuff stmt (fun stuff -> (loc, DeclareFunction stuff)) + | (loc, DeclareInterface stuff) -> + id_loc this#declare_interface loc stuff stmt (fun stuff -> (loc, DeclareInterface stuff)) + | (loc, DeclareModule m) -> + id_loc this#declare_module loc m stmt (fun m -> (loc, DeclareModule m)) + | (loc, DeclareTypeAlias stuff) -> + id_loc this#declare_type_alias loc stuff stmt (fun stuff -> (loc, DeclareTypeAlias stuff)) + | (loc, DeclareVariable stuff) -> + id_loc this#declare_variable loc stuff stmt (fun stuff -> (loc, DeclareVariable stuff)) + | (loc, DeclareModuleExports annot) -> + id_loc this#declare_module_exports loc annot stmt (fun annot -> + (loc, DeclareModuleExports annot) + ) + | (loc, DoWhile stuff) -> + id_loc this#do_while loc stuff stmt (fun stuff -> (loc, DoWhile stuff)) + | (loc, Empty empty) -> id_loc this#empty loc empty stmt (fun empty -> (loc, Empty empty)) + | (loc, EnumDeclaration enum) -> + id_loc this#enum_declaration loc enum stmt (fun enum -> (loc, EnumDeclaration enum)) + | (loc, ExportDefaultDeclaration decl) -> + id_loc this#export_default_declaration loc decl stmt (fun decl -> + (loc, ExportDefaultDeclaration decl) + ) + | (loc, ExportNamedDeclaration decl) -> + id_loc this#export_named_declaration loc decl stmt (fun decl -> + (loc, ExportNamedDeclaration decl) + ) + | (loc, Expression expr) -> + id_loc this#expression_statement loc expr stmt (fun expr -> (loc, Expression expr)) + | (loc, For for_stmt) -> + id_loc this#for_statement loc for_stmt stmt (fun for_stmt -> (loc, For for_stmt)) + | (loc, ForIn stuff) -> + id_loc this#for_in_statement loc stuff stmt (fun stuff -> (loc, ForIn stuff)) + | (loc, ForOf stuff) -> + id_loc this#for_of_statement loc stuff stmt (fun stuff -> (loc, ForOf stuff)) + | (loc, FunctionDeclaration func) -> + id_loc this#function_declaration loc func stmt (fun func -> (loc, FunctionDeclaration func)) + | (loc, If if_stmt) -> + id_loc this#if_statement loc if_stmt stmt (fun if_stmt -> (loc, If if_stmt)) + | (loc, ImportDeclaration decl) -> + id_loc this#import_declaration loc decl stmt (fun decl -> (loc, ImportDeclaration decl)) + | (loc, InterfaceDeclaration stuff) -> + id_loc this#interface_declaration loc stuff stmt (fun stuff -> + (loc, InterfaceDeclaration stuff) + ) + | (loc, Labeled label) -> + id_loc this#labeled_statement loc label stmt (fun label -> (loc, Labeled label)) + | (loc, OpaqueType otype) -> + id_loc this#opaque_type loc otype stmt (fun otype -> (loc, OpaqueType otype)) + | (loc, Return ret) -> id_loc this#return loc ret stmt (fun ret -> (loc, Return ret)) + | (loc, Switch switch) -> + id_loc this#switch loc switch stmt (fun switch -> (loc, Switch switch)) + | (loc, Throw throw) -> id_loc this#throw loc throw stmt (fun throw -> (loc, Throw throw)) + | (loc, Try try_stmt) -> + id_loc this#try_catch loc try_stmt stmt (fun try_stmt -> (loc, Try try_stmt)) + | (loc, VariableDeclaration decl) -> + id_loc this#variable_declaration loc decl stmt (fun decl -> (loc, VariableDeclaration decl)) + | (loc, While stuff) -> id_loc this#while_ loc stuff stmt (fun stuff -> (loc, While stuff)) + | (loc, With stuff) -> id_loc this#with_ loc stuff stmt (fun stuff -> (loc, With stuff)) + | (loc, TypeAlias stuff) -> + id_loc this#type_alias loc stuff stmt (fun stuff -> (loc, TypeAlias stuff)) + | (loc, DeclareOpaqueType otype) -> + id_loc this#opaque_type loc otype stmt (fun otype -> (loc, OpaqueType otype)) + + method comment (c : 'loc Ast.Comment.t) = c + + method syntax_opt + : 'internal. ('loc, 'internal) Ast.Syntax.t option -> ('loc, 'internal) Ast.Syntax.t option + = + map_opt this#syntax + + method syntax : 'internal. ('loc, 'internal) Ast.Syntax.t -> ('loc, 'internal) Ast.Syntax.t = + fun attached -> + let open Ast.Syntax in + let { leading; trailing; internal } = attached in + let leading' = map_list this#comment leading in + let trailing' = map_list this#comment trailing in + if leading == leading' && trailing == trailing' then + attached + else + { leading = leading'; trailing = trailing'; internal } + + method expression (expr : ('loc, 'loc) Ast.Expression.t) = + let open Ast.Expression in + match expr with + | (loc, Array x) -> id_loc this#array loc x expr (fun x -> (loc, Array x)) + | (loc, ArrowFunction x) -> + id_loc this#arrow_function loc x expr (fun x -> (loc, ArrowFunction x)) + | (loc, Assignment x) -> id_loc this#assignment loc x expr (fun x -> (loc, Assignment x)) + | (loc, Binary x) -> id_loc this#binary loc x expr (fun x -> (loc, Binary x)) + | (loc, Call x) -> id_loc this#call loc x expr (fun x -> (loc, Call x)) + | (loc, Class x) -> id_loc this#class_expression loc x expr (fun x -> (loc, Class x)) + | (loc, Comprehension x) -> + id_loc this#comprehension loc x expr (fun x -> (loc, Comprehension x)) + | (loc, Conditional x) -> id_loc this#conditional loc x expr (fun x -> (loc, Conditional x)) + | (loc, Function x) -> id_loc this#function_expression loc x expr (fun x -> (loc, Function x)) + | (loc, Generator x) -> id_loc this#generator loc x expr (fun x -> (loc, Generator x)) + | (loc, Identifier x) -> id this#identifier x expr (fun x -> (loc, Identifier x)) + | (loc, Import x) -> id (this#import loc) x expr (fun x -> (loc, Import x)) + | (loc, JSXElement x) -> id_loc this#jsx_element loc x expr (fun x -> (loc, JSXElement x)) + | (loc, JSXFragment x) -> id_loc this#jsx_fragment loc x expr (fun x -> (loc, JSXFragment x)) + | (loc, Literal x) -> id_loc this#literal loc x expr (fun x -> (loc, Literal x)) + | (loc, Logical x) -> id_loc this#logical loc x expr (fun x -> (loc, Logical x)) + | (loc, Member x) -> id_loc this#member loc x expr (fun x -> (loc, Member x)) + | (loc, MetaProperty x) -> + id_loc this#meta_property loc x expr (fun x -> (loc, MetaProperty x)) + | (loc, New x) -> id_loc this#new_ loc x expr (fun x -> (loc, New x)) + | (loc, Object x) -> id_loc this#object_ loc x expr (fun x -> (loc, Object x)) + | (loc, OptionalCall x) -> id (this#optional_call loc) x expr (fun x -> (loc, OptionalCall x)) + | (loc, OptionalMember x) -> + id_loc this#optional_member loc x expr (fun x -> (loc, OptionalMember x)) + | (loc, Sequence x) -> id_loc this#sequence loc x expr (fun x -> (loc, Sequence x)) + | (loc, Super x) -> id_loc this#super_expression loc x expr (fun x -> (loc, Super x)) + | (loc, TaggedTemplate x) -> + id_loc this#tagged_template loc x expr (fun x -> (loc, TaggedTemplate x)) + | (loc, TemplateLiteral x) -> + id_loc this#template_literal loc x expr (fun x -> (loc, TemplateLiteral x)) + | (loc, This x) -> id_loc this#this_expression loc x expr (fun x -> (loc, This x)) + | (loc, TypeCast x) -> id_loc this#type_cast loc x expr (fun x -> (loc, TypeCast x)) + | (loc, Unary x) -> id_loc this#unary_expression loc x expr (fun x -> (loc, Unary x)) + | (loc, Update x) -> id_loc this#update_expression loc x expr (fun x -> (loc, Update x)) + | (loc, Yield x) -> id_loc this#yield loc x expr (fun x -> (loc, Yield x)) + + method array _loc (expr : ('loc, 'loc) Ast.Expression.Array.t) = + let open Ast.Expression in + let { Array.elements; comments } = expr in + let elements' = map_list this#array_element elements in + let comments' = this#syntax_opt comments in + if elements == elements' && comments == comments' then + expr + else + { Array.elements = elements'; comments = comments' } + + method array_element element = + let open Ast.Expression.Array in + match element with + | Expression expr -> id this#expression expr element (fun expr -> Expression expr) + | Spread spread -> id this#spread_element spread element (fun spread -> Spread spread) + | Hole _ -> element + + method arrow_function loc (expr : ('loc, 'loc) Ast.Function.t) = this#function_ loc expr + + method assignment _loc (expr : ('loc, 'loc) Ast.Expression.Assignment.t) = + let open Ast.Expression.Assignment in + let { operator = _; left; right; comments } = expr in + let left' = this#assignment_pattern left in + let right' = this#expression right in + let comments' = this#syntax_opt comments in + if left == left' && right == right' && comments == comments' then + expr + else + { expr with left = left'; right = right'; comments = comments' } + + method binary _loc (expr : ('loc, 'loc) Ast.Expression.Binary.t) = + let open Ast.Expression.Binary in + let { operator = _; left; right; comments } = expr in + let left' = this#expression left in + let right' = this#expression right in + let comments' = this#syntax_opt comments in + if left == left' && right == right' && comments == comments' then + expr + else + { expr with left = left'; right = right'; comments = comments' } + + method block _loc (stmt : ('loc, 'loc) Ast.Statement.Block.t) = + let open Ast.Statement.Block in + let { body; comments } = stmt in + let body' = this#statement_list body in + let comments' = this#syntax_opt comments in + if body == body' && comments == comments' then + stmt + else + { body = body'; comments = comments' } + + method break _loc (break : 'loc Ast.Statement.Break.t) = + let open Ast.Statement.Break in + let { label; comments } = break in + let label' = map_opt this#label_identifier label in + let comments' = this#syntax_opt comments in + if label == label' && comments == comments' then + break + else + { label = label'; comments = comments' } + + method call _loc (expr : ('loc, 'loc) Ast.Expression.Call.t) = + let open Ast.Expression.Call in + let { callee; targs; arguments; comments } = expr in + let callee' = this#expression callee in + let targs' = map_opt this#call_type_args targs in + let arguments' = this#call_arguments arguments in + let comments' = this#syntax_opt comments in + if callee == callee' && targs == targs' && arguments == arguments' && comments == comments' + then + expr + else + { callee = callee'; targs = targs'; arguments = arguments'; comments = comments' } + + method call_arguments (arg_list : ('loc, 'loc) Ast.Expression.ArgList.t) = + let open Ast.Expression.ArgList in + let (loc, { arguments; comments }) = arg_list in + let arguments' = map_list this#expression_or_spread arguments in + let comments' = this#syntax_opt comments in + if arguments == arguments' && comments == comments' then + arg_list + else + (loc, { arguments = arguments'; comments = comments' }) + + method optional_call loc (expr : ('loc, 'loc) Ast.Expression.OptionalCall.t) = + let open Ast.Expression.OptionalCall in + let { call; optional = _; filtered_out = _ } = expr in + let call' = this#call loc call in + if call == call' then + expr + else + { expr with call = call' } + + method call_type_args (targs : ('loc, 'loc) Ast.Expression.CallTypeArgs.t) = + let open Ast.Expression.CallTypeArgs in + let (loc, { arguments; comments }) = targs in + let arguments' = map_list this#call_type_arg arguments in + let comments' = this#syntax_opt comments in + if arguments == arguments' && comments == comments' then + targs + else + (loc, { arguments = arguments'; comments = comments' }) + + method call_type_arg t = + let open Ast.Expression.CallTypeArg in + match t with + | Explicit x -> + let x' = this#type_ x in + if x' == x then + t + else + Explicit x' + | Implicit (loc, { Implicit.comments }) -> + let comments' = this#syntax_opt comments in + if comments == comments' then + t + else + Implicit (loc, { Implicit.comments = comments' }) + + method catch_body (body : 'loc * ('loc, 'loc) Ast.Statement.Block.t) = map_loc this#block body + + method catch_clause _loc (clause : ('loc, 'loc) Ast.Statement.Try.CatchClause.t') = + let open Ast.Statement.Try.CatchClause in + let { param; body; comments } = clause in + let param' = map_opt this#catch_clause_pattern param in + let body' = this#catch_body body in + let comments' = this#syntax_opt comments in + if param == param' && body == body' && comments == comments' then + clause + else + { param = param'; body = body'; comments = comments' } + + method class_declaration loc (cls : ('loc, 'loc) Ast.Class.t) = this#class_ loc cls + + method class_expression loc (cls : ('loc, 'loc) Ast.Class.t) = this#class_ loc cls + + method class_ _loc (cls : ('loc, 'loc) Ast.Class.t) = + let open Ast.Class in + let { id; body; tparams; extends; implements; class_decorators; comments } = cls in + let id' = map_opt this#class_identifier id in + let tparams' = map_opt this#type_params tparams in + let body' = this#class_body body in + let extends' = map_opt (map_loc this#class_extends) extends in + let implements' = map_opt this#class_implements implements in + let class_decorators' = map_list this#class_decorator class_decorators in + let comments' = this#syntax_opt comments in + if + id == id' + && body == body' + && extends == extends' + && implements == implements' + && class_decorators == class_decorators' + && comments == comments' + && tparams == tparams' + then + cls + else + { + id = id'; + body = body'; + extends = extends'; + implements = implements'; + class_decorators = class_decorators'; + comments = comments'; + tparams = tparams'; + } + + method class_extends _loc (extends : ('loc, 'loc) Ast.Class.Extends.t') = + let open Ast.Class.Extends in + let { expr; targs; comments } = extends in + let expr' = this#expression expr in + let targs' = map_opt this#type_args targs in + let comments' = this#syntax_opt comments in + if expr == expr' && targs == targs' && comments == comments' then + extends + else + { expr = expr'; targs = targs'; comments = comments' } + + method class_identifier (ident : ('loc, 'loc) Ast.Identifier.t) = + this#pattern_identifier ~kind:Ast.Statement.VariableDeclaration.Let ident + + method class_body (cls_body : ('loc, 'loc) Ast.Class.Body.t) = + let open Ast.Class.Body in + let (loc, { body; comments }) = cls_body in + let body' = map_list this#class_element body in + let comments' = this#syntax_opt comments in + if body == body' && comments == comments' then + cls_body + else + (loc, { body = body'; comments = comments' }) + + method class_decorator (dec : ('loc, 'loc) Ast.Class.Decorator.t) = + let open Ast.Class.Decorator in + let (loc, { expression; comments }) = dec in + let expression' = this#expression expression in + let comments' = this#syntax_opt comments in + if expression == expression' && comments == comments' then + dec + else + (loc, { expression = expression'; comments = comments' }) + + method class_element (elem : ('loc, 'loc) Ast.Class.Body.element) = + let open Ast.Class.Body in + match elem with + | Method (loc, meth) -> id_loc this#class_method loc meth elem (fun meth -> Method (loc, meth)) + | Property (loc, prop) -> + id_loc this#class_property loc prop elem (fun prop -> Property (loc, prop)) + | PrivateField (loc, field) -> + id_loc this#class_private_field loc field elem (fun field -> PrivateField (loc, field)) + + method class_implements (implements : ('loc, 'loc) Ast.Class.Implements.t) = + let open Ast.Class.Implements in + let (loc, { interfaces; comments }) = implements in + let interfaces' = map_list this#class_implements_interface interfaces in + let comments' = this#syntax_opt comments in + if interfaces == interfaces' && comments == comments' then + implements + else + (loc, { interfaces = interfaces'; comments = comments' }) + + method class_implements_interface (interface : ('loc, 'loc) Ast.Class.Implements.Interface.t) = + let open Ast.Class.Implements.Interface in + let (loc, { id; targs }) = interface in + let id' = this#type_identifier_reference id in + let targs' = map_opt this#type_args targs in + if id == id' && targs == targs' then + interface + else + (loc, { id = id'; targs = targs' }) + + method class_method _loc (meth : ('loc, 'loc) Ast.Class.Method.t') = + let open Ast.Class.Method in + let { kind = _; key; value; static = _; decorators; comments } = meth in + let key' = this#object_key key in + let value' = map_loc this#function_expression_or_method value in + let decorators' = map_list this#class_decorator decorators in + let comments' = this#syntax_opt comments in + if key == key' && value == value' && decorators == decorators' && comments == comments' then + meth + else + { meth with key = key'; value = value'; decorators = decorators'; comments = comments' } + + method class_property _loc (prop : ('loc, 'loc) Ast.Class.Property.t') = + let open Ast.Class.Property in + let { key; value; annot; static = _; variance; comments } = prop in + let key' = this#object_key key in + let value' = this#class_property_value value in + let annot' = this#type_annotation_hint annot in + let variance' = this#variance_opt variance in + let comments' = this#syntax_opt comments in + if + key == key' + && value == value' + && annot' == annot + && variance' == variance + && comments' == comments + then + prop + else + { + prop with + key = key'; + value = value'; + annot = annot'; + variance = variance'; + comments = comments'; + } + + method class_property_value (value : ('loc, 'loc) Ast.Class.Property.value) = + let open Ast.Class.Property in + match value with + | Declared -> value + | Uninitialized -> value + | Initialized x -> + let x' = this#expression x in + if x == x' then + value + else + Initialized x' + + method class_private_field _loc (prop : ('loc, 'loc) Ast.Class.PrivateField.t') = + let open Ast.Class.PrivateField in + let { key; value; annot; static = _; variance; comments } = prop in + let key' = this#private_name key in + let value' = this#class_property_value value in + let annot' = this#type_annotation_hint annot in + let variance' = this#variance_opt variance in + let comments' = this#syntax_opt comments in + if + key == key' + && value == value' + && annot' == annot + && variance' == variance + && comments' == comments + then + prop + else + { + prop with + key = key'; + value = value'; + annot = annot'; + variance = variance'; + comments = comments'; + } + + (* TODO *) + method comprehension _loc (expr : ('loc, 'loc) Ast.Expression.Comprehension.t) = expr + + method conditional _loc (expr : ('loc, 'loc) Ast.Expression.Conditional.t) = + let open Ast.Expression.Conditional in + let { test; consequent; alternate; comments } = expr in + let test' = this#predicate_expression test in + let consequent' = this#expression consequent in + let alternate' = this#expression alternate in + let comments' = this#syntax_opt comments in + if + test == test' + && consequent == consequent' + && alternate == alternate' + && comments == comments' + then + expr + else + { test = test'; consequent = consequent'; alternate = alternate'; comments = comments' } + + method continue _loc (cont : 'loc Ast.Statement.Continue.t) = + let open Ast.Statement.Continue in + let { label; comments } = cont in + let label' = map_opt this#label_identifier label in + let comments' = this#syntax_opt comments in + if label == label' && comments == comments' then + cont + else + { label = label'; comments = comments' } + + method debugger _loc (dbg : 'loc Ast.Statement.Debugger.t) = + let open Ast.Statement.Debugger in + let { comments } = dbg in + let comments' = this#syntax_opt comments in + if comments == comments' then + dbg + else + { comments = comments' } + + method declare_class _loc (decl : ('loc, 'loc) Ast.Statement.DeclareClass.t) = + let open Ast.Statement.DeclareClass in + let { id = ident; tparams; body; extends; mixins; implements; comments } = decl in + let id' = this#class_identifier ident in + let tparams' = map_opt this#type_params tparams in + let body' = map_loc this#object_type body in + let extends' = map_opt (map_loc this#generic_type) extends in + let mixins' = map_list (map_loc this#generic_type) mixins in + let implements' = map_opt this#class_implements implements in + let comments' = this#syntax_opt comments in + if + id' == ident + && tparams' == tparams + && body' == body + && extends' == extends + && mixins' == mixins + && implements' == implements + && comments' == comments + then + decl + else + { + id = id'; + tparams = tparams'; + body = body'; + extends = extends'; + mixins = mixins'; + implements = implements'; + comments = comments'; + } + + method declare_export_declaration + _loc (decl : ('loc, 'loc) Ast.Statement.DeclareExportDeclaration.t) = + let open Ast.Statement.DeclareExportDeclaration in + let { default; source; specifiers; declaration; comments } = decl in + let source' = map_loc_opt this#export_source source in + let specifiers' = map_opt this#export_named_specifier specifiers in + let declaration' = map_opt this#declare_export_declaration_decl declaration in + let comments' = this#syntax_opt comments in + if + source == source' + && specifiers == specifiers' + && declaration == declaration' + && comments == comments' + then + decl + else + { + default; + source = source'; + specifiers = specifiers'; + declaration = declaration'; + comments = comments'; + } + + method declare_export_declaration_decl + (decl : ('loc, 'loc) Ast.Statement.DeclareExportDeclaration.declaration) = + let open Ast.Statement.DeclareExportDeclaration in + match decl with + | Variable (loc, dv) -> + let dv' = this#declare_variable loc dv in + if dv' == dv then + decl + else + Variable (loc, dv') + | Function (loc, df) -> + let df' = this#declare_function loc df in + if df' == df then + decl + else + Function (loc, df') + | Class (loc, dc) -> + let dc' = this#declare_class loc dc in + if dc' == dc then + decl + else + Class (loc, dc') + | DefaultType t -> + let t' = this#type_ t in + if t' == t then + decl + else + DefaultType t' + | NamedType (loc, ta) -> + let ta' = this#type_alias loc ta in + if ta' == ta then + decl + else + NamedType (loc, ta') + | NamedOpaqueType (loc, ot) -> + let ot' = this#opaque_type loc ot in + if ot' == ot then + decl + else + NamedOpaqueType (loc, ot') + | Interface (loc, i) -> + let i' = this#interface loc i in + if i' == i then + decl + else + Interface (loc, i') + + method declare_function _loc (decl : ('loc, 'loc) Ast.Statement.DeclareFunction.t) = + let open Ast.Statement.DeclareFunction in + let { id = ident; annot; predicate; comments } = decl in + let id' = this#function_identifier ident in + let annot' = this#type_annotation annot in + let predicate' = map_opt this#predicate predicate in + let comments' = this#syntax_opt comments in + if id' == ident && annot' == annot && predicate' == predicate && comments' == comments then + decl + else + { id = id'; annot = annot'; predicate = predicate'; comments = comments' } + + method declare_interface loc (decl : ('loc, 'loc) Ast.Statement.Interface.t) = + this#interface loc decl + + method declare_module _loc (m : ('loc, 'loc) Ast.Statement.DeclareModule.t) = + let open Ast.Statement.DeclareModule in + let { id; body; kind; comments } = m in + let body' = map_loc this#block body in + let comments' = this#syntax_opt comments in + if body' == body && comments == comments' then + m + else + { id; body = body'; kind; comments = comments' } + + method declare_module_exports _loc (exports : ('loc, 'loc) Ast.Statement.DeclareModuleExports.t) + = + let open Ast.Statement.DeclareModuleExports in + let { annot; comments } = exports in + let annot' = this#type_annotation annot in + let comments' = this#syntax_opt comments in + if annot == annot' && comments == comments' then + exports + else + { annot = annot'; comments = comments' } + + method declare_type_alias loc (decl : ('loc, 'loc) Ast.Statement.TypeAlias.t) = + this#type_alias loc decl + + method declare_variable _loc (decl : ('loc, 'loc) Ast.Statement.DeclareVariable.t) = + let open Ast.Statement.DeclareVariable in + let { id = ident; annot; comments } = decl in + let id' = this#pattern_identifier ~kind:Ast.Statement.VariableDeclaration.Var ident in + let annot' = this#type_annotation annot in + let comments' = this#syntax_opt comments in + if id' == ident && annot' == annot && comments' == comments then + decl + else + { id = id'; annot = annot'; comments = comments' } + + method do_while _loc (stuff : ('loc, 'loc) Ast.Statement.DoWhile.t) = + let open Ast.Statement.DoWhile in + let { body; test; comments } = stuff in + let body' = this#statement body in + let test' = this#predicate_expression test in + let comments' = this#syntax_opt comments in + if body == body' && test == test' && comments == comments' then + stuff + else + { body = body'; test = test'; comments = comments' } + + method empty _loc empty = + let open Ast.Statement.Empty in + let { comments } = empty in + let comments' = this#syntax_opt comments in + if comments == comments' then + empty + else + { comments = comments' } + + method enum_declaration _loc (enum : ('loc, 'loc) Ast.Statement.EnumDeclaration.t) = + let open Ast.Statement.EnumDeclaration in + let { id = ident; body; comments } = enum in + let id' = this#pattern_identifier ~kind:Ast.Statement.VariableDeclaration.Const ident in + let body' = this#enum_body body in + let comments' = this#syntax_opt comments in + if ident == id' && body == body' && comments == comments' then + enum + else + { id = id'; body = body'; comments = comments' } + + method enum_body (body : 'loc Ast.Statement.EnumDeclaration.body) = + let open Ast.Statement.EnumDeclaration in + match body with + | (loc, BooleanBody boolean_body) -> + id this#enum_boolean_body boolean_body body (fun body -> (loc, BooleanBody body)) + | (loc, NumberBody number_body) -> + id this#enum_number_body number_body body (fun body -> (loc, NumberBody body)) + | (loc, StringBody string_body) -> + id this#enum_string_body string_body body (fun body -> (loc, StringBody body)) + | (loc, SymbolBody symbol_body) -> + id this#enum_symbol_body symbol_body body (fun body -> (loc, SymbolBody body)) + + method enum_boolean_body (body : 'loc Ast.Statement.EnumDeclaration.BooleanBody.t) = + let open Ast.Statement.EnumDeclaration.BooleanBody in + let { members; explicit_type = _; has_unknown_members = _; comments } = body in + let members' = map_list this#enum_boolean_member members in + let comments' = this#syntax_opt comments in + if members == members' && comments == comments' then + body + else + { body with members = members'; comments = comments' } + + method enum_number_body (body : 'loc Ast.Statement.EnumDeclaration.NumberBody.t) = + let open Ast.Statement.EnumDeclaration.NumberBody in + let { members; explicit_type = _; has_unknown_members = _; comments } = body in + let members' = map_list this#enum_number_member members in + let comments' = this#syntax_opt comments in + if members == members' && comments == comments' then + body + else + { body with members = members'; comments = comments' } + + method enum_string_body (body : 'loc Ast.Statement.EnumDeclaration.StringBody.t) = + let open Ast.Statement.EnumDeclaration.StringBody in + let { members; explicit_type = _; has_unknown_members = _; comments } = body in + let members' = + match members with + | Defaulted m -> id (map_list this#enum_defaulted_member) m members (fun m -> Defaulted m) + | Initialized m -> id (map_list this#enum_string_member) m members (fun m -> Initialized m) + in + let comments' = this#syntax_opt comments in + if members == members' && comments == comments' then + body + else + { body with members = members'; comments = comments' } + + method enum_symbol_body (body : 'loc Ast.Statement.EnumDeclaration.SymbolBody.t) = + let open Ast.Statement.EnumDeclaration.SymbolBody in + let { members; has_unknown_members = _; comments } = body in + let members' = map_list this#enum_defaulted_member members in + let comments' = this#syntax_opt comments in + if members == members' && comments == comments' then + body + else + { body with members = members'; comments = comments' } + + method enum_defaulted_member (member : 'loc Ast.Statement.EnumDeclaration.DefaultedMember.t) = + let open Ast.Statement.EnumDeclaration.DefaultedMember in + let (loc, { id = ident }) = member in + let id' = this#enum_member_identifier ident in + if ident == id' then + member + else + (loc, { id = id' }) + + method enum_boolean_member + (member : + ('loc Ast.BooleanLiteral.t, 'loc) Ast.Statement.EnumDeclaration.InitializedMember.t + ) = + let open Ast.Statement.EnumDeclaration.InitializedMember in + let (loc, { id = ident; init }) = member in + let id' = this#enum_member_identifier ident in + if ident == id' then + member + else + (loc, { id = id'; init }) + + method enum_number_member + (member : ('loc Ast.NumberLiteral.t, 'loc) Ast.Statement.EnumDeclaration.InitializedMember.t) + = + let open Ast.Statement.EnumDeclaration.InitializedMember in + let (loc, { id = ident; init }) = member in + let id' = this#enum_member_identifier ident in + if ident == id' then + member + else + (loc, { id = id'; init }) + + method enum_string_member + (member : ('loc Ast.StringLiteral.t, 'loc) Ast.Statement.EnumDeclaration.InitializedMember.t) + = + let open Ast.Statement.EnumDeclaration.InitializedMember in + let (loc, { id = ident; init }) = member in + let id' = this#enum_member_identifier ident in + if ident == id' then + member + else + (loc, { id = id'; init }) + + method enum_member_identifier (id : ('loc, 'loc) Ast.Identifier.t) = this#identifier id + + method export_default_declaration + _loc (decl : ('loc, 'loc) Ast.Statement.ExportDefaultDeclaration.t) = + let open Ast.Statement.ExportDefaultDeclaration in + let { default; declaration; comments } = decl in + let declaration' = this#export_default_declaration_decl declaration in + let comments' = this#syntax_opt comments in + if declaration' == declaration && comments' == comments then + decl + else + { default; declaration = declaration'; comments = comments' } + + method export_default_declaration_decl + (decl : ('loc, 'loc) Ast.Statement.ExportDefaultDeclaration.declaration) = + let open Ast.Statement.ExportDefaultDeclaration in + match decl with + | Declaration stmt -> id this#statement stmt decl (fun stmt -> Declaration stmt) + | Expression expr -> id this#expression expr decl (fun expr -> Expression expr) + + method export_named_declaration _loc (decl : ('loc, 'loc) Ast.Statement.ExportNamedDeclaration.t) + = + let open Ast.Statement.ExportNamedDeclaration in + let { export_kind; source; specifiers; declaration; comments } = decl in + let source' = map_loc_opt this#export_source source in + let specifiers' = map_opt this#export_named_specifier specifiers in + let declaration' = map_opt this#statement declaration in + let comments' = this#syntax_opt comments in + if + source == source' + && specifiers == specifiers' + && declaration == declaration' + && comments == comments' + then + decl + else + { + export_kind; + source = source'; + specifiers = specifiers'; + declaration = declaration'; + comments = comments'; + } + + method export_named_declaration_specifier + (spec : 'loc Ast.Statement.ExportNamedDeclaration.ExportSpecifier.t) = + let open Ast.Statement.ExportNamedDeclaration.ExportSpecifier in + let (loc, { local; exported }) = spec in + let local' = this#identifier local in + let exported' = map_opt this#identifier exported in + if local == local' && exported == exported' then + spec + else + (loc, { local = local'; exported = exported' }) + + method export_batch_specifier + (spec : 'loc Ast.Statement.ExportNamedDeclaration.ExportBatchSpecifier.t) = + let (loc, id_opt) = spec in + let id_opt' = map_opt this#identifier id_opt in + if id_opt == id_opt' then + spec + else + (loc, id_opt') + + method export_named_specifier (spec : 'loc Ast.Statement.ExportNamedDeclaration.specifier) = + let open Ast.Statement.ExportNamedDeclaration in + match spec with + | ExportSpecifiers spec_list -> + let spec_list' = map_list this#export_named_declaration_specifier spec_list in + if spec_list == spec_list' then + spec + else + ExportSpecifiers spec_list' + | ExportBatchSpecifier batch -> + let batch' = this#export_batch_specifier batch in + if batch == batch' then + spec + else + ExportBatchSpecifier batch' + + method export_source _loc (source : 'loc Ast.StringLiteral.t) = + let open Ast.StringLiteral in + let { value; raw; comments } = source in + let comments' = this#syntax_opt comments in + if comments == comments' then + source + else + { value; raw; comments = comments' } + + method expression_statement _loc (stmt : ('loc, 'loc) Ast.Statement.Expression.t) = + let open Ast.Statement.Expression in + let { expression = expr; directive; comments } = stmt in + let expr' = this#expression expr in + let comments' = this#syntax_opt comments in + if expr == expr' && comments == comments' then + stmt + else + { expression = expr'; directive; comments = comments' } + + method expression_or_spread expr_or_spread = + let open Ast.Expression in + match expr_or_spread with + | Expression expr -> id this#expression expr expr_or_spread (fun expr -> Expression expr) + | Spread spread -> id this#spread_element spread expr_or_spread (fun spread -> Spread spread) + + method for_in_statement _loc (stmt : ('loc, 'loc) Ast.Statement.ForIn.t) = + let open Ast.Statement.ForIn in + let { left; right; body; each; comments } = stmt in + let left' = this#for_in_statement_lhs left in + let right' = this#expression right in + let body' = this#statement body in + let comments' = this#syntax_opt comments in + if left == left' && right == right' && body == body' && comments == comments' then + stmt + else + { left = left'; right = right'; body = body'; each; comments = comments' } + + method for_in_statement_lhs (left : ('loc, 'loc) Ast.Statement.ForIn.left) = + let open Ast.Statement.ForIn in + match left with + | LeftDeclaration decl -> + id this#for_in_left_declaration decl left (fun decl -> LeftDeclaration decl) + | LeftPattern patt -> + id this#for_in_assignment_pattern patt left (fun patt -> LeftPattern patt) + + method for_in_left_declaration left = + let (loc, decl) = left in + id_loc this#variable_declaration loc decl left (fun decl -> (loc, decl)) + + method for_of_statement _loc (stuff : ('loc, 'loc) Ast.Statement.ForOf.t) = + let open Ast.Statement.ForOf in + let { left; right; body; await; comments } = stuff in + let left' = this#for_of_statement_lhs left in + let right' = this#expression right in + let body' = this#statement body in + let comments' = this#syntax_opt comments in + if left == left' && right == right' && body == body' && comments == comments' then + stuff + else + { left = left'; right = right'; body = body'; await; comments = comments' } + + method for_of_statement_lhs (left : ('loc, 'loc) Ast.Statement.ForOf.left) = + let open Ast.Statement.ForOf in + match left with + | LeftDeclaration decl -> + id this#for_of_left_declaration decl left (fun decl -> LeftDeclaration decl) + | LeftPattern patt -> + id this#for_of_assignment_pattern patt left (fun patt -> LeftPattern patt) + + method for_of_left_declaration left = + let (loc, decl) = left in + id_loc this#variable_declaration loc decl left (fun decl -> (loc, decl)) + + method for_statement _loc (stmt : ('loc, 'loc) Ast.Statement.For.t) = + let open Ast.Statement.For in + let { init; test; update; body; comments } = stmt in + let init' = map_opt this#for_statement_init init in + let test' = map_opt this#predicate_expression test in + let update' = map_opt this#expression update in + let body' = this#statement body in + let comments' = this#syntax_opt comments in + if + init == init' + && test == test' + && update == update' + && body == body' + && comments == comments' + then + stmt + else + { init = init'; test = test'; update = update'; body = body'; comments = comments' } + + method for_statement_init (init : ('loc, 'loc) Ast.Statement.For.init) = + let open Ast.Statement.For in + match init with + | InitDeclaration decl -> + id this#for_init_declaration decl init (fun decl -> InitDeclaration decl) + | InitExpression expr -> id this#expression expr init (fun expr -> InitExpression expr) + + method for_init_declaration init = + let (loc, decl) = init in + id_loc this#variable_declaration loc decl init (fun decl -> (loc, decl)) + + method function_param_type (fpt : ('loc, 'loc) Ast.Type.Function.Param.t) = + let open Ast.Type.Function.Param in + let (loc, { annot; name; optional }) = fpt in + let annot' = this#type_ annot in + let name' = map_opt this#identifier name in + if annot' == annot && name' == name then + fpt + else + (loc, { annot = annot'; name = name'; optional }) + + method function_rest_param_type (frpt : ('loc, 'loc) Ast.Type.Function.RestParam.t) = + let open Ast.Type.Function.RestParam in + let (loc, { argument; comments }) = frpt in + let argument' = this#function_param_type argument in + let comments' = this#syntax_opt comments in + if argument' == argument && comments' == comments then + frpt + else + (loc, { argument = argument'; comments = comments' }) + + method function_this_param_type (this_param : ('loc, 'loc) Ast.Type.Function.ThisParam.t) = + let open Ast.Type.Function.ThisParam in + let (loc, { annot; comments }) = this_param in + let annot' = this#type_annotation annot in + let comments' = this#syntax_opt comments in + if annot' == annot && comments' == comments then + this_param + else + (loc, { annot = annot'; comments = comments' }) + + method function_type _loc (ft : ('loc, 'loc) Ast.Type.Function.t) = + let open Ast.Type.Function in + let { + params = (params_loc, { Params.this_; params = ps; rest = rpo; comments = params_comments }); + return; + tparams; + comments = func_comments; + } = + ft + in + let tparams' = map_opt this#type_params tparams in + let this_' = map_opt this#function_this_param_type this_ in + let ps' = map_list this#function_param_type ps in + let rpo' = map_opt this#function_rest_param_type rpo in + let return' = this#type_ return in + let func_comments' = this#syntax_opt func_comments in + let params_comments' = this#syntax_opt params_comments in + if + ps' == ps + && rpo' == rpo + && return' == return + && tparams' == tparams + && func_comments' == func_comments + && params_comments' == params_comments + && this_' == this_ + then + ft + else + { + params = + ( params_loc, + { Params.this_ = this_'; params = ps'; rest = rpo'; comments = params_comments' } + ); + return = return'; + tparams = tparams'; + comments = func_comments'; + } + + method label_identifier (ident : ('loc, 'loc) Ast.Identifier.t) = this#identifier ident + + method object_property_value_type (opvt : ('loc, 'loc) Ast.Type.Object.Property.value) = + let open Ast.Type.Object.Property in + match opvt with + | Init t -> id this#type_ t opvt (fun t -> Init t) + | Get t -> id this#object_type_property_getter t opvt (fun t -> Get t) + | Set t -> id this#object_type_property_setter t opvt (fun t -> Set t) + + method object_type_property_getter getter = + let (loc, ft) = getter in + id_loc this#function_type loc ft getter (fun ft -> (loc, ft)) + + method object_type_property_setter setter = + let (loc, ft) = setter in + id_loc this#function_type loc ft setter (fun ft -> (loc, ft)) + + method object_property_type (opt : ('loc, 'loc) Ast.Type.Object.Property.t) = + let open Ast.Type.Object.Property in + let (loc, { key; value; optional; static; proto; _method; variance; comments }) = opt in + let key' = this#object_key key in + let value' = this#object_property_value_type value in + let variance' = this#variance_opt variance in + let comments' = this#syntax_opt comments in + if key' == key && value' == value && variance' == variance && comments' == comments then + opt + else + ( loc, + { + key = key'; + value = value'; + optional; + static; + proto; + _method; + variance = variance'; + comments = comments'; + } + ) + + method object_spread_property_type (opt : ('loc, 'loc) Ast.Type.Object.SpreadProperty.t) = + let open Ast.Type.Object.SpreadProperty in + let (loc, { argument; comments }) = opt in + let argument' = this#type_ argument in + let comments' = this#syntax_opt comments in + if argument' == argument && comments == comments' then + opt + else + (loc, { argument = argument'; comments = comments' }) + + method object_indexer_property_type (opt : ('loc, 'loc) Ast.Type.Object.Indexer.t) = + let open Ast.Type.Object.Indexer in + let (loc, { id; key; value; static; variance; comments }) = opt in + let key' = this#type_ key in + let value' = this#type_ value in + let variance' = this#variance_opt variance in + let comments' = this#syntax_opt comments in + if key' == key && value' == value && variance' == variance && comments' == comments then + opt + else + (loc, { id; key = key'; value = value'; static; variance = variance'; comments = comments' }) + + method object_internal_slot_property_type (slot : ('loc, 'loc) Ast.Type.Object.InternalSlot.t) = + let open Ast.Type.Object.InternalSlot in + let (loc, { id; value; optional; static; _method; comments }) = slot in + let id' = this#identifier id in + let value' = this#type_ value in + let comments' = this#syntax_opt comments in + if id == id' && value == value' && comments == comments' then + slot + else + (loc, { id = id'; value = value'; optional; static; _method; comments = comments' }) + + method object_call_property_type (call : ('loc, 'loc) Ast.Type.Object.CallProperty.t) = + let open Ast.Type.Object.CallProperty in + let (loc, { value = (value_loc, value); static; comments }) = call in + let value' = this#function_type value_loc value in + let comments' = this#syntax_opt comments in + if value == value' && comments == comments' then + call + else + (loc, { value = (value_loc, value'); static; comments = comments' }) + + method object_type _loc (ot : ('loc, 'loc) Ast.Type.Object.t) = + let open Ast.Type.Object in + let { properties; exact; inexact; comments } = ot in + let properties' = + map_list + (fun p -> + match p with + | Property p' -> id this#object_property_type p' p (fun p' -> Property p') + | SpreadProperty p' -> + id this#object_spread_property_type p' p (fun p' -> SpreadProperty p') + | Indexer p' -> id this#object_indexer_property_type p' p (fun p' -> Indexer p') + | InternalSlot p' -> + id this#object_internal_slot_property_type p' p (fun p' -> InternalSlot p') + | CallProperty p' -> id this#object_call_property_type p' p (fun p' -> CallProperty p')) + properties + in + let comments' = this#syntax_opt comments in + if properties' == properties && comments == comments' then + ot + else + { properties = properties'; exact; inexact; comments = comments' } + + method interface_type _loc (i : ('loc, 'loc) Ast.Type.Interface.t) = + let open Ast.Type.Interface in + let { extends; body; comments } = i in + let extends' = map_list (map_loc this#generic_type) extends in + let body' = map_loc this#object_type body in + let comments' = this#syntax_opt comments in + if extends' == extends && body' == body && comments == comments' then + i + else + { extends = extends'; body = body'; comments = comments' } + + method generic_identifier_type (git : ('loc, 'loc) Ast.Type.Generic.Identifier.t) = + let open Ast.Type.Generic.Identifier in + match git with + | Unqualified i -> id this#type_identifier_reference i git (fun i -> Unqualified i) + | Qualified i -> id this#generic_qualified_identifier_type i git (fun i -> Qualified i) + + method generic_qualified_identifier_type qual = + let open Ast.Type.Generic.Identifier in + let (loc, { qualification; id }) = qual in + let qualification' = this#generic_identifier_type qualification in + let id' = this#member_type_identifier id in + if qualification' == qualification && id' == id then + qual + else + (loc, { qualification = qualification'; id = id' }) + + method member_type_identifier id = this#identifier id + + method variance (variance : 'loc Ast.Variance.t) = + let (loc, { Ast.Variance.kind; comments }) = variance in + let comments' = this#syntax_opt comments in + if comments == comments' then + variance + else + (loc, { Ast.Variance.kind; comments = comments' }) + + method variance_opt (opt : 'loc Ast.Variance.t option) = map_opt this#variance opt + + method type_args (targs : ('loc, 'loc) Ast.Type.TypeArgs.t) = + let open Ast.Type.TypeArgs in + let (loc, { arguments; comments }) = targs in + let arguments' = map_list this#type_ arguments in + let comments' = this#syntax_opt comments in + if arguments == arguments' && comments == comments' then + targs + else + (loc, { arguments = arguments'; comments = comments' }) + + method type_params (tparams : ('loc, 'loc) Ast.Type.TypeParams.t) = + let open Ast.Type.TypeParams in + let (loc, { params = tps; comments }) = tparams in + let tps' = map_list this#type_param tps in + let comments' = this#syntax_opt comments in + if tps' == tps && comments' == comments then + tparams + else + (loc, { params = tps'; comments = comments' }) + + method type_param (tparam : ('loc, 'loc) Ast.Type.TypeParam.t) = + let open Ast.Type.TypeParam in + let (loc, { name; bound; variance; default }) = tparam in + let bound' = this#type_annotation_hint bound in + let variance' = this#variance_opt variance in + let default' = map_opt this#type_ default in + let name' = this#binding_type_identifier name in + if name' == name && bound' == bound && variance' == variance && default' == default then + tparam + else + (loc, { name = name'; bound = bound'; variance = variance'; default = default' }) + + method generic_type _loc (gt : ('loc, 'loc) Ast.Type.Generic.t) = + let open Ast.Type.Generic in + let { id; targs; comments } = gt in + let id' = this#generic_identifier_type id in + let targs' = map_opt this#type_args targs in + let comments' = this#syntax_opt comments in + if id' == id && targs' == targs && comments' == comments then + gt + else + { id = id'; targs = targs'; comments = comments' } + + method indexed_access _loc (ia : ('loc, 'loc) Ast.Type.IndexedAccess.t) = + let open Ast.Type.IndexedAccess in + let { _object; index; comments } = ia in + let _object' = this#type_ _object in + let index' = this#type_ index in + let comments' = this#syntax_opt comments in + if _object' == _object && index' == index && comments' == comments then + ia + else + { _object = _object'; index = index'; comments = comments' } + + method optional_indexed_access loc (ia : ('loc, 'loc) Ast.Type.OptionalIndexedAccess.t) = + let open Ast.Type.OptionalIndexedAccess in + let { indexed_access; optional } = ia in + let indexed_access' = this#indexed_access loc indexed_access in + if indexed_access' == indexed_access then + ia + else + { indexed_access = indexed_access'; optional } + + method string_literal_type _loc (lit : 'loc Ast.StringLiteral.t) = + let open Ast.StringLiteral in + let { value; raw; comments } = lit in + let comments' = this#syntax_opt comments in + if comments == comments' then + lit + else + { value; raw; comments = comments' } + + method number_literal_type _loc (lit : 'loc Ast.NumberLiteral.t) = + let open Ast.NumberLiteral in + let { value; raw; comments } = lit in + let comments' = this#syntax_opt comments in + if comments == comments' then + lit + else + { value; raw; comments = comments' } + + method bigint_literal_type _loc (lit : 'loc Ast.BigIntLiteral.t) = + let open Ast.BigIntLiteral in + let { value; raw; comments } = lit in + let comments' = this#syntax_opt comments in + if comments == comments' then + lit + else + { value; raw; comments = comments' } + + method boolean_literal_type _loc (lit : 'loc Ast.BooleanLiteral.t) = + let open Ast.BooleanLiteral in + let { value; comments } = lit in + let comments' = this#syntax_opt comments in + if comments == comments' then + lit + else + { value; comments = comments' } + + method nullable_type (t : ('loc, 'loc) Ast.Type.Nullable.t) = + let open Ast.Type.Nullable in + let { argument; comments } = t in + let argument' = this#type_ argument in + let comments' = this#syntax_opt comments in + if argument == argument' && comments == comments' then + t + else + { argument = argument'; comments = comments' } + + method typeof_type (t : ('loc, 'loc) Ast.Type.Typeof.t) = + let open Ast.Type.Typeof in + let { argument; comments } = t in + let argument' = this#typeof_expression argument in + let comments' = this#syntax_opt comments in + if argument == argument' && comments == comments' then + t + else + { argument = argument'; comments = comments' } + + method typeof_expression (git : ('loc, 'loc) Ast.Type.Typeof.Target.t) = + let open Ast.Type.Typeof.Target in + match git with + | Unqualified i -> id this#typeof_identifier i git (fun i -> Unqualified i) + | Qualified i -> id this#typeof_qualified_identifier i git (fun i -> Qualified i) + + method typeof_identifier id = this#identifier id + + method typeof_member_identifier id = this#identifier id + + method typeof_qualified_identifier qual = + let open Ast.Type.Typeof.Target in + let (loc, { qualification; id }) = qual in + let qualification' = this#typeof_expression qualification in + let id' = this#typeof_member_identifier id in + if qualification' == qualification && id' == id then + qual + else + (loc, { qualification = qualification'; id = id' }) + + method tuple_type (t : ('loc, 'loc) Ast.Type.Tuple.t) = + let open Ast.Type.Tuple in + let { types; comments } = t in + let types' = map_list this#type_ types in + let comments' = this#syntax_opt comments in + if types == types' && comments == comments' then + t + else + { types = types'; comments = comments' } + + method array_type (t : ('loc, 'loc) Ast.Type.Array.t) = + let open Ast.Type.Array in + let { argument; comments } = t in + let argument' = this#type_ argument in + let comments' = this#syntax_opt comments in + if argument == argument' && comments == comments' then + t + else + { argument = argument'; comments = comments' } + + method union_type _loc (t : ('loc, 'loc) Ast.Type.Union.t) = + let open Ast.Type.Union in + let { types = (t0, t1, ts); comments } = t in + let t0' = this#type_ t0 in + let t1' = this#type_ t1 in + let ts' = map_list this#type_ ts in + let comments' = this#syntax_opt comments in + if t0' == t0 && t1' == t1 && ts' == ts && comments' == comments then + t + else + { types = (t0', t1', ts'); comments = comments' } + + method intersection_type _loc (t : ('loc, 'loc) Ast.Type.Intersection.t) = + let open Ast.Type.Intersection in + let { types = (t0, t1, ts); comments } = t in + let t0' = this#type_ t0 in + let t1' = this#type_ t1 in + let ts' = map_list this#type_ ts in + let comments' = this#syntax_opt comments in + if t0' == t0 && t1' == t1 && ts' == ts && comments' == comments then + t + else + { types = (t0', t1', ts'); comments = comments' } + + method type_ (t : ('loc, 'loc) Ast.Type.t) = + let open Ast.Type in + match t with + | (loc, Any comments) -> id this#syntax_opt comments t (fun comments -> (loc, Any comments)) + | (loc, Mixed comments) -> + id this#syntax_opt comments t (fun comments -> (loc, Mixed comments)) + | (loc, Empty comments) -> + id this#syntax_opt comments t (fun comments -> (loc, Empty comments)) + | (loc, Void comments) -> id this#syntax_opt comments t (fun comments -> (loc, Void comments)) + | (loc, Null comments) -> id this#syntax_opt comments t (fun comments -> (loc, Null comments)) + | (loc, Symbol comments) -> + id this#syntax_opt comments t (fun comments -> (loc, Symbol comments)) + | (loc, Number comments) -> + id this#syntax_opt comments t (fun comments -> (loc, Number comments)) + | (loc, BigInt comments) -> + id this#syntax_opt comments t (fun comments -> (loc, BigInt comments)) + | (loc, String comments) -> + id this#syntax_opt comments t (fun comments -> (loc, String comments)) + | (loc, Boolean comments) -> + id this#syntax_opt comments t (fun comments -> (loc, Boolean comments)) + | (loc, Exists comments) -> + id this#syntax_opt comments t (fun comments -> (loc, Exists comments)) + | (loc, Nullable t') -> id this#nullable_type t' t (fun t' -> (loc, Nullable t')) + | (loc, Array t') -> id this#array_type t' t (fun t' -> (loc, Array t')) + | (loc, Typeof t') -> id this#typeof_type t' t (fun t' -> (loc, Typeof t')) + | (loc, Function ft) -> id_loc this#function_type loc ft t (fun ft -> (loc, Function ft)) + | (loc, Object ot) -> id_loc this#object_type loc ot t (fun ot -> (loc, Object ot)) + | (loc, Interface i) -> id_loc this#interface_type loc i t (fun i -> (loc, Interface i)) + | (loc, Generic gt) -> id_loc this#generic_type loc gt t (fun gt -> (loc, Generic gt)) + | (loc, IndexedAccess ia) -> + id_loc this#indexed_access loc ia t (fun ia -> (loc, IndexedAccess ia)) + | (loc, OptionalIndexedAccess ia) -> + id_loc this#optional_indexed_access loc ia t (fun ia -> (loc, OptionalIndexedAccess ia)) + | (loc, StringLiteral lit) -> + id_loc this#string_literal_type loc lit t (fun lit -> (loc, StringLiteral lit)) + | (loc, NumberLiteral lit) -> + id_loc this#number_literal_type loc lit t (fun lit -> (loc, NumberLiteral lit)) + | (loc, BigIntLiteral lit) -> + id_loc this#bigint_literal_type loc lit t (fun lit -> (loc, BigIntLiteral lit)) + | (loc, BooleanLiteral lit) -> + id_loc this#boolean_literal_type loc lit t (fun lit -> (loc, BooleanLiteral lit)) + | (loc, Union t') -> id_loc this#union_type loc t' t (fun t' -> (loc, Union t')) + | (loc, Intersection t') -> + id_loc this#intersection_type loc t' t (fun t' -> (loc, Intersection t')) + | (loc, Tuple t') -> id this#tuple_type t' t (fun t' -> (loc, Tuple t')) + + method type_annotation (annot : ('loc, 'loc) Ast.Type.annotation) = + let (loc, a) = annot in + id this#type_ a annot (fun a -> (loc, a)) + + method type_annotation_hint (return : ('M, 'T) Ast.Type.annotation_or_hint) = + let open Ast.Type in + match return with + | Available annot -> + let annot' = this#type_annotation annot in + if annot' == annot then + return + else + Available annot' + | Missing _loc -> return + + method function_declaration loc (stmt : ('loc, 'loc) Ast.Function.t) = this#function_ loc stmt + + method function_expression loc (stmt : ('loc, 'loc) Ast.Function.t) = + this#function_expression_or_method loc stmt + + (** previously, we conflated [function_expression] and [class_method]. callers should be + updated to override those individually. *) + method function_expression_or_method loc (stmt : ('loc, 'loc) Ast.Function.t) = + this#function_ loc stmt + [@@alert deprecated "Use either function_expression or class_method"] + + (* Internal helper for function declarations, function expressions and arrow functions *) + method function_ _loc (expr : ('loc, 'loc) Ast.Function.t) = + let open Ast.Function in + let { + id = ident; + params; + body; + async; + generator; + predicate; + return; + tparams; + sig_loc; + comments; + } = + expr + in + let ident' = map_opt this#function_identifier ident in + let tparams' = map_opt this#type_params tparams in + let params' = this#function_params params in + let return' = this#type_annotation_hint return in + let body' = this#function_body_any body in + let predicate' = map_opt this#predicate predicate in + let comments' = this#syntax_opt comments in + if + ident == ident' + && params == params' + && body == body' + && predicate == predicate' + && return == return' + && tparams == tparams' + && comments == comments' + then + expr + else + { + id = ident'; + params = params'; + return = return'; + body = body'; + async; + generator; + predicate = predicate'; + tparams = tparams'; + sig_loc; + comments = comments'; + } + + method function_params (params : ('loc, 'loc) Ast.Function.Params.t) = + let open Ast.Function in + let (loc, { Params.params = params_list; rest; comments; this_ }) = params in + let params_list' = map_list this#function_param params_list in + let rest' = map_opt this#function_rest_param rest in + let this_' = map_opt this#function_this_param this_ in + let comments' = this#syntax_opt comments in + if params_list == params_list' && rest == rest' && comments == comments' && this_ == this_' + then + params + else + (loc, { Params.params = params_list'; rest = rest'; comments = comments'; this_ = this_' }) + + method function_this_param (this_param : ('loc, 'loc) Ast.Function.ThisParam.t) = + let open Ast.Function.ThisParam in + let (loc, { annot; comments }) = this_param in + let annot' = this#type_annotation annot in + let comments' = this#syntax_opt comments in + if annot' == annot && comments' == comments then + this_param + else + (loc, { annot = annot'; comments = comments' }) + + method function_param (param : ('loc, 'loc) Ast.Function.Param.t) = + let open Ast.Function.Param in + let (loc, { argument; default }) = param in + let argument' = this#function_param_pattern argument in + let default' = map_opt this#expression default in + if argument == argument' && default == default' then + param + else + (loc, { argument = argument'; default = default' }) + + method function_body_any (body : ('loc, 'loc) Ast.Function.body) = + match body with + | Ast.Function.BodyBlock block -> + id this#function_body block body (fun block -> Ast.Function.BodyBlock block) + | Ast.Function.BodyExpression expr -> + id this#expression expr body (fun expr -> Ast.Function.BodyExpression expr) + + method function_body (body : 'loc * ('loc, 'loc) Ast.Statement.Block.t) = + let (loc, block) = body in + id_loc this#block loc block body (fun block -> (loc, block)) + + method function_identifier (ident : ('loc, 'loc) Ast.Identifier.t) = + this#pattern_identifier ~kind:Ast.Statement.VariableDeclaration.Var ident + + (* TODO *) + method generator _loc (expr : ('loc, 'loc) Ast.Expression.Generator.t) = expr + + method identifier (id : ('loc, 'loc) Ast.Identifier.t) = + let open Ast.Identifier in + let (loc, { name; comments }) = id in + let comments' = this#syntax_opt comments in + if comments == comments' then + id + else + (loc, { name; comments = comments' }) + + method type_identifier (id : ('loc, 'loc) Ast.Identifier.t) = this#identifier id + + method type_identifier_reference (id : ('loc, 'loc) Ast.Identifier.t) = this#type_identifier id + + method binding_type_identifier (id : ('loc, 'loc) Ast.Identifier.t) = this#type_identifier id + + method interface _loc (interface : ('loc, 'loc) Ast.Statement.Interface.t) = + let open Ast.Statement.Interface in + let { id = ident; tparams; extends; body; comments } = interface in + let id' = this#binding_type_identifier ident in + let tparams' = map_opt this#type_params tparams in + let extends' = map_list (map_loc this#generic_type) extends in + let body' = map_loc this#object_type body in + let comments' = this#syntax_opt comments in + if + id' == ident + && tparams' == tparams + && extends' == extends + && body' == body + && comments' == comments + then + interface + else + { id = id'; tparams = tparams'; extends = extends'; body = body'; comments = comments' } + + method interface_declaration loc (decl : ('loc, 'loc) Ast.Statement.Interface.t) = + this#interface loc decl + + method private_name (id : 'loc Ast.PrivateName.t) = + let open Ast.PrivateName in + let (loc, { name; comments }) = id in + let comments' = this#syntax_opt comments in + if comments == comments' then + id + else + (loc, { name; comments = comments' }) + + method computed_key (key : ('loc, 'loc) Ast.ComputedKey.t) = + let open Ast.ComputedKey in + let (loc, { expression; comments }) = key in + let expression' = this#expression expression in + let comments' = this#syntax_opt comments in + if expression == expression' && comments == comments' then + key + else + (loc, { expression = expression'; comments = comments' }) + + method import _loc (expr : ('loc, 'loc) Ast.Expression.Import.t) = + let open Ast.Expression.Import in + let { argument; comments } = expr in + let argument' = this#expression argument in + let comments' = this#syntax_opt comments in + if argument == argument' && comments == comments' then + expr + else + { argument = argument'; comments = comments' } + + method if_consequent_statement ~has_else (stmt : ('loc, 'loc) Ast.Statement.t) = + ignore has_else; + this#statement stmt + + method if_alternate_statement _loc (altern : ('loc, 'loc) Ast.Statement.If.Alternate.t') = + let open Ast.Statement.If.Alternate in + let { body; comments } = altern in + let body' = this#statement body in + let comments' = this#syntax_opt comments in + if body == body' && comments == comments' then + altern + else + { body = body'; comments = comments' } + + method if_statement _loc (stmt : ('loc, 'loc) Ast.Statement.If.t) = + let open Ast.Statement.If in + let { test; consequent; alternate; comments } = stmt in + let test' = this#predicate_expression test in + let consequent' = this#if_consequent_statement ~has_else:(alternate <> None) consequent in + let alternate' = map_opt (map_loc this#if_alternate_statement) alternate in + let comments' = this#syntax_opt comments in + if + test == test' + && consequent == consequent' + && alternate == alternate' + && comments == comments' + then + stmt + else + { test = test'; consequent = consequent'; alternate = alternate'; comments = comments' } + + method import_declaration _loc (decl : ('loc, 'loc) Ast.Statement.ImportDeclaration.t) = + let open Ast.Statement.ImportDeclaration in + let { import_kind; source; specifiers; default; comments } = decl in + let source' = map_loc this#import_source source in + let specifiers' = map_opt (this#import_specifier ~import_kind) specifiers in + let default' = map_opt (this#import_default_specifier ~import_kind) default in + let comments' = this#syntax_opt comments in + if + source == source' + && specifiers == specifiers' + && default == default' + && comments == comments' + then + decl + else + { + import_kind; + source = source'; + specifiers = specifiers'; + default = default'; + comments = comments'; + } + + method import_source _loc (source : 'loc Ast.StringLiteral.t) = + let open Ast.StringLiteral in + let { value; raw; comments } = source in + let comments' = this#syntax_opt comments in + if comments == comments' then + source + else + { value; raw; comments = comments' } + + method import_specifier + ~import_kind (specifier : ('loc, 'loc) Ast.Statement.ImportDeclaration.specifier) = + let open Ast.Statement.ImportDeclaration in + match specifier with + | ImportNamedSpecifiers named_specifiers -> + let named_specifiers' = + map_list (this#import_named_specifier ~import_kind) named_specifiers + in + if named_specifiers == named_specifiers' then + specifier + else + ImportNamedSpecifiers named_specifiers' + | ImportNamespaceSpecifier (loc, ident) -> + id_loc (this#import_namespace_specifier ~import_kind) loc ident specifier (fun ident -> + ImportNamespaceSpecifier (loc, ident) + ) + + method remote_identifier id = this#identifier id + + method import_named_specifier + ~(import_kind : Ast.Statement.ImportDeclaration.import_kind) + (specifier : ('loc, 'loc) Ast.Statement.ImportDeclaration.named_specifier) = + let open Ast.Statement.ImportDeclaration in + let { kind; local; remote } = specifier in + let (is_type_remote, is_type_local) = + match (import_kind, kind) with + | (ImportType, _) + | (_, Some ImportType) -> + (true, true) + | (ImportTypeof, _) + | (_, Some ImportTypeof) -> + (false, true) + | _ -> (false, false) + in + let remote' = + match local with + | None -> + if is_type_remote then + this#binding_type_identifier remote + else + this#pattern_identifier ~kind:Ast.Statement.VariableDeclaration.Let remote + | Some _ -> this#remote_identifier remote + in + let local' = + match local with + | None -> None + | Some ident -> + let local_visitor = + if is_type_local then + this#binding_type_identifier + else + this#pattern_identifier ~kind:Ast.Statement.VariableDeclaration.Let + in + id local_visitor ident local (fun ident -> Some ident) + in + if local == local' && remote == remote' then + specifier + else + { kind; local = local'; remote = remote' } + + method import_default_specifier ~import_kind (id : ('loc, 'loc) Ast.Identifier.t) = + let open Ast.Statement.ImportDeclaration in + let local_visitor = + match import_kind with + | ImportType + | ImportTypeof -> + this#binding_type_identifier + | _ -> this#pattern_identifier ~kind:Ast.Statement.VariableDeclaration.Let + in + local_visitor id + + method import_namespace_specifier ~import_kind _loc (id : ('loc, 'loc) Ast.Identifier.t) = + let open Ast.Statement.ImportDeclaration in + let local_visitor = + match import_kind with + | ImportType + | ImportTypeof -> + this#binding_type_identifier + | _ -> this#pattern_identifier ~kind:Ast.Statement.VariableDeclaration.Let + in + local_visitor id + + method jsx_element _loc (expr : ('loc, 'loc) Ast.JSX.element) = + let open Ast.JSX in + let { opening_element; closing_element; children; comments } = expr in + let opening_element' = this#jsx_opening_element opening_element in + let closing_element' = map_opt this#jsx_closing_element closing_element in + let children' = this#jsx_children children in + let comments' = this#syntax_opt comments in + if + opening_element == opening_element' + && closing_element == closing_element' + && children == children' + && comments == comments' + then + expr + else + { + opening_element = opening_element'; + closing_element = closing_element'; + children = children'; + comments = comments'; + } + + method jsx_fragment _loc (expr : ('loc, 'loc) Ast.JSX.fragment) = + let open Ast.JSX in + let { frag_children; frag_comments; _ } = expr in + let children' = this#jsx_children frag_children in + let frag_comments' = this#syntax_opt frag_comments in + if frag_children == children' && frag_comments == frag_comments' then + expr + else + { expr with frag_children = children'; frag_comments = frag_comments' } + + method jsx_opening_element (elem : ('loc, 'loc) Ast.JSX.Opening.t) = + let open Ast.JSX.Opening in + let (loc, { name; self_closing; attributes }) = elem in + let name' = this#jsx_element_name name in + let attributes' = map_list this#jsx_opening_attribute attributes in + if name == name' && attributes == attributes' then + elem + else + (loc, { name = name'; self_closing; attributes = attributes' }) + + method jsx_closing_element (elem : ('loc, 'loc) Ast.JSX.Closing.t) = + let open Ast.JSX.Closing in + let (loc, { name }) = elem in + let name' = this#jsx_element_name name in + if name == name' then + elem + else + (loc, { name = name' }) + + method jsx_opening_attribute (jsx_attr : ('loc, 'loc) Ast.JSX.Opening.attribute) = + let open Ast.JSX.Opening in + match jsx_attr with + | Attribute attr -> id this#jsx_attribute attr jsx_attr (fun attr -> Attribute attr) + | SpreadAttribute (loc, attr) -> + id_loc this#jsx_spread_attribute loc attr jsx_attr (fun attr -> SpreadAttribute (loc, attr)) + + method jsx_spread_attribute _loc (attr : ('loc, 'loc) Ast.JSX.SpreadAttribute.t') = + let open Ast.JSX.SpreadAttribute in + let { argument; comments } = attr in + let argument' = this#expression argument in + let comments' = this#syntax_opt comments in + if argument == argument' && comments == comments' then + attr + else + { argument = argument'; comments = comments' } + + method jsx_attribute (attr : ('loc, 'loc) Ast.JSX.Attribute.t) = + let open Ast.JSX.Attribute in + let (loc, { name; value }) = attr in + let name' = this#jsx_attribute_name name in + let value' = map_opt this#jsx_attribute_value value in + if name == name' && value == value' then + attr + else + (loc, { name = name'; value = value' }) + + method jsx_attribute_name (name : ('loc, 'loc) Ast.JSX.Attribute.name) = + let open Ast.JSX.Attribute in + match name with + | Identifier ident -> + id this#jsx_attribute_name_identifier ident name (fun ident -> Identifier ident) + | NamespacedName ns -> + id this#jsx_attribute_name_namespaced ns name (fun ns -> NamespacedName ns) + + method jsx_attribute_name_identifier ident = this#jsx_identifier ident + + method jsx_attribute_name_namespaced ns = this#jsx_namespaced_name ns + + method jsx_attribute_value (value : ('loc, 'loc) Ast.JSX.Attribute.value) = + let open Ast.JSX.Attribute in + match value with + | Literal (loc, lit) -> + id_loc this#jsx_attribute_value_literal loc lit value (fun lit -> Literal (loc, lit)) + | ExpressionContainer (loc, expr) -> + id_loc this#jsx_attribute_value_expression loc expr value (fun expr -> + ExpressionContainer (loc, expr) + ) + + method jsx_attribute_value_expression loc (jsx_expr : ('loc, 'loc) Ast.JSX.ExpressionContainer.t) + = + this#jsx_expression loc jsx_expr + + method jsx_attribute_value_literal loc (lit : 'loc Ast.Literal.t) = this#literal loc lit + + method jsx_children ((loc, children) as orig : 'loc * ('loc, 'loc) Ast.JSX.child list) = + let children' = map_list this#jsx_child children in + if children == children' then + orig + else + (loc, children') + + method jsx_child (child : ('loc, 'loc) Ast.JSX.child) = + let open Ast.JSX in + match child with + | (loc, Element elem) -> + id_loc this#jsx_element loc elem child (fun elem -> (loc, Element elem)) + | (loc, Fragment frag) -> + id_loc this#jsx_fragment loc frag child (fun frag -> (loc, Fragment frag)) + | (loc, ExpressionContainer expr) -> + id_loc this#jsx_expression loc expr child (fun expr -> (loc, ExpressionContainer expr)) + | (loc, SpreadChild spread) -> + id this#jsx_spread_child spread child (fun spread -> (loc, SpreadChild spread)) + | (_loc, Text _) -> child + + method jsx_expression _loc (jsx_expr : ('loc, 'loc) Ast.JSX.ExpressionContainer.t) = + let open Ast.JSX.ExpressionContainer in + let { expression; comments } = jsx_expr in + let comments' = this#syntax_opt comments in + match expression with + | Expression expr -> + let expr' = this#expression expr in + if expr == expr' && comments == comments' then + jsx_expr + else + { expression = Expression expr'; comments = comments' } + | EmptyExpression -> + if comments == comments' then + jsx_expr + else + { expression = EmptyExpression; comments = comments' } + + method jsx_spread_child (jsx_spread_child : ('loc, 'loc) Ast.JSX.SpreadChild.t) = + let open Ast.JSX.SpreadChild in + let { expression; comments } = jsx_spread_child in + let expression' = this#expression expression in + let comments' = this#syntax_opt comments in + if expression == expression' && comments == comments' then + jsx_spread_child + else + { expression = expression'; comments = comments' } + + method jsx_element_name (name : ('loc, 'loc) Ast.JSX.name) = + let open Ast.JSX in + match name with + | Identifier ident -> + id this#jsx_element_name_identifier ident name (fun ident -> Identifier ident) + | NamespacedName ns -> + id this#jsx_element_name_namespaced ns name (fun ns -> NamespacedName ns) + | MemberExpression expr -> + id this#jsx_element_name_member_expression expr name (fun expr -> MemberExpression expr) + + method jsx_element_name_identifier ident = this#jsx_identifier ident + + method jsx_element_name_namespaced ns = this#jsx_namespaced_name ns + + method jsx_element_name_member_expression expr = this#jsx_member_expression expr + + method jsx_namespaced_name (namespaced_name : ('loc, 'loc) Ast.JSX.NamespacedName.t) = + let open Ast.JSX in + NamespacedName.( + let (loc, { namespace; name }) = namespaced_name in + let namespace' = this#jsx_identifier namespace in + let name' = this#jsx_identifier name in + if namespace == namespace' && name == name' then + namespaced_name + else + (loc, { namespace = namespace'; name = name' }) + ) + + method jsx_member_expression (member_exp : ('loc, 'loc) Ast.JSX.MemberExpression.t) = + let open Ast.JSX in + let (loc, { MemberExpression._object; MemberExpression.property }) = member_exp in + let _object' = this#jsx_member_expression_object _object in + let property' = this#jsx_identifier property in + if _object == _object' && property == property' then + member_exp + else + (loc, MemberExpression.{ _object = _object'; property = property' }) + + method jsx_member_expression_object (_object : ('loc, 'loc) Ast.JSX.MemberExpression._object) = + let open Ast.JSX.MemberExpression in + match _object with + | Identifier ident -> + id this#jsx_member_expression_identifier ident _object (fun ident -> Identifier ident) + | MemberExpression nested_exp -> + id this#jsx_member_expression nested_exp _object (fun exp -> MemberExpression exp) + + method jsx_member_expression_identifier ident = this#jsx_element_name_identifier ident + + method jsx_identifier (id : ('loc, 'loc) Ast.JSX.Identifier.t) = + let open Ast.JSX.Identifier in + let (loc, { name; comments }) = id in + let comments' = this#syntax_opt comments in + if comments == comments' then + id + else + (loc, { name; comments = comments' }) + + method labeled_statement _loc (stmt : ('loc, 'loc) Ast.Statement.Labeled.t) = + let open Ast.Statement.Labeled in + let { label; body; comments } = stmt in + let label' = this#label_identifier label in + let body' = this#statement body in + let comments' = this#syntax_opt comments in + if label == label' && body == body' && comments == comments' then + stmt + else + { label = label'; body = body'; comments = comments' } + + method literal _loc (expr : 'loc Ast.Literal.t) = + let open Ast.Literal in + let { value; raw; comments } = expr in + let comments' = this#syntax_opt comments in + if comments == comments' then + expr + else + { value; raw; comments = comments' } + + method logical _loc (expr : ('loc, 'loc) Ast.Expression.Logical.t) = + let open Ast.Expression.Logical in + let { operator = _; left; right; comments } = expr in + let left' = this#expression left in + let right' = this#expression right in + let comments' = this#syntax_opt comments in + if left == left' && right == right' && comments == comments' then + expr + else + { expr with left = left'; right = right'; comments = comments' } + + method member _loc (expr : ('loc, 'loc) Ast.Expression.Member.t) = + let open Ast.Expression.Member in + let { _object; property; comments } = expr in + let _object' = this#expression _object in + let property' = this#member_property property in + let comments' = this#syntax_opt comments in + if _object == _object' && property == property' && comments == comments' then + expr + else + { _object = _object'; property = property'; comments = comments' } + + method optional_member loc (expr : ('loc, 'loc) Ast.Expression.OptionalMember.t) = + let open Ast.Expression.OptionalMember in + let { member; optional = _; filtered_out = _ } = expr in + let member' = this#member loc member in + if member == member' then + expr + else + { expr with member = member' } + + method member_property (expr : ('loc, 'loc) Ast.Expression.Member.property) = + let open Ast.Expression.Member in + match expr with + | PropertyIdentifier ident -> + id this#member_property_identifier ident expr (fun ident -> PropertyIdentifier ident) + | PropertyPrivateName ident -> + id this#member_private_name ident expr (fun ident -> PropertyPrivateName ident) + | PropertyExpression e -> + id this#member_property_expression e expr (fun e -> PropertyExpression e) + + method member_property_identifier (ident : ('loc, 'loc) Ast.Identifier.t) = + this#identifier ident + + method member_private_name (name : 'loc Ast.PrivateName.t) = this#private_name name + + method member_property_expression (expr : ('loc, 'loc) Ast.Expression.t) = this#expression expr + + method meta_property _loc (expr : 'loc Ast.Expression.MetaProperty.t) = + let open Ast.Expression.MetaProperty in + let { meta; property; comments } = expr in + let meta' = this#identifier meta in + let property' = this#identifier property in + let comments' = this#syntax_opt comments in + if meta == meta' && property == property' && comments == comments' then + expr + else + { meta = meta'; property = property'; comments = comments' } + + method new_ _loc (expr : ('loc, 'loc) Ast.Expression.New.t) = + let open Ast.Expression.New in + let { callee; targs; arguments; comments } = expr in + let callee' = this#expression callee in + let targs' = map_opt this#call_type_args targs in + let arguments' = map_opt this#call_arguments arguments in + let comments' = this#syntax_opt comments in + if callee == callee' && targs == targs' && arguments == arguments' && comments == comments' + then + expr + else + { callee = callee'; targs = targs'; arguments = arguments'; comments = comments' } + + method object_ _loc (expr : ('loc, 'loc) Ast.Expression.Object.t) = + let open Ast.Expression.Object in + let { properties; comments } = expr in + let properties' = + map_list + (fun prop -> + match prop with + | Property p -> + let p' = this#object_property p in + if p == p' then + prop + else + Property p' + | SpreadProperty s -> + let s' = this#spread_property s in + if s == s' then + prop + else + SpreadProperty s') + properties + in + let comments' = this#syntax_opt comments in + if properties == properties' && comments == comments' then + expr + else + { properties = properties'; comments = comments' } + + method object_property (prop : ('loc, 'loc) Ast.Expression.Object.Property.t) = + let open Ast.Expression.Object.Property in + match prop with + | (loc, Init { key; value; shorthand }) -> + let key' = this#object_key key in + let value' = this#expression value in + let shorthand' = + (* Try to figure out if shorthand should still be true--if + key and value change differently, it should become false *) + shorthand + && + match (key', value') with + | ( Identifier (_, { Ast.Identifier.name = key_name; _ }), + (_, Ast.Expression.Identifier (_, { Ast.Identifier.name = value_name; _ })) + ) -> + String.equal key_name value_name + | _ -> key == key' && value == value' + in + if key == key' && value == value' && shorthand == shorthand' then + prop + else + (loc, Init { key = key'; value = value'; shorthand = shorthand' }) + | (loc, Method { key; value = fn }) -> + let key' = this#object_key key in + let fn' = map_loc this#function_expression_or_method fn in + if key == key' && fn == fn' then + prop + else + (loc, Method { key = key'; value = fn' }) + | (loc, Get { key; value = fn; comments }) -> + let key' = this#object_key key in + let fn' = map_loc this#function_expression_or_method fn in + let comments' = this#syntax_opt comments in + if key == key' && fn == fn' && comments == comments' then + prop + else + (loc, Get { key = key'; value = fn'; comments = comments' }) + | (loc, Set { key; value = fn; comments }) -> + let key' = this#object_key key in + let fn' = map_loc this#function_expression_or_method fn in + let comments' = this#syntax_opt comments in + if key == key' && fn == fn' && comments == comments' then + prop + else + (loc, Set { key = key'; value = fn'; comments = comments' }) + + method object_key (key : ('loc, 'loc) Ast.Expression.Object.Property.key) = + let open Ast.Expression.Object.Property in + match key with + | Literal literal -> id this#object_key_literal literal key (fun lit -> Literal lit) + | Identifier ident -> id this#object_key_identifier ident key (fun ident -> Identifier ident) + | PrivateName ident -> id this#private_name ident key (fun ident -> PrivateName ident) + | Computed computed -> id this#object_key_computed computed key (fun expr -> Computed expr) + + method object_key_literal (literal : 'loc * 'loc Ast.Literal.t) = + let (loc, lit) = literal in + id_loc this#literal loc lit literal (fun lit -> (loc, lit)) + + method object_key_identifier (ident : ('loc, 'loc) Ast.Identifier.t) = this#identifier ident + + method object_key_computed (key : ('loc, 'loc) Ast.ComputedKey.t) = this#computed_key key + + method opaque_type _loc (otype : ('loc, 'loc) Ast.Statement.OpaqueType.t) = + let open Ast.Statement.OpaqueType in + let { id; tparams; impltype; supertype; comments } = otype in + let id' = this#binding_type_identifier id in + let tparams' = map_opt this#type_params tparams in + let impltype' = map_opt this#type_ impltype in + let supertype' = map_opt this#type_ supertype in + let comments' = this#syntax_opt comments in + if + id == id' + && impltype == impltype' + && tparams == tparams' + && impltype == impltype' + && supertype == supertype' + && comments == comments' + then + otype + else + { + id = id'; + tparams = tparams'; + impltype = impltype'; + supertype = supertype'; + comments = comments'; + } + + method function_param_pattern (expr : ('loc, 'loc) Ast.Pattern.t) = + this#binding_pattern ~kind:Ast.Statement.VariableDeclaration.Let expr + + method variable_declarator_pattern ~kind (expr : ('loc, 'loc) Ast.Pattern.t) = + this#binding_pattern ~kind expr + + method catch_clause_pattern (expr : ('loc, 'loc) Ast.Pattern.t) = + this#binding_pattern ~kind:Ast.Statement.VariableDeclaration.Let expr + + method for_in_assignment_pattern (expr : ('loc, 'loc) Ast.Pattern.t) = + this#assignment_pattern expr + + method for_of_assignment_pattern (expr : ('loc, 'loc) Ast.Pattern.t) = + this#assignment_pattern expr + + method binding_pattern + ?(kind = Ast.Statement.VariableDeclaration.Var) (expr : ('loc, 'loc) Ast.Pattern.t) = + this#pattern ~kind expr + + method assignment_pattern (expr : ('loc, 'loc) Ast.Pattern.t) = this#pattern expr + + (* NOTE: Patterns are highly overloaded. A pattern can be a binding pattern, + which has a kind (Var/Let/Const, with Var being the default for all pre-ES5 + bindings), or an assignment pattern, which has no kind. Subterms that are + patterns inherit the kind (or lack thereof). *) + method pattern ?kind (expr : ('loc, 'loc) Ast.Pattern.t) = + let open Ast.Pattern in + let (loc, patt) = expr in + let patt' = + match patt with + | Object { Object.properties; annot; comments } -> + let properties' = map_list (this#pattern_object_p ?kind) properties in + let annot' = this#type_annotation_hint annot in + let comments' = this#syntax_opt comments in + if properties' == properties && annot' == annot && comments' == comments then + patt + else + Object { Object.properties = properties'; annot = annot'; comments = comments' } + | Array { Array.elements; annot; comments } -> + let elements' = map_list (this#pattern_array_e ?kind) elements in + let annot' = this#type_annotation_hint annot in + let comments' = this#syntax_opt comments in + if comments == comments' && elements' == elements && annot' == annot then + patt + else + Array { Array.elements = elements'; annot = annot'; comments = comments' } + | Identifier { Identifier.name; annot; optional } -> + let name' = this#pattern_identifier ?kind name in + let annot' = this#type_annotation_hint annot in + if name == name' && annot == annot' then + patt + else + Identifier { Identifier.name = name'; annot = annot'; optional } + | Expression e -> id this#pattern_expression e patt (fun e -> Expression e) + in + if patt == patt' then + expr + else + (loc, patt') + + method pattern_identifier ?kind (ident : ('loc, 'loc) Ast.Identifier.t) = + ignore kind; + this#identifier ident + + method pattern_literal ?kind loc (expr : 'loc Ast.Literal.t) = + ignore kind; + this#literal loc expr + + method pattern_object_p ?kind (p : ('loc, 'loc) Ast.Pattern.Object.property) = + let open Ast.Pattern.Object in + match p with + | Property prop -> id (this#pattern_object_property ?kind) prop p (fun prop -> Property prop) + | RestElement prop -> + id (this#pattern_object_rest_property ?kind) prop p (fun prop -> RestElement prop) + + method pattern_object_property ?kind (prop : ('loc, 'loc) Ast.Pattern.Object.Property.t) = + let open Ast.Pattern.Object.Property in + let (loc, { key; pattern; default; shorthand }) = prop in + let key' = this#pattern_object_property_key ?kind key in + let pattern' = this#pattern_object_property_pattern ?kind pattern in + let default' = map_opt this#expression default in + let shorthand' = + (* Try to figure out if shorthand should still be true--if + key and value change differently, it should become false *) + shorthand + && + match (key', pattern') with + | ( Identifier (_, { Ast.Identifier.name = key_name; _ }), + ( _, + Ast.Pattern.Identifier + { Ast.Pattern.Identifier.name = (_, { Ast.Identifier.name = value_name; _ }); _ } + ) + ) -> + String.equal key_name value_name + | _ -> key == key' && pattern == pattern' + in + if key' == key && pattern' == pattern && default' == default && shorthand == shorthand' then + prop + else + (loc, { key = key'; pattern = pattern'; default = default'; shorthand = shorthand' }) + + method pattern_object_property_key ?kind (key : ('loc, 'loc) Ast.Pattern.Object.Property.key) = + let open Ast.Pattern.Object.Property in + match key with + | Literal lit -> + id (this#pattern_object_property_literal_key ?kind) lit key (fun lit' -> Literal lit') + | Identifier identifier -> + id (this#pattern_object_property_identifier_key ?kind) identifier key (fun id' -> + Identifier id' + ) + | Computed expr -> + id (this#pattern_object_property_computed_key ?kind) expr key (fun expr' -> Computed expr') + + method pattern_object_property_literal_key ?kind (literal : 'loc * 'loc Ast.Literal.t) = + let (loc, key) = literal in + id_loc (this#pattern_literal ?kind) loc key literal (fun key' -> (loc, key')) + + method pattern_object_property_identifier_key ?kind (key : ('loc, 'loc) Ast.Identifier.t) = + this#pattern_identifier ?kind key + + method pattern_object_property_computed_key ?kind (key : ('loc, 'loc) Ast.ComputedKey.t) = + ignore kind; + this#computed_key key + + method pattern_object_rest_property ?kind (prop : ('loc, 'loc) Ast.Pattern.RestElement.t) = + let open Ast.Pattern.RestElement in + let (loc, { argument; comments }) = prop in + let argument' = this#pattern_object_rest_property_pattern ?kind argument in + let comments' = this#syntax_opt comments in + if argument' == argument && comments == comments' then + prop + else + (loc, { argument = argument'; comments = comments' }) + + method pattern_object_property_pattern ?kind (expr : ('loc, 'loc) Ast.Pattern.t) = + this#pattern ?kind expr + + method pattern_object_rest_property_pattern ?kind (expr : ('loc, 'loc) Ast.Pattern.t) = + this#pattern ?kind expr + + method pattern_array_e ?kind (e : ('loc, 'loc) Ast.Pattern.Array.element) = + let open Ast.Pattern.Array in + match e with + | Hole _ -> e + | Element elem -> id (this#pattern_array_element ?kind) elem e (fun elem -> Element elem) + | RestElement elem -> + id (this#pattern_array_rest_element ?kind) elem e (fun elem -> RestElement elem) + + method pattern_array_element ?kind (elem : ('loc, 'loc) Ast.Pattern.Array.Element.t) = + let open Ast.Pattern.Array.Element in + let (loc, { argument; default }) = elem in + let argument' = this#pattern_array_element_pattern ?kind argument in + let default' = map_opt this#expression default in + if argument == argument' && default == default' then + elem + else + (loc, { argument = argument'; default = default' }) + + method pattern_array_element_pattern ?kind (patt : ('loc, 'loc) Ast.Pattern.t) = + this#pattern ?kind patt + + method pattern_array_rest_element ?kind (elem : ('loc, 'loc) Ast.Pattern.RestElement.t) = + let open Ast.Pattern.RestElement in + let (loc, { argument; comments }) = elem in + let argument' = this#pattern_array_rest_element_pattern ?kind argument in + let comments' = this#syntax_opt comments in + if argument' == argument && comments == comments' then + elem + else + (loc, { argument = argument'; comments = comments' }) + + method pattern_array_rest_element_pattern ?kind (expr : ('loc, 'loc) Ast.Pattern.t) = + this#pattern ?kind expr + + method pattern_expression (expr : ('loc, 'loc) Ast.Expression.t) = this#expression expr + + method predicate (pred : ('loc, 'loc) Ast.Type.Predicate.t) = + let open Ast.Type.Predicate in + let (loc, { kind; comments }) = pred in + let kind' = + match kind with + | Inferred -> kind + | Declared expr -> id this#expression expr kind (fun expr' -> Declared expr') + in + let comments' = this#syntax_opt comments in + if kind == kind' && comments == comments' then + pred + else + (loc, { kind = kind'; comments = comments' }) + + method predicate_expression (expr : ('loc, 'loc) Ast.Expression.t) = this#expression expr + + method function_rest_param (expr : ('loc, 'loc) Ast.Function.RestParam.t) = + let open Ast.Function.RestParam in + let (loc, { argument; comments }) = expr in + let argument' = this#function_param_pattern argument in + let comments' = this#syntax_opt comments in + if argument == argument' && comments == comments' then + expr + else + (loc, { argument = argument'; comments = comments' }) + + method return _loc (stmt : ('loc, 'loc) Ast.Statement.Return.t) = + let open Ast.Statement.Return in + let { argument; comments; return_out } = stmt in + let argument' = map_opt this#expression argument in + let comments' = this#syntax_opt comments in + if argument == argument' && comments == comments' then + stmt + else + { argument = argument'; comments = comments'; return_out } + + method sequence _loc (expr : ('loc, 'loc) Ast.Expression.Sequence.t) = + let open Ast.Expression.Sequence in + let { expressions; comments } = expr in + let expressions' = map_list this#expression expressions in + let comments' = this#syntax_opt comments in + if expressions == expressions' && comments == comments' then + expr + else + { expressions = expressions'; comments = comments' } + + method toplevel_statement_list (stmts : ('loc, 'loc) Ast.Statement.t list) = + this#statement_list stmts + + method statement_list (stmts : ('loc, 'loc) Ast.Statement.t list) = + map_list_multiple this#statement_fork_point stmts + + method statement_fork_point (stmt : ('loc, 'loc) Ast.Statement.t) = [this#statement stmt] + + method spread_element (expr : ('loc, 'loc) Ast.Expression.SpreadElement.t) = + let open Ast.Expression.SpreadElement in + let (loc, { argument; comments }) = expr in + let argument' = this#expression argument in + let comments' = this#syntax_opt comments in + if argument == argument' && comments == comments' then + expr + else + (loc, { argument = argument'; comments = comments' }) + + method spread_property (expr : ('loc, 'loc) Ast.Expression.Object.SpreadProperty.t) = + let open Ast.Expression.Object.SpreadProperty in + let (loc, { argument; comments }) = expr in + let argument' = this#expression argument in + let comments' = this#syntax_opt comments in + if argument == argument' && comments == comments' then + expr + else + (loc, { argument = argument'; comments = comments' }) + + method super_expression _loc (expr : 'loc Ast.Expression.Super.t) = + let open Ast.Expression.Super in + let { comments } = expr in + let comments' = this#syntax_opt comments in + if comments == comments' then + expr + else + { comments = comments' } + + method switch _loc (switch : ('loc, 'loc) Ast.Statement.Switch.t) = + let open Ast.Statement.Switch in + let { discriminant; cases; comments; exhaustive_out } = switch in + let discriminant' = this#expression discriminant in + let cases' = map_list this#switch_case cases in + let comments' = this#syntax_opt comments in + if discriminant == discriminant' && cases == cases' && comments == comments' then + switch + else + { discriminant = discriminant'; cases = cases'; comments = comments'; exhaustive_out } + + method switch_case (case : ('loc, 'loc) Ast.Statement.Switch.Case.t) = + let open Ast.Statement.Switch.Case in + let (loc, { test; consequent; comments }) = case in + let test' = map_opt this#expression test in + let consequent' = this#statement_list consequent in + let comments' = this#syntax_opt comments in + if test == test' && consequent == consequent' && comments == comments' then + case + else + (loc, { test = test'; consequent = consequent'; comments = comments' }) + + method tagged_template _loc (expr : ('loc, 'loc) Ast.Expression.TaggedTemplate.t) = + let open Ast.Expression.TaggedTemplate in + let { tag; quasi; comments } = expr in + let tag' = this#expression tag in + let quasi' = map_loc this#template_literal quasi in + let comments' = this#syntax_opt comments in + if tag == tag' && quasi == quasi' && comments == comments' then + expr + else + { tag = tag'; quasi = quasi'; comments = comments' } + + method template_literal _loc (expr : ('loc, 'loc) Ast.Expression.TemplateLiteral.t) = + let open Ast.Expression.TemplateLiteral in + let { quasis; expressions; comments } = expr in + let quasis' = map_list this#template_literal_element quasis in + let expressions' = map_list this#expression expressions in + let comments' = this#syntax_opt comments in + if quasis == quasis' && expressions == expressions' && comments == comments' then + expr + else + { quasis = quasis'; expressions = expressions'; comments = comments' } + + (* TODO *) + method template_literal_element (elem : 'loc Ast.Expression.TemplateLiteral.Element.t) = elem + + method this_expression _loc (expr : 'loc Ast.Expression.This.t) = + let open Ast.Expression.This in + let { comments } = expr in + let comments' = this#syntax_opt comments in + if comments == comments' then + expr + else + { comments = comments' } + + method throw _loc (stmt : ('loc, 'loc) Ast.Statement.Throw.t) = + let open Ast.Statement.Throw in + let { argument; comments } = stmt in + let argument' = this#expression argument in + let comments' = this#syntax_opt comments in + if argument == argument' && comments == comments' then + stmt + else + { argument = argument'; comments = comments' } + + method try_catch _loc (stmt : ('loc, 'loc) Ast.Statement.Try.t) = + let open Ast.Statement.Try in + let { block; handler; finalizer; comments } = stmt in + let block' = map_loc this#block block in + let handler' = + match handler with + | Some (loc, clause) -> + id_loc this#catch_clause loc clause handler (fun clause -> Some (loc, clause)) + | None -> handler + in + let finalizer' = + match finalizer with + | Some (finalizer_loc, block) -> + id_loc this#block finalizer_loc block finalizer (fun block -> Some (finalizer_loc, block)) + | None -> finalizer + in + let comments' = this#syntax_opt comments in + if block == block' && handler == handler' && finalizer == finalizer' && comments == comments' + then + stmt + else + { block = block'; handler = handler'; finalizer = finalizer'; comments = comments' } + + method type_cast _loc (expr : ('loc, 'loc) Ast.Expression.TypeCast.t) = + let open Ast.Expression.TypeCast in + let { expression; annot; comments } = expr in + let expression' = this#expression expression in + let annot' = this#type_annotation annot in + let comments' = this#syntax_opt comments in + if expression' == expression && annot' == annot && comments' == comments then + expr + else + { expression = expression'; annot = annot'; comments = comments' } + + method unary_expression _loc (expr : ('loc, 'loc) Flow_ast.Expression.Unary.t) = + let open Flow_ast.Expression.Unary in + let { argument; operator = _; comments } = expr in + let argument' = this#expression argument in + let comments' = this#syntax_opt comments in + if argument == argument' && comments == comments' then + expr + else + { expr with argument = argument'; comments = comments' } + + method update_expression _loc (expr : ('loc, 'loc) Ast.Expression.Update.t) = + let open Ast.Expression.Update in + let { argument; operator = _; prefix = _; comments } = expr in + let argument' = this#expression argument in + let comments' = this#syntax_opt comments in + if argument == argument' && comments == comments' then + expr + else + { expr with argument = argument'; comments = comments' } + + method variable_declaration _loc (decl : ('loc, 'loc) Ast.Statement.VariableDeclaration.t) = + let open Ast.Statement.VariableDeclaration in + let { declarations; kind; comments } = decl in + let decls' = map_list (this#variable_declarator ~kind) declarations in + let comments' = this#syntax_opt comments in + if declarations == decls' && comments == comments' then + decl + else + { declarations = decls'; kind; comments = comments' } + + method variable_declarator + ~kind (decl : ('loc, 'loc) Ast.Statement.VariableDeclaration.Declarator.t) = + let open Ast.Statement.VariableDeclaration.Declarator in + let (loc, { id; init }) = decl in + let id' = this#variable_declarator_pattern ~kind id in + let init' = map_opt this#expression init in + if id == id' && init == init' then + decl + else + (loc, { id = id'; init = init' }) + + method while_ _loc (stuff : ('loc, 'loc) Ast.Statement.While.t) = + let open Ast.Statement.While in + let { test; body; comments } = stuff in + let test' = this#predicate_expression test in + let body' = this#statement body in + let comments' = this#syntax_opt comments in + if test == test' && body == body' && comments == comments' then + stuff + else + { test = test'; body = body'; comments = comments' } + + method with_ _loc (stuff : ('loc, 'loc) Ast.Statement.With.t) = + let open Ast.Statement.With in + let { _object; body; comments } = stuff in + let _object' = this#expression _object in + let body' = this#statement body in + let comments' = this#syntax_opt comments in + if _object == _object' && body == body' && comments == comments' then + stuff + else + { _object = _object'; body = body'; comments = comments' } + + method type_alias _loc (stuff : ('loc, 'loc) Ast.Statement.TypeAlias.t) = + let open Ast.Statement.TypeAlias in + let { id; tparams; right; comments } = stuff in + let id' = this#binding_type_identifier id in + let tparams' = map_opt this#type_params tparams in + let right' = this#type_ right in + let comments' = this#syntax_opt comments in + if id == id' && right == right' && tparams == tparams' && comments == comments' then + stuff + else + { id = id'; tparams = tparams'; right = right'; comments = comments' } + + method yield _loc (expr : ('loc, 'loc) Ast.Expression.Yield.t) = + let open Ast.Expression.Yield in + let { argument; delegate; comments; result_out } = expr in + let argument' = map_opt this#expression argument in + let comments' = this#syntax_opt comments in + if comments == comments' && argument == argument' then + expr + else + { argument = argument'; delegate; comments = comments'; result_out } + end + +let fold_program (mappers : 'a mapper list) ast = + List.fold_left (fun ast (m : 'a mapper) -> m#program ast) ast mappers diff --git a/analysis/vendor/js_parser/flow_ast_utils.ml b/analysis/vendor/js_parser/flow_ast_utils.ml new file mode 100644 index 000000000..cdaee7b07 --- /dev/null +++ b/analysis/vendor/js_parser/flow_ast_utils.ml @@ -0,0 +1,339 @@ +(* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) + +open Flow_ast + +type 'loc binding = 'loc * string +type 'loc ident = 'loc * string +type 'loc source = 'loc * string + +let rec fold_bindings_of_pattern = + Pattern.( + let property f acc = + Object.( + function + | Property (_, { Property.pattern = p; _ }) + | RestElement (_, { RestElement.argument = p; comments = _ }) -> + fold_bindings_of_pattern f acc p + ) + in + let element f acc = + Array.( + function + | Hole _ -> acc + | Element (_, { Element.argument = p; default = _ }) + | RestElement (_, { RestElement.argument = p; comments = _ }) -> + fold_bindings_of_pattern f acc p + ) + in + fun f acc -> function + | (_, Identifier { Identifier.name; _ }) -> f acc name + | (_, Object { Object.properties; _ }) -> List.fold_left (property f) acc properties + | (_, Array { Array.elements; _ }) -> List.fold_left (element f) acc elements + (* This is for assignment and default param destructuring `[a.b=1]=c`, ignore these for now. *) + | (_, Expression _) -> acc + ) + +let fold_bindings_of_variable_declarations f acc declarations = + let open Flow_ast.Statement.VariableDeclaration in + List.fold_left + (fun acc -> function + | (_, { Declarator.id = pattern; _ }) -> + let has_anno = + (* Only the toplevel annotation in a pattern is meaningful *) + let open Flow_ast.Pattern in + match pattern with + | (_, Array { Array.annot = Flow_ast.Type.Available _; _ }) + | (_, Object { Object.annot = Flow_ast.Type.Available _; _ }) + | (_, Identifier { Identifier.annot = Flow_ast.Type.Available _; _ }) -> + true + | _ -> false + in + fold_bindings_of_pattern (f has_anno) acc pattern) + acc + declarations + +let partition_directives statements = + let open Flow_ast.Statement in + let rec helper directives = function + | ((_, Expression { Expression.directive = Some _; _ }) as directive) :: rest -> + helper (directive :: directives) rest + | rest -> (List.rev directives, rest) + in + helper [] statements + +let hoist_function_declarations stmts = + let open Flow_ast.Statement in + let (func_decs, other_stmts) = + List.partition + (function + (* function f() {} *) + | (_, FunctionDeclaration { Flow_ast.Function.id = Some _; _ }) + (* export function f() {} *) + | ( _, + ExportNamedDeclaration + { + ExportNamedDeclaration.declaration = + Some (_, FunctionDeclaration { Flow_ast.Function.id = Some _; _ }); + _; + } + ) + (* export default function f() {} *) + | ( _, + ExportDefaultDeclaration + { + ExportDefaultDeclaration.declaration = + ExportDefaultDeclaration.Declaration + (_, FunctionDeclaration { Flow_ast.Function.id = Some _; _ }); + _; + } + ) + (* declare function f(): void; *) + | (_, DeclareFunction _) + (* declare export function f(): void; *) + | ( _, + DeclareExportDeclaration DeclareExportDeclaration.{ declaration = Some (Function _); _ } + ) -> + true + | _ -> false) + stmts + in + func_decs @ other_stmts + +let negate_number_literal (value, raw) = + let raw_len = String.length raw in + let raw = + if raw_len > 0 && raw.[0] = '-' then + String.sub raw 1 (raw_len - 1) + else + "-" ^ raw + in + (~-.value, raw) + +let is_call_to_invariant callee = + match callee with + | (_, Expression.Identifier (_, { Identifier.name = "invariant"; _ })) -> true + | _ -> false + +let is_call_to_is_array callee = + match callee with + | ( _, + Flow_ast.Expression.Member + { + Flow_ast.Expression.Member._object = + ( _, + Flow_ast.Expression.Identifier + (_, { Flow_ast.Identifier.name = "Array"; comments = _ }) + ); + property = + Flow_ast.Expression.Member.PropertyIdentifier + (_, { Flow_ast.Identifier.name = "isArray"; comments = _ }); + comments = _; + } + ) -> + true + | _ -> false + +let is_call_to_object_dot_freeze callee = + match callee with + | ( _, + Flow_ast.Expression.Member + { + Flow_ast.Expression.Member._object = + ( _, + Flow_ast.Expression.Identifier + (_, { Flow_ast.Identifier.name = "Object"; comments = _ }) + ); + property = + Flow_ast.Expression.Member.PropertyIdentifier + (_, { Flow_ast.Identifier.name = "freeze"; comments = _ }); + comments = _; + } + ) -> + true + | _ -> false + +let is_call_to_object_static_method callee = + match callee with + | ( _, + Flow_ast.Expression.Member + { + Flow_ast.Expression.Member._object = + ( _, + Flow_ast.Expression.Identifier + (_, { Flow_ast.Identifier.name = "Object"; comments = _ }) + ); + property = Flow_ast.Expression.Member.PropertyIdentifier _; + comments = _; + } + ) -> + true + | _ -> false + +let loc_of_statement = fst +let loc_of_expression = fst +let loc_of_pattern = fst +let loc_of_ident = fst +let name_of_ident (_, { Identifier.name; comments = _ }) = name +let source_of_ident (loc, { Identifier.name; comments = _ }) = (loc, name) +let ident_of_source ?comments (loc, name) = (loc, { Identifier.name; comments }) +let mk_comments ?(leading = []) ?(trailing = []) a = { Syntax.leading; trailing; internal = a } + +let mk_comments_opt ?(leading = []) ?(trailing = []) () = + match (leading, trailing) with + | ([], []) -> None + | (_, _) -> Some (mk_comments ~leading ~trailing ()) + +let mk_comments_with_internal_opt ?(leading = []) ?(trailing = []) ~internal () = + match (leading, trailing, internal) with + | ([], [], []) -> None + | _ -> Some (mk_comments ~leading ~trailing internal) + +let merge_comments ~inner ~outer = + let open Syntax in + match (inner, outer) with + | (None, c) + | (c, None) -> + c + | (Some inner, Some outer) -> + mk_comments_opt + ~leading:(outer.leading @ inner.leading) + ~trailing:(inner.trailing @ outer.trailing) + () + +let merge_comments_with_internal ~inner ~outer = + match (inner, outer) with + | (inner, None) -> inner + | (None, Some { Syntax.leading; trailing; _ }) -> + mk_comments_with_internal_opt ~leading ~trailing ~internal:[] () + | ( Some { Syntax.leading = inner_leading; trailing = inner_trailing; internal }, + Some { Syntax.leading = outer_leading; trailing = outer_trailing; _ } + ) -> + mk_comments_with_internal_opt + ~leading:(outer_leading @ inner_leading) + ~trailing:(inner_trailing @ outer_trailing) + ~internal + () + +let split_comments comments = + match comments with + | None -> (None, None) + | Some { Syntax.leading; trailing; _ } -> + (mk_comments_opt ~leading (), mk_comments_opt ~trailing ()) + +let string_of_assignment_operator op = + let open Flow_ast.Expression.Assignment in + match op with + | PlusAssign -> "+=" + | MinusAssign -> "-=" + | MultAssign -> "*=" + | ExpAssign -> "**=" + | DivAssign -> "/=" + | ModAssign -> "%=" + | LShiftAssign -> "<<=" + | RShiftAssign -> ">>=" + | RShift3Assign -> ">>>=" + | BitOrAssign -> "|=" + | BitXorAssign -> "^=" + | BitAndAssign -> "&=" + | NullishAssign -> "??=" + | AndAssign -> "&&=" + | OrAssign -> "||=" + +let string_of_binary_operator op = + let open Flow_ast.Expression.Binary in + match op with + | Equal -> "==" + | NotEqual -> "!=" + | StrictEqual -> "===" + | StrictNotEqual -> "!==" + | LessThan -> "<" + | LessThanEqual -> "<=" + | GreaterThan -> ">" + | GreaterThanEqual -> ">=" + | LShift -> "<<" + | RShift -> ">>" + | RShift3 -> ">>>" + | Plus -> "+" + | Minus -> "-" + | Mult -> "*" + | Exp -> "**" + | Div -> "/" + | Mod -> "%" + | BitOr -> "|" + | Xor -> "^" + | BitAnd -> "&" + | In -> "in" + | Instanceof -> "instanceof" + +module ExpressionSort = struct + type t = + | Array + | ArrowFunction + | Assignment + | Binary + | Call + | Class + | Comprehension + | Conditional + | Function + | Generator + | Identifier + | Import + | JSXElement + | JSXFragment + | Literal + | Logical + | Member + | MetaProperty + | New + | Object + | OptionalCall + | OptionalMember + | Sequence + | Super + | TaggedTemplate + | TemplateLiteral + | This + | TypeCast + | Unary + | Update + | Yield + + let to_string = function + | Array -> "array" + | ArrowFunction -> "arrow function" + | Assignment -> "assignment expression" + | Binary -> "binary expression" + | Call -> "call expression" + | Class -> "class" + | Comprehension -> "comprehension expression" + | Conditional -> "conditional expression" + | Function -> "function" + | Generator -> "generator" + | Identifier -> "identifier" + | Import -> "import expression" + | JSXElement -> "JSX element" + | JSXFragment -> "JSX fragment" + | Literal -> "literal" + | Logical -> "logical expression" + | Member -> "member expression" + | MetaProperty -> "metaproperty expression" + | New -> "new expression" + | Object -> "object" + | OptionalCall -> "optional call expression" + | OptionalMember -> "optional member expression" + | Sequence -> "sequence" + | Super -> "`super` reference" + | TaggedTemplate -> "tagged template expression" + | TemplateLiteral -> "template literal" + | This -> "`this` reference" + | TypeCast -> "type cast" + | Unary -> "unary expression" + | Update -> "update expression" + | Yield -> "yield expression" +end diff --git a/analysis/vendor/js_parser/flow_ast_utils.mli b/analysis/vendor/js_parser/flow_ast_utils.mli new file mode 100644 index 000000000..2155346b1 --- /dev/null +++ b/analysis/vendor/js_parser/flow_ast_utils.mli @@ -0,0 +1,128 @@ +(* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) + +type 'loc binding = 'loc * string + +type 'loc ident = 'loc * string + +type 'loc source = 'loc * string + +val fold_bindings_of_pattern : + ('a -> ('m, 't) Flow_ast.Identifier.t -> 'a) -> 'a -> ('m, 't) Flow_ast.Pattern.t -> 'a + +val fold_bindings_of_variable_declarations : + (bool -> 'a -> ('m, 't) Flow_ast.Identifier.t -> 'a) -> + 'a -> + ('m, 't) Flow_ast.Statement.VariableDeclaration.Declarator.t list -> + 'a + +val partition_directives : + (Loc.t, Loc.t) Flow_ast.Statement.t list -> + (Loc.t, Loc.t) Flow_ast.Statement.t list * (Loc.t, Loc.t) Flow_ast.Statement.t list + +val hoist_function_declarations : + ('a, 'b) Flow_ast.Statement.t list -> ('a, 'b) Flow_ast.Statement.t list + +val is_call_to_invariant : ('a, 'b) Flow_ast.Expression.t -> bool + +val is_call_to_is_array : ('a, 'b) Flow_ast.Expression.t -> bool + +val is_call_to_object_dot_freeze : ('a, 'b) Flow_ast.Expression.t -> bool + +val is_call_to_object_static_method : ('a, 'b) Flow_ast.Expression.t -> bool + +val negate_number_literal : float * string -> float * string + +val loc_of_expression : ('a, 'a) Flow_ast.Expression.t -> 'a + +val loc_of_statement : ('a, 'a) Flow_ast.Statement.t -> 'a + +val loc_of_pattern : ('a, 'a) Flow_ast.Pattern.t -> 'a + +val loc_of_ident : ('a, 'a) Flow_ast.Identifier.t -> 'a + +val name_of_ident : ('loc, 'a) Flow_ast.Identifier.t -> string + +val source_of_ident : ('a, 'a) Flow_ast.Identifier.t -> 'a source + +val ident_of_source : + ?comments:('a, unit) Flow_ast.Syntax.t -> 'a source -> ('a, 'a) Flow_ast.Identifier.t + +val mk_comments : + ?leading:'loc Flow_ast.Comment.t list -> + ?trailing:'loc Flow_ast.Comment.t list -> + 'a -> + ('loc, 'a) Flow_ast.Syntax.t + +val mk_comments_opt : + ?leading:'loc Flow_ast.Comment.t list -> + ?trailing:'loc Flow_ast.Comment.t list -> + unit -> + ('loc, unit) Flow_ast.Syntax.t option + +val mk_comments_with_internal_opt : + ?leading:'loc Flow_ast.Comment.t list -> + ?trailing:'loc Flow_ast.Comment.t list -> + internal:'loc Flow_ast.Comment.t list -> + unit -> + ('loc, 'loc Flow_ast.Comment.t list) Flow_ast.Syntax.t option + +val merge_comments : + inner:('M, unit) Flow_ast.Syntax.t option -> + outer:('M, unit) Flow_ast.Syntax.t option -> + ('M, unit) Flow_ast.Syntax.t option + +val merge_comments_with_internal : + inner:('M, 'loc Flow_ast.Comment.t list) Flow_ast.Syntax.t option -> + outer:('M, 'a) Flow_ast.Syntax.t option -> + ('M, 'loc Flow_ast.Comment.t list) Flow_ast.Syntax.t option + +val split_comments : + ('loc, unit) Flow_ast.Syntax.t option -> + ('loc, unit) Flow_ast.Syntax.t option * ('loc, unit) Flow_ast.Syntax.t option + +module ExpressionSort : sig + type t = + | Array + | ArrowFunction + | Assignment + | Binary + | Call + | Class + | Comprehension + | Conditional + | Function + | Generator + | Identifier + | Import + | JSXElement + | JSXFragment + | Literal + | Logical + | Member + | MetaProperty + | New + | Object + | OptionalCall + | OptionalMember + | Sequence + | Super + | TaggedTemplate + | TemplateLiteral + | This + | TypeCast + | Unary + | Update + | Yield + + + val to_string : t -> string +end + +val string_of_assignment_operator : Flow_ast.Expression.Assignment.operator -> string + +val string_of_binary_operator : Flow_ast.Expression.Binary.operator -> string diff --git a/analysis/vendor/js_parser/flow_lexer.ml b/analysis/vendor/js_parser/flow_lexer.ml new file mode 100644 index 000000000..bf4c9f44b --- /dev/null +++ b/analysis/vendor/js_parser/flow_lexer.ml @@ -0,0 +1,13521 @@ + +let __sedlex_table_58 = + "\001\001\001\001\001\001\001\001\001\001\000\001\001" +let __sedlex_table_2 = + "\001\000\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001" +let __sedlex_table_17 = + "\001\000\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001" +let __sedlex_table_28 = + "\001\000\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\003\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001" +let __sedlex_table_41 = + "\001\000\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\002\000\003\004\004\004\004\004\004\004\004\004\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001" +let __sedlex_table_52 = + "\001\000\000\002\003\003\003\003\003\003\003\003\003" +let __sedlex_table_70 = + "\001\000\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002\003\003\003\003\003\003\003\003\003\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001" +let __sedlex_table_47 = + "\001\001\001\001\001\001\001\001\001\001\002\001\001\003\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\004" +let __sedlex_table_57 = + "\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002" +let __sedlex_table_29 = + "\001\002\000\003\004\004\004\004\004\004\004\004\004" +let __sedlex_table_30 = + "\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002" +let __sedlex_table_42 = + "\001\000\002\002\002\002\002\002\002\002\002\002\000\000\000\000\000\000\000\000\000\000\000\003\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\003" +let __sedlex_table_5 = "\001\002" +let __sedlex_table_3 = + "\001\001\001\001\001\001\001\001\001\001\000\001\001\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\001\001\001" +let __sedlex_table_21 = + "\001\001\001\001\001\001\001\001\001\001\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\001\001\001\001\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001" +let __sedlex_table_60 = + "\001\001\001\001\001\001\001\001\001\001\000\001\001\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001" +let __sedlex_table_83 = + "\001\002\002\002\002\002\002\002\002\002\002\003\002\002\004\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\005\002\002\002\006\005\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\005\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\005\002\007" +let __sedlex_table_18 = + "\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002" +let __sedlex_table_23 = + "\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002" +let __sedlex_table_43 = + "\001\002\002\002\002\002\002\002\002\002\002\003\002\002\004\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\005\006\006\006\006\006\006\006\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\002\002\002\002\002\b\002\002\002\t\002\002\002\002\002\002\002\n\002\002\002\011\002\012\r\014\002\015" +let __sedlex_table_76 = + "\001\001\001\001\001\001\001\001\001\002\003\002\002\004\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\002\001\001\001\001\001\001\001\001\001\001\001\001\001\001\005\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\006\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\002\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\002\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001" +let __sedlex_table_82 = + "\001\000\001\000\000\002\003\003\003\003\003\003\003\003\003" +let __sedlex_table_10 = "\001\001\001\001\001\001\001\001\001\001\000\002" +let __sedlex_table_12 = + "\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001" +let __sedlex_table_33 = + "\001\001\001\001\001\001\001\001\001\001\000\001\001\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\001\001\001\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001" +let __sedlex_table_45 = + "\001\001\001\001\001\001\001\001\001\001\002\001\001\003" +let __sedlex_table_78 = + "\001\002\002\002\002\002\002\002\002\002\002\003\002\002\004\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\005\006" +let __sedlex_table_88 = + "\001\000\002\002\002\002\002\002\002\002\002\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\003" +let __sedlex_table_11 = + "\001\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\000\002\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001" +let __sedlex_table_14 = + "\001\000\000\000\000\000\000\000\000\000\000\000\002\002\002\002\002\002\002\002\002\002\000\000\000\000\000\000\000\002\002\002\002\002\002\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\002\002\002\002\002\002\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001" +let __sedlex_table_16 = + "\001\000\000\000\000\000\000\000\000\000\000\000\002\002\002\002\002\002\002\002\002\002\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\003\001\001\001\001\001\001\001\001\001\001\001\001" +let __sedlex_table_22 = + "\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\001\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001" +let __sedlex_table_27 = + "\001\000\000\000\000\000\000\000\000\000\002\000\003\003\003\003\003\003\003\003\003\003\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\004\001\001\001\001\001\001\001\001\001\001\001\001" +let __sedlex_table_32 = + "\001\000\000\000\000\000\000\000\000\000\002\000\003\003\003\003\003\003\003\003\003\003\000\000\000\000\000\000\000\001\001\001\001\004\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\005\000\001\001\001\001\004\001\001\001\001\001\001\001\001\006\001\001\001\001\001\001\001\001\001\001\001\001" +let __sedlex_table_38 = + "\001\000\000\000\000\000\000\000\000\000\000\000\002\002\002\002\002\002\002\002\002\002\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001" +let __sedlex_table_46 = + "\001\000\000\000\000\000\000\000\000\000\000\000\002\002\002\002\002\002\002\002\002\002\000\000\000\000\000\000\000\001\001\001\001\003\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\001\001\001\001\003\001\001\001\001\001\001\001\001\004\001\001\001\001\001\001\001\001\001\001\001\001" +let __sedlex_table_49 = + "\001\000\000\000\000\000\000\000\000\000\000\000\002\002\002\002\002\002\002\002\002\002\000\000\000\000\000\000\000\001\001\001\001\003\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\004\000\001\001\001\001\003\001\001\001\001\001\001\001\001\005\001\001\001\001\001\001\001\001\001\001\001\001" +let __sedlex_table_55 = + "\001\000\000\000\000\000\000\000\000\000\000\000\002\002\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001" +let __sedlex_table_59 = + "\001\000\000\000\000\000\000\000\000\000\002\000\003\003\003\003\003\003\003\003\004\004\000\000\000\000\000\000\000\001\005\001\001\006\001\001\001\001\001\001\001\001\001\007\001\001\001\001\001\001\001\001\b\001\001\000\000\000\000\000\000\001\005\001\001\006\001\001\001\001\001\001\001\001\t\007\001\001\001\001\001\001\001\001\b\001\001" +let __sedlex_table_62 = + "\001\000\000\000\000\000\000\000\000\000\000\000\002\002\002\002\002\002\002\002\001\001\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001" +let __sedlex_table_63 = + "\001\000\000\000\000\000\000\000\000\000\000\000\002\002\002\002\002\002\002\002\002\002\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\003\000\001\001\001\001\001\001\001\001\001\001\001\001\001\004\001\001\001\001\001\001\001\001\001\001\001\001" +let __sedlex_table_65 = + "\001\000\000\000\000\000\000\000\000\000\000\000\002\002\002\002\002\002\002\002\001\001\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\003\000\001\001\001\001\001\001\001\001\001\001\001\001\001\004\001\001\001\001\001\001\001\001\001\001\001\001" +let __sedlex_table_68 = + "\001\000\000\000\000\000\000\000\000\000\002\000\003\003\003\003\003\003\003\003\003\003\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\004\000\001\001\001\001\001\001\001\001\001\001\001\001\001\005\001\001\001\001\001\001\001\001\001\001\001\001" +let __sedlex_table_73 = + "\001\000\000\000\000\000\000\000\000\000\000\000\002\002\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\003\000\001\001\001\001\001\001\001\001\001\001\001\001\001\004\001\001\001\001\001\001\001\001\001\001\001\001" +let __sedlex_table_75 = + "\001\000\000\000\000\000\000\000\000\000\002\000\003\003\003\003\003\003\003\003\004\004\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\005\001\001\001\001\001\001\001\001\001\001\001\001" +let __sedlex_table_77 = + "\001\000\000\000\000\000\000\000\000\000\000\000\002\002\002\002\002\002\002\002\002\002\000\000\000\000\000\000\000\002\002\002\002\002\002\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\003\000\002\002\002\002\002\002\001\001\001\001\001\001\001\004\001\001\001\001\001\001\001\001\001\001\001\001" +let __sedlex_table_89 = + "\001\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001" +let __sedlex_table_1 = + "\001\002\002\002\002\002\002\002\002\002\003\004\003\003\005\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\003\006\007\b\t\n\011\007\012\r\014\015\016\017\018\019\020\021\021\021\021\021\021\021\021\021\022\023\024\025\026\027\028\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\029\030\031 \t!\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"#$%\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\003\002\002\002\002\002\002\002\002\002\t\002\002\002\002\002\002\002\002\002\002\t\002\002\002\002\t\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\t\t\002\002\002\002\002\002\002\t\002\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\t\t\002\t\t\002\002\t\t\t\t\002\t\002\002\002\002\002\002\t\002\t\t\t\002\t\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\t\002\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\002\t\t\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\002\002\002\002\002\002\002\t\t\002\002\002\002\002\002\002\002\002\002\t\t\t\002\002\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\002\002\002\002\002\002\002\002\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\002\002\002\002\002\002\t\t\002\002\002\002\t\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\002\t\002\002\002\002\002\002\002\002\002\t\002\002\002\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\t\t\t\t\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\002\t\t\t\t\t\t\t\t\002\002\t\t\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\t\t\t\t\t\t\t\002\t\002\002\002\t\t\t\t\002\002\002\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\002\t\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\002\002\002\002\002\002\002\002\002\002\t\002\002\002\002\002\002\002\002\t\t\t\t\t\t\002\002\002\002\t\t\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\t\t\t\t\t\t\t\002\t\t\002\t\t\002\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\t\002\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\t\002\t\t\t\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\t\t\t\t\t\t\t\002\t\t\002\t\t\t\t\t\002\002\002\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\002\002\002\002\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\002\002\t\t\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\t\t\t\t\t\t\t\002\t\t\002\t\t\t\t\t\002\002\002\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\002\t\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\002\t\t\t\t\t\t\002\002\002\t\t\t\002\t\t\t\t\002\002\002\t\t\002\t\002\t\t\002\002\002\t\t\002\002\002\t\t\t\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\002\t\t\t\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\002\002\t\002\002\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\002\002\002\002\t\t\t\t\t\t\t\t\002\t\t\t\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\t\t\t\t\t\t\t\t\t\t\002\t\t\t\t\t\002\002\002\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\002\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\t\002\t\t\t\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\002\002\002\002\002\t\t\t\002\002\002\002\002\002\002\002\t\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\t\t\t\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\t\t\t\t\t\t\t\t\t\002\t\002\002\t\t\t\t\t\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\t\t\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\t\t\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\002\t\002\t\t\t\t\t\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\t\002\t\t\t\t\t\t\t\t\t\t\002\t\t\002\002\002\002\002\002\002\002\002\t\002\002\t\t\t\t\t\002\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\t\t\t\002\002\002\002\t\t\t\t\002\002\002\t\002\002\002\t\t\002\002\002\002\002\002\002\t\t\t\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\002\002\002\002\002\002\002\002\002\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\t\002\002\002\002\002\t\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\t\t\t\t\002\002\t\t\t\t\t\t\t\002\t\002\t\t\t\t\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\t\t\t\t\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\t\t\t\t\002\002\t\t\t\t\t\t\t\002\t\002\t\t\t\t\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\t\t\t\t\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\t\t\t\t\t\t\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\003\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\t\t\t\t\t\t\t\t\t\t\t\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\002\t\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\002\002\002\002\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\t\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\t\t\t\t\t\002\002\002\002\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\002\002\002\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\002\002\002\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\t\t\t\t\t\t\t\t\t\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\t\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\t\002\t\t\t\t\t\t\002\t\t\002\002\002\t\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\t\t\t\t\t\t\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\t\t\t\t\t\t\002\002\t\t\t\t\t\t\t\t\002\t\002\t\002\t\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\002\t\t\t\t\t\t\t\002\t\002\002\002\t\t\t\002\t\t\t\t\t\t\t\002\002\002\t\t\t\t\002\002\t\t\t\t\t\t\002\002\002\002\t\t\t\t\t\t\t\t\t\t\t\t\t\002\002\002\002\002\t\t\t\002\t\t\t\t\t\t\t\002\002\002" +let __sedlex_table_61 = + "\001\002\002\002\002\002\002\002\002\002\003\004\003\003\005\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\003\002\002\002\002\002\002\002\002\002\002\002\002\002\002\006\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\003\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\003\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002" +let __sedlex_table_66 = + "\001\002\002\002\002\002\002\002\002\002\002\003\002\002\004" +let __sedlex_table_72 = "\001\000\000\000\000\002" +let __sedlex_table_74 = + "\001\002\002\002\002\002\002\002\002\002\003\004\003\003\005\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\003\002\006\002\007\b\t\006\n\011\012\r\014\015\016\017\018\019\019\019\019\019\019\019\019\019\020\021\022\023\024\025\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\026\027\028\002\007\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\029\030\031\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\003\002\002\002\002\002\002\002\002\002\007\002\002\002\002\002\002\002\002\002\002\007\002\002\002\002\007\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\002\002\002\002\002\002\002\007\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\002\007\007\002\002\007\007\007\007\002\007\002\002\002\002\002\002\007\002\007\007\007\002\007\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\007\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\002\002\002\002\002\002\002\007\007\002\002\002\002\002\002\002\002\002\002\007\007\007\002\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\007\007\002\002\002\002\007\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\007\002\002\002\002\002\002\002\002\002\007\002\002\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\007\007\007\007\007\007\007\007\002\002\007\007\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\007\007\007\002\007\002\002\002\007\007\007\007\002\002\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\002\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\002\002\002\002\002\002\002\002\002\002\007\002\002\002\002\002\002\002\002\007\007\007\007\007\007\002\002\002\002\007\007\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\007\007\007\002\007\007\002\007\007\002\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\002\007\007\007\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\007\007\007\002\007\007\002\007\007\007\007\007\002\002\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\002\002\007\007\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\007\007\007\002\007\007\002\007\007\007\007\007\002\002\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\002\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\002\007\007\007\007\007\007\002\002\002\007\007\007\002\007\007\007\007\002\002\002\007\007\002\007\002\007\007\002\002\002\007\007\002\002\002\007\007\007\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\002\007\007\007\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\002\002\007\002\002\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\002\002\002\002\007\007\007\007\007\007\007\007\002\007\007\007\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\007\002\002\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\002\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\002\007\007\007\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\002\002\002\002\002\007\007\007\002\002\002\002\002\002\002\002\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\007\007\007\007\007\002\007\002\002\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\002\007\002\007\007\007\007\007\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\002\007\007\007\007\007\007\007\007\007\007\002\007\007\002\002\002\002\002\002\002\002\002\007\002\002\007\007\007\007\007\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\002\002\002\002\007\007\007\007\002\002\002\007\002\002\002\007\007\002\002\002\002\002\002\002\007\007\007\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\002\002\002\002\002\007\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\002\002\007\007\007\007\007\007\007\002\007\002\007\007\007\007\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\002\002\007\007\007\007\007\007\007\002\007\002\007\007\007\007\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\007\007\007\007\007\007\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\003\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\002\002\002\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\002\007\007\007\007\007\007\002\007\007\002\002\002\007\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\007\007\007\007\007\007\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\007\007\007\007\007\007\002\002\007\007\007\007\007\007\007\007\002\007\002\007\002\007\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\007\007\007\002\007\002\002\002\007\007\007\002\007\007\007\007\007\007\007\002\002\002\007\007\007\007\002\002\007\007\007\007\007\007\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\007\007\007\002\007\007\007\007\007\007\007\002\002\002" +let __sedlex_table_91 = + "\001\002\002\002\002\002\002\002\002\002\003\004\003\003\005\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\003\002\006\002\007\002\002\006\002\002\002\002\002\002\b\t\002\002\002\002\002\002\002\002\002\002\n\002\011\012\r\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\014\002\002\007\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\015\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\003\002\002\002\002\002\002\002\002\002\007\002\002\002\002\002\002\002\002\002\002\007\002\002\002\002\007\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\002\002\002\002\002\002\002\007\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\002\007\007\002\002\007\007\007\007\002\007\002\002\002\002\002\002\007\002\007\007\007\002\007\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\007\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\002\002\002\002\002\002\002\007\007\002\002\002\002\002\002\002\002\002\002\007\007\007\002\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\007\007\002\002\002\002\007\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\007\002\002\002\002\002\002\002\002\002\007\002\002\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\007\007\007\007\007\007\007\007\002\002\007\007\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\007\007\007\002\007\002\002\002\007\007\007\007\002\002\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\002\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\002\002\002\002\002\002\002\002\002\002\007\002\002\002\002\002\002\002\002\007\007\007\007\007\007\002\002\002\002\007\007\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\007\007\007\002\007\007\002\007\007\002\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\002\007\007\007\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\007\007\007\002\007\007\002\007\007\007\007\007\002\002\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\002\002\007\007\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\007\007\007\002\007\007\002\007\007\007\007\007\002\002\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\002\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\002\007\007\007\007\007\007\002\002\002\007\007\007\002\007\007\007\007\002\002\002\007\007\002\007\002\007\007\002\002\002\007\007\002\002\002\007\007\007\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\002\007\007\007\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\002\002\007\002\002\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\002\002\002\002\007\007\007\007\007\007\007\007\002\007\007\007\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\007\002\002\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\002\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\002\007\007\007\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\002\002\002\002\002\007\007\007\002\002\002\002\002\002\002\002\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\007\007\007\007\007\002\007\002\002\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\002\007\002\007\007\007\007\007\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\002\007\007\007\007\007\007\007\007\007\007\002\007\007\002\002\002\002\002\002\002\002\002\007\002\002\007\007\007\007\007\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\002\002\002\002\007\007\007\007\002\002\002\007\002\002\002\007\007\002\002\002\002\002\002\002\007\007\007\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\002\002\002\002\002\007\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\002\002\007\007\007\007\007\007\007\002\007\002\007\007\007\007\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\002\002\007\007\007\007\007\007\007\002\007\002\007\007\007\007\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\007\007\007\007\007\007\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\003\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\002\002\002\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\002\007\007\007\007\007\007\002\007\007\002\002\002\007\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\007\007\007\007\007\007\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\007\007\007\007\007\007\002\002\007\007\007\007\007\007\007\007\002\007\002\007\002\007\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\002\007\007\007\007\007\007\007\002\007\002\002\002\007\007\007\002\007\007\007\007\007\007\007\002\002\002\007\007\007\007\002\002\007\007\007\007\007\007\002\002\002\002\007\007\007\007\007\007\007\007\007\007\007\007\007\002\002\002\002\002\007\007\007\002\007\007\007\007\007\007\007\002\002\002" +let __sedlex_table_51 = "\001\000\000\002" +let __sedlex_table_8 = + "\001\002\002\002\002\002\002\002\002\002\002\003\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\004\002\002\002\002\004\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\005" +let __sedlex_table_20 = + "\001\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\003" +let __sedlex_table_69 = + "\001\002\002\002\002\002\002\002\002\002\002\003\002\002\004\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\005\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\006\007" +let __sedlex_table_15 = + "\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002" +let __sedlex_table_48 = + "\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002" +let __sedlex_table_81 = + "\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\003\000\000\000\000\000\002" +let __sedlex_table_9 = + "\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\003" +let __sedlex_table_26 = + "\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002\000\001\001\001\001\001\001\000\000\000\000\000\000\000\003" +let __sedlex_table_35 = + "\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002" +let __sedlex_table_67 = + "\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002" +let __sedlex_table_36 = "\001\000\000\000\000\000\000\000\002" +let __sedlex_table_39 = + "\001\002\002\002\002\002\002\002\002\002\002\003\002\002\004\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\005\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\006\002\002\002\007" +let __sedlex_table_50 = + "\001\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\003" +let __sedlex_table_90 = + "\001\002\000\000\000\000\000\000\000\000\000\000\000\002\002\002\002\002\002\002\002\002\002\000\000\000\000\000\000\000\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\000\000\000\000\000\000\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002" +let __sedlex_table_37 = + "\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\003" +let __sedlex_table_7 = + "\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001" +let __sedlex_table_13 = "\001\000\002\003\003\003\003\003\003\003\003\003" +let __sedlex_table_53 = + "\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002\000\001\001\001\001\001\001" +let __sedlex_table_87 = + "\001\001\001\001\001\001\001\001\001\001\000\002\000\000\000\000\000\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001" +let __sedlex_table_34 = + "\001\001\001\001\001\001\001\001\001\001\000\001\001\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001" +let __sedlex_table_54 = "\001\000\002\002\002\002\002\002\002\002\002\002" +let __sedlex_table_71 = + "\001\000\000\000\000\000\000\002\000\002\000\000\003\004\004\004\004\004\004\004\004\004\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001" +let __sedlex_table_80 = "\001\001\001\001\001\001\001\001\002\002" +let __sedlex_table_4 = + "\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002" +let __sedlex_table_79 = + "\001\002\002\002\002\002\002\002\002\002\002\003\002\002\004\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\005\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\006" +let __sedlex_table_84 = + "\001\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\003\002\002\002\002\002\002\002\002\002\002\002\003\003\003\003\003\003\003\003\003\003\002\002\002\002\002\002\002\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\002\004\002\002\003\002\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003" +let __sedlex_table_85 = + "\001\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\003\002\002\002\002\002\002\002\002\003\002\002\003\003\003\003\003\003\003\003\003\003\002\002\002\002\002\002\002\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\002\004\002\002\003\002\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003" +let __sedlex_table_64 = + "\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\002\000\000\001\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\001\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\000\000\000\000\000\000\000\001\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\000\001\001\000\000\001\001\001\001\000\001\000\000\000\000\000\000\001\000\001\001\001\000\001\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\001\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\000\000\000\000\000\000\000\001\001\000\000\000\000\000\000\000\000\000\000\001\001\001\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\001\001\000\000\000\000\001\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\001\000\000\000\000\000\000\000\000\000\001\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\001\001\001\001\001\001\001\001\000\000\001\001\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\001\001\001\001\001\001\001\000\001\000\000\000\001\001\001\001\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\000\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\001\001\001\001\001\001\000\000\000\000\001\001\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\001\001\001\001\001\001\001\000\001\001\000\001\001\000\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\000\001\001\001\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\001\001\001\001\001\001\001\000\001\001\000\001\001\001\001\001\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\000\000\001\001\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\001\001\001\001\001\001\001\000\001\001\000\001\001\001\001\001\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\000\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\000\001\001\001\001\001\001\000\000\000\001\001\001\000\001\001\001\001\000\000\000\001\001\000\001\000\001\001\000\000\000\001\001\000\000\000\001\001\001\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\000\001\001\001\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\000\000\001\000\000\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\001\001\001\001\001\001\001\001\000\001\001\001\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\001\001\001\001\001\001\001\001\001\001\000\001\001\001\001\001\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\000\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\000\001\001\001\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\001\001\001\000\000\000\000\000\000\000\000\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\001\001\001\001\001\001\001\001\001\000\001\000\000\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\001\001\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\000\001\000\001\001\001\001\001\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\001\000\001\001\001\001\001\001\001\001\001\001\000\001\001\000\000\000\000\000\000\000\000\000\001\000\000\001\001\001\001\001\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\000\000\000\000\001\001\001\001\000\000\000\001\000\000\000\001\001\000\000\000\000\000\000\000\001\001\001\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\001\000\000\000\000\000\001\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\001\001\001\001\000\000\001\001\001\001\001\001\001\000\001\000\001\001\001\001\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\001\001\001\001\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\001\001\001\001\000\000\001\001\001\001\001\001\001\000\001\000\001\001\001\001\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\001\001\001\001\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\001\001\001\001\001\001\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\000\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\001\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\000\001\001\001\001\001\001\000\001\001\000\000\000\001\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\001\001\001\001\001\001\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\001\001\001\001\001\001\000\000\001\001\001\001\001\001\001\001\000\001\000\001\000\001\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\001\001\001\001\001\001\001\000\001\000\000\000\001\001\001\000\001\001\001\001\001\001\001\000\000\000\001\001\001\001\000\000\001\001\001\001\001\001\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\001\001\001\000\001\001\001\001\001\001\001" +let __sedlex_table_86 = "\001\000\002" +let __sedlex_table_6 = + "\001\001\001\001\001\001\001\001\001\001\000\001\001\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\000\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001" +let __sedlex_table_24 = + "\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002" +let __sedlex_table_31 = "\001\002\002\002\002\002\002\002\002\002" +let __sedlex_table_25 = + "\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\003" +let __sedlex_table_56 = + "\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\001\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002" +let __sedlex_table_44 = + "\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002" +let __sedlex_table_19 = + "\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002" +let __sedlex_table_40 = + "\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002" +let __sedlex_partition_94 c = + if c <= 120 then (-1) else if c <= 121 then 0 else (-1) +let __sedlex_partition_50 c = + if c <= 8191 + then (Char.code (String.unsafe_get __sedlex_table_1 (c - (-1)))) - 1 + else + if c <= 194559 + then + (if c <= 69599 + then + (if c <= 43711 + then + (if c <= 12703 + then + (if c <= 11519 + then + (if c <= 8489 + then + (if c <= 8454 + then + (if c <= 8304 + then + (if c <= 8238 + then + (if c <= 8231 + then (if c <= 8202 then 2 else 1) + else if c <= 8233 then 3 else 1) + else + if c <= 8286 + then (if c <= 8239 then 2 else 1) + else if c <= 8287 then 2 else 1) + else + if c <= 8335 + then + (if c <= 8318 + then (if c <= 8305 then 8 else 1) + else if c <= 8319 then 8 else 1) + else + if c <= 8449 + then (if c <= 8348 then 8 else 1) + else if c <= 8450 then 8 else 1) + else + if c <= 8477 + then + (if c <= 8468 + then + (if c <= 8457 + then (if c <= 8455 then 8 else 1) + else if c <= 8467 then 8 else 1) + else + if c <= 8471 + then (if c <= 8469 then 8 else 1) + else 8) + else + if c <= 8485 + then + (if c <= 8483 + then 1 + else if c <= 8484 then 8 else 1) + else + if c <= 8487 + then (if c <= 8486 then 8 else 1) + else if c <= 8488 then 8 else 1) + else + if c <= 8543 + then + (if c <= 8505 + then 8 + else + if c <= 8516 + then + (if c <= 8507 + then 1 + else if c <= 8511 then 8 else 1) + else + if c <= 8525 + then (if c <= 8521 then 8 else 1) + else if c <= 8526 then 8 else 1) + else + if c <= 11389 + then + (if c <= 8584 + then 8 + else if c <= 11263 then 1 else 8) + else + if c <= 11498 + then (if c <= 11492 then 8 else 1) + else + if c <= 11505 + then (if c <= 11502 then 8 else 1) + else if c <= 11507 then 8 else 1) + else + if c <= 12294 + then + (if c <= 11695 + then + (if c <= 11630 + then + (if c <= 11564 + then + (if c <= 11558 + then (if c <= 11557 then 8 else 1) + else if c <= 11559 then 8 else 1) + else + if c <= 11567 + then (if c <= 11565 then 8 else 1) + else if c <= 11623 then 8 else 1) + else + if c <= 11679 + then + (if c <= 11647 + then (if c <= 11631 then 8 else 1) + else if c <= 11670 then 8 else 1) + else + if c <= 11687 + then (if c <= 11686 then 8 else 1) + else if c <= 11694 then 8 else 1) + else + if c <= 11727 + then + (if c <= 11711 + then + (if c <= 11703 + then (if c <= 11702 then 8 else 1) + else if c <= 11710 then 8 else 1) + else + if c <= 11719 + then (if c <= 11718 then 8 else 1) + else if c <= 11726 then 8 else 1) + else + if c <= 12287 + then + (if c <= 11735 + then (if c <= 11734 then 8 else 1) + else if c <= 11742 then 8 else 1) + else + if c <= 12292 + then (if c <= 12288 then 2 else 1) + else 8) + else + if c <= 12442 + then + (if c <= 12343 + then + (if c <= 12320 + then (if c <= 12295 then 8 else 1) + else + if c <= 12336 + then (if c <= 12329 then 8 else 1) + else if c <= 12341 then 8 else 1) + else + if c <= 12348 + then 8 + else + if c <= 12352 + then 1 + else if c <= 12438 then 8 else 1) + else + if c <= 12539 + then + (if c <= 12447 + then 8 + else + if c <= 12448 + then 1 + else if c <= 12538 then 8 else 1) + else + if c <= 12548 + then (if c <= 12543 then 8 else 1) + else + if c <= 12592 + then (if c <= 12591 then 8 else 1) + else if c <= 12686 then 8 else 1) + else + if c <= 42999 + then + (if c <= 42653 + then + (if c <= 42239 + then + (if c <= 40981 + then + (if c <= 13311 + then + (if c <= 12783 + then (if c <= 12735 then 8 else 1) + else if c <= 12799 then 8 else 1) + else + if c <= 19967 + then (if c <= 19903 then 8 else 1) + else 8) + else + if c <= 42191 + then (if c <= 42124 then 8 else 1) + else if c <= 42237 then 8 else 1) + else + if c <= 42559 + then + (if c <= 42511 + then (if c <= 42508 then 8 else 1) + else + if c <= 42537 + then (if c <= 42527 then 8 else 1) + else if c <= 42539 then 8 else 1) + else + if c <= 42622 + then (if c <= 42606 then 8 else 1) + else 8) + else + if c <= 42890 + then + (if c <= 42785 + then + (if c <= 42735 + then (if c <= 42655 then 1 else 8) + else + if c <= 42774 + then 1 + else if c <= 42783 then 8 else 1) + else + if c <= 42887 + then 8 + else if c <= 42888 then 8 else 1) + else + if c <= 42962 + then + (if c <= 42954 + then 8 + else + if c <= 42959 + then 1 + else if c <= 42961 then 8 else 1) + else + if c <= 42993 + then + (if c <= 42964 + then (if c <= 42963 then 8 else 1) + else if c <= 42969 then 8 else 1) + else 8) + else + if c <= 43470 + then + (if c <= 43137 + then + (if c <= 43010 + then + (if c <= 43002 + then 8 + else if c <= 43009 then 8 else 1) + else + if c <= 43019 + then + (if c <= 43014 + then (if c <= 43013 then 8 else 1) + else if c <= 43018 then 8 else 1) + else + if c <= 43071 + then (if c <= 43042 then 8 else 1) + else if c <= 43123 then 8 else 1) + else + if c <= 43273 + then + (if c <= 43258 + then + (if c <= 43249 + then (if c <= 43187 then 8 else 1) + else if c <= 43255 then 8 else 1) + else + if c <= 43260 + then (if c <= 43259 then 8 else 1) + else if c <= 43262 then 8 else 1) + else + if c <= 43359 + then + (if c <= 43311 + then (if c <= 43301 then 8 else 1) + else if c <= 43334 then 8 else 1) + else + if c <= 43395 + then (if c <= 43388 then 8 else 1) + else if c <= 43442 then 8 else 1) + else + if c <= 43615 + then + (if c <= 43513 + then + (if c <= 43493 + then + (if c <= 43487 + then (if c <= 43471 then 8 else 1) + else if c <= 43492 then 8 else 1) + else if c <= 43503 then 8 else 1) + else + if c <= 43583 + then + (if c <= 43519 + then (if c <= 43518 then 8 else 1) + else if c <= 43560 then 8 else 1) + else + if c <= 43587 + then (if c <= 43586 then 8 else 1) + else if c <= 43595 then 8 else 1) + else + if c <= 43645 + then + (if c <= 43638 + then 8 + else + if c <= 43641 + then 1 + else if c <= 43642 then 8 else 1) + else + if c <= 43700 + then + (if c <= 43696 + then (if c <= 43695 then 8 else 1) + else if c <= 43697 then 8 else 1) + else + if c <= 43704 + then (if c <= 43702 then 8 else 1) + else if c <= 43709 then 8 else 1) + else + if c <= 66377 + then + (if c <= 64325 + then + (if c <= 43887 + then + (if c <= 43784 + then + (if c <= 43743 + then + (if c <= 43738 + then + (if c <= 43713 + then (if c <= 43712 then 8 else 1) + else if c <= 43714 then 8 else 1) + else if c <= 43741 then 8 else 1) + else + if c <= 43764 + then + (if c <= 43761 + then (if c <= 43754 then 8 else 1) + else 8) + else + if c <= 43776 + then 1 + else if c <= 43782 then 8 else 1) + else + if c <= 43823 + then + (if c <= 43807 + then + (if c <= 43792 + then (if c <= 43790 then 8 else 1) + else if c <= 43798 then 8 else 1) + else + if c <= 43815 + then (if c <= 43814 then 8 else 1) + else if c <= 43822 then 8 else 1) + else + if c <= 43880 + then + (if c <= 43867 + then (if c <= 43866 then 8 else 1) + else 8) + else if c <= 43881 then 8 else 1) + else + if c <= 64274 + then + (if c <= 55242 + then + (if c <= 44031 + then (if c <= 44002 then 8 else 1) + else + if c <= 55215 + then (if c <= 55203 then 8 else 1) + else if c <= 55238 then 8 else 1) + else + if c <= 64111 + then + (if c <= 63743 + then (if c <= 55291 then 8 else 1) + else if c <= 64109 then 8 else 1) + else + if c <= 64255 + then (if c <= 64217 then 8 else 1) + else if c <= 64262 then 8 else 1) + else + if c <= 64311 + then + (if c <= 64286 + then + (if c <= 64284 + then (if c <= 64279 then 8 else 1) + else if c <= 64285 then 8 else 1) + else + if c <= 64297 + then (if c <= 64296 then 8 else 1) + else if c <= 64310 then 8 else 1) + else + if c <= 64319 + then + (if c <= 64317 + then (if c <= 64316 then 8 else 1) + else if c <= 64318 then 8 else 1) + else + if c <= 64322 + then (if c <= 64321 then 8 else 1) + else if c <= 64324 then 8 else 1) + else + if c <= 65481 + then + (if c <= 65312 + then + (if c <= 65007 + then + (if c <= 64847 + then + (if c <= 64466 + then (if c <= 64433 then 8 else 1) + else if c <= 64829 then 8 else 1) + else + if c <= 64913 + then (if c <= 64911 then 8 else 1) + else if c <= 64967 then 8 else 1) + else + if c <= 65141 + then + (if c <= 65135 + then (if c <= 65019 then 8 else 1) + else if c <= 65140 then 8 else 1) + else + if c <= 65278 + then (if c <= 65276 then 8 else 1) + else if c <= 65279 then 2 else 1) + else + if c <= 65437 + then + (if c <= 65381 + then + (if c <= 65344 + then (if c <= 65338 then 8 else 1) + else if c <= 65370 then 8 else 1) + else 8) + else + if c <= 65470 + then 8 + else + if c <= 65473 + then 1 + else if c <= 65479 then 8 else 1) + else + if c <= 65615 + then + (if c <= 65548 + then + (if c <= 65497 + then + (if c <= 65489 + then (if c <= 65487 then 8 else 1) + else if c <= 65495 then 8 else 1) + else + if c <= 65535 + then (if c <= 65500 then 8 else 1) + else if c <= 65547 then 8 else 1) + else + if c <= 65595 + then + (if c <= 65575 + then (if c <= 65574 then 8 else 1) + else if c <= 65594 then 8 else 1) + else + if c <= 65598 + then (if c <= 65597 then 8 else 1) + else if c <= 65613 then 8 else 1) + else + if c <= 66207 + then + (if c <= 65855 + then + (if c <= 65663 + then (if c <= 65629 then 8 else 1) + else if c <= 65786 then 8 else 1) + else + if c <= 66175 + then (if c <= 65908 then 8 else 1) + else if c <= 66204 then 8 else 1) + else + if c <= 66348 + then + (if c <= 66303 + then (if c <= 66256 then 8 else 1) + else if c <= 66335 then 8 else 1) + else 8) + else + if c <= 67646 + then + (if c <= 66963 + then + (if c <= 66717 + then + (if c <= 66463 + then + (if c <= 66383 + then (if c <= 66378 then 8 else 1) + else + if c <= 66431 + then (if c <= 66421 then 8 else 1) + else if c <= 66461 then 8 else 1) + else + if c <= 66512 + then + (if c <= 66503 + then (if c <= 66499 then 8 else 1) + else if c <= 66511 then 8 else 1) + else + if c <= 66559 + then (if c <= 66517 then 8 else 1) + else 8) + else + if c <= 66863 + then + (if c <= 66775 + then + (if c <= 66735 + then 1 + else if c <= 66771 then 8 else 1) + else + if c <= 66815 + then (if c <= 66811 then 8 else 1) + else if c <= 66855 then 8 else 1) + else + if c <= 66939 + then + (if c <= 66927 + then (if c <= 66915 then 8 else 1) + else if c <= 66938 then 8 else 1) + else + if c <= 66955 + then (if c <= 66954 then 8 else 1) + else if c <= 66962 then 8 else 1) + else + if c <= 67455 + then + (if c <= 67002 + then + (if c <= 66978 + then + (if c <= 66966 + then (if c <= 66965 then 8 else 1) + else if c <= 66977 then 8 else 1) + else + if c <= 66994 + then (if c <= 66993 then 8 else 1) + else if c <= 67001 then 8 else 1) + else + if c <= 67391 + then + (if c <= 67071 + then (if c <= 67004 then 8 else 1) + else if c <= 67382 then 8 else 1) + else + if c <= 67423 + then (if c <= 67413 then 8 else 1) + else if c <= 67431 then 8 else 1) + else + if c <= 67591 + then + (if c <= 67505 + then + (if c <= 67462 + then (if c <= 67461 then 8 else 1) + else if c <= 67504 then 8 else 1) + else + if c <= 67583 + then (if c <= 67514 then 8 else 1) + else if c <= 67589 then 8 else 1) + else + if c <= 67638 + then + (if c <= 67593 + then (if c <= 67592 then 8 else 1) + else if c <= 67637 then 8 else 1) + else + if c <= 67643 + then (if c <= 67640 then 8 else 1) + else if c <= 67644 then 8 else 1) + else + if c <= 68296 + then + (if c <= 68029 + then + (if c <= 67827 + then + (if c <= 67711 + then + (if c <= 67679 + then (if c <= 67669 then 8 else 1) + else if c <= 67702 then 8 else 1) + else + if c <= 67807 + then (if c <= 67742 then 8 else 1) + else if c <= 67826 then 8 else 1) + else + if c <= 67871 + then + (if c <= 67839 + then (if c <= 67829 then 8 else 1) + else if c <= 67861 then 8 else 1) + else + if c <= 67967 + then (if c <= 67897 then 8 else 1) + else if c <= 68023 then 8 else 1) + else + if c <= 68120 + then + (if c <= 68111 + then + (if c <= 68095 + then (if c <= 68031 then 8 else 1) + else if c <= 68096 then 8 else 1) + else + if c <= 68116 + then (if c <= 68115 then 8 else 1) + else if c <= 68119 then 8 else 1) + else + if c <= 68223 + then + (if c <= 68191 + then (if c <= 68149 then 8 else 1) + else if c <= 68220 then 8 else 1) + else + if c <= 68287 + then (if c <= 68252 then 8 else 1) + else if c <= 68295 then 8 else 1) + else + if c <= 68863 + then + (if c <= 68479 + then + (if c <= 68415 + then + (if c <= 68351 + then (if c <= 68324 then 8 else 1) + else if c <= 68405 then 8 else 1) + else + if c <= 68447 + then (if c <= 68437 then 8 else 1) + else if c <= 68466 then 8 else 1) + else + if c <= 68735 + then + (if c <= 68607 + then (if c <= 68497 then 8 else 1) + else if c <= 68680 then 8 else 1) + else + if c <= 68799 + then (if c <= 68786 then 8 else 1) + else if c <= 68850 then 8 else 1) + else + if c <= 69414 + then + (if c <= 69295 + then + (if c <= 69247 + then (if c <= 68899 then 8 else 1) + else if c <= 69289 then 8 else 1) + else + if c <= 69375 + then (if c <= 69297 then 8 else 1) + else if c <= 69404 then 8 else 1) + else + if c <= 69487 + then + (if c <= 69423 + then (if c <= 69415 then 8 else 1) + else if c <= 69445 then 8 else 1) + else + if c <= 69551 + then (if c <= 69505 then 8 else 1) + else if c <= 69572 then 8 else 1) + else + if c <= 120122 + then + (if c <= 72348 + then + (if c <= 70655 + then + (if c <= 70162 + then + (if c <= 69958 + then + (if c <= 69762 + then + (if c <= 69744 + then + (if c <= 69634 + then (if c <= 69622 then 8 else 1) + else if c <= 69687 then 8 else 1) + else + if c <= 69748 + then (if c <= 69746 then 8 else 1) + else if c <= 69749 then 8 else 1) + else + if c <= 69890 + then + (if c <= 69839 + then (if c <= 69807 then 8 else 1) + else if c <= 69864 then 8 else 1) + else + if c <= 69955 + then (if c <= 69926 then 8 else 1) + else if c <= 69956 then 8 else 1) + else + if c <= 70080 + then + (if c <= 70005 + then + (if c <= 69967 + then (if c <= 69959 then 8 else 1) + else if c <= 70002 then 8 else 1) + else + if c <= 70018 + then (if c <= 70006 then 8 else 1) + else if c <= 70066 then 8 else 1) + else + if c <= 70107 + then + (if c <= 70105 + then (if c <= 70084 then 8 else 1) + else if c <= 70106 then 8 else 1) + else + if c <= 70143 + then (if c <= 70108 then 8 else 1) + else if c <= 70161 then 8 else 1) + else + if c <= 70414 + then + (if c <= 70286 + then + (if c <= 70279 + then + (if c <= 70271 + then (if c <= 70187 then 8 else 1) + else if c <= 70278 then 8 else 1) + else + if c <= 70281 + then (if c <= 70280 then 8 else 1) + else if c <= 70285 then 8 else 1) + else + if c <= 70319 + then + (if c <= 70302 + then (if c <= 70301 then 8 else 1) + else if c <= 70312 then 8 else 1) + else + if c <= 70404 + then (if c <= 70366 then 8 else 1) + else if c <= 70412 then 8 else 1) + else + if c <= 70452 + then + (if c <= 70441 + then + (if c <= 70418 + then (if c <= 70416 then 8 else 1) + else if c <= 70440 then 8 else 1) + else + if c <= 70449 + then (if c <= 70448 then 8 else 1) + else if c <= 70451 then 8 else 1) + else + if c <= 70479 + then + (if c <= 70460 + then (if c <= 70457 then 8 else 1) + else if c <= 70461 then 8 else 1) + else + if c <= 70492 + then (if c <= 70480 then 8 else 1) + else if c <= 70497 then 8 else 1) + else + if c <= 71934 + then + (if c <= 71167 + then + (if c <= 70851 + then + (if c <= 70750 + then + (if c <= 70726 + then (if c <= 70708 then 8 else 1) + else if c <= 70730 then 8 else 1) + else + if c <= 70783 + then (if c <= 70753 then 8 else 1) + else if c <= 70831 then 8 else 1) + else + if c <= 71039 + then + (if c <= 70854 + then (if c <= 70853 then 8 else 1) + else if c <= 70855 then 8 else 1) + else + if c <= 71127 + then (if c <= 71086 then 8 else 1) + else if c <= 71131 then 8 else 1) + else + if c <= 71423 + then + (if c <= 71295 + then + (if c <= 71235 + then (if c <= 71215 then 8 else 1) + else if c <= 71236 then 8 else 1) + else + if c <= 71351 + then (if c <= 71338 then 8 else 1) + else if c <= 71352 then 8 else 1) + else + if c <= 71679 + then + (if c <= 71487 + then (if c <= 71450 then 8 else 1) + else if c <= 71494 then 8 else 1) + else + if c <= 71839 + then (if c <= 71723 then 8 else 1) + else if c <= 71903 then 8 else 1) + else + if c <= 72105 + then + (if c <= 71959 + then + (if c <= 71947 + then + (if c <= 71944 + then (if c <= 71942 then 8 else 1) + else if c <= 71945 then 8 else 1) + else + if c <= 71956 + then (if c <= 71955 then 8 else 1) + else if c <= 71958 then 8 else 1) + else + if c <= 72000 + then + (if c <= 71998 + then (if c <= 71983 then 8 else 1) + else if c <= 71999 then 8 else 1) + else + if c <= 72095 + then (if c <= 72001 then 8 else 1) + else if c <= 72103 then 8 else 1) + else + if c <= 72202 + then + (if c <= 72162 + then + (if c <= 72160 + then (if c <= 72144 then 8 else 1) + else if c <= 72161 then 8 else 1) + else + if c <= 72191 + then (if c <= 72163 then 8 else 1) + else if c <= 72192 then 8 else 1) + else + if c <= 72271 + then + (if c <= 72249 + then (if c <= 72242 then 8 else 1) + else if c <= 72250 then 8 else 1) + else + if c <= 72283 + then (if c <= 72272 then 8 else 1) + else if c <= 72329 then 8 else 1) + else + if c <= 94031 + then + (if c <= 73727 + then + (if c <= 72970 + then + (if c <= 72767 + then + (if c <= 72703 + then + (if c <= 72367 + then (if c <= 72349 then 8 else 1) + else if c <= 72440 then 8 else 1) + else + if c <= 72713 + then (if c <= 72712 then 8 else 1) + else if c <= 72750 then 8 else 1) + else + if c <= 72959 + then + (if c <= 72817 + then (if c <= 72768 then 8 else 1) + else if c <= 72847 then 8 else 1) + else + if c <= 72967 + then (if c <= 72966 then 8 else 1) + else if c <= 72969 then 8 else 1) + else + if c <= 73065 + then + (if c <= 73055 + then + (if c <= 73029 + then (if c <= 73008 then 8 else 1) + else if c <= 73030 then 8 else 1) + else + if c <= 73062 + then (if c <= 73061 then 8 else 1) + else if c <= 73064 then 8 else 1) + else + if c <= 73439 + then + (if c <= 73111 + then (if c <= 73097 then 8 else 1) + else if c <= 73112 then 8 else 1) + else + if c <= 73647 + then (if c <= 73458 then 8 else 1) + else if c <= 73648 then 8 else 1) + else + if c <= 92783 + then + (if c <= 77823 + then + (if c <= 74879 + then + (if c <= 74751 + then (if c <= 74649 then 8 else 1) + else if c <= 74862 then 8 else 1) + else + if c <= 77711 + then (if c <= 75075 then 8 else 1) + else if c <= 77808 then 8 else 1) + else + if c <= 92159 + then + (if c <= 82943 + then (if c <= 78894 then 8 else 1) + else if c <= 83526 then 8 else 1) + else + if c <= 92735 + then (if c <= 92728 then 8 else 1) + else if c <= 92766 then 8 else 1) + else + if c <= 93026 + then + (if c <= 92927 + then + (if c <= 92879 + then (if c <= 92862 then 8 else 1) + else if c <= 92909 then 8 else 1) + else + if c <= 92991 + then (if c <= 92975 then 8 else 1) + else if c <= 92995 then 8 else 1) + else + if c <= 93759 + then + (if c <= 93052 + then (if c <= 93047 then 8 else 1) + else if c <= 93071 then 8 else 1) + else + if c <= 93951 + then (if c <= 93823 then 8 else 1) + else if c <= 94026 then 8 else 1) + else + if c <= 113791 + then + (if c <= 110580 + then + (if c <= 94207 + then + (if c <= 94175 + then + (if c <= 94098 + then (if c <= 94032 then 8 else 1) + else if c <= 94111 then 8 else 1) + else + if c <= 94178 + then (if c <= 94177 then 8 else 1) + else if c <= 94179 then 8 else 1) + else + if c <= 101631 + then + (if c <= 100351 + then (if c <= 100343 then 8 else 1) + else if c <= 101589 then 8 else 1) + else + if c <= 110575 + then (if c <= 101640 then 8 else 1) + else if c <= 110579 then 8 else 1) + else + if c <= 110947 + then + (if c <= 110591 + then + (if c <= 110588 + then (if c <= 110587 then 8 else 1) + else if c <= 110590 then 8 else 1) + else + if c <= 110927 + then (if c <= 110882 then 8 else 1) + else if c <= 110930 then 8 else 1) + else + if c <= 113663 + then + (if c <= 110959 + then (if c <= 110951 then 8 else 1) + else if c <= 111355 then 8 else 1) + else + if c <= 113775 + then (if c <= 113770 then 8 else 1) + else if c <= 113788 then 8 else 1) + else + if c <= 119981 + then + (if c <= 119965 + then + (if c <= 119807 + then + (if c <= 113807 + then (if c <= 113800 then 8 else 1) + else if c <= 113817 then 8 else 1) + else + if c <= 119893 + then (if c <= 119892 then 8 else 1) + else if c <= 119964 then 8 else 1) + else + if c <= 119972 + then + (if c <= 119969 + then (if c <= 119967 then 8 else 1) + else if c <= 119970 then 8 else 1) + else + if c <= 119976 + then (if c <= 119974 then 8 else 1) + else if c <= 119980 then 8 else 1) + else + if c <= 120070 + then + (if c <= 119996 + then + (if c <= 119994 + then (if c <= 119993 then 8 else 1) + else if c <= 119995 then 8 else 1) + else + if c <= 120004 + then (if c <= 120003 then 8 else 1) + else if c <= 120069 then 8 else 1) + else + if c <= 120085 + then + (if c <= 120076 + then (if c <= 120074 then 8 else 1) + else if c <= 120084 then 8 else 1) + else + if c <= 120093 + then (if c <= 120092 then 8 else 1) + else if c <= 120121 then 8 else 1) + else + if c <= 131071 + then + (if c <= 126468 + then + (if c <= 122623 + then + (if c <= 120571 + then + (if c <= 120145 + then + (if c <= 120133 + then + (if c <= 120127 + then (if c <= 120126 then 8 else 1) + else if c <= 120132 then 8 else 1) + else + if c <= 120137 + then (if c <= 120134 then 8 else 1) + else if c <= 120144 then 8 else 1) + else + if c <= 120513 + then + (if c <= 120487 + then (if c <= 120485 then 8 else 1) + else if c <= 120512 then 8 else 1) + else + if c <= 120539 + then (if c <= 120538 then 8 else 1) + else if c <= 120570 then 8 else 1) + else + if c <= 120687 + then + (if c <= 120629 + then + (if c <= 120597 + then (if c <= 120596 then 8 else 1) + else if c <= 120628 then 8 else 1) + else + if c <= 120655 + then (if c <= 120654 then 8 else 1) + else if c <= 120686 then 8 else 1) + else + if c <= 120745 + then + (if c <= 120713 + then (if c <= 120712 then 8 else 1) + else if c <= 120744 then 8 else 1) + else + if c <= 120771 + then (if c <= 120770 then 8 else 1) + else if c <= 120779 then 8 else 1) + else + if c <= 124895 + then + (if c <= 123190 + then + (if c <= 122654 + then 8 + else + if c <= 123135 + then 1 + else if c <= 123180 then 8 else 1) + else + if c <= 123535 + then + (if c <= 123213 + then (if c <= 123197 then 8 else 1) + else if c <= 123214 then 8 else 1) + else + if c <= 123583 + then (if c <= 123565 then 8 else 1) + else if c <= 123627 then 8 else 1) + else + if c <= 124927 + then + (if c <= 124908 + then + (if c <= 124903 + then (if c <= 124902 then 8 else 1) + else if c <= 124907 then 8 else 1) + else + if c <= 124911 + then (if c <= 124910 then 8 else 1) + else if c <= 124926 then 8 else 1) + else + if c <= 125258 + then + (if c <= 125183 + then (if c <= 125124 then 8 else 1) + else if c <= 125251 then 8 else 1) + else + if c <= 126463 + then (if c <= 125259 then 8 else 1) + else if c <= 126467 then 8 else 1) + else + if c <= 126552 + then + (if c <= 126529 + then + (if c <= 126504 + then + (if c <= 126499 + then + (if c <= 126496 + then (if c <= 126495 then 8 else 1) + else if c <= 126498 then 8 else 1) + else + if c <= 126502 + then (if c <= 126500 then 8 else 1) + else if c <= 126503 then 8 else 1) + else + if c <= 126520 + then + (if c <= 126515 + then (if c <= 126514 then 8 else 1) + else if c <= 126519 then 8 else 1) + else + if c <= 126522 + then (if c <= 126521 then 8 else 1) + else if c <= 126523 then 8 else 1) + else + if c <= 126540 + then + (if c <= 126536 + then + (if c <= 126534 + then (if c <= 126530 then 8 else 1) + else if c <= 126535 then 8 else 1) + else + if c <= 126538 + then (if c <= 126537 then 8 else 1) + else if c <= 126539 then 8 else 1) + else + if c <= 126547 + then + (if c <= 126544 + then (if c <= 126543 then 8 else 1) + else if c <= 126546 then 8 else 1) + else + if c <= 126550 + then (if c <= 126548 then 8 else 1) + else if c <= 126551 then 8 else 1) + else + if c <= 126579 + then + (if c <= 126560 + then + (if c <= 126556 + then + (if c <= 126554 + then (if c <= 126553 then 8 else 1) + else if c <= 126555 then 8 else 1) + else + if c <= 126558 + then (if c <= 126557 then 8 else 1) + else if c <= 126559 then 8 else 1) + else + if c <= 126566 + then + (if c <= 126563 + then (if c <= 126562 then 8 else 1) + else if c <= 126564 then 8 else 1) + else + if c <= 126571 + then (if c <= 126570 then 8 else 1) + else if c <= 126578 then 8 else 1) + else + if c <= 126602 + then + (if c <= 126589 + then + (if c <= 126584 + then (if c <= 126583 then 8 else 1) + else if c <= 126588 then 8 else 1) + else + if c <= 126591 + then (if c <= 126590 then 8 else 1) + else if c <= 126601 then 8 else 1) + else + if c <= 126628 + then + (if c <= 126624 + then (if c <= 126619 then 8 else 1) + else if c <= 126627 then 8 else 1) + else + if c <= 126634 + then (if c <= 126633 then 8 else 1) + else if c <= 126651 then 8 else 1) + else + if c <= 183983 + then + (if c <= 177983 + then + (if c <= 173823 + then (if c <= 173791 then 8 else 1) + else if c <= 177976 then 8 else 1) + else + if c <= 178207 + then (if c <= 178205 then 8 else 1) + else if c <= 183969 then 8 else 1) + else if c <= 191456 then 8 else 1) + else (-1) +let __sedlex_partition_58 c = + if c <= 45 then (-1) else if c <= 46 then 0 else (-1) +let __sedlex_partition_51 c = + if c <= 8 + then (-1) + else + if c <= 5760 + then (Char.code (String.unsafe_get __sedlex_table_2 (c - 9))) - 1 + else + if c <= 8191 + then (-1) + else + if c <= 65279 + then + (if c <= 12288 + then + (if c <= 8239 + then (if c <= 8202 then 0 else if c <= 8238 then (-1) else 0) + else + if c <= 8286 + then (-1) + else if c <= 8287 then 0 else if c <= 12287 then (-1) else 0) + else if c <= 65278 then (-1) else 0) + else (-1) +let __sedlex_partition_21 c = + if c <= (-1) + then (-1) + else + if c <= 95 + then (Char.code (String.unsafe_get __sedlex_table_3 c)) - 1 + else if c <= 96 then (-1) else 0 +let __sedlex_partition_91 c = + if c <= 63 then (-1) else if c <= 64 then 0 else (-1) +let __sedlex_partition_112 c = + if c <= 47 + then (-1) + else + if c <= 120 + then (Char.code (String.unsafe_get __sedlex_table_4 (c - 48))) - 1 + else (-1) +let __sedlex_partition_33 c = + if c <= 47 then (-1) else if c <= 57 then 0 else (-1) +let __sedlex_partition_102 c = + if c <= 91 + then (-1) + else + if c <= 93 + then (Char.code (String.unsafe_get __sedlex_table_5 (c - 92))) - 1 + else (-1) +let __sedlex_partition_104 c = + if c <= (-1) + then (-1) + else + if c <= 90 + then (Char.code (String.unsafe_get __sedlex_table_6 c)) - 1 + else + if c <= 92 + then (-1) + else if c <= 8231 then 0 else if c <= 8233 then (-1) else 0 +let __sedlex_partition_4 c = + if c <= 47 + then (-1) + else + if c <= 102 + then (Char.code (String.unsafe_get __sedlex_table_7 (c - 48))) - 1 + else (-1) +let __sedlex_partition_18 c = + if c <= 92 + then (Char.code (String.unsafe_get __sedlex_table_8 (c - (-1)))) - 1 + else 1 +let __sedlex_partition_42 c = + if c <= 47 + then (-1) + else + if c <= 110 + then (Char.code (String.unsafe_get __sedlex_table_9 (c - 48))) - 1 + else (-1) +let __sedlex_partition_129 c = + if c <= 61 then (-1) else if c <= 62 then 0 else (-1) +let __sedlex_partition_130 c = + if c <= 123 then (-1) else if c <= 124 then 0 else (-1) +let __sedlex_partition_113 c = + if c <= 47 + then (-1) + else + if c <= 59 + then (Char.code (String.unsafe_get __sedlex_table_10 (c - 48))) - 1 + else (-1) +let __sedlex_partition_115 c = + if c <= 35 + then (-1) + else + if c <= 122 + then (Char.code (String.unsafe_get __sedlex_table_11 (c - 36))) - 1 + else (-1) +let __sedlex_partition_34 c = + if c <= 87 + then (-1) + else + if c <= 120 + then (Char.code (String.unsafe_get __sedlex_table_12 (c - 88))) - 1 + else (-1) +let __sedlex_partition_37 c = + if c <= 45 + then (-1) + else + if c <= 57 + then (Char.code (String.unsafe_get __sedlex_table_13 (c - 46))) - 1 + else (-1) +let __sedlex_partition_84 c = + if c <= 35 + then (-1) + else + if c <= 122 + then (Char.code (String.unsafe_get __sedlex_table_14 (c - 36))) - 1 + else (-1) +let __sedlex_partition_5 c = + if c <= 47 + then (-1) + else + if c <= 125 + then (Char.code (String.unsafe_get __sedlex_table_15 (c - 48))) - 1 + else (-1) +let __sedlex_partition_62 c = + if c <= 35 + then (-1) + else + if c <= 122 + then (Char.code (String.unsafe_get __sedlex_table_16 (c - 36))) - 1 + else (-1) +let __sedlex_partition_121 c = + if c <= 8 + then (-1) + else + if c <= 5760 + then (Char.code (String.unsafe_get __sedlex_table_17 (c - 9))) - 1 + else + if c <= 8191 + then (-1) + else + if c <= 65279 + then + (if c <= 12288 + then + (if c <= 8239 + then (if c <= 8202 then 0 else if c <= 8238 then (-1) else 0) + else + if c <= 8286 + then (-1) + else if c <= 8287 then 0 else if c <= 12287 then (-1) else 0) + else if c <= 65278 then (-1) else 0) + else (-1) +let __sedlex_partition_131 c = + if c <= 124 then (-1) else if c <= 125 then 0 else (-1) +let __sedlex_partition_43 c = + if c <= 45 + then (-1) + else + if c <= 101 + then (Char.code (String.unsafe_get __sedlex_table_18 (c - 46))) - 1 + else (-1) +let __sedlex_partition_56 c = + if c <= 42 + then (-1) + else + if c <= 61 + then (Char.code (String.unsafe_get __sedlex_table_19 (c - 43))) - 1 + else (-1) +let __sedlex_partition_7 c = + if c <= 92 + then (Char.code (String.unsafe_get __sedlex_table_20 (c - (-1)))) - 1 + else 1 +let __sedlex_partition_19 c = + if c <= (-1) + then (-1) + else + if c <= 91 + then (Char.code (String.unsafe_get __sedlex_table_21 c)) - 1 + else if c <= 92 then (-1) else 0 +let __sedlex_partition_105 c = + if c <= 35 + then (-1) + else + if c <= 122 + then (Char.code (String.unsafe_get __sedlex_table_22 (c - 36))) - 1 + else (-1) +let __sedlex_partition_57 c = + if c <= 44 + then (-1) + else + if c <= 61 + then (Char.code (String.unsafe_get __sedlex_table_23 (c - 45))) - 1 + else (-1) +let __sedlex_partition_127 c = + if c <= 103 then (-1) else if c <= 104 then 0 else (-1) +let __sedlex_partition_28 c = + if c <= 47 + then (-1) + else + if c <= 95 + then (Char.code (String.unsafe_get __sedlex_table_24 (c - 48))) - 1 + else (-1) +let __sedlex_partition_27 c = + if c <= 47 + then (-1) + else + if c <= 110 + then (Char.code (String.unsafe_get __sedlex_table_25 (c - 48))) - 1 + else (-1) +let __sedlex_partition_35 c = + if c <= 47 + then (-1) + else + if c <= 110 + then (Char.code (String.unsafe_get __sedlex_table_26 (c - 48))) - 1 + else (-1) +let __sedlex_partition_79 c = + if c <= 35 + then (-1) + else + if c <= 122 + then (Char.code (String.unsafe_get __sedlex_table_27 (c - 36))) - 1 + else (-1) +let __sedlex_partition_65 c = + if c <= 8 + then (-1) + else + if c <= 5760 + then (Char.code (String.unsafe_get __sedlex_table_28 (c - 9))) - 1 + else + if c <= 8191 + then (-1) + else + if c <= 65279 + then + (if c <= 12288 + then + (if c <= 8239 + then (if c <= 8202 then 0 else if c <= 8238 then (-1) else 0) + else + if c <= 8286 + then (-1) + else if c <= 8287 then 0 else if c <= 12287 then (-1) else 0) + else if c <= 65278 then (-1) else 0) + else (-1) +let __sedlex_partition_122 c = + if c <= 44 + then (-1) + else + if c <= 57 + then (Char.code (String.unsafe_get __sedlex_table_29 (c - 45))) - 1 + else (-1) +let __sedlex_partition_26 c = + if c <= 47 then (-1) else if c <= 49 then 0 else (-1) +let __sedlex_partition_31 c = + if c <= 47 + then (-1) + else + if c <= 95 + then (Char.code (String.unsafe_get __sedlex_table_30 (c - 48))) - 1 + else (-1) +let __sedlex_partition_40 c = + if c <= 47 + then (-1) + else + if c <= 57 + then (Char.code (String.unsafe_get __sedlex_table_31 (c - 48))) - 1 + else (-1) +let __sedlex_partition_86 c = + if c <= 35 + then (-1) + else + if c <= 122 + then (Char.code (String.unsafe_get __sedlex_table_32 (c - 36))) - 1 + else (-1) +let __sedlex_partition_93 c = + if c <= 114 then (-1) else if c <= 115 then 0 else (-1) +let __sedlex_partition_52 c = + if c <= 60 then (-1) else if c <= 61 then 0 else (-1) +let __sedlex_partition_110 c = + if c <= (-1) + then (-1) + else + if c <= 122 + then (Char.code (String.unsafe_get __sedlex_table_33 c)) - 1 + else + if c <= 123 + then (-1) + else if c <= 8231 then 0 else if c <= 8233 then (-1) else 0 +let __sedlex_partition_10 c = + if c <= (-1) + then (-1) + else + if c <= 41 + then (Char.code (String.unsafe_get __sedlex_table_34 c)) - 1 + else + if c <= 42 + then (-1) + else if c <= 8231 then 0 else if c <= 8233 then (-1) else 0 +let __sedlex_partition_88 c = + if c <= 59 + then (-1) + else + if c <= 61 + then (Char.code (String.unsafe_get __sedlex_table_5 (c - 60))) - 1 + else (-1) +let __sedlex_partition_41 c = + if c <= 47 + then (-1) + else + if c <= 110 + then (Char.code (String.unsafe_get __sedlex_table_35 (c - 48))) - 1 + else (-1) +let __sedlex_partition_92 c = + if c <= 96 + then (-1) + else + if c <= 105 + then (Char.code (String.unsafe_get __sedlex_table_36 (c - 97))) - 1 + else (-1) +let __sedlex_partition_30 c = + if c <= 47 + then (-1) + else + if c <= 110 + then (Char.code (String.unsafe_get __sedlex_table_37 (c - 48))) - 1 + else (-1) +let __sedlex_partition_89 c = + if c <= 60 + then (-1) + else + if c <= 62 + then (Char.code (String.unsafe_get __sedlex_table_5 (c - 61))) - 1 + else (-1) +let __sedlex_partition_22 c = + if c <= 122 then (-1) else if c <= 123 then 0 else (-1) +let __sedlex_partition_25 c = + if c <= 65 + then (-1) + else + if c <= 98 + then (Char.code (String.unsafe_get __sedlex_table_12 (c - 66))) - 1 + else (-1) +let __sedlex_partition_63 c = + if c <= 35 + then (-1) + else + if c <= 122 + then (Char.code (String.unsafe_get __sedlex_table_38 (c - 36))) - 1 + else (-1) +let __sedlex_partition_20 c = + if c <= 96 + then (Char.code (String.unsafe_get __sedlex_table_39 (c - (-1)))) - 1 + else 1 +let __sedlex_partition_96 c = + if c <= 115 then (-1) else if c <= 116 then 0 else (-1) +let __sedlex_partition_17 c = + if c <= 47 then (-1) else if c <= 55 then 0 else (-1) +let __sedlex_partition_72 c = + if c <= 109 then (-1) else if c <= 110 then 0 else (-1) +let __sedlex_partition_99 c = + if c <= 60 + then (-1) + else + if c <= 124 + then (Char.code (String.unsafe_get __sedlex_table_40 (c - 61))) - 1 + else (-1) +let __sedlex_partition_68 c = + if c <= 110 then (-1) else if c <= 111 then 0 else (-1) +let __sedlex_partition_73 c = + if c <= 98 then (-1) else if c <= 99 then 0 else (-1) +let __sedlex_partition_24 c = + if c <= 47 then (-1) else if c <= 48 then 0 else (-1) +let __sedlex_partition_123 c = + if c <= 8 + then (-1) + else + if c <= 5760 + then (Char.code (String.unsafe_get __sedlex_table_41 (c - 9))) - 1 + else + if c <= 8191 + then (-1) + else + if c <= 65279 + then + (if c <= 12288 + then + (if c <= 8239 + then (if c <= 8202 then 0 else if c <= 8238 then (-1) else 0) + else + if c <= 8286 + then (-1) + else if c <= 8287 then 0 else if c <= 12287 then (-1) else 0) + else if c <= 65278 then (-1) else 0) + else (-1) +let __sedlex_partition_45 c = + if c <= 45 + then (-1) + else + if c <= 101 + then (Char.code (String.unsafe_get __sedlex_table_42 (c - 46))) - 1 + else (-1) +let __sedlex_partition_29 c = + if c <= 78 + then (-1) + else + if c <= 111 + then (Char.code (String.unsafe_get __sedlex_table_12 (c - 79))) - 1 + else (-1) +let __sedlex_partition_23 c = + if c <= 41 then (-1) else if c <= 42 then 0 else (-1) +let __sedlex_partition_16 c = + if c <= 120 + then (Char.code (String.unsafe_get __sedlex_table_43 (c - (-1)))) - 1 + else if c <= 8233 then (if c <= 8231 then 1 else 2) else 1 +let __sedlex_partition_53 c = + if c <= 32 then (-1) else if c <= 33 then 0 else (-1) +let __sedlex_partition_54 c = + if c <= 37 + then (-1) + else + if c <= 61 + then (Char.code (String.unsafe_get __sedlex_table_44 (c - 38))) - 1 + else (-1) +let __sedlex_partition_106 c = + if c <= (-1) + then (-1) + else + if c <= 13 + then (Char.code (String.unsafe_get __sedlex_table_45 c)) - 1 + else if c <= 8233 then (if c <= 8231 then 0 else 1) else 0 +let __sedlex_partition_77 c = + if c <= 35 + then (-1) + else + if c <= 122 + then (Char.code (String.unsafe_get __sedlex_table_46 (c - 36))) - 1 + else (-1) +let __sedlex_partition_9 c = + if c <= (-1) + then (-1) + else + if c <= 42 + then (Char.code (String.unsafe_get __sedlex_table_47 c)) - 1 + else if c <= 8233 then (if c <= 8231 then 0 else 1) else 0 +let __sedlex_partition_44 c = + if c <= 47 + then (-1) + else + if c <= 101 + then (Char.code (String.unsafe_get __sedlex_table_48 (c - 48))) - 1 + else (-1) +let __sedlex_partition_59 c = + if c <= 35 + then (-1) + else + if c <= 122 + then (Char.code (String.unsafe_get __sedlex_table_49 (c - 36))) - 1 + else (-1) +let __sedlex_partition_55 c = + if c <= 41 + then (-1) + else + if c <= 61 + then (Char.code (String.unsafe_get __sedlex_table_50 (c - 42))) - 1 + else (-1) +let __sedlex_partition_95 c = + if c <= 72 then (-1) else if c <= 73 then 0 else (-1) +let __sedlex_partition_120 c = + if c <= 44 + then (-1) + else + if c <= 48 + then (Char.code (String.unsafe_get __sedlex_table_51 (c - 45))) - 1 + else (-1) +let __sedlex_partition_124 c = + if c <= 44 + then (-1) + else + if c <= 57 + then (Char.code (String.unsafe_get __sedlex_table_52 (c - 45))) - 1 + else (-1) +let __sedlex_partition_70 c = + if c <= 44 then (-1) else if c <= 45 then 0 else (-1) +let __sedlex_partition_71 c = + if c <= 104 then (-1) else if c <= 105 then 0 else (-1) +let __sedlex_partition_67 c = + if c <= 107 then (-1) else if c <= 108 then 0 else (-1) +let __sedlex_partition_74 c = + if c <= 99 then (-1) else if c <= 100 then 0 else (-1) +let __sedlex_partition_36 c = + if c <= 47 + then (-1) + else + if c <= 102 + then (Char.code (String.unsafe_get __sedlex_table_53 (c - 48))) - 1 + else (-1) +let __sedlex_partition_97 c = + if c <= 113 then (-1) else if c <= 114 then 0 else (-1) +let __sedlex_partition_47 c = + if c <= 45 + then (-1) + else + if c <= 57 + then (Char.code (String.unsafe_get __sedlex_table_54 (c - 46))) - 1 + else (-1) +let __sedlex_partition_80 c = + if c <= 35 + then (-1) + else + if c <= 122 + then (Char.code (String.unsafe_get __sedlex_table_55 (c - 36))) - 1 + else (-1) +let __sedlex_partition_3 c = + if c <= 47 + then (-1) + else + if c <= 123 + then (Char.code (String.unsafe_get __sedlex_table_56 (c - 48))) - 1 + else (-1) +let __sedlex_partition_90 c = + if c <= 45 + then (-1) + else + if c <= 63 + then (Char.code (String.unsafe_get __sedlex_table_57 (c - 46))) - 1 + else (-1) +let __sedlex_partition_8 c = + if c <= (-1) + then (-1) + else if c <= 91 then 0 else if c <= 92 then (-1) else 0 +let __sedlex_partition_15 c = + if c <= (-1) + then (-1) + else + if c <= 12 + then (Char.code (String.unsafe_get __sedlex_table_58 c)) - 1 + else + if c <= 13 + then (-1) + else if c <= 8231 then 0 else if c <= 8233 then (-1) else 0 +let __sedlex_partition_76 c = + if c <= 35 + then (-1) + else + if c <= 122 + then (Char.code (String.unsafe_get __sedlex_table_59 (c - 36))) - 1 + else (-1) +let __sedlex_partition_101 c = + if c <= (-1) + then (-1) + else + if c <= 91 + then (Char.code (String.unsafe_get __sedlex_table_60 c)) - 1 + else + if c <= 93 + then (-1) + else if c <= 8231 then 0 else if c <= 8233 then (-1) else 0 +let __sedlex_partition_107 c = + if c <= 8191 + then (Char.code (String.unsafe_get __sedlex_table_61 (c - (-1)))) - 1 + else + if c <= 12287 + then + (if c <= 8238 + then + (if c <= 8231 + then (if c <= 8202 then 2 else 1) + else if c <= 8233 then 3 else 1) + else + if c <= 8286 + then (if c <= 8239 then 2 else 1) + else if c <= 8287 then 2 else 1) + else + if c <= 65278 + then (if c <= 12288 then 2 else 1) + else if c <= 65279 then 2 else 1 +let __sedlex_partition_11 c = + if c <= 9 then (-1) else if c <= 10 then 0 else (-1) +let __sedlex_partition_82 c = + if c <= 35 + then (-1) + else + if c <= 122 + then (Char.code (String.unsafe_get __sedlex_table_62 (c - 36))) - 1 + else (-1) +let __sedlex_partition_98 c = + if c <= 96 then (-1) else if c <= 97 then 0 else (-1) +let __sedlex_partition_64 c = + if c <= 35 + then (-1) + else + if c <= 122 + then (Char.code (String.unsafe_get __sedlex_table_63 (c - 36))) - 1 + else (-1) +let __sedlex_partition_132 c = + if c <= 35 + then (-1) + else + if c <= 8188 + then (Char.code (String.unsafe_get __sedlex_table_64 (c - 36))) - 1 + else + if c <= 8304 + then (-1) + else + if c <= 201546 + then + (if c <= 69864 + then + (if c <= 43754 + then + (if c <= 40981 + then + (if c <= 11623 + then + (if c <= 8504 + then + (if c <= 8472 + then + (if c <= 8450 + then + (if c <= 8319 + then + (if c <= 8305 + then 0 + else if c <= 8318 then (-1) else 0) + else + if c <= 8335 + then (-1) + else + if c <= 8348 + then 0 + else if c <= 8449 then (-1) else 0) + else + if c <= 8454 + then (-1) + else + if c <= 8467 + then + (if c <= 8455 + then 0 + else if c <= 8457 then (-1) else 0) + else + if c <= 8468 + then (-1) + else + if c <= 8469 + then 0 + else if c <= 8471 then (-1) else 0) + else + if c <= 8488 + then + (if c <= 8484 + then + (if c <= 8477 + then 0 + else if c <= 8483 then (-1) else 0) + else + if c <= 8485 + then (-1) + else + if c <= 8486 + then 0 + else if c <= 8487 then (-1) else 0) + else if c <= 8489 then (-1) else 0) + else + if c <= 11387 + then + (if c <= 8526 + then + (if c <= 8511 + then + (if c <= 8505 + then 0 + else if c <= 8507 then (-1) else 0) + else + if c <= 8516 + then (-1) + else + if c <= 8521 + then 0 + else if c <= 8525 then (-1) else 0) + else + if c <= 8543 + then (-1) + else + if c <= 8580 + then 0 + else + if c <= 8584 + then 0 + else if c <= 11263 then (-1) else 0) + else + if c <= 11507 + then + (if c <= 11492 + then 0 + else + if c <= 11498 + then (-1) + else + if c <= 11502 + then 0 + else if c <= 11505 then (-1) else 0) + else + if c <= 11519 + then (-1) + else + if c <= 11559 + then + (if c <= 11557 + then 0 + else if c <= 11558 then (-1) else 0) + else + if c <= 11564 + then (-1) + else + if c <= 11565 + then 0 + else if c <= 11567 then (-1) else 0) + else + if c <= 11630 + then (-1) + else + if c <= 12346 + then + (if c <= 11726 + then + (if c <= 11694 + then + (if c <= 11670 + then + (if c <= 11631 + then 0 + else if c <= 11647 then (-1) else 0) + else + if c <= 11679 + then (-1) + else + if c <= 11686 + then 0 + else if c <= 11687 then (-1) else 0) + else + if c <= 11695 + then (-1) + else + if c <= 11710 + then + (if c <= 11702 + then 0 + else if c <= 11703 then (-1) else 0) + else + if c <= 11711 + then (-1) + else + if c <= 11718 + then 0 + else if c <= 11719 then (-1) else 0) + else + if c <= 11727 + then (-1) + else + if c <= 12294 + then + (if c <= 11742 + then + (if c <= 11734 + then 0 + else if c <= 11735 then (-1) else 0) + else if c <= 12292 then (-1) else 0) + else + if c <= 12329 + then + (if c <= 12295 + then 0 + else if c <= 12320 then (-1) else 0) + else + if c <= 12336 + then (-1) + else + if c <= 12341 + then 0 + else if c <= 12343 then (-1) else 0) + else + if c <= 12542 + then + (if c <= 12444 + then + (if c <= 12348 + then 0 + else + if c <= 12352 + then (-1) + else + if c <= 12438 + then 0 + else if c <= 12442 then (-1) else 0) + else + if c <= 12447 + then 0 + else + if c <= 12448 + then (-1) + else + if c <= 12538 + then 0 + else if c <= 12539 then (-1) else 0) + else + if c <= 12735 + then + (if c <= 12591 + then + (if c <= 12543 + then 0 + else if c <= 12548 then (-1) else 0) + else + if c <= 12592 + then (-1) + else + if c <= 12686 + then 0 + else if c <= 12703 then (-1) else 0) + else + if c <= 12783 + then (-1) + else + if c <= 19903 + then + (if c <= 12799 + then 0 + else if c <= 13311 then (-1) else 0) + else if c <= 19967 then (-1) else 0) + else + if c <= 43013 + then + (if c <= 42863 + then + (if c <= 42605 + then + (if c <= 42507 + then + (if c <= 42231 + then + (if c <= 42124 + then 0 + else if c <= 42191 then (-1) else 0) + else + if c <= 42237 + then 0 + else if c <= 42239 then (-1) else 0) + else + if c <= 42527 + then + (if c <= 42508 + then 0 + else if c <= 42511 then (-1) else 0) + else + if c <= 42537 + then (-1) + else + if c <= 42539 + then 0 + else if c <= 42559 then (-1) else 0) + else + if c <= 42653 + then + (if c <= 42623 + then + (if c <= 42606 + then 0 + else if c <= 42622 then (-1) else 0) + else 0) + else + if c <= 42655 + then (-1) + else + if c <= 42735 + then 0 + else + if c <= 42774 + then (-1) + else + if c <= 42783 + then 0 + else if c <= 42785 then (-1) else 0) + else + if c <= 42963 + then + (if c <= 42894 + then + (if c <= 42887 + then 0 + else + if c <= 42888 + then 0 + else if c <= 42890 then (-1) else 0) + else + if c <= 42954 + then 0 + else + if c <= 42959 + then (-1) + else + if c <= 42961 + then 0 + else if c <= 42962 then (-1) else 0) + else + if c <= 42964 + then (-1) + else + if c <= 42999 + then + (if c <= 42996 + then + (if c <= 42969 + then 0 + else if c <= 42993 then (-1) else 0) + else 0) + else + if c <= 43002 + then 0 + else + if c <= 43009 + then 0 + else if c <= 43010 then (-1) else 0) + else + if c <= 43014 + then (-1) + else + if c <= 43518 + then + (if c <= 43301 + then + (if c <= 43187 + then + (if c <= 43042 + then + (if c <= 43018 + then 0 + else if c <= 43019 then (-1) else 0) + else + if c <= 43071 + then (-1) + else + if c <= 43123 + then 0 + else if c <= 43137 then (-1) else 0) + else + if c <= 43249 + then (-1) + else + if c <= 43259 + then + (if c <= 43255 + then 0 + else if c <= 43258 then (-1) else 0) + else + if c <= 43260 + then (-1) + else + if c <= 43262 + then 0 + else if c <= 43273 then (-1) else 0) + else + if c <= 43311 + then (-1) + else + if c <= 43471 + then + (if c <= 43388 + then + (if c <= 43334 + then 0 + else if c <= 43359 then (-1) else 0) + else + if c <= 43395 + then (-1) + else + if c <= 43442 + then 0 + else if c <= 43470 then (-1) else 0) + else + if c <= 43487 + then (-1) + else + if c <= 43494 + then + (if c <= 43492 + then 0 + else if c <= 43493 then (-1) else 0) + else + if c <= 43503 + then 0 + else if c <= 43513 then (-1) else 0) + else + if c <= 43519 + then (-1) + else + if c <= 43695 + then + (if c <= 43631 + then + (if c <= 43586 + then + (if c <= 43560 + then 0 + else if c <= 43583 then (-1) else 0) + else + if c <= 43587 + then (-1) + else + if c <= 43595 + then 0 + else if c <= 43615 then (-1) else 0) + else + if c <= 43638 + then 0 + else + if c <= 43641 + then (-1) + else + if c <= 43642 + then 0 + else if c <= 43645 then (-1) else 0) + else + if c <= 43696 + then (-1) + else + if c <= 43712 + then + (if c <= 43702 + then + (if c <= 43697 + then 0 + else if c <= 43700 then (-1) else 0) + else + if c <= 43704 + then (-1) + else + if c <= 43709 + then 0 + else if c <= 43711 then (-1) else 0) + else + if c <= 43713 + then (-1) + else + if c <= 43740 + then + (if c <= 43714 + then 0 + else if c <= 43738 then (-1) else 0) + else + if c <= 43741 + then 0 + else if c <= 43743 then (-1) else 0) + else + if c <= 43761 + then (-1) + else + if c <= 66511 + then + (if c <= 65019 + then + (if c <= 55291 + then + (if c <= 43866 + then + (if c <= 43790 + then + (if c <= 43764 + then 0 + else + if c <= 43776 + then (-1) + else + if c <= 43782 + then 0 + else if c <= 43784 then (-1) else 0) + else + if c <= 43792 + then (-1) + else + if c <= 43814 + then + (if c <= 43798 + then 0 + else if c <= 43807 then (-1) else 0) + else + if c <= 43815 + then (-1) + else + if c <= 43822 + then 0 + else if c <= 43823 then (-1) else 0) + else + if c <= 43867 + then (-1) + else + if c <= 43967 + then + (if c <= 43880 + then 0 + else + if c <= 43881 + then 0 + else if c <= 43887 then (-1) else 0) + else + if c <= 55203 + then + (if c <= 44002 + then 0 + else if c <= 44031 then (-1) else 0) + else + if c <= 55215 + then (-1) + else + if c <= 55238 + then 0 + else if c <= 55242 then (-1) else 0) + else + if c <= 63743 + then (-1) + else + if c <= 64316 + then + (if c <= 64279 + then + (if c <= 64217 + then + (if c <= 64109 + then 0 + else if c <= 64111 then (-1) else 0) + else + if c <= 64255 + then (-1) + else + if c <= 64262 + then 0 + else if c <= 64274 then (-1) else 0) + else + if c <= 64284 + then (-1) + else + if c <= 64296 + then + (if c <= 64285 + then 0 + else if c <= 64286 then (-1) else 0) + else + if c <= 64297 + then (-1) + else + if c <= 64310 + then 0 + else if c <= 64311 then (-1) else 0) + else + if c <= 64317 + then (-1) + else + if c <= 64433 + then + (if c <= 64321 + then + (if c <= 64318 + then 0 + else if c <= 64319 then (-1) else 0) + else + if c <= 64322 + then (-1) + else + if c <= 64324 + then 0 + else if c <= 64325 then (-1) else 0) + else + if c <= 64466 + then (-1) + else + if c <= 64911 + then + (if c <= 64829 + then 0 + else if c <= 64847 then (-1) else 0) + else + if c <= 64913 + then (-1) + else + if c <= 64967 + then 0 + else if c <= 65007 then (-1) else 0) + else + if c <= 65135 + then (-1) + else + if c <= 65594 + then + (if c <= 65439 + then + (if c <= 65370 + then + (if c <= 65276 + then + (if c <= 65140 + then 0 + else if c <= 65141 then (-1) else 0) + else + if c <= 65312 + then (-1) + else + if c <= 65338 + then 0 + else if c <= 65344 then (-1) else 0) + else if c <= 65381 then (-1) else 0) + else + if c <= 65495 + then + (if c <= 65479 + then + (if c <= 65470 + then 0 + else if c <= 65473 then (-1) else 0) + else + if c <= 65481 + then (-1) + else + if c <= 65487 + then 0 + else if c <= 65489 then (-1) else 0) + else + if c <= 65497 + then (-1) + else + if c <= 65547 + then + (if c <= 65500 + then 0 + else if c <= 65535 then (-1) else 0) + else + if c <= 65548 + then (-1) + else + if c <= 65574 + then 0 + else if c <= 65575 then (-1) else 0) + else + if c <= 65595 + then (-1) + else + if c <= 66335 + then + (if c <= 65786 + then + (if c <= 65613 + then + (if c <= 65597 + then 0 + else if c <= 65598 then (-1) else 0) + else + if c <= 65615 + then (-1) + else + if c <= 65629 + then 0 + else if c <= 65663 then (-1) else 0) + else + if c <= 65855 + then (-1) + else + if c <= 66204 + then + (if c <= 65908 + then 0 + else if c <= 66175 then (-1) else 0) + else + if c <= 66207 + then (-1) + else + if c <= 66256 + then 0 + else if c <= 66303 then (-1) else 0) + else + if c <= 66348 + then (-1) + else + if c <= 66378 + then 0 + else + if c <= 66383 + then (-1) + else + if c <= 66461 + then + (if c <= 66421 + then 0 + else if c <= 66431 then (-1) else 0) + else + if c <= 66463 + then (-1) + else + if c <= 66499 + then 0 + else if c <= 66503 then (-1) else 0) + else + if c <= 66512 + then (-1) + else + if c <= 67861 + then + (if c <= 67382 + then + (if c <= 66938 + then + (if c <= 66771 + then + (if c <= 66639 + then + (if c <= 66517 + then 0 + else if c <= 66559 then (-1) else 0) + else + if c <= 66717 + then 0 + else if c <= 66735 then (-1) else 0) + else + if c <= 66775 + then (-1) + else + if c <= 66855 + then + (if c <= 66811 + then 0 + else if c <= 66815 then (-1) else 0) + else + if c <= 66863 + then (-1) + else + if c <= 66915 + then 0 + else if c <= 66927 then (-1) else 0) + else + if c <= 66939 + then (-1) + else + if c <= 66977 + then + (if c <= 66962 + then + (if c <= 66954 + then 0 + else if c <= 66955 then (-1) else 0) + else + if c <= 66963 + then (-1) + else + if c <= 66965 + then 0 + else if c <= 66966 then (-1) else 0) + else + if c <= 66978 + then (-1) + else + if c <= 67001 + then + (if c <= 66993 + then 0 + else if c <= 66994 then (-1) else 0) + else + if c <= 67002 + then (-1) + else + if c <= 67004 + then 0 + else if c <= 67071 then (-1) else 0) + else + if c <= 67391 + then (-1) + else + if c <= 67637 + then + (if c <= 67504 + then + (if c <= 67431 + then + (if c <= 67413 + then 0 + else if c <= 67423 then (-1) else 0) + else + if c <= 67455 + then (-1) + else + if c <= 67461 + then 0 + else if c <= 67462 then (-1) else 0) + else + if c <= 67505 + then (-1) + else + if c <= 67589 + then + (if c <= 67514 + then 0 + else if c <= 67583 then (-1) else 0) + else + if c <= 67591 + then (-1) + else + if c <= 67592 + then 0 + else if c <= 67593 then (-1) else 0) + else + if c <= 67638 + then (-1) + else + if c <= 67702 + then + (if c <= 67644 + then + (if c <= 67640 + then 0 + else if c <= 67643 then (-1) else 0) + else + if c <= 67646 + then (-1) + else + if c <= 67669 + then 0 + else if c <= 67679 then (-1) else 0) + else + if c <= 67711 + then (-1) + else + if c <= 67826 + then + (if c <= 67742 + then 0 + else if c <= 67807 then (-1) else 0) + else + if c <= 67827 + then (-1) + else + if c <= 67829 + then 0 + else if c <= 67839 then (-1) else 0) + else + if c <= 67871 + then (-1) + else + if c <= 68680 + then + (if c <= 68220 + then + (if c <= 68096 + then + (if c <= 68023 + then + (if c <= 67897 + then 0 + else if c <= 67967 then (-1) else 0) + else + if c <= 68029 + then (-1) + else + if c <= 68031 + then 0 + else if c <= 68095 then (-1) else 0) + else + if c <= 68111 + then (-1) + else + if c <= 68119 + then + (if c <= 68115 + then 0 + else if c <= 68116 then (-1) else 0) + else + if c <= 68120 + then (-1) + else + if c <= 68149 + then 0 + else if c <= 68191 then (-1) else 0) + else + if c <= 68223 + then (-1) + else + if c <= 68405 + then + (if c <= 68295 + then + (if c <= 68252 + then 0 + else if c <= 68287 then (-1) else 0) + else + if c <= 68296 + then (-1) + else + if c <= 68324 + then 0 + else if c <= 68351 then (-1) else 0) + else + if c <= 68415 + then (-1) + else + if c <= 68466 + then + (if c <= 68437 + then 0 + else if c <= 68447 then (-1) else 0) + else + if c <= 68479 + then (-1) + else + if c <= 68497 + then 0 + else if c <= 68607 then (-1) else 0) + else + if c <= 68735 + then (-1) + else + if c <= 69445 + then + (if c <= 69289 + then + (if c <= 68850 + then + (if c <= 68786 + then 0 + else if c <= 68799 then (-1) else 0) + else + if c <= 68863 + then (-1) + else + if c <= 68899 + then 0 + else if c <= 69247 then (-1) else 0) + else + if c <= 69295 + then (-1) + else + if c <= 69404 + then + (if c <= 69297 + then 0 + else if c <= 69375 then (-1) else 0) + else + if c <= 69414 + then (-1) + else + if c <= 69415 + then 0 + else if c <= 69423 then (-1) else 0) + else + if c <= 69487 + then (-1) + else + if c <= 69687 + then + (if c <= 69572 + then + (if c <= 69505 + then 0 + else if c <= 69551 then (-1) else 0) + else + if c <= 69599 + then (-1) + else + if c <= 69622 + then 0 + else if c <= 69634 then (-1) else 0) + else + if c <= 69744 + then (-1) + else + if c <= 69749 + then + (if c <= 69746 + then 0 + else if c <= 69748 then (-1) else 0) + else + if c <= 69762 + then (-1) + else + if c <= 69807 + then 0 + else if c <= 69839 then (-1) else 0) + else + if c <= 69890 + then (-1) + else + if c <= 120512 + then + (if c <= 72847 + then + (if c <= 70855 + then + (if c <= 70312 + then + (if c <= 70106 + then + (if c <= 70002 + then + (if c <= 69956 + then + (if c <= 69926 + then 0 + else if c <= 69955 then (-1) else 0) + else + if c <= 69958 + then (-1) + else + if c <= 69959 + then 0 + else if c <= 69967 then (-1) else 0) + else + if c <= 70005 + then (-1) + else + if c <= 70066 + then + (if c <= 70006 + then 0 + else if c <= 70018 then (-1) else 0) + else + if c <= 70080 + then (-1) + else + if c <= 70084 + then 0 + else if c <= 70105 then (-1) else 0) + else + if c <= 70107 + then (-1) + else + if c <= 70278 + then + (if c <= 70161 + then + (if c <= 70108 + then 0 + else if c <= 70143 then (-1) else 0) + else + if c <= 70162 + then (-1) + else + if c <= 70187 + then 0 + else if c <= 70271 then (-1) else 0) + else + if c <= 70279 + then (-1) + else + if c <= 70285 + then + (if c <= 70280 + then 0 + else if c <= 70281 then (-1) else 0) + else + if c <= 70286 + then (-1) + else + if c <= 70301 + then 0 + else if c <= 70302 then (-1) else 0) + else + if c <= 70319 + then (-1) + else + if c <= 70461 + then + (if c <= 70440 + then + (if c <= 70412 + then + (if c <= 70366 + then 0 + else if c <= 70404 then (-1) else 0) + else + if c <= 70414 + then (-1) + else + if c <= 70416 + then 0 + else if c <= 70418 then (-1) else 0) + else + if c <= 70441 + then (-1) + else + if c <= 70451 + then + (if c <= 70448 + then 0 + else if c <= 70449 then (-1) else 0) + else + if c <= 70452 + then (-1) + else + if c <= 70457 + then 0 + else if c <= 70460 then (-1) else 0) + else + if c <= 70479 + then (-1) + else + if c <= 70730 + then + (if c <= 70497 + then + (if c <= 70480 + then 0 + else if c <= 70492 then (-1) else 0) + else + if c <= 70655 + then (-1) + else + if c <= 70708 + then 0 + else if c <= 70726 then (-1) else 0) + else + if c <= 70750 + then (-1) + else + if c <= 70831 + then + (if c <= 70753 + then 0 + else if c <= 70783 then (-1) else 0) + else + if c <= 70851 + then (-1) + else + if c <= 70853 + then 0 + else if c <= 70854 then (-1) else 0) + else + if c <= 71039 + then (-1) + else + if c <= 71999 + then + (if c <= 71494 + then + (if c <= 71236 + then + (if c <= 71131 + then + (if c <= 71086 + then 0 + else if c <= 71127 then (-1) else 0) + else + if c <= 71167 + then (-1) + else + if c <= 71215 + then 0 + else if c <= 71235 then (-1) else 0) + else + if c <= 71295 + then (-1) + else + if c <= 71352 + then + (if c <= 71338 + then 0 + else if c <= 71351 then (-1) else 0) + else + if c <= 71423 + then (-1) + else + if c <= 71450 + then 0 + else if c <= 71487 then (-1) else 0) + else + if c <= 71679 + then (-1) + else + if c <= 71945 + then + (if c <= 71903 + then + (if c <= 71723 + then 0 + else if c <= 71839 then (-1) else 0) + else + if c <= 71934 + then (-1) + else + if c <= 71942 + then 0 + else if c <= 71944 then (-1) else 0) + else + if c <= 71947 + then (-1) + else + if c <= 71958 + then + (if c <= 71955 + then 0 + else if c <= 71956 then (-1) else 0) + else + if c <= 71959 + then (-1) + else + if c <= 71983 + then 0 + else if c <= 71998 then (-1) else 0) + else + if c <= 72000 + then (-1) + else + if c <= 72250 + then + (if c <= 72161 + then + (if c <= 72103 + then + (if c <= 72001 + then 0 + else if c <= 72095 then (-1) else 0) + else + if c <= 72105 + then (-1) + else + if c <= 72144 + then 0 + else if c <= 72160 then (-1) else 0) + else + if c <= 72162 + then (-1) + else + if c <= 72192 + then + (if c <= 72163 + then 0 + else if c <= 72191 then (-1) else 0) + else + if c <= 72202 + then (-1) + else + if c <= 72242 + then 0 + else if c <= 72249 then (-1) else 0) + else + if c <= 72271 + then (-1) + else + if c <= 72440 + then + (if c <= 72329 + then + (if c <= 72272 + then 0 + else if c <= 72283 then (-1) else 0) + else + if c <= 72348 + then (-1) + else + if c <= 72349 + then 0 + else if c <= 72367 then (-1) else 0) + else + if c <= 72703 + then (-1) + else + if c <= 72750 + then + (if c <= 72712 + then 0 + else if c <= 72713 then (-1) else 0) + else + if c <= 72767 + then (-1) + else + if c <= 72768 + then 0 + else if c <= 72817 then (-1) else 0) + else + if c <= 72959 + then (-1) + else + if c <= 101589 + then + (if c <= 83526 + then + (if c <= 73112 + then + (if c <= 73030 + then + (if c <= 72969 + then + (if c <= 72966 + then 0 + else if c <= 72967 then (-1) else 0) + else + if c <= 72970 + then (-1) + else + if c <= 73008 + then 0 + else if c <= 73029 then (-1) else 0) + else + if c <= 73055 + then (-1) + else + if c <= 73064 + then + (if c <= 73061 + then 0 + else if c <= 73062 then (-1) else 0) + else + if c <= 73065 + then (-1) + else + if c <= 73097 + then 0 + else if c <= 73111 then (-1) else 0) + else + if c <= 73439 + then (-1) + else + if c <= 74862 + then + (if c <= 73648 + then + (if c <= 73458 + then 0 + else if c <= 73647 then (-1) else 0) + else + if c <= 73727 + then (-1) + else + if c <= 74649 + then 0 + else if c <= 74751 then (-1) else 0) + else + if c <= 74879 + then (-1) + else + if c <= 77808 + then + (if c <= 75075 + then 0 + else if c <= 77711 then (-1) else 0) + else + if c <= 77823 + then (-1) + else + if c <= 78894 + then 0 + else if c <= 82943 then (-1) else 0) + else + if c <= 92159 + then (-1) + else + if c <= 93071 + then + (if c <= 92909 + then + (if c <= 92766 + then + (if c <= 92728 + then 0 + else if c <= 92735 then (-1) else 0) + else + if c <= 92783 + then (-1) + else + if c <= 92862 + then 0 + else if c <= 92879 then (-1) else 0) + else + if c <= 92927 + then (-1) + else + if c <= 92995 + then + (if c <= 92975 + then 0 + else if c <= 92991 then (-1) else 0) + else + if c <= 93026 + then (-1) + else + if c <= 93047 + then 0 + else if c <= 93052 then (-1) else 0) + else + if c <= 93759 + then (-1) + else + if c <= 94111 + then + (if c <= 94026 + then + (if c <= 93823 + then 0 + else if c <= 93951 then (-1) else 0) + else + if c <= 94031 + then (-1) + else + if c <= 94032 + then 0 + else if c <= 94098 then (-1) else 0) + else + if c <= 94175 + then (-1) + else + if c <= 94179 + then + (if c <= 94177 + then 0 + else if c <= 94178 then (-1) else 0) + else + if c <= 94207 + then (-1) + else + if c <= 100343 + then 0 + else if c <= 100351 then (-1) else 0) + else + if c <= 101631 + then (-1) + else + if c <= 119970 + then + (if c <= 111355 + then + (if c <= 110590 + then + (if c <= 110579 + then + (if c <= 101640 + then 0 + else if c <= 110575 then (-1) else 0) + else + if c <= 110580 + then (-1) + else + if c <= 110587 + then 0 + else if c <= 110588 then (-1) else 0) + else + if c <= 110591 + then (-1) + else + if c <= 110930 + then + (if c <= 110882 + then 0 + else if c <= 110927 then (-1) else 0) + else + if c <= 110947 + then (-1) + else + if c <= 110951 + then 0 + else if c <= 110959 then (-1) else 0) + else + if c <= 113663 + then (-1) + else + if c <= 113817 + then + (if c <= 113788 + then + (if c <= 113770 + then 0 + else if c <= 113775 then (-1) else 0) + else + if c <= 113791 + then (-1) + else + if c <= 113800 + then 0 + else if c <= 113807 then (-1) else 0) + else + if c <= 119807 + then (-1) + else + if c <= 119964 + then + (if c <= 119892 + then 0 + else if c <= 119893 then (-1) else 0) + else + if c <= 119965 + then (-1) + else + if c <= 119967 + then 0 + else if c <= 119969 then (-1) else 0) + else + if c <= 119972 + then (-1) + else + if c <= 120084 + then + (if c <= 119995 + then + (if c <= 119980 + then + (if c <= 119974 + then 0 + else if c <= 119976 then (-1) else 0) + else + if c <= 119981 + then (-1) + else + if c <= 119993 + then 0 + else if c <= 119994 then (-1) else 0) + else + if c <= 119996 + then (-1) + else + if c <= 120069 + then + (if c <= 120003 + then 0 + else if c <= 120004 then (-1) else 0) + else + if c <= 120070 + then (-1) + else + if c <= 120074 + then 0 + else if c <= 120076 then (-1) else 0) + else + if c <= 120085 + then (-1) + else + if c <= 120132 + then + (if c <= 120121 + then + (if c <= 120092 + then 0 + else if c <= 120093 then (-1) else 0) + else + if c <= 120122 + then (-1) + else + if c <= 120126 + then 0 + else if c <= 120127 then (-1) else 0) + else + if c <= 120133 + then (-1) + else + if c <= 120144 + then + (if c <= 120134 + then 0 + else if c <= 120137 then (-1) else 0) + else + if c <= 120145 + then (-1) + else + if c <= 120485 + then 0 + else + if c <= 120487 then (-1) else 0) + else + if c <= 120513 + then (-1) + else + if c <= 195101 + then + (if c <= 126519 + then + (if c <= 123214 + then + (if c <= 120744 + then + (if c <= 120628 + then + (if c <= 120570 + then + (if c <= 120538 + then 0 + else if c <= 120539 then (-1) else 0) + else + if c <= 120571 + then (-1) + else + if c <= 120596 + then 0 + else if c <= 120597 then (-1) else 0) + else + if c <= 120629 + then (-1) + else + if c <= 120686 + then + (if c <= 120654 + then 0 + else if c <= 120655 then (-1) else 0) + else + if c <= 120687 + then (-1) + else + if c <= 120712 + then 0 + else if c <= 120713 then (-1) else 0) + else + if c <= 120745 + then (-1) + else + if c <= 122634 + then + (if c <= 120779 + then + (if c <= 120770 + then 0 + else if c <= 120771 then (-1) else 0) + else if c <= 122623 then (-1) else 0) + else + if c <= 123180 + then + (if c <= 122654 + then 0 + else if c <= 123135 then (-1) else 0) + else + if c <= 123190 + then (-1) + else + if c <= 123197 + then 0 + else if c <= 123213 then (-1) else 0) + else + if c <= 123535 + then (-1) + else + if c <= 125251 + then + (if c <= 124907 + then + (if c <= 123627 + then + (if c <= 123565 + then 0 + else if c <= 123583 then (-1) else 0) + else + if c <= 124895 + then (-1) + else + if c <= 124902 + then 0 + else if c <= 124903 then (-1) else 0) + else + if c <= 124908 + then (-1) + else + if c <= 124926 + then + (if c <= 124910 + then 0 + else if c <= 124911 then (-1) else 0) + else + if c <= 124927 + then (-1) + else + if c <= 125124 + then 0 + else if c <= 125183 then (-1) else 0) + else + if c <= 125258 + then (-1) + else + if c <= 126498 + then + (if c <= 126467 + then + (if c <= 125259 + then 0 + else if c <= 126463 then (-1) else 0) + else + if c <= 126468 + then (-1) + else + if c <= 126495 + then 0 + else if c <= 126496 then (-1) else 0) + else + if c <= 126499 + then (-1) + else + if c <= 126503 + then + (if c <= 126500 + then 0 + else if c <= 126502 then (-1) else 0) + else + if c <= 126504 + then (-1) + else + if c <= 126514 + then 0 + else if c <= 126515 then (-1) else 0) + else + if c <= 126520 + then (-1) + else + if c <= 126564 + then + (if c <= 126546 + then + (if c <= 126535 + then + (if c <= 126523 + then + (if c <= 126521 + then 0 + else if c <= 126522 then (-1) else 0) + else + if c <= 126529 + then (-1) + else + if c <= 126530 + then 0 + else if c <= 126534 then (-1) else 0) + else + if c <= 126536 + then (-1) + else + if c <= 126539 + then + (if c <= 126537 + then 0 + else if c <= 126538 then (-1) else 0) + else + if c <= 126540 + then (-1) + else + if c <= 126543 + then 0 + else if c <= 126544 then (-1) else 0) + else + if c <= 126547 + then (-1) + else + if c <= 126555 + then + (if c <= 126551 + then + (if c <= 126548 + then 0 + else if c <= 126550 then (-1) else 0) + else + if c <= 126552 + then (-1) + else + if c <= 126553 + then 0 + else if c <= 126554 then (-1) else 0) + else + if c <= 126556 + then (-1) + else + if c <= 126559 + then + (if c <= 126557 + then 0 + else if c <= 126558 then (-1) else 0) + else + if c <= 126560 + then (-1) + else + if c <= 126562 + then 0 + else if c <= 126563 then (-1) else 0) + else + if c <= 126566 + then (-1) + else + if c <= 126627 + then + (if c <= 126588 + then + (if c <= 126578 + then + (if c <= 126570 + then 0 + else if c <= 126571 then (-1) else 0) + else + if c <= 126579 + then (-1) + else + if c <= 126583 + then 0 + else if c <= 126584 then (-1) else 0) + else + if c <= 126589 + then (-1) + else + if c <= 126601 + then + (if c <= 126590 + then 0 + else if c <= 126591 then (-1) else 0) + else + if c <= 126602 + then (-1) + else + if c <= 126619 + then 0 + else if c <= 126624 then (-1) else 0) + else + if c <= 126628 + then (-1) + else + if c <= 177976 + then + (if c <= 126651 + then + (if c <= 126633 + then 0 + else if c <= 126634 then (-1) else 0) + else + if c <= 131071 + then (-1) + else + if c <= 173791 + then 0 + else if c <= 173823 then (-1) else 0) + else + if c <= 177983 + then (-1) + else + if c <= 183969 + then + (if c <= 178205 + then 0 + else if c <= 178207 then (-1) else 0) + else + if c <= 183983 + then (-1) + else + if c <= 191456 + then 0 + else + if c <= 194559 then (-1) else 0) + else if c <= 196607 then (-1) else 0) + else (-1) +let __sedlex_partition_83 c = + if c <= 35 + then (-1) + else + if c <= 122 + then (Char.code (String.unsafe_get __sedlex_table_65 (c - 36))) - 1 + else (-1) +let __sedlex_partition_128 c = + if c <= 106 then (-1) else if c <= 107 then 0 else (-1) +let __sedlex_partition_14 c = + if c <= 13 + then (Char.code (String.unsafe_get __sedlex_table_66 (c - (-1)))) - 1 + else if c <= 8233 then (if c <= 8231 then 1 else 2) else 1 +let __sedlex_partition_46 c = + if c <= 47 + then (-1) + else + if c <= 95 + then (Char.code (String.unsafe_get __sedlex_table_67 (c - 48))) - 1 + else (-1) +let __sedlex_partition_87 c = + if c <= 35 + then (-1) + else + if c <= 122 + then (Char.code (String.unsafe_get __sedlex_table_68 (c - 36))) - 1 + else (-1) +let __sedlex_partition_103 c = + if c <= 92 + then (Char.code (String.unsafe_get __sedlex_table_69 (c - (-1)))) - 1 + else if c <= 8233 then (if c <= 8231 then 1 else 2) else 1 +let __sedlex_partition_75 c = + if c <= 100 then (-1) else if c <= 101 then 0 else (-1) +let __sedlex_partition_116 c = + if c <= 58 then (-1) else if c <= 59 then 0 else (-1) +let __sedlex_partition_125 c = + if c <= 8 + then (-1) + else + if c <= 5760 + then (Char.code (String.unsafe_get __sedlex_table_70 (c - 9))) - 1 + else + if c <= 8191 + then (-1) + else + if c <= 65279 + then + (if c <= 12288 + then + (if c <= 8239 + then (if c <= 8202 then 0 else if c <= 8238 then (-1) else 0) + else + if c <= 8286 + then (-1) + else if c <= 8287 then 0 else if c <= 12287 then (-1) else 0) + else if c <= 65278 then (-1) else 0) + else (-1) +let __sedlex_partition_61 c = + if c <= 35 + then (-1) + else + if c <= 122 + then (Char.code (String.unsafe_get __sedlex_table_71 (c - 36))) - 1 + else (-1) +let __sedlex_partition_108 c = + if c <= 41 + then (-1) + else + if c <= 47 + then (Char.code (String.unsafe_get __sedlex_table_72 (c - 42))) - 1 + else (-1) +let __sedlex_partition_81 c = + if c <= 35 + then (-1) + else + if c <= 122 + then (Char.code (String.unsafe_get __sedlex_table_73 (c - 36))) - 1 + else (-1) +let __sedlex_partition_126 c = + if c <= 8191 + then (Char.code (String.unsafe_get __sedlex_table_74 (c - (-1)))) - 1 + else + if c <= 194559 + then + (if c <= 69599 + then + (if c <= 43711 + then + (if c <= 12703 + then + (if c <= 11519 + then + (if c <= 8489 + then + (if c <= 8454 + then + (if c <= 8304 + then + (if c <= 8238 + then + (if c <= 8231 + then (if c <= 8202 then 2 else 1) + else if c <= 8233 then 3 else 1) + else + if c <= 8286 + then (if c <= 8239 then 2 else 1) + else if c <= 8287 then 2 else 1) + else + if c <= 8335 + then + (if c <= 8318 + then (if c <= 8305 then 6 else 1) + else if c <= 8319 then 6 else 1) + else + if c <= 8449 + then (if c <= 8348 then 6 else 1) + else if c <= 8450 then 6 else 1) + else + if c <= 8477 + then + (if c <= 8468 + then + (if c <= 8457 + then (if c <= 8455 then 6 else 1) + else if c <= 8467 then 6 else 1) + else + if c <= 8471 + then (if c <= 8469 then 6 else 1) + else 6) + else + if c <= 8485 + then + (if c <= 8483 + then 1 + else if c <= 8484 then 6 else 1) + else + if c <= 8487 + then (if c <= 8486 then 6 else 1) + else if c <= 8488 then 6 else 1) + else + if c <= 8543 + then + (if c <= 8505 + then 6 + else + if c <= 8516 + then + (if c <= 8507 + then 1 + else if c <= 8511 then 6 else 1) + else + if c <= 8525 + then (if c <= 8521 then 6 else 1) + else if c <= 8526 then 6 else 1) + else + if c <= 11389 + then + (if c <= 8584 + then 6 + else if c <= 11263 then 1 else 6) + else + if c <= 11498 + then (if c <= 11492 then 6 else 1) + else + if c <= 11505 + then (if c <= 11502 then 6 else 1) + else if c <= 11507 then 6 else 1) + else + if c <= 12294 + then + (if c <= 11695 + then + (if c <= 11630 + then + (if c <= 11564 + then + (if c <= 11558 + then (if c <= 11557 then 6 else 1) + else if c <= 11559 then 6 else 1) + else + if c <= 11567 + then (if c <= 11565 then 6 else 1) + else if c <= 11623 then 6 else 1) + else + if c <= 11679 + then + (if c <= 11647 + then (if c <= 11631 then 6 else 1) + else if c <= 11670 then 6 else 1) + else + if c <= 11687 + then (if c <= 11686 then 6 else 1) + else if c <= 11694 then 6 else 1) + else + if c <= 11727 + then + (if c <= 11711 + then + (if c <= 11703 + then (if c <= 11702 then 6 else 1) + else if c <= 11710 then 6 else 1) + else + if c <= 11719 + then (if c <= 11718 then 6 else 1) + else if c <= 11726 then 6 else 1) + else + if c <= 12287 + then + (if c <= 11735 + then (if c <= 11734 then 6 else 1) + else if c <= 11742 then 6 else 1) + else + if c <= 12292 + then (if c <= 12288 then 2 else 1) + else 6) + else + if c <= 12442 + then + (if c <= 12343 + then + (if c <= 12320 + then (if c <= 12295 then 6 else 1) + else + if c <= 12336 + then (if c <= 12329 then 6 else 1) + else if c <= 12341 then 6 else 1) + else + if c <= 12348 + then 6 + else + if c <= 12352 + then 1 + else if c <= 12438 then 6 else 1) + else + if c <= 12539 + then + (if c <= 12447 + then 6 + else + if c <= 12448 + then 1 + else if c <= 12538 then 6 else 1) + else + if c <= 12548 + then (if c <= 12543 then 6 else 1) + else + if c <= 12592 + then (if c <= 12591 then 6 else 1) + else if c <= 12686 then 6 else 1) + else + if c <= 42999 + then + (if c <= 42653 + then + (if c <= 42239 + then + (if c <= 40981 + then + (if c <= 13311 + then + (if c <= 12783 + then (if c <= 12735 then 6 else 1) + else if c <= 12799 then 6 else 1) + else + if c <= 19967 + then (if c <= 19903 then 6 else 1) + else 6) + else + if c <= 42191 + then (if c <= 42124 then 6 else 1) + else if c <= 42237 then 6 else 1) + else + if c <= 42559 + then + (if c <= 42511 + then (if c <= 42508 then 6 else 1) + else + if c <= 42537 + then (if c <= 42527 then 6 else 1) + else if c <= 42539 then 6 else 1) + else + if c <= 42622 + then (if c <= 42606 then 6 else 1) + else 6) + else + if c <= 42890 + then + (if c <= 42785 + then + (if c <= 42735 + then (if c <= 42655 then 1 else 6) + else + if c <= 42774 + then 1 + else if c <= 42783 then 6 else 1) + else + if c <= 42887 + then 6 + else if c <= 42888 then 6 else 1) + else + if c <= 42962 + then + (if c <= 42954 + then 6 + else + if c <= 42959 + then 1 + else if c <= 42961 then 6 else 1) + else + if c <= 42993 + then + (if c <= 42964 + then (if c <= 42963 then 6 else 1) + else if c <= 42969 then 6 else 1) + else 6) + else + if c <= 43470 + then + (if c <= 43137 + then + (if c <= 43010 + then + (if c <= 43002 + then 6 + else if c <= 43009 then 6 else 1) + else + if c <= 43019 + then + (if c <= 43014 + then (if c <= 43013 then 6 else 1) + else if c <= 43018 then 6 else 1) + else + if c <= 43071 + then (if c <= 43042 then 6 else 1) + else if c <= 43123 then 6 else 1) + else + if c <= 43273 + then + (if c <= 43258 + then + (if c <= 43249 + then (if c <= 43187 then 6 else 1) + else if c <= 43255 then 6 else 1) + else + if c <= 43260 + then (if c <= 43259 then 6 else 1) + else if c <= 43262 then 6 else 1) + else + if c <= 43359 + then + (if c <= 43311 + then (if c <= 43301 then 6 else 1) + else if c <= 43334 then 6 else 1) + else + if c <= 43395 + then (if c <= 43388 then 6 else 1) + else if c <= 43442 then 6 else 1) + else + if c <= 43615 + then + (if c <= 43513 + then + (if c <= 43493 + then + (if c <= 43487 + then (if c <= 43471 then 6 else 1) + else if c <= 43492 then 6 else 1) + else if c <= 43503 then 6 else 1) + else + if c <= 43583 + then + (if c <= 43519 + then (if c <= 43518 then 6 else 1) + else if c <= 43560 then 6 else 1) + else + if c <= 43587 + then (if c <= 43586 then 6 else 1) + else if c <= 43595 then 6 else 1) + else + if c <= 43645 + then + (if c <= 43638 + then 6 + else + if c <= 43641 + then 1 + else if c <= 43642 then 6 else 1) + else + if c <= 43700 + then + (if c <= 43696 + then (if c <= 43695 then 6 else 1) + else if c <= 43697 then 6 else 1) + else + if c <= 43704 + then (if c <= 43702 then 6 else 1) + else if c <= 43709 then 6 else 1) + else + if c <= 66377 + then + (if c <= 64325 + then + (if c <= 43887 + then + (if c <= 43784 + then + (if c <= 43743 + then + (if c <= 43738 + then + (if c <= 43713 + then (if c <= 43712 then 6 else 1) + else if c <= 43714 then 6 else 1) + else if c <= 43741 then 6 else 1) + else + if c <= 43764 + then + (if c <= 43761 + then (if c <= 43754 then 6 else 1) + else 6) + else + if c <= 43776 + then 1 + else if c <= 43782 then 6 else 1) + else + if c <= 43823 + then + (if c <= 43807 + then + (if c <= 43792 + then (if c <= 43790 then 6 else 1) + else if c <= 43798 then 6 else 1) + else + if c <= 43815 + then (if c <= 43814 then 6 else 1) + else if c <= 43822 then 6 else 1) + else + if c <= 43880 + then + (if c <= 43867 + then (if c <= 43866 then 6 else 1) + else 6) + else if c <= 43881 then 6 else 1) + else + if c <= 64274 + then + (if c <= 55242 + then + (if c <= 44031 + then (if c <= 44002 then 6 else 1) + else + if c <= 55215 + then (if c <= 55203 then 6 else 1) + else if c <= 55238 then 6 else 1) + else + if c <= 64111 + then + (if c <= 63743 + then (if c <= 55291 then 6 else 1) + else if c <= 64109 then 6 else 1) + else + if c <= 64255 + then (if c <= 64217 then 6 else 1) + else if c <= 64262 then 6 else 1) + else + if c <= 64311 + then + (if c <= 64286 + then + (if c <= 64284 + then (if c <= 64279 then 6 else 1) + else if c <= 64285 then 6 else 1) + else + if c <= 64297 + then (if c <= 64296 then 6 else 1) + else if c <= 64310 then 6 else 1) + else + if c <= 64319 + then + (if c <= 64317 + then (if c <= 64316 then 6 else 1) + else if c <= 64318 then 6 else 1) + else + if c <= 64322 + then (if c <= 64321 then 6 else 1) + else if c <= 64324 then 6 else 1) + else + if c <= 65481 + then + (if c <= 65312 + then + (if c <= 65007 + then + (if c <= 64847 + then + (if c <= 64466 + then (if c <= 64433 then 6 else 1) + else if c <= 64829 then 6 else 1) + else + if c <= 64913 + then (if c <= 64911 then 6 else 1) + else if c <= 64967 then 6 else 1) + else + if c <= 65141 + then + (if c <= 65135 + then (if c <= 65019 then 6 else 1) + else if c <= 65140 then 6 else 1) + else + if c <= 65278 + then (if c <= 65276 then 6 else 1) + else if c <= 65279 then 2 else 1) + else + if c <= 65437 + then + (if c <= 65381 + then + (if c <= 65344 + then (if c <= 65338 then 6 else 1) + else if c <= 65370 then 6 else 1) + else 6) + else + if c <= 65470 + then 6 + else + if c <= 65473 + then 1 + else if c <= 65479 then 6 else 1) + else + if c <= 65615 + then + (if c <= 65548 + then + (if c <= 65497 + then + (if c <= 65489 + then (if c <= 65487 then 6 else 1) + else if c <= 65495 then 6 else 1) + else + if c <= 65535 + then (if c <= 65500 then 6 else 1) + else if c <= 65547 then 6 else 1) + else + if c <= 65595 + then + (if c <= 65575 + then (if c <= 65574 then 6 else 1) + else if c <= 65594 then 6 else 1) + else + if c <= 65598 + then (if c <= 65597 then 6 else 1) + else if c <= 65613 then 6 else 1) + else + if c <= 66207 + then + (if c <= 65855 + then + (if c <= 65663 + then (if c <= 65629 then 6 else 1) + else if c <= 65786 then 6 else 1) + else + if c <= 66175 + then (if c <= 65908 then 6 else 1) + else if c <= 66204 then 6 else 1) + else + if c <= 66348 + then + (if c <= 66303 + then (if c <= 66256 then 6 else 1) + else if c <= 66335 then 6 else 1) + else 6) + else + if c <= 67646 + then + (if c <= 66963 + then + (if c <= 66717 + then + (if c <= 66463 + then + (if c <= 66383 + then (if c <= 66378 then 6 else 1) + else + if c <= 66431 + then (if c <= 66421 then 6 else 1) + else if c <= 66461 then 6 else 1) + else + if c <= 66512 + then + (if c <= 66503 + then (if c <= 66499 then 6 else 1) + else if c <= 66511 then 6 else 1) + else + if c <= 66559 + then (if c <= 66517 then 6 else 1) + else 6) + else + if c <= 66863 + then + (if c <= 66775 + then + (if c <= 66735 + then 1 + else if c <= 66771 then 6 else 1) + else + if c <= 66815 + then (if c <= 66811 then 6 else 1) + else if c <= 66855 then 6 else 1) + else + if c <= 66939 + then + (if c <= 66927 + then (if c <= 66915 then 6 else 1) + else if c <= 66938 then 6 else 1) + else + if c <= 66955 + then (if c <= 66954 then 6 else 1) + else if c <= 66962 then 6 else 1) + else + if c <= 67455 + then + (if c <= 67002 + then + (if c <= 66978 + then + (if c <= 66966 + then (if c <= 66965 then 6 else 1) + else if c <= 66977 then 6 else 1) + else + if c <= 66994 + then (if c <= 66993 then 6 else 1) + else if c <= 67001 then 6 else 1) + else + if c <= 67391 + then + (if c <= 67071 + then (if c <= 67004 then 6 else 1) + else if c <= 67382 then 6 else 1) + else + if c <= 67423 + then (if c <= 67413 then 6 else 1) + else if c <= 67431 then 6 else 1) + else + if c <= 67591 + then + (if c <= 67505 + then + (if c <= 67462 + then (if c <= 67461 then 6 else 1) + else if c <= 67504 then 6 else 1) + else + if c <= 67583 + then (if c <= 67514 then 6 else 1) + else if c <= 67589 then 6 else 1) + else + if c <= 67638 + then + (if c <= 67593 + then (if c <= 67592 then 6 else 1) + else if c <= 67637 then 6 else 1) + else + if c <= 67643 + then (if c <= 67640 then 6 else 1) + else if c <= 67644 then 6 else 1) + else + if c <= 68296 + then + (if c <= 68029 + then + (if c <= 67827 + then + (if c <= 67711 + then + (if c <= 67679 + then (if c <= 67669 then 6 else 1) + else if c <= 67702 then 6 else 1) + else + if c <= 67807 + then (if c <= 67742 then 6 else 1) + else if c <= 67826 then 6 else 1) + else + if c <= 67871 + then + (if c <= 67839 + then (if c <= 67829 then 6 else 1) + else if c <= 67861 then 6 else 1) + else + if c <= 67967 + then (if c <= 67897 then 6 else 1) + else if c <= 68023 then 6 else 1) + else + if c <= 68120 + then + (if c <= 68111 + then + (if c <= 68095 + then (if c <= 68031 then 6 else 1) + else if c <= 68096 then 6 else 1) + else + if c <= 68116 + then (if c <= 68115 then 6 else 1) + else if c <= 68119 then 6 else 1) + else + if c <= 68223 + then + (if c <= 68191 + then (if c <= 68149 then 6 else 1) + else if c <= 68220 then 6 else 1) + else + if c <= 68287 + then (if c <= 68252 then 6 else 1) + else if c <= 68295 then 6 else 1) + else + if c <= 68863 + then + (if c <= 68479 + then + (if c <= 68415 + then + (if c <= 68351 + then (if c <= 68324 then 6 else 1) + else if c <= 68405 then 6 else 1) + else + if c <= 68447 + then (if c <= 68437 then 6 else 1) + else if c <= 68466 then 6 else 1) + else + if c <= 68735 + then + (if c <= 68607 + then (if c <= 68497 then 6 else 1) + else if c <= 68680 then 6 else 1) + else + if c <= 68799 + then (if c <= 68786 then 6 else 1) + else if c <= 68850 then 6 else 1) + else + if c <= 69414 + then + (if c <= 69295 + then + (if c <= 69247 + then (if c <= 68899 then 6 else 1) + else if c <= 69289 then 6 else 1) + else + if c <= 69375 + then (if c <= 69297 then 6 else 1) + else if c <= 69404 then 6 else 1) + else + if c <= 69487 + then + (if c <= 69423 + then (if c <= 69415 then 6 else 1) + else if c <= 69445 then 6 else 1) + else + if c <= 69551 + then (if c <= 69505 then 6 else 1) + else if c <= 69572 then 6 else 1) + else + if c <= 120122 + then + (if c <= 72348 + then + (if c <= 70655 + then + (if c <= 70162 + then + (if c <= 69958 + then + (if c <= 69762 + then + (if c <= 69744 + then + (if c <= 69634 + then (if c <= 69622 then 6 else 1) + else if c <= 69687 then 6 else 1) + else + if c <= 69748 + then (if c <= 69746 then 6 else 1) + else if c <= 69749 then 6 else 1) + else + if c <= 69890 + then + (if c <= 69839 + then (if c <= 69807 then 6 else 1) + else if c <= 69864 then 6 else 1) + else + if c <= 69955 + then (if c <= 69926 then 6 else 1) + else if c <= 69956 then 6 else 1) + else + if c <= 70080 + then + (if c <= 70005 + then + (if c <= 69967 + then (if c <= 69959 then 6 else 1) + else if c <= 70002 then 6 else 1) + else + if c <= 70018 + then (if c <= 70006 then 6 else 1) + else if c <= 70066 then 6 else 1) + else + if c <= 70107 + then + (if c <= 70105 + then (if c <= 70084 then 6 else 1) + else if c <= 70106 then 6 else 1) + else + if c <= 70143 + then (if c <= 70108 then 6 else 1) + else if c <= 70161 then 6 else 1) + else + if c <= 70414 + then + (if c <= 70286 + then + (if c <= 70279 + then + (if c <= 70271 + then (if c <= 70187 then 6 else 1) + else if c <= 70278 then 6 else 1) + else + if c <= 70281 + then (if c <= 70280 then 6 else 1) + else if c <= 70285 then 6 else 1) + else + if c <= 70319 + then + (if c <= 70302 + then (if c <= 70301 then 6 else 1) + else if c <= 70312 then 6 else 1) + else + if c <= 70404 + then (if c <= 70366 then 6 else 1) + else if c <= 70412 then 6 else 1) + else + if c <= 70452 + then + (if c <= 70441 + then + (if c <= 70418 + then (if c <= 70416 then 6 else 1) + else if c <= 70440 then 6 else 1) + else + if c <= 70449 + then (if c <= 70448 then 6 else 1) + else if c <= 70451 then 6 else 1) + else + if c <= 70479 + then + (if c <= 70460 + then (if c <= 70457 then 6 else 1) + else if c <= 70461 then 6 else 1) + else + if c <= 70492 + then (if c <= 70480 then 6 else 1) + else if c <= 70497 then 6 else 1) + else + if c <= 71934 + then + (if c <= 71167 + then + (if c <= 70851 + then + (if c <= 70750 + then + (if c <= 70726 + then (if c <= 70708 then 6 else 1) + else if c <= 70730 then 6 else 1) + else + if c <= 70783 + then (if c <= 70753 then 6 else 1) + else if c <= 70831 then 6 else 1) + else + if c <= 71039 + then + (if c <= 70854 + then (if c <= 70853 then 6 else 1) + else if c <= 70855 then 6 else 1) + else + if c <= 71127 + then (if c <= 71086 then 6 else 1) + else if c <= 71131 then 6 else 1) + else + if c <= 71423 + then + (if c <= 71295 + then + (if c <= 71235 + then (if c <= 71215 then 6 else 1) + else if c <= 71236 then 6 else 1) + else + if c <= 71351 + then (if c <= 71338 then 6 else 1) + else if c <= 71352 then 6 else 1) + else + if c <= 71679 + then + (if c <= 71487 + then (if c <= 71450 then 6 else 1) + else if c <= 71494 then 6 else 1) + else + if c <= 71839 + then (if c <= 71723 then 6 else 1) + else if c <= 71903 then 6 else 1) + else + if c <= 72105 + then + (if c <= 71959 + then + (if c <= 71947 + then + (if c <= 71944 + then (if c <= 71942 then 6 else 1) + else if c <= 71945 then 6 else 1) + else + if c <= 71956 + then (if c <= 71955 then 6 else 1) + else if c <= 71958 then 6 else 1) + else + if c <= 72000 + then + (if c <= 71998 + then (if c <= 71983 then 6 else 1) + else if c <= 71999 then 6 else 1) + else + if c <= 72095 + then (if c <= 72001 then 6 else 1) + else if c <= 72103 then 6 else 1) + else + if c <= 72202 + then + (if c <= 72162 + then + (if c <= 72160 + then (if c <= 72144 then 6 else 1) + else if c <= 72161 then 6 else 1) + else + if c <= 72191 + then (if c <= 72163 then 6 else 1) + else if c <= 72192 then 6 else 1) + else + if c <= 72271 + then + (if c <= 72249 + then (if c <= 72242 then 6 else 1) + else if c <= 72250 then 6 else 1) + else + if c <= 72283 + then (if c <= 72272 then 6 else 1) + else if c <= 72329 then 6 else 1) + else + if c <= 94031 + then + (if c <= 73727 + then + (if c <= 72970 + then + (if c <= 72767 + then + (if c <= 72703 + then + (if c <= 72367 + then (if c <= 72349 then 6 else 1) + else if c <= 72440 then 6 else 1) + else + if c <= 72713 + then (if c <= 72712 then 6 else 1) + else if c <= 72750 then 6 else 1) + else + if c <= 72959 + then + (if c <= 72817 + then (if c <= 72768 then 6 else 1) + else if c <= 72847 then 6 else 1) + else + if c <= 72967 + then (if c <= 72966 then 6 else 1) + else if c <= 72969 then 6 else 1) + else + if c <= 73065 + then + (if c <= 73055 + then + (if c <= 73029 + then (if c <= 73008 then 6 else 1) + else if c <= 73030 then 6 else 1) + else + if c <= 73062 + then (if c <= 73061 then 6 else 1) + else if c <= 73064 then 6 else 1) + else + if c <= 73439 + then + (if c <= 73111 + then (if c <= 73097 then 6 else 1) + else if c <= 73112 then 6 else 1) + else + if c <= 73647 + then (if c <= 73458 then 6 else 1) + else if c <= 73648 then 6 else 1) + else + if c <= 92783 + then + (if c <= 77823 + then + (if c <= 74879 + then + (if c <= 74751 + then (if c <= 74649 then 6 else 1) + else if c <= 74862 then 6 else 1) + else + if c <= 77711 + then (if c <= 75075 then 6 else 1) + else if c <= 77808 then 6 else 1) + else + if c <= 92159 + then + (if c <= 82943 + then (if c <= 78894 then 6 else 1) + else if c <= 83526 then 6 else 1) + else + if c <= 92735 + then (if c <= 92728 then 6 else 1) + else if c <= 92766 then 6 else 1) + else + if c <= 93026 + then + (if c <= 92927 + then + (if c <= 92879 + then (if c <= 92862 then 6 else 1) + else if c <= 92909 then 6 else 1) + else + if c <= 92991 + then (if c <= 92975 then 6 else 1) + else if c <= 92995 then 6 else 1) + else + if c <= 93759 + then + (if c <= 93052 + then (if c <= 93047 then 6 else 1) + else if c <= 93071 then 6 else 1) + else + if c <= 93951 + then (if c <= 93823 then 6 else 1) + else if c <= 94026 then 6 else 1) + else + if c <= 113791 + then + (if c <= 110580 + then + (if c <= 94207 + then + (if c <= 94175 + then + (if c <= 94098 + then (if c <= 94032 then 6 else 1) + else if c <= 94111 then 6 else 1) + else + if c <= 94178 + then (if c <= 94177 then 6 else 1) + else if c <= 94179 then 6 else 1) + else + if c <= 101631 + then + (if c <= 100351 + then (if c <= 100343 then 6 else 1) + else if c <= 101589 then 6 else 1) + else + if c <= 110575 + then (if c <= 101640 then 6 else 1) + else if c <= 110579 then 6 else 1) + else + if c <= 110947 + then + (if c <= 110591 + then + (if c <= 110588 + then (if c <= 110587 then 6 else 1) + else if c <= 110590 then 6 else 1) + else + if c <= 110927 + then (if c <= 110882 then 6 else 1) + else if c <= 110930 then 6 else 1) + else + if c <= 113663 + then + (if c <= 110959 + then (if c <= 110951 then 6 else 1) + else if c <= 111355 then 6 else 1) + else + if c <= 113775 + then (if c <= 113770 then 6 else 1) + else if c <= 113788 then 6 else 1) + else + if c <= 119981 + then + (if c <= 119965 + then + (if c <= 119807 + then + (if c <= 113807 + then (if c <= 113800 then 6 else 1) + else if c <= 113817 then 6 else 1) + else + if c <= 119893 + then (if c <= 119892 then 6 else 1) + else if c <= 119964 then 6 else 1) + else + if c <= 119972 + then + (if c <= 119969 + then (if c <= 119967 then 6 else 1) + else if c <= 119970 then 6 else 1) + else + if c <= 119976 + then (if c <= 119974 then 6 else 1) + else if c <= 119980 then 6 else 1) + else + if c <= 120070 + then + (if c <= 119996 + then + (if c <= 119994 + then (if c <= 119993 then 6 else 1) + else if c <= 119995 then 6 else 1) + else + if c <= 120004 + then (if c <= 120003 then 6 else 1) + else if c <= 120069 then 6 else 1) + else + if c <= 120085 + then + (if c <= 120076 + then (if c <= 120074 then 6 else 1) + else if c <= 120084 then 6 else 1) + else + if c <= 120093 + then (if c <= 120092 then 6 else 1) + else if c <= 120121 then 6 else 1) + else + if c <= 131071 + then + (if c <= 126468 + then + (if c <= 122623 + then + (if c <= 120571 + then + (if c <= 120145 + then + (if c <= 120133 + then + (if c <= 120127 + then (if c <= 120126 then 6 else 1) + else if c <= 120132 then 6 else 1) + else + if c <= 120137 + then (if c <= 120134 then 6 else 1) + else if c <= 120144 then 6 else 1) + else + if c <= 120513 + then + (if c <= 120487 + then (if c <= 120485 then 6 else 1) + else if c <= 120512 then 6 else 1) + else + if c <= 120539 + then (if c <= 120538 then 6 else 1) + else if c <= 120570 then 6 else 1) + else + if c <= 120687 + then + (if c <= 120629 + then + (if c <= 120597 + then (if c <= 120596 then 6 else 1) + else if c <= 120628 then 6 else 1) + else + if c <= 120655 + then (if c <= 120654 then 6 else 1) + else if c <= 120686 then 6 else 1) + else + if c <= 120745 + then + (if c <= 120713 + then (if c <= 120712 then 6 else 1) + else if c <= 120744 then 6 else 1) + else + if c <= 120771 + then (if c <= 120770 then 6 else 1) + else if c <= 120779 then 6 else 1) + else + if c <= 124895 + then + (if c <= 123190 + then + (if c <= 122654 + then 6 + else + if c <= 123135 + then 1 + else if c <= 123180 then 6 else 1) + else + if c <= 123535 + then + (if c <= 123213 + then (if c <= 123197 then 6 else 1) + else if c <= 123214 then 6 else 1) + else + if c <= 123583 + then (if c <= 123565 then 6 else 1) + else if c <= 123627 then 6 else 1) + else + if c <= 124927 + then + (if c <= 124908 + then + (if c <= 124903 + then (if c <= 124902 then 6 else 1) + else if c <= 124907 then 6 else 1) + else + if c <= 124911 + then (if c <= 124910 then 6 else 1) + else if c <= 124926 then 6 else 1) + else + if c <= 125258 + then + (if c <= 125183 + then (if c <= 125124 then 6 else 1) + else if c <= 125251 then 6 else 1) + else + if c <= 126463 + then (if c <= 125259 then 6 else 1) + else if c <= 126467 then 6 else 1) + else + if c <= 126552 + then + (if c <= 126529 + then + (if c <= 126504 + then + (if c <= 126499 + then + (if c <= 126496 + then (if c <= 126495 then 6 else 1) + else if c <= 126498 then 6 else 1) + else + if c <= 126502 + then (if c <= 126500 then 6 else 1) + else if c <= 126503 then 6 else 1) + else + if c <= 126520 + then + (if c <= 126515 + then (if c <= 126514 then 6 else 1) + else if c <= 126519 then 6 else 1) + else + if c <= 126522 + then (if c <= 126521 then 6 else 1) + else if c <= 126523 then 6 else 1) + else + if c <= 126540 + then + (if c <= 126536 + then + (if c <= 126534 + then (if c <= 126530 then 6 else 1) + else if c <= 126535 then 6 else 1) + else + if c <= 126538 + then (if c <= 126537 then 6 else 1) + else if c <= 126539 then 6 else 1) + else + if c <= 126547 + then + (if c <= 126544 + then (if c <= 126543 then 6 else 1) + else if c <= 126546 then 6 else 1) + else + if c <= 126550 + then (if c <= 126548 then 6 else 1) + else if c <= 126551 then 6 else 1) + else + if c <= 126579 + then + (if c <= 126560 + then + (if c <= 126556 + then + (if c <= 126554 + then (if c <= 126553 then 6 else 1) + else if c <= 126555 then 6 else 1) + else + if c <= 126558 + then (if c <= 126557 then 6 else 1) + else if c <= 126559 then 6 else 1) + else + if c <= 126566 + then + (if c <= 126563 + then (if c <= 126562 then 6 else 1) + else if c <= 126564 then 6 else 1) + else + if c <= 126571 + then (if c <= 126570 then 6 else 1) + else if c <= 126578 then 6 else 1) + else + if c <= 126602 + then + (if c <= 126589 + then + (if c <= 126584 + then (if c <= 126583 then 6 else 1) + else if c <= 126588 then 6 else 1) + else + if c <= 126591 + then (if c <= 126590 then 6 else 1) + else if c <= 126601 then 6 else 1) + else + if c <= 126628 + then + (if c <= 126624 + then (if c <= 126619 then 6 else 1) + else if c <= 126627 then 6 else 1) + else + if c <= 126634 + then (if c <= 126633 then 6 else 1) + else if c <= 126651 then 6 else 1) + else + if c <= 183983 + then + (if c <= 177983 + then + (if c <= 173823 + then (if c <= 173791 then 6 else 1) + else if c <= 177976 then 6 else 1) + else + if c <= 178207 + then (if c <= 178205 then 6 else 1) + else if c <= 183969 then 6 else 1) + else if c <= 191456 then 6 else 1) + else (-1) +let __sedlex_partition_78 c = + if c <= 35 + then (-1) + else + if c <= 122 + then (Char.code (String.unsafe_get __sedlex_table_75 (c - 36))) - 1 + else (-1) +let __sedlex_partition_119 c = + if c <= (-1) + then (-1) + else + if c <= 8191 + then (Char.code (String.unsafe_get __sedlex_table_76 c)) - 1 + else + if c <= 12287 + then + (if c <= 8238 + then + (if c <= 8231 + then (if c <= 8202 then 1 else 0) + else if c <= 8233 then 2 else 0) + else + if c <= 8286 + then (if c <= 8239 then 1 else 0) + else if c <= 8287 then 1 else 0) + else + if c <= 65278 + then (if c <= 12288 then 1 else 0) + else if c <= 65279 then 1 else 0 +let __sedlex_partition_69 c = + if c <= 118 then (-1) else if c <= 119 then 0 else (-1) +let __sedlex_partition_85 c = + if c <= 35 + then (-1) + else + if c <= 122 + then (Char.code (String.unsafe_get __sedlex_table_77 (c - 36))) - 1 + else (-1) +let __sedlex_partition_100 c = + if c <= 93 + then (Char.code (String.unsafe_get __sedlex_table_78 (c - (-1)))) - 1 + else if c <= 8233 then (if c <= 8231 then 1 else 2) else 1 +let __sedlex_partition_118 c = + if c <= 123 + then (Char.code (String.unsafe_get __sedlex_table_79 (c - (-1)))) - 1 + else if c <= 8233 then (if c <= 8231 then 1 else 2) else 1 +let __sedlex_partition_32 c = + if c <= 47 + then (-1) + else + if c <= 57 + then (Char.code (String.unsafe_get __sedlex_table_80 (c - 48))) - 1 + else (-1) +let __sedlex_partition_38 c = + if c <= 47 + then (-1) + else + if c <= 101 + then (Char.code (String.unsafe_get __sedlex_table_81 (c - 48))) - 1 + else (-1) +let __sedlex_partition_39 c = + if c <= 42 + then (-1) + else + if c <= 57 + then (Char.code (String.unsafe_get __sedlex_table_82 (c - 43))) - 1 + else (-1) +let __sedlex_partition_109 c = + if c <= 125 + then (Char.code (String.unsafe_get __sedlex_table_83 (c - (-1)))) - 1 + else if c <= 8233 then (if c <= 8231 then 1 else 2) else 1 +let __sedlex_partition_1 c = + if c <= 122 + then (Char.code (String.unsafe_get __sedlex_table_84 (c - (-1)))) - 1 + else 1 +let __sedlex_partition_6 c = + if c <= 122 + then (Char.code (String.unsafe_get __sedlex_table_85 (c - (-1)))) - 1 + else 1 +let __sedlex_partition_12 c = + if c <= 44 + then (-1) + else + if c <= 47 + then (Char.code (String.unsafe_get __sedlex_table_86 (c - 45))) - 1 + else (-1) +let __sedlex_partition_114 c = + if c <= 47 + then (-1) + else + if c <= 102 + then (Char.code (String.unsafe_get __sedlex_table_87 (c - 48))) - 1 + else (-1) +let __sedlex_partition_49 c = + if c <= 62 then (-1) else if c <= 63 then 0 else (-1) +let __sedlex_partition_48 c = + if c <= 45 + then (-1) + else + if c <= 95 + then (Char.code (String.unsafe_get __sedlex_table_88 (c - 46))) - 1 + else (-1) +let __sedlex_partition_2 c = + if c <= 116 then (-1) else if c <= 117 then 0 else (-1) +let __sedlex_partition_13 c = + if c <= 46 then (-1) else if c <= 47 then 0 else (-1) +let __sedlex_partition_66 c = + if c <= 57 then (-1) else if c <= 58 then 0 else (-1) +let __sedlex_partition_60 c = + if c <= 35 + then (-1) + else + if c <= 122 + then (Char.code (String.unsafe_get __sedlex_table_89 (c - 36))) - 1 + else (-1) +let __sedlex_partition_111 c = + if c <= 34 + then (-1) + else + if c <= 122 + then (Char.code (String.unsafe_get __sedlex_table_90 (c - 35))) - 1 + else (-1) +let __sedlex_partition_117 c = + if c <= 8191 + then (Char.code (String.unsafe_get __sedlex_table_91 (c - (-1)))) - 1 + else + if c <= 194559 + then + (if c <= 69599 + then + (if c <= 43711 + then + (if c <= 12703 + then + (if c <= 11519 + then + (if c <= 8489 + then + (if c <= 8454 + then + (if c <= 8304 + then + (if c <= 8238 + then + (if c <= 8231 + then (if c <= 8202 then 2 else 1) + else if c <= 8233 then 3 else 1) + else + if c <= 8286 + then (if c <= 8239 then 2 else 1) + else if c <= 8287 then 2 else 1) + else + if c <= 8335 + then + (if c <= 8318 + then (if c <= 8305 then 6 else 1) + else if c <= 8319 then 6 else 1) + else + if c <= 8449 + then (if c <= 8348 then 6 else 1) + else if c <= 8450 then 6 else 1) + else + if c <= 8477 + then + (if c <= 8468 + then + (if c <= 8457 + then (if c <= 8455 then 6 else 1) + else if c <= 8467 then 6 else 1) + else + if c <= 8471 + then (if c <= 8469 then 6 else 1) + else 6) + else + if c <= 8485 + then + (if c <= 8483 + then 1 + else if c <= 8484 then 6 else 1) + else + if c <= 8487 + then (if c <= 8486 then 6 else 1) + else if c <= 8488 then 6 else 1) + else + if c <= 8543 + then + (if c <= 8505 + then 6 + else + if c <= 8516 + then + (if c <= 8507 + then 1 + else if c <= 8511 then 6 else 1) + else + if c <= 8525 + then (if c <= 8521 then 6 else 1) + else if c <= 8526 then 6 else 1) + else + if c <= 11389 + then + (if c <= 8584 + then 6 + else if c <= 11263 then 1 else 6) + else + if c <= 11498 + then (if c <= 11492 then 6 else 1) + else + if c <= 11505 + then (if c <= 11502 then 6 else 1) + else if c <= 11507 then 6 else 1) + else + if c <= 12294 + then + (if c <= 11695 + then + (if c <= 11630 + then + (if c <= 11564 + then + (if c <= 11558 + then (if c <= 11557 then 6 else 1) + else if c <= 11559 then 6 else 1) + else + if c <= 11567 + then (if c <= 11565 then 6 else 1) + else if c <= 11623 then 6 else 1) + else + if c <= 11679 + then + (if c <= 11647 + then (if c <= 11631 then 6 else 1) + else if c <= 11670 then 6 else 1) + else + if c <= 11687 + then (if c <= 11686 then 6 else 1) + else if c <= 11694 then 6 else 1) + else + if c <= 11727 + then + (if c <= 11711 + then + (if c <= 11703 + then (if c <= 11702 then 6 else 1) + else if c <= 11710 then 6 else 1) + else + if c <= 11719 + then (if c <= 11718 then 6 else 1) + else if c <= 11726 then 6 else 1) + else + if c <= 12287 + then + (if c <= 11735 + then (if c <= 11734 then 6 else 1) + else if c <= 11742 then 6 else 1) + else + if c <= 12292 + then (if c <= 12288 then 2 else 1) + else 6) + else + if c <= 12442 + then + (if c <= 12343 + then + (if c <= 12320 + then (if c <= 12295 then 6 else 1) + else + if c <= 12336 + then (if c <= 12329 then 6 else 1) + else if c <= 12341 then 6 else 1) + else + if c <= 12348 + then 6 + else + if c <= 12352 + then 1 + else if c <= 12438 then 6 else 1) + else + if c <= 12539 + then + (if c <= 12447 + then 6 + else + if c <= 12448 + then 1 + else if c <= 12538 then 6 else 1) + else + if c <= 12548 + then (if c <= 12543 then 6 else 1) + else + if c <= 12592 + then (if c <= 12591 then 6 else 1) + else if c <= 12686 then 6 else 1) + else + if c <= 42999 + then + (if c <= 42653 + then + (if c <= 42239 + then + (if c <= 40981 + then + (if c <= 13311 + then + (if c <= 12783 + then (if c <= 12735 then 6 else 1) + else if c <= 12799 then 6 else 1) + else + if c <= 19967 + then (if c <= 19903 then 6 else 1) + else 6) + else + if c <= 42191 + then (if c <= 42124 then 6 else 1) + else if c <= 42237 then 6 else 1) + else + if c <= 42559 + then + (if c <= 42511 + then (if c <= 42508 then 6 else 1) + else + if c <= 42537 + then (if c <= 42527 then 6 else 1) + else if c <= 42539 then 6 else 1) + else + if c <= 42622 + then (if c <= 42606 then 6 else 1) + else 6) + else + if c <= 42890 + then + (if c <= 42785 + then + (if c <= 42735 + then (if c <= 42655 then 1 else 6) + else + if c <= 42774 + then 1 + else if c <= 42783 then 6 else 1) + else + if c <= 42887 + then 6 + else if c <= 42888 then 6 else 1) + else + if c <= 42962 + then + (if c <= 42954 + then 6 + else + if c <= 42959 + then 1 + else if c <= 42961 then 6 else 1) + else + if c <= 42993 + then + (if c <= 42964 + then (if c <= 42963 then 6 else 1) + else if c <= 42969 then 6 else 1) + else 6) + else + if c <= 43470 + then + (if c <= 43137 + then + (if c <= 43010 + then + (if c <= 43002 + then 6 + else if c <= 43009 then 6 else 1) + else + if c <= 43019 + then + (if c <= 43014 + then (if c <= 43013 then 6 else 1) + else if c <= 43018 then 6 else 1) + else + if c <= 43071 + then (if c <= 43042 then 6 else 1) + else if c <= 43123 then 6 else 1) + else + if c <= 43273 + then + (if c <= 43258 + then + (if c <= 43249 + then (if c <= 43187 then 6 else 1) + else if c <= 43255 then 6 else 1) + else + if c <= 43260 + then (if c <= 43259 then 6 else 1) + else if c <= 43262 then 6 else 1) + else + if c <= 43359 + then + (if c <= 43311 + then (if c <= 43301 then 6 else 1) + else if c <= 43334 then 6 else 1) + else + if c <= 43395 + then (if c <= 43388 then 6 else 1) + else if c <= 43442 then 6 else 1) + else + if c <= 43615 + then + (if c <= 43513 + then + (if c <= 43493 + then + (if c <= 43487 + then (if c <= 43471 then 6 else 1) + else if c <= 43492 then 6 else 1) + else if c <= 43503 then 6 else 1) + else + if c <= 43583 + then + (if c <= 43519 + then (if c <= 43518 then 6 else 1) + else if c <= 43560 then 6 else 1) + else + if c <= 43587 + then (if c <= 43586 then 6 else 1) + else if c <= 43595 then 6 else 1) + else + if c <= 43645 + then + (if c <= 43638 + then 6 + else + if c <= 43641 + then 1 + else if c <= 43642 then 6 else 1) + else + if c <= 43700 + then + (if c <= 43696 + then (if c <= 43695 then 6 else 1) + else if c <= 43697 then 6 else 1) + else + if c <= 43704 + then (if c <= 43702 then 6 else 1) + else if c <= 43709 then 6 else 1) + else + if c <= 66377 + then + (if c <= 64325 + then + (if c <= 43887 + then + (if c <= 43784 + then + (if c <= 43743 + then + (if c <= 43738 + then + (if c <= 43713 + then (if c <= 43712 then 6 else 1) + else if c <= 43714 then 6 else 1) + else if c <= 43741 then 6 else 1) + else + if c <= 43764 + then + (if c <= 43761 + then (if c <= 43754 then 6 else 1) + else 6) + else + if c <= 43776 + then 1 + else if c <= 43782 then 6 else 1) + else + if c <= 43823 + then + (if c <= 43807 + then + (if c <= 43792 + then (if c <= 43790 then 6 else 1) + else if c <= 43798 then 6 else 1) + else + if c <= 43815 + then (if c <= 43814 then 6 else 1) + else if c <= 43822 then 6 else 1) + else + if c <= 43880 + then + (if c <= 43867 + then (if c <= 43866 then 6 else 1) + else 6) + else if c <= 43881 then 6 else 1) + else + if c <= 64274 + then + (if c <= 55242 + then + (if c <= 44031 + then (if c <= 44002 then 6 else 1) + else + if c <= 55215 + then (if c <= 55203 then 6 else 1) + else if c <= 55238 then 6 else 1) + else + if c <= 64111 + then + (if c <= 63743 + then (if c <= 55291 then 6 else 1) + else if c <= 64109 then 6 else 1) + else + if c <= 64255 + then (if c <= 64217 then 6 else 1) + else if c <= 64262 then 6 else 1) + else + if c <= 64311 + then + (if c <= 64286 + then + (if c <= 64284 + then (if c <= 64279 then 6 else 1) + else if c <= 64285 then 6 else 1) + else + if c <= 64297 + then (if c <= 64296 then 6 else 1) + else if c <= 64310 then 6 else 1) + else + if c <= 64319 + then + (if c <= 64317 + then (if c <= 64316 then 6 else 1) + else if c <= 64318 then 6 else 1) + else + if c <= 64322 + then (if c <= 64321 then 6 else 1) + else if c <= 64324 then 6 else 1) + else + if c <= 65481 + then + (if c <= 65312 + then + (if c <= 65007 + then + (if c <= 64847 + then + (if c <= 64466 + then (if c <= 64433 then 6 else 1) + else if c <= 64829 then 6 else 1) + else + if c <= 64913 + then (if c <= 64911 then 6 else 1) + else if c <= 64967 then 6 else 1) + else + if c <= 65141 + then + (if c <= 65135 + then (if c <= 65019 then 6 else 1) + else if c <= 65140 then 6 else 1) + else + if c <= 65278 + then (if c <= 65276 then 6 else 1) + else if c <= 65279 then 2 else 1) + else + if c <= 65437 + then + (if c <= 65381 + then + (if c <= 65344 + then (if c <= 65338 then 6 else 1) + else if c <= 65370 then 6 else 1) + else 6) + else + if c <= 65470 + then 6 + else + if c <= 65473 + then 1 + else if c <= 65479 then 6 else 1) + else + if c <= 65615 + then + (if c <= 65548 + then + (if c <= 65497 + then + (if c <= 65489 + then (if c <= 65487 then 6 else 1) + else if c <= 65495 then 6 else 1) + else + if c <= 65535 + then (if c <= 65500 then 6 else 1) + else if c <= 65547 then 6 else 1) + else + if c <= 65595 + then + (if c <= 65575 + then (if c <= 65574 then 6 else 1) + else if c <= 65594 then 6 else 1) + else + if c <= 65598 + then (if c <= 65597 then 6 else 1) + else if c <= 65613 then 6 else 1) + else + if c <= 66207 + then + (if c <= 65855 + then + (if c <= 65663 + then (if c <= 65629 then 6 else 1) + else if c <= 65786 then 6 else 1) + else + if c <= 66175 + then (if c <= 65908 then 6 else 1) + else if c <= 66204 then 6 else 1) + else + if c <= 66348 + then + (if c <= 66303 + then (if c <= 66256 then 6 else 1) + else if c <= 66335 then 6 else 1) + else 6) + else + if c <= 67646 + then + (if c <= 66963 + then + (if c <= 66717 + then + (if c <= 66463 + then + (if c <= 66383 + then (if c <= 66378 then 6 else 1) + else + if c <= 66431 + then (if c <= 66421 then 6 else 1) + else if c <= 66461 then 6 else 1) + else + if c <= 66512 + then + (if c <= 66503 + then (if c <= 66499 then 6 else 1) + else if c <= 66511 then 6 else 1) + else + if c <= 66559 + then (if c <= 66517 then 6 else 1) + else 6) + else + if c <= 66863 + then + (if c <= 66775 + then + (if c <= 66735 + then 1 + else if c <= 66771 then 6 else 1) + else + if c <= 66815 + then (if c <= 66811 then 6 else 1) + else if c <= 66855 then 6 else 1) + else + if c <= 66939 + then + (if c <= 66927 + then (if c <= 66915 then 6 else 1) + else if c <= 66938 then 6 else 1) + else + if c <= 66955 + then (if c <= 66954 then 6 else 1) + else if c <= 66962 then 6 else 1) + else + if c <= 67455 + then + (if c <= 67002 + then + (if c <= 66978 + then + (if c <= 66966 + then (if c <= 66965 then 6 else 1) + else if c <= 66977 then 6 else 1) + else + if c <= 66994 + then (if c <= 66993 then 6 else 1) + else if c <= 67001 then 6 else 1) + else + if c <= 67391 + then + (if c <= 67071 + then (if c <= 67004 then 6 else 1) + else if c <= 67382 then 6 else 1) + else + if c <= 67423 + then (if c <= 67413 then 6 else 1) + else if c <= 67431 then 6 else 1) + else + if c <= 67591 + then + (if c <= 67505 + then + (if c <= 67462 + then (if c <= 67461 then 6 else 1) + else if c <= 67504 then 6 else 1) + else + if c <= 67583 + then (if c <= 67514 then 6 else 1) + else if c <= 67589 then 6 else 1) + else + if c <= 67638 + then + (if c <= 67593 + then (if c <= 67592 then 6 else 1) + else if c <= 67637 then 6 else 1) + else + if c <= 67643 + then (if c <= 67640 then 6 else 1) + else if c <= 67644 then 6 else 1) + else + if c <= 68296 + then + (if c <= 68029 + then + (if c <= 67827 + then + (if c <= 67711 + then + (if c <= 67679 + then (if c <= 67669 then 6 else 1) + else if c <= 67702 then 6 else 1) + else + if c <= 67807 + then (if c <= 67742 then 6 else 1) + else if c <= 67826 then 6 else 1) + else + if c <= 67871 + then + (if c <= 67839 + then (if c <= 67829 then 6 else 1) + else if c <= 67861 then 6 else 1) + else + if c <= 67967 + then (if c <= 67897 then 6 else 1) + else if c <= 68023 then 6 else 1) + else + if c <= 68120 + then + (if c <= 68111 + then + (if c <= 68095 + then (if c <= 68031 then 6 else 1) + else if c <= 68096 then 6 else 1) + else + if c <= 68116 + then (if c <= 68115 then 6 else 1) + else if c <= 68119 then 6 else 1) + else + if c <= 68223 + then + (if c <= 68191 + then (if c <= 68149 then 6 else 1) + else if c <= 68220 then 6 else 1) + else + if c <= 68287 + then (if c <= 68252 then 6 else 1) + else if c <= 68295 then 6 else 1) + else + if c <= 68863 + then + (if c <= 68479 + then + (if c <= 68415 + then + (if c <= 68351 + then (if c <= 68324 then 6 else 1) + else if c <= 68405 then 6 else 1) + else + if c <= 68447 + then (if c <= 68437 then 6 else 1) + else if c <= 68466 then 6 else 1) + else + if c <= 68735 + then + (if c <= 68607 + then (if c <= 68497 then 6 else 1) + else if c <= 68680 then 6 else 1) + else + if c <= 68799 + then (if c <= 68786 then 6 else 1) + else if c <= 68850 then 6 else 1) + else + if c <= 69414 + then + (if c <= 69295 + then + (if c <= 69247 + then (if c <= 68899 then 6 else 1) + else if c <= 69289 then 6 else 1) + else + if c <= 69375 + then (if c <= 69297 then 6 else 1) + else if c <= 69404 then 6 else 1) + else + if c <= 69487 + then + (if c <= 69423 + then (if c <= 69415 then 6 else 1) + else if c <= 69445 then 6 else 1) + else + if c <= 69551 + then (if c <= 69505 then 6 else 1) + else if c <= 69572 then 6 else 1) + else + if c <= 120122 + then + (if c <= 72348 + then + (if c <= 70655 + then + (if c <= 70162 + then + (if c <= 69958 + then + (if c <= 69762 + then + (if c <= 69744 + then + (if c <= 69634 + then (if c <= 69622 then 6 else 1) + else if c <= 69687 then 6 else 1) + else + if c <= 69748 + then (if c <= 69746 then 6 else 1) + else if c <= 69749 then 6 else 1) + else + if c <= 69890 + then + (if c <= 69839 + then (if c <= 69807 then 6 else 1) + else if c <= 69864 then 6 else 1) + else + if c <= 69955 + then (if c <= 69926 then 6 else 1) + else if c <= 69956 then 6 else 1) + else + if c <= 70080 + then + (if c <= 70005 + then + (if c <= 69967 + then (if c <= 69959 then 6 else 1) + else if c <= 70002 then 6 else 1) + else + if c <= 70018 + then (if c <= 70006 then 6 else 1) + else if c <= 70066 then 6 else 1) + else + if c <= 70107 + then + (if c <= 70105 + then (if c <= 70084 then 6 else 1) + else if c <= 70106 then 6 else 1) + else + if c <= 70143 + then (if c <= 70108 then 6 else 1) + else if c <= 70161 then 6 else 1) + else + if c <= 70414 + then + (if c <= 70286 + then + (if c <= 70279 + then + (if c <= 70271 + then (if c <= 70187 then 6 else 1) + else if c <= 70278 then 6 else 1) + else + if c <= 70281 + then (if c <= 70280 then 6 else 1) + else if c <= 70285 then 6 else 1) + else + if c <= 70319 + then + (if c <= 70302 + then (if c <= 70301 then 6 else 1) + else if c <= 70312 then 6 else 1) + else + if c <= 70404 + then (if c <= 70366 then 6 else 1) + else if c <= 70412 then 6 else 1) + else + if c <= 70452 + then + (if c <= 70441 + then + (if c <= 70418 + then (if c <= 70416 then 6 else 1) + else if c <= 70440 then 6 else 1) + else + if c <= 70449 + then (if c <= 70448 then 6 else 1) + else if c <= 70451 then 6 else 1) + else + if c <= 70479 + then + (if c <= 70460 + then (if c <= 70457 then 6 else 1) + else if c <= 70461 then 6 else 1) + else + if c <= 70492 + then (if c <= 70480 then 6 else 1) + else if c <= 70497 then 6 else 1) + else + if c <= 71934 + then + (if c <= 71167 + then + (if c <= 70851 + then + (if c <= 70750 + then + (if c <= 70726 + then (if c <= 70708 then 6 else 1) + else if c <= 70730 then 6 else 1) + else + if c <= 70783 + then (if c <= 70753 then 6 else 1) + else if c <= 70831 then 6 else 1) + else + if c <= 71039 + then + (if c <= 70854 + then (if c <= 70853 then 6 else 1) + else if c <= 70855 then 6 else 1) + else + if c <= 71127 + then (if c <= 71086 then 6 else 1) + else if c <= 71131 then 6 else 1) + else + if c <= 71423 + then + (if c <= 71295 + then + (if c <= 71235 + then (if c <= 71215 then 6 else 1) + else if c <= 71236 then 6 else 1) + else + if c <= 71351 + then (if c <= 71338 then 6 else 1) + else if c <= 71352 then 6 else 1) + else + if c <= 71679 + then + (if c <= 71487 + then (if c <= 71450 then 6 else 1) + else if c <= 71494 then 6 else 1) + else + if c <= 71839 + then (if c <= 71723 then 6 else 1) + else if c <= 71903 then 6 else 1) + else + if c <= 72105 + then + (if c <= 71959 + then + (if c <= 71947 + then + (if c <= 71944 + then (if c <= 71942 then 6 else 1) + else if c <= 71945 then 6 else 1) + else + if c <= 71956 + then (if c <= 71955 then 6 else 1) + else if c <= 71958 then 6 else 1) + else + if c <= 72000 + then + (if c <= 71998 + then (if c <= 71983 then 6 else 1) + else if c <= 71999 then 6 else 1) + else + if c <= 72095 + then (if c <= 72001 then 6 else 1) + else if c <= 72103 then 6 else 1) + else + if c <= 72202 + then + (if c <= 72162 + then + (if c <= 72160 + then (if c <= 72144 then 6 else 1) + else if c <= 72161 then 6 else 1) + else + if c <= 72191 + then (if c <= 72163 then 6 else 1) + else if c <= 72192 then 6 else 1) + else + if c <= 72271 + then + (if c <= 72249 + then (if c <= 72242 then 6 else 1) + else if c <= 72250 then 6 else 1) + else + if c <= 72283 + then (if c <= 72272 then 6 else 1) + else if c <= 72329 then 6 else 1) + else + if c <= 94031 + then + (if c <= 73727 + then + (if c <= 72970 + then + (if c <= 72767 + then + (if c <= 72703 + then + (if c <= 72367 + then (if c <= 72349 then 6 else 1) + else if c <= 72440 then 6 else 1) + else + if c <= 72713 + then (if c <= 72712 then 6 else 1) + else if c <= 72750 then 6 else 1) + else + if c <= 72959 + then + (if c <= 72817 + then (if c <= 72768 then 6 else 1) + else if c <= 72847 then 6 else 1) + else + if c <= 72967 + then (if c <= 72966 then 6 else 1) + else if c <= 72969 then 6 else 1) + else + if c <= 73065 + then + (if c <= 73055 + then + (if c <= 73029 + then (if c <= 73008 then 6 else 1) + else if c <= 73030 then 6 else 1) + else + if c <= 73062 + then (if c <= 73061 then 6 else 1) + else if c <= 73064 then 6 else 1) + else + if c <= 73439 + then + (if c <= 73111 + then (if c <= 73097 then 6 else 1) + else if c <= 73112 then 6 else 1) + else + if c <= 73647 + then (if c <= 73458 then 6 else 1) + else if c <= 73648 then 6 else 1) + else + if c <= 92783 + then + (if c <= 77823 + then + (if c <= 74879 + then + (if c <= 74751 + then (if c <= 74649 then 6 else 1) + else if c <= 74862 then 6 else 1) + else + if c <= 77711 + then (if c <= 75075 then 6 else 1) + else if c <= 77808 then 6 else 1) + else + if c <= 92159 + then + (if c <= 82943 + then (if c <= 78894 then 6 else 1) + else if c <= 83526 then 6 else 1) + else + if c <= 92735 + then (if c <= 92728 then 6 else 1) + else if c <= 92766 then 6 else 1) + else + if c <= 93026 + then + (if c <= 92927 + then + (if c <= 92879 + then (if c <= 92862 then 6 else 1) + else if c <= 92909 then 6 else 1) + else + if c <= 92991 + then (if c <= 92975 then 6 else 1) + else if c <= 92995 then 6 else 1) + else + if c <= 93759 + then + (if c <= 93052 + then (if c <= 93047 then 6 else 1) + else if c <= 93071 then 6 else 1) + else + if c <= 93951 + then (if c <= 93823 then 6 else 1) + else if c <= 94026 then 6 else 1) + else + if c <= 113791 + then + (if c <= 110580 + then + (if c <= 94207 + then + (if c <= 94175 + then + (if c <= 94098 + then (if c <= 94032 then 6 else 1) + else if c <= 94111 then 6 else 1) + else + if c <= 94178 + then (if c <= 94177 then 6 else 1) + else if c <= 94179 then 6 else 1) + else + if c <= 101631 + then + (if c <= 100351 + then (if c <= 100343 then 6 else 1) + else if c <= 101589 then 6 else 1) + else + if c <= 110575 + then (if c <= 101640 then 6 else 1) + else if c <= 110579 then 6 else 1) + else + if c <= 110947 + then + (if c <= 110591 + then + (if c <= 110588 + then (if c <= 110587 then 6 else 1) + else if c <= 110590 then 6 else 1) + else + if c <= 110927 + then (if c <= 110882 then 6 else 1) + else if c <= 110930 then 6 else 1) + else + if c <= 113663 + then + (if c <= 110959 + then (if c <= 110951 then 6 else 1) + else if c <= 111355 then 6 else 1) + else + if c <= 113775 + then (if c <= 113770 then 6 else 1) + else if c <= 113788 then 6 else 1) + else + if c <= 119981 + then + (if c <= 119965 + then + (if c <= 119807 + then + (if c <= 113807 + then (if c <= 113800 then 6 else 1) + else if c <= 113817 then 6 else 1) + else + if c <= 119893 + then (if c <= 119892 then 6 else 1) + else if c <= 119964 then 6 else 1) + else + if c <= 119972 + then + (if c <= 119969 + then (if c <= 119967 then 6 else 1) + else if c <= 119970 then 6 else 1) + else + if c <= 119976 + then (if c <= 119974 then 6 else 1) + else if c <= 119980 then 6 else 1) + else + if c <= 120070 + then + (if c <= 119996 + then + (if c <= 119994 + then (if c <= 119993 then 6 else 1) + else if c <= 119995 then 6 else 1) + else + if c <= 120004 + then (if c <= 120003 then 6 else 1) + else if c <= 120069 then 6 else 1) + else + if c <= 120085 + then + (if c <= 120076 + then (if c <= 120074 then 6 else 1) + else if c <= 120084 then 6 else 1) + else + if c <= 120093 + then (if c <= 120092 then 6 else 1) + else if c <= 120121 then 6 else 1) + else + if c <= 131071 + then + (if c <= 126468 + then + (if c <= 122623 + then + (if c <= 120571 + then + (if c <= 120145 + then + (if c <= 120133 + then + (if c <= 120127 + then (if c <= 120126 then 6 else 1) + else if c <= 120132 then 6 else 1) + else + if c <= 120137 + then (if c <= 120134 then 6 else 1) + else if c <= 120144 then 6 else 1) + else + if c <= 120513 + then + (if c <= 120487 + then (if c <= 120485 then 6 else 1) + else if c <= 120512 then 6 else 1) + else + if c <= 120539 + then (if c <= 120538 then 6 else 1) + else if c <= 120570 then 6 else 1) + else + if c <= 120687 + then + (if c <= 120629 + then + (if c <= 120597 + then (if c <= 120596 then 6 else 1) + else if c <= 120628 then 6 else 1) + else + if c <= 120655 + then (if c <= 120654 then 6 else 1) + else if c <= 120686 then 6 else 1) + else + if c <= 120745 + then + (if c <= 120713 + then (if c <= 120712 then 6 else 1) + else if c <= 120744 then 6 else 1) + else + if c <= 120771 + then (if c <= 120770 then 6 else 1) + else if c <= 120779 then 6 else 1) + else + if c <= 124895 + then + (if c <= 123190 + then + (if c <= 122654 + then 6 + else + if c <= 123135 + then 1 + else if c <= 123180 then 6 else 1) + else + if c <= 123535 + then + (if c <= 123213 + then (if c <= 123197 then 6 else 1) + else if c <= 123214 then 6 else 1) + else + if c <= 123583 + then (if c <= 123565 then 6 else 1) + else if c <= 123627 then 6 else 1) + else + if c <= 124927 + then + (if c <= 124908 + then + (if c <= 124903 + then (if c <= 124902 then 6 else 1) + else if c <= 124907 then 6 else 1) + else + if c <= 124911 + then (if c <= 124910 then 6 else 1) + else if c <= 124926 then 6 else 1) + else + if c <= 125258 + then + (if c <= 125183 + then (if c <= 125124 then 6 else 1) + else if c <= 125251 then 6 else 1) + else + if c <= 126463 + then (if c <= 125259 then 6 else 1) + else if c <= 126467 then 6 else 1) + else + if c <= 126552 + then + (if c <= 126529 + then + (if c <= 126504 + then + (if c <= 126499 + then + (if c <= 126496 + then (if c <= 126495 then 6 else 1) + else if c <= 126498 then 6 else 1) + else + if c <= 126502 + then (if c <= 126500 then 6 else 1) + else if c <= 126503 then 6 else 1) + else + if c <= 126520 + then + (if c <= 126515 + then (if c <= 126514 then 6 else 1) + else if c <= 126519 then 6 else 1) + else + if c <= 126522 + then (if c <= 126521 then 6 else 1) + else if c <= 126523 then 6 else 1) + else + if c <= 126540 + then + (if c <= 126536 + then + (if c <= 126534 + then (if c <= 126530 then 6 else 1) + else if c <= 126535 then 6 else 1) + else + if c <= 126538 + then (if c <= 126537 then 6 else 1) + else if c <= 126539 then 6 else 1) + else + if c <= 126547 + then + (if c <= 126544 + then (if c <= 126543 then 6 else 1) + else if c <= 126546 then 6 else 1) + else + if c <= 126550 + then (if c <= 126548 then 6 else 1) + else if c <= 126551 then 6 else 1) + else + if c <= 126579 + then + (if c <= 126560 + then + (if c <= 126556 + then + (if c <= 126554 + then (if c <= 126553 then 6 else 1) + else if c <= 126555 then 6 else 1) + else + if c <= 126558 + then (if c <= 126557 then 6 else 1) + else if c <= 126559 then 6 else 1) + else + if c <= 126566 + then + (if c <= 126563 + then (if c <= 126562 then 6 else 1) + else if c <= 126564 then 6 else 1) + else + if c <= 126571 + then (if c <= 126570 then 6 else 1) + else if c <= 126578 then 6 else 1) + else + if c <= 126602 + then + (if c <= 126589 + then + (if c <= 126584 + then (if c <= 126583 then 6 else 1) + else if c <= 126588 then 6 else 1) + else + if c <= 126591 + then (if c <= 126590 then 6 else 1) + else if c <= 126601 then 6 else 1) + else + if c <= 126628 + then + (if c <= 126624 + then (if c <= 126619 then 6 else 1) + else if c <= 126627 then 6 else 1) + else + if c <= 126634 + then (if c <= 126633 then 6 else 1) + else if c <= 126651 then 6 else 1) + else + if c <= 183983 + then + (if c <= 177983 + then + (if c <= 173823 + then (if c <= 173791 then 6 else 1) + else if c <= 177976 then 6 else 1) + else + if c <= 178207 + then (if c <= 178205 then 6 else 1) + else if c <= 183969 then 6 else 1) + else if c <= 191456 then 6 else 1) + else (-1) +[@@@warning "-39"] +open Token +open Lex_env +module Sedlexing = Flow_sedlexing +let lexeme = Sedlexing.Utf8.lexeme +let lexeme_to_buffer = Sedlexing.Utf8.lexeme_to_buffer +let lexeme_to_buffer2 = Sedlexing.Utf8.lexeme_to_buffer2 +let sub_lexeme = Sedlexing.Utf8.sub_lexeme +let is_whitespace = + function + | 0x0009 | 0x000B | 0x000C | 0x0020 | 0x00A0 | 0xfeff | 0x1680 | 0x2000 + | 0x2001 | 0x2002 | 0x2003 | 0x2004 | 0x2005 | 0x2006 | 0x2007 | 0x2008 + | 0x2009 | 0x200a | 0x202f | 0x205f | 0x3000 -> true + | _ -> false +let rec loop_id_continues lexbuf = + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_1 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 1 + | 1 -> 2 + | 2 -> 0 + | 3 -> __sedlex_state_4 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_4 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 2; + (match __sedlex_partition_2 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_5 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_5 = + function + | lexbuf -> + (match __sedlex_partition_3 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_6 lexbuf + | 1 -> __sedlex_state_10 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_6 = + function + | lexbuf -> + (match __sedlex_partition_4 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_7 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_7 = + function + | lexbuf -> + (match __sedlex_partition_4 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_8 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_8 = + function + | lexbuf -> + (match __sedlex_partition_4 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 0 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_10 = + function + | lexbuf -> + (match __sedlex_partition_4 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_11 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_11 = + function + | lexbuf -> + (match __sedlex_partition_5 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_11 lexbuf + | 1 -> 0 + | _ -> Sedlexing.backtrack lexbuf) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> loop_id_continues lexbuf + | 1 -> true + | 2 -> + let s = Sedlexing.current_code_point lexbuf in + if Js_id.is_valid_unicode_id s + then loop_id_continues lexbuf + else (Sedlexing.backoff lexbuf 1; false) + | _ -> assert false) +let rec loop_jsx_id_continues lexbuf = + (let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_6 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 1 + | 1 -> 2 + | 2 -> 0 + | 3 -> __sedlex_state_4 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_4 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 2; + (match __sedlex_partition_2 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_5 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_5 = + function + | lexbuf -> + (match __sedlex_partition_3 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_6 lexbuf + | 1 -> __sedlex_state_10 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_6 = + function + | lexbuf -> + (match __sedlex_partition_4 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_7 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_7 = + function + | lexbuf -> + (match __sedlex_partition_4 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_8 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_8 = + function + | lexbuf -> + (match __sedlex_partition_4 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 0 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_10 = + function + | lexbuf -> + (match __sedlex_partition_4 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_11 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_11 = + function + | lexbuf -> + (match __sedlex_partition_5 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_11 lexbuf + | 1 -> 0 + | _ -> Sedlexing.backtrack lexbuf) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> loop_jsx_id_continues lexbuf + | 1 -> () + | 2 -> + let s = Sedlexing.current_code_point lexbuf in + if Js_id.is_valid_unicode_id s + then loop_jsx_id_continues lexbuf + else Sedlexing.backoff lexbuf 1 + | _ -> assert false) : unit) +let pos_at_offset env offset = + { + Loc.line = (Lex_env.line env); + column = (offset - (Lex_env.bol_offset env)) + } +let loc_of_offsets env start_offset end_offset = + { + Loc.source = (Lex_env.source env); + start = (pos_at_offset env start_offset); + _end = (pos_at_offset env end_offset) + } +let start_pos_of_lexbuf env (lexbuf : Sedlexing.lexbuf) = + let start_offset = Sedlexing.lexeme_start lexbuf in + pos_at_offset env start_offset +let end_pos_of_lexbuf env (lexbuf : Sedlexing.lexbuf) = + let end_offset = Sedlexing.lexeme_end lexbuf in + pos_at_offset env end_offset +let loc_of_lexbuf env (lexbuf : Sedlexing.lexbuf) = + let start_offset = Sedlexing.lexeme_start lexbuf in + let end_offset = Sedlexing.lexeme_end lexbuf in + loc_of_offsets env start_offset end_offset +let loc_of_token env lex_token = + match lex_token with + | T_IDENTIFIER { loc;_} | T_JSX_IDENTIFIER { loc;_} | T_STRING + (loc, _, _, _) -> loc + | T_JSX_TEXT (loc, _, _) -> loc + | T_TEMPLATE_PART (loc, _, _) -> loc + | T_REGEXP (loc, _, _) -> loc + | _ -> loc_of_lexbuf env env.lex_lb +let lex_error (env : Lex_env.t) loc err = + (let lex_errors_acc = (loc, err) :: ((env.lex_state).lex_errors_acc) in + { env with lex_state = { lex_errors_acc } } : Lex_env.t) +let unexpected_error (env : Lex_env.t) (loc : Loc.t) value = + lex_error env loc (Parse_error.Unexpected (quote_token_value value)) +let unexpected_error_w_suggest (env : Lex_env.t) (loc : Loc.t) value suggest + = + lex_error env loc + (Parse_error.UnexpectedTokenWithSuggestion (value, suggest)) +let illegal (env : Lex_env.t) (loc : Loc.t) = + lex_error env loc (Parse_error.Unexpected "token ILLEGAL") +let new_line env lexbuf = + let offset = Sedlexing.lexeme_end lexbuf in + let lex_bol = { line = ((Lex_env.line env) + 1); offset } in + { env with Lex_env.lex_bol = lex_bol } +let bigint_strip_n raw = + let size = String.length raw in + let str = + if (size != 0) && ((raw.[size - 1]) == 'n') + then String.sub raw 0 (size - 1) + else raw in + str +let mk_comment (env : Lex_env.t) (start : Loc.position) (_end : Loc.position) + (buf : Buffer.t) (multiline : bool) = + (let open Flow_ast.Comment in + let loc = { Loc.source = (Lex_env.source env); start; _end } in + let text = Buffer.contents buf in + let kind = if multiline then Block else Line in + let on_newline = + let open Loc in + ((env.lex_last_loc)._end).Loc.line < (loc.start).Loc.line in + let c = { kind; text; on_newline } in (loc, c) : Loc.t + Flow_ast.Comment.t) +let split_number_type = + let rec strip_whitespace i len lexeme = + if is_whitespace (lexeme.(i)) + then ((strip_whitespace)[@tailcall ]) (i + 1) len lexeme + else Sedlexing.string_of_utf8 (Array.sub lexeme i (len - i)) in + fun (lexeme : int array) -> + if (lexeme.(0)) = (Char.code '-') + then + let num = strip_whitespace 1 (Array.length lexeme) lexeme in + let raw = Sedlexing.string_of_utf8 lexeme in (true, num, raw) + else (let raw = Sedlexing.string_of_utf8 lexeme in (false, raw, raw)) +let mk_num_singleton number_type (lexeme : int array) = + let (neg, num, raw) = split_number_type lexeme in + let value = + match number_type with + | LEGACY_OCTAL -> + (try Int64.to_float (Int64.of_string ("0o" ^ num)) + with | Failure _ -> failwith ("Invalid legacy octal " ^ num)) + | BINARY | OCTAL -> + (try Int64.to_float (Int64.of_string num) + with | Failure _ -> failwith ("Invalid binary/octal " ^ num)) + | LEGACY_NON_OCTAL | NORMAL -> + (try float_of_string num + with | Failure _ -> failwith ("Invalid number " ^ num)) in + let value = if neg then -. value else value in + T_NUMBER_SINGLETON_TYPE { kind = number_type; value; raw } +let mk_bignum_singleton kind lexeme = + let (neg, num, raw) = split_number_type lexeme in + let postraw = bigint_strip_n num in + let value = + (Int64.of_string_opt postraw) |> + (Option.map (fun value -> if neg then Int64.neg value else value)) in + T_BIGINT_SINGLETON_TYPE { kind; value; raw } +let assert_valid_unicode_in_identifier env loc code = + if Js_id.is_valid_unicode_id code + then env + else lex_error env loc Parse_error.IllegalUnicodeEscape +let decode_identifier = + let loc_and_sub_lexeme env offset lexbuf trim_start trim_end = + let start_offset = offset + (Sedlexing.lexeme_start lexbuf) in + let end_offset = offset + (Sedlexing.lexeme_end lexbuf) in + let loc = loc_of_offsets env start_offset end_offset in + (loc, + (sub_lexeme lexbuf trim_start + (((Sedlexing.lexeme_length lexbuf) - trim_start) - trim_end))) in + let rec id_char env offset buf lexbuf = + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_7 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 2 + | 1 -> __sedlex_state_2 lexbuf + | 2 -> __sedlex_state_3 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_2 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 3; + (match __sedlex_partition_8 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_2 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_3 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 3; + (match __sedlex_partition_2 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_4 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_4 = + function + | lexbuf -> + (match __sedlex_partition_3 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_5 lexbuf + | 1 -> __sedlex_state_9 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_5 = + function + | lexbuf -> + (match __sedlex_partition_4 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_6 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_6 = + function + | lexbuf -> + (match __sedlex_partition_4 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_7 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_7 = + function + | lexbuf -> + (match __sedlex_partition_4 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 0 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_9 = + function + | lexbuf -> + (match __sedlex_partition_4 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_10 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_10 = + function + | lexbuf -> + (match __sedlex_partition_5 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_10 lexbuf + | 1 -> 1 + | _ -> Sedlexing.backtrack lexbuf) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> + let (loc, hex) = loc_and_sub_lexeme env offset lexbuf 2 0 in + let code = int_of_string ("0x" ^ hex) in + let env = + if not (Uchar.is_valid code) + then lex_error env loc Parse_error.IllegalUnicodeEscape + else assert_valid_unicode_in_identifier env loc code in + (Wtf8.add_wtf_8 buf code; id_char env offset buf lexbuf) + | 1 -> + let (loc, hex) = loc_and_sub_lexeme env offset lexbuf 3 1 in + let code = int_of_string ("0x" ^ hex) in + let env = assert_valid_unicode_in_identifier env loc code in + (Wtf8.add_wtf_8 buf code; id_char env offset buf lexbuf) + | 2 -> (env, (Buffer.contents buf)) + | 3 -> (lexeme_to_buffer lexbuf buf; id_char env offset buf lexbuf) + | _ -> failwith "unreachable id_char") in + fun env -> + fun raw -> + let offset = Sedlexing.lexeme_start env.lex_lb in + let lexbuf = Sedlexing.from_int_array raw in + let buf = Buffer.create (Array.length raw) in + id_char env offset buf lexbuf +let recover env lexbuf ~f = + let env = illegal env (loc_of_lexbuf env lexbuf) in + Sedlexing.rollback lexbuf; f env lexbuf +type jsx_text_mode = + | JSX_SINGLE_QUOTED_TEXT + | JSX_DOUBLE_QUOTED_TEXT + | JSX_CHILD_TEXT +type result = + | Token of Lex_env.t * Token.t + | Comment of Lex_env.t * Loc.t Flow_ast.Comment.t + | Continue of Lex_env.t +let rec comment env buf lexbuf = + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_9 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | 1 -> 0 + | 2 -> __sedlex_state_3 lexbuf + | 3 -> __sedlex_state_5 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_1 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 3; + (match __sedlex_partition_10 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_3 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_11 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 0 + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_5 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 3; + (match __sedlex_partition_12 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_6 lexbuf + | 1 -> 1 + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_6 = + function + | lexbuf -> + (match __sedlex_partition_13 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 2 + | _ -> Sedlexing.backtrack lexbuf) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> + let env = new_line env lexbuf in + (lexeme_to_buffer lexbuf buf; comment env buf lexbuf) + | 1 -> + let env = + if is_in_comment_syntax env + then + let loc = loc_of_lexbuf env lexbuf in + unexpected_error_w_suggest env loc "*/" "*-/" + else env in + (env, (end_pos_of_lexbuf env lexbuf)) + | 2 -> + if is_in_comment_syntax env + then (env, (end_pos_of_lexbuf env lexbuf)) + else (Buffer.add_string buf "*-/"; comment env buf lexbuf) + | 3 -> (lexeme_to_buffer lexbuf buf; comment env buf lexbuf) + | _ -> + let env = illegal env (loc_of_lexbuf env lexbuf) in + (env, (end_pos_of_lexbuf env lexbuf))) +let rec line_comment env buf lexbuf = + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_14 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 0 + | 1 -> __sedlex_state_2 lexbuf + | 2 -> 1 + | 3 -> __sedlex_state_4 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_2 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 2; + (match __sedlex_partition_15 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_2 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_4 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 1; + (match __sedlex_partition_11 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 1 + | _ -> Sedlexing.backtrack lexbuf)) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> (env, (end_pos_of_lexbuf env lexbuf)) + | 1 -> + let { Loc.line = line; column } = end_pos_of_lexbuf env lexbuf in + let env = new_line env lexbuf in + let len = Sedlexing.lexeme_length lexbuf in + let end_pos = { Loc.line = line; column = (column - len) } in + (env, end_pos) + | 2 -> (lexeme_to_buffer lexbuf buf; line_comment env buf lexbuf) + | _ -> failwith "unreachable line_comment") +let string_escape env lexbuf = + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_16 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 0 + | 1 -> 16 + | 2 -> 15 + | 3 -> __sedlex_state_4 lexbuf + | 4 -> __sedlex_state_6 lexbuf + | 5 -> __sedlex_state_9 lexbuf + | 6 -> 0 + | 7 -> 5 + | 8 -> 6 + | 9 -> 7 + | 10 -> 8 + | 11 -> 9 + | 12 -> __sedlex_state_16 lexbuf + | 13 -> 10 + | 14 -> __sedlex_state_25 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_4 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 15; + (match __sedlex_partition_11 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 15 + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_6 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 4; + (match __sedlex_partition_17 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_7 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_7 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 3; + (match __sedlex_partition_17 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 2 + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_9 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 11; + (match __sedlex_partition_17 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_7 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_16 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 14; + (match __sedlex_partition_3 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_17 lexbuf + | 1 -> __sedlex_state_21 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_17 = + function + | lexbuf -> + (match __sedlex_partition_4 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_18 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_18 = + function + | lexbuf -> + (match __sedlex_partition_4 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_19 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_19 = + function + | lexbuf -> + (match __sedlex_partition_4 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 12 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_21 = + function + | lexbuf -> + (match __sedlex_partition_4 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_22 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_22 = + function + | lexbuf -> + (match __sedlex_partition_5 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_22 lexbuf + | 1 -> 13 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_25 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 14; + (match __sedlex_partition_4 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_26 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_26 = + function + | lexbuf -> + (match __sedlex_partition_4 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 1 + | _ -> Sedlexing.backtrack lexbuf) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> + let str = lexeme lexbuf in + let codes = Sedlexing.lexeme lexbuf in (env, str, codes, false) + | 1 -> + let str = lexeme lexbuf in + let code = int_of_string ("0" ^ str) in (env, str, [|code|], false) + | 2 -> + let str = lexeme lexbuf in + let code = int_of_string ("0o" ^ str) in + if code < 256 + then (env, str, [|code|], true) + else + (let remainder = code land 7 in + let code = code lsr 3 in + (env, str, [|code;((Char.code '0') + remainder)|], true)) + | 3 -> + let str = lexeme lexbuf in + let code = int_of_string ("0o" ^ str) in (env, str, [|code|], true) + | 4 -> (env, "0", [|0x0|], false) + | 5 -> (env, "b", [|0x8|], false) + | 6 -> (env, "f", [|0xC|], false) + | 7 -> (env, "n", [|0xA|], false) + | 8 -> (env, "r", [|0xD|], false) + | 9 -> (env, "t", [|0x9|], false) + | 10 -> (env, "v", [|0xB|], false) + | 11 -> + let str = lexeme lexbuf in + let code = int_of_string ("0o" ^ str) in (env, str, [|code|], true) + | 12 -> + let str = lexeme lexbuf in + let hex = String.sub str 1 ((String.length str) - 1) in + let code = int_of_string ("0x" ^ hex) in (env, str, [|code|], false) + | 13 -> + let str = lexeme lexbuf in + let hex = String.sub str 2 ((String.length str) - 3) in + let code = int_of_string ("0x" ^ hex) in + let env = + if code > 0x10FFFF + then illegal env (loc_of_lexbuf env lexbuf) + else env in + (env, str, [|code|], false) + | 14 -> + let str = lexeme lexbuf in + let codes = Sedlexing.lexeme lexbuf in + let env = illegal env (loc_of_lexbuf env lexbuf) in + (env, str, codes, false) + | 15 -> + let str = lexeme lexbuf in + let env = new_line env lexbuf in (env, str, [||], false) + | 16 -> + let str = lexeme lexbuf in + let codes = Sedlexing.lexeme lexbuf in (env, str, codes, false) + | _ -> failwith "unreachable string_escape") +let rec string_quote env q buf raw octal lexbuf = + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_18 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 3 + | 1 -> __sedlex_state_2 lexbuf + | 2 -> 2 + | 3 -> 0 + | 4 -> 1 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_2 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 4; + (match __sedlex_partition_19 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_2 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> + let q' = lexeme lexbuf in + (Buffer.add_string raw q'; + if q = q' + then (env, (end_pos_of_lexbuf env lexbuf), octal) + else + (Buffer.add_string buf q'; string_quote env q buf raw octal lexbuf)) + | 1 -> + (Buffer.add_string raw "\\"; + (let (env, str, codes, octal') = string_escape env lexbuf in + let octal = octal' || octal in + Buffer.add_string raw str; + Array.iter (Wtf8.add_wtf_8 buf) codes; + string_quote env q buf raw octal lexbuf)) + | 2 -> + let x = lexeme lexbuf in + (Buffer.add_string raw x; + (let env = illegal env (loc_of_lexbuf env lexbuf) in + let env = new_line env lexbuf in + Buffer.add_string buf x; + (env, (end_pos_of_lexbuf env lexbuf), octal))) + | 3 -> + let x = lexeme lexbuf in + (Buffer.add_string raw x; + (let env = illegal env (loc_of_lexbuf env lexbuf) in + Buffer.add_string buf x; + (env, (end_pos_of_lexbuf env lexbuf), octal))) + | 4 -> + (lexeme_to_buffer2 lexbuf raw buf; + string_quote env q buf raw octal lexbuf) + | _ -> failwith "unreachable string_quote") +let rec template_part env cooked raw literal lexbuf = + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_20 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 0 + | 1 -> __sedlex_state_2 lexbuf + | 2 -> 5 + | 3 -> __sedlex_state_4 lexbuf + | 4 -> __sedlex_state_6 lexbuf + | 5 -> 3 + | 6 -> 1 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_2 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 6; + (match __sedlex_partition_21 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_2 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_4 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 5; + (match __sedlex_partition_11 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 4 + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_6 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 6; + (match __sedlex_partition_22 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 2 + | _ -> Sedlexing.backtrack lexbuf)) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> let env = illegal env (loc_of_lexbuf env lexbuf) in (env, true) + | 1 -> (Buffer.add_char literal '`'; (env, true)) + | 2 -> (Buffer.add_string literal "${"; (env, false)) + | 3 -> + (Buffer.add_char raw '\\'; + Buffer.add_char literal '\\'; + (let (env, str, codes, _) = string_escape env lexbuf in + Buffer.add_string raw str; + Buffer.add_string literal str; + Array.iter (Wtf8.add_wtf_8 cooked) codes; + template_part env cooked raw literal lexbuf)) + | 4 -> + (Buffer.add_string raw "\r\n"; + Buffer.add_string literal "\r\n"; + Buffer.add_string cooked "\n"; + (let env = new_line env lexbuf in + template_part env cooked raw literal lexbuf)) + | 5 -> + let lf = lexeme lexbuf in + (Buffer.add_string raw lf; + Buffer.add_string literal lf; + Buffer.add_char cooked '\n'; + (let env = new_line env lexbuf in + template_part env cooked raw literal lexbuf)) + | 6 -> + let c = lexeme lexbuf in + (Buffer.add_string raw c; + Buffer.add_string literal c; + Buffer.add_string cooked c; + template_part env cooked raw literal lexbuf) + | _ -> failwith "unreachable template_part") +let token (env : Lex_env.t) lexbuf = + (let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_50 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 98 + | 1 -> 99 + | 2 -> __sedlex_state_3 lexbuf + | 3 -> 0 + | 4 -> __sedlex_state_6 lexbuf + | 5 -> __sedlex_state_8 lexbuf + | 6 -> 7 + | 7 -> __sedlex_state_12 lexbuf + | 8 -> 97 + | 9 -> __sedlex_state_15 lexbuf + | 10 -> __sedlex_state_17 lexbuf + | 11 -> 38 + | 12 -> 39 + | 13 -> __sedlex_state_23 lexbuf + | 14 -> __sedlex_state_28 lexbuf + | 15 -> 45 + | 16 -> __sedlex_state_32 lexbuf + | 17 -> __sedlex_state_35 lexbuf + | 18 -> __sedlex_state_58 lexbuf + | 19 -> __sedlex_state_76 lexbuf + | 20 -> __sedlex_state_129 lexbuf + | 21 -> 46 + | 22 -> 44 + | 23 -> __sedlex_state_135 lexbuf + | 24 -> __sedlex_state_139 lexbuf + | 25 -> __sedlex_state_143 lexbuf + | 26 -> __sedlex_state_149 lexbuf + | 27 -> __sedlex_state_154 lexbuf + | 28 -> 40 + | 29 -> __sedlex_state_177 lexbuf + | 30 -> 41 + | 31 -> __sedlex_state_186 lexbuf + | 32 -> 8 + | 33 -> 36 + | 34 -> __sedlex_state_190 lexbuf + | 35 -> 37 + | 36 -> 89 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_3 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 1; + (match __sedlex_partition_51 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_4 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_4 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 1; + (match __sedlex_partition_51 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_4 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_6 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_11 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 0 + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_8 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 88; + (match __sedlex_partition_52 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_9 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_9 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 58; + (match __sedlex_partition_52 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 54 + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_12 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 95; + (match __sedlex_partition_53 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 6 + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_15 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 84; + (match __sedlex_partition_52 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 71 + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_17 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 86; + (match __sedlex_partition_54 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_18 lexbuf + | 1 -> 72 + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_18 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 51; + (match __sedlex_partition_52 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 76 + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_23 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 82; + (match __sedlex_partition_55 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_24 lexbuf + | 1 -> 4 + | 2 -> 69 + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_24 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 83; + (match __sedlex_partition_52 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 70 + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_28 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 80; + (match __sedlex_partition_56 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 59 + | 1 -> 67 + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_32 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 81; + (match __sedlex_partition_57 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 60 + | 1 -> 68 + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_35 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 43; + (match __sedlex_partition_47 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_36 lexbuf + | 1 -> __sedlex_state_38 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_36 = + function + | lexbuf -> + (match __sedlex_partition_58 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 42 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_38 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 34; + (match __sedlex_partition_59 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_39 lexbuf + | 1 -> __sedlex_state_38 lexbuf + | 2 -> __sedlex_state_40 lexbuf + | 3 -> __sedlex_state_54 lexbuf + | 4 -> __sedlex_state_56 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_39 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 33; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_39 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_40 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 33; + (match __sedlex_partition_61 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_39 lexbuf + | 1 -> __sedlex_state_41 lexbuf + | 2 -> __sedlex_state_49 lexbuf + | 3 -> __sedlex_state_53 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_41 = + function + | lexbuf -> + (match __sedlex_partition_40 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_42 lexbuf + | 1 -> __sedlex_state_46 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_42 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 28; + (match __sedlex_partition_62 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_43 lexbuf + | 1 -> __sedlex_state_42 lexbuf + | 2 -> __sedlex_state_44 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_43 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 27; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_43 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_44 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 26; + (match __sedlex_partition_63 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_45 lexbuf + | 1 -> __sedlex_state_43 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_45 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 25; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_45 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_46 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 28; + (match __sedlex_partition_64 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_43 lexbuf + | 1 -> __sedlex_state_46 lexbuf + | 2 -> __sedlex_state_47 lexbuf + | 3 -> __sedlex_state_44 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_47 = + function + | lexbuf -> + (match __sedlex_partition_33 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_48 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_48 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 28; + (match __sedlex_partition_64 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_43 lexbuf + | 1 -> __sedlex_state_48 lexbuf + | 2 -> __sedlex_state_47 lexbuf + | 3 -> __sedlex_state_44 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_49 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 28; + (match __sedlex_partition_62 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_50 lexbuf + | 1 -> __sedlex_state_49 lexbuf + | 2 -> __sedlex_state_51 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_50 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 27; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_50 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_51 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 26; + (match __sedlex_partition_63 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_52 lexbuf + | 1 -> __sedlex_state_50 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_52 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 25; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_52 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_53 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 28; + (match __sedlex_partition_64 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_50 lexbuf + | 1 -> __sedlex_state_53 lexbuf + | 2 -> __sedlex_state_47 lexbuf + | 3 -> __sedlex_state_51 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_54 = + function + | lexbuf -> + (match __sedlex_partition_33 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_55 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_55 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 34; + (match __sedlex_partition_59 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_39 lexbuf + | 1 -> __sedlex_state_55 lexbuf + | 2 -> __sedlex_state_40 lexbuf + | 3 -> __sedlex_state_54 lexbuf + | 4 -> __sedlex_state_56 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_56 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 31; + (match __sedlex_partition_63 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_57 lexbuf + | 1 -> __sedlex_state_39 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_57 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 29; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_57 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_58 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 93; + (match __sedlex_partition_55 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_59 lexbuf + | 1 -> 5 + | 2 -> 92 + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_59 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 2; + (match __sedlex_partition_65 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_60 lexbuf + | 1 -> __sedlex_state_61 lexbuf + | 2 -> __sedlex_state_63 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_60 = + function + | lexbuf -> + (match __sedlex_partition_65 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_60 lexbuf + | 1 -> __sedlex_state_61 lexbuf + | 2 -> __sedlex_state_63 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_61 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 3; + (match __sedlex_partition_66 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 3 + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_63 = + function + | lexbuf -> + (match __sedlex_partition_67 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_64 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_64 = + function + | lexbuf -> + (match __sedlex_partition_68 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_65 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_65 = + function + | lexbuf -> + (match __sedlex_partition_69 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_66 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_66 = + function + | lexbuf -> + (match __sedlex_partition_70 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_67 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_67 = + function + | lexbuf -> + (match __sedlex_partition_71 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_68 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_68 = + function + | lexbuf -> + (match __sedlex_partition_72 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_69 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_69 = + function + | lexbuf -> + (match __sedlex_partition_73 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_70 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_70 = + function + | lexbuf -> + (match __sedlex_partition_67 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_71 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_71 = + function + | lexbuf -> + (match __sedlex_partition_2 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_72 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_72 = + function + | lexbuf -> + (match __sedlex_partition_74 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_73 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_73 = + function + | lexbuf -> + (match __sedlex_partition_75 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 3 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_76 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 34; + (match __sedlex_partition_76 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_39 lexbuf + | 1 -> __sedlex_state_77 lexbuf + | 2 -> __sedlex_state_81 lexbuf + | 3 -> __sedlex_state_93 lexbuf + | 4 -> __sedlex_state_97 lexbuf + | 5 -> __sedlex_state_40 lexbuf + | 6 -> __sedlex_state_107 lexbuf + | 7 -> __sedlex_state_117 lexbuf + | 8 -> __sedlex_state_127 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_77 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 34; + (match __sedlex_partition_77 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_39 lexbuf + | 1 -> __sedlex_state_78 lexbuf + | 2 -> __sedlex_state_40 lexbuf + | 3 -> __sedlex_state_56 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_78 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 34; + (match __sedlex_partition_59 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_39 lexbuf + | 1 -> __sedlex_state_78 lexbuf + | 2 -> __sedlex_state_40 lexbuf + | 3 -> __sedlex_state_79 lexbuf + | 4 -> __sedlex_state_56 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_79 = + function + | lexbuf -> + (match __sedlex_partition_33 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_80 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_80 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 34; + (match __sedlex_partition_59 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_39 lexbuf + | 1 -> __sedlex_state_80 lexbuf + | 2 -> __sedlex_state_40 lexbuf + | 3 -> __sedlex_state_79 lexbuf + | 4 -> __sedlex_state_56 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_81 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 20; + (match __sedlex_partition_78 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_82 lexbuf + | 1 -> __sedlex_state_83 lexbuf + | 2 -> __sedlex_state_81 lexbuf + | 3 -> __sedlex_state_87 lexbuf + | 4 -> __sedlex_state_91 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_82 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 19; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_82 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_83 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 34; + (match __sedlex_partition_62 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_39 lexbuf + | 1 -> __sedlex_state_84 lexbuf + | 2 -> __sedlex_state_56 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_84 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 34; + (match __sedlex_partition_64 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_39 lexbuf + | 1 -> __sedlex_state_84 lexbuf + | 2 -> __sedlex_state_85 lexbuf + | 3 -> __sedlex_state_56 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_85 = + function + | lexbuf -> + (match __sedlex_partition_33 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_86 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_86 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 34; + (match __sedlex_partition_64 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_39 lexbuf + | 1 -> __sedlex_state_86 lexbuf + | 2 -> __sedlex_state_85 lexbuf + | 3 -> __sedlex_state_56 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_87 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 18; + (match __sedlex_partition_79 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_88 lexbuf + | 1 -> __sedlex_state_83 lexbuf + | 2 -> __sedlex_state_87 lexbuf + | 3 -> __sedlex_state_89 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_88 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 17; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_88 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_89 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 17; + (match __sedlex_partition_63 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_90 lexbuf + | 1 -> __sedlex_state_88 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_90 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 17; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_90 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_91 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 19; + (match __sedlex_partition_63 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_92 lexbuf + | 1 -> __sedlex_state_82 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_92 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 19; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_92 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_93 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 18; + (match __sedlex_partition_79 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_94 lexbuf + | 1 -> __sedlex_state_83 lexbuf + | 2 -> __sedlex_state_93 lexbuf + | 3 -> __sedlex_state_95 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_94 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 17; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_94 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_95 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 17; + (match __sedlex_partition_63 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_96 lexbuf + | 1 -> __sedlex_state_94 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_96 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 17; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_96 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_97 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 33; + (match __sedlex_partition_80 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_39 lexbuf + | 1 -> __sedlex_state_98 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_98 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 12; + (match __sedlex_partition_81 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_99 lexbuf + | 1 -> __sedlex_state_98 lexbuf + | 2 -> __sedlex_state_100 lexbuf + | 3 -> __sedlex_state_105 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_99 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 11; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_99 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_100 = + function + | lexbuf -> + (match __sedlex_partition_26 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_101 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_101 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 12; + (match __sedlex_partition_81 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_102 lexbuf + | 1 -> __sedlex_state_101 lexbuf + | 2 -> __sedlex_state_100 lexbuf + | 3 -> __sedlex_state_103 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_102 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 11; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_102 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_103 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 10; + (match __sedlex_partition_63 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_104 lexbuf + | 1 -> __sedlex_state_102 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_104 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 9; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_104 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_105 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 10; + (match __sedlex_partition_63 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_106 lexbuf + | 1 -> __sedlex_state_99 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_106 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 9; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_106 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_107 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 33; + (match __sedlex_partition_82 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_39 lexbuf + | 1 -> __sedlex_state_108 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_108 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 16; + (match __sedlex_partition_83 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_109 lexbuf + | 1 -> __sedlex_state_108 lexbuf + | 2 -> __sedlex_state_110 lexbuf + | 3 -> __sedlex_state_115 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_109 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 15; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_109 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_110 = + function + | lexbuf -> + (match __sedlex_partition_17 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_111 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_111 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 16; + (match __sedlex_partition_83 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_112 lexbuf + | 1 -> __sedlex_state_111 lexbuf + | 2 -> __sedlex_state_110 lexbuf + | 3 -> __sedlex_state_113 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_112 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 15; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_112 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_113 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 14; + (match __sedlex_partition_63 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_114 lexbuf + | 1 -> __sedlex_state_112 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_114 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 13; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_114 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_115 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 14; + (match __sedlex_partition_63 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_116 lexbuf + | 1 -> __sedlex_state_109 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_116 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 13; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_116 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_117 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 33; + (match __sedlex_partition_84 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_39 lexbuf + | 1 -> __sedlex_state_118 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_118 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 24; + (match __sedlex_partition_85 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_119 lexbuf + | 1 -> __sedlex_state_118 lexbuf + | 2 -> __sedlex_state_120 lexbuf + | 3 -> __sedlex_state_125 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_119 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 23; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_119 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_120 = + function + | lexbuf -> + (match __sedlex_partition_4 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_121 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_121 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 24; + (match __sedlex_partition_85 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_122 lexbuf + | 1 -> __sedlex_state_121 lexbuf + | 2 -> __sedlex_state_120 lexbuf + | 3 -> __sedlex_state_123 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_122 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 23; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_122 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_123 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 22; + (match __sedlex_partition_63 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_124 lexbuf + | 1 -> __sedlex_state_122 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_124 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 21; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_124 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_125 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 22; + (match __sedlex_partition_63 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_126 lexbuf + | 1 -> __sedlex_state_119 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_126 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 21; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_126 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_127 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 32; + (match __sedlex_partition_63 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_128 lexbuf + | 1 -> __sedlex_state_39 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_128 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 30; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_128 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_129 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 34; + (match __sedlex_partition_86 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_39 lexbuf + | 1 -> __sedlex_state_77 lexbuf + | 2 -> __sedlex_state_130 lexbuf + | 3 -> __sedlex_state_40 lexbuf + | 4 -> __sedlex_state_131 lexbuf + | 5 -> __sedlex_state_127 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_130 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 34; + (match __sedlex_partition_86 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_39 lexbuf + | 1 -> __sedlex_state_77 lexbuf + | 2 -> __sedlex_state_130 lexbuf + | 3 -> __sedlex_state_40 lexbuf + | 4 -> __sedlex_state_131 lexbuf + | 5 -> __sedlex_state_127 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_131 = + function + | lexbuf -> + (match __sedlex_partition_33 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_132 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_132 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 34; + (match __sedlex_partition_87 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_39 lexbuf + | 1 -> __sedlex_state_83 lexbuf + | 2 -> __sedlex_state_132 lexbuf + | 3 -> __sedlex_state_131 lexbuf + | 4 -> __sedlex_state_127 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_135 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 78; + (match __sedlex_partition_88 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_136 lexbuf + | 1 -> 55 + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_136 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 62; + (match __sedlex_partition_52 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 61 + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_139 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 90; + (match __sedlex_partition_89 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_140 lexbuf + | 1 -> 91 + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_140 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 57; + (match __sedlex_partition_52 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 53 + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_143 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 79; + (match __sedlex_partition_89 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 56 + | 1 -> __sedlex_state_145 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_145 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 66; + (match __sedlex_partition_89 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 63 + | 1 -> __sedlex_state_147 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_147 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 65; + (match __sedlex_partition_52 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 64 + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_149 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 50; + (match __sedlex_partition_90 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_150 lexbuf + | 1 -> __sedlex_state_152 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_150 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 48; + (match __sedlex_partition_33 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 47 + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_152 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 49; + (match __sedlex_partition_52 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 75 + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_154 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 94; + (match __sedlex_partition_91 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_155 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_155 = + function + | lexbuf -> + (match __sedlex_partition_92 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_156 lexbuf + | 1 -> __sedlex_state_169 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_156 = + function + | lexbuf -> + (match __sedlex_partition_93 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_157 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_157 = + function + | lexbuf -> + (match __sedlex_partition_94 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_158 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_158 = + function + | lexbuf -> + (match __sedlex_partition_72 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_159 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_159 = + function + | lexbuf -> + (match __sedlex_partition_73 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_160 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_160 = + function + | lexbuf -> + (match __sedlex_partition_95 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_161 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_161 = + function + | lexbuf -> + (match __sedlex_partition_96 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_162 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_162 = + function + | lexbuf -> + (match __sedlex_partition_75 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_163 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_163 = + function + | lexbuf -> + (match __sedlex_partition_97 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_164 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_164 = + function + | lexbuf -> + (match __sedlex_partition_98 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_165 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_165 = + function + | lexbuf -> + (match __sedlex_partition_96 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_166 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_166 = + function + | lexbuf -> + (match __sedlex_partition_68 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_167 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_167 = + function + | lexbuf -> + (match __sedlex_partition_97 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 35 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_169 = + function + | lexbuf -> + (match __sedlex_partition_96 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_170 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_170 = + function + | lexbuf -> + (match __sedlex_partition_75 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_171 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_171 = + function + | lexbuf -> + (match __sedlex_partition_97 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_172 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_172 = + function + | lexbuf -> + (match __sedlex_partition_98 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_173 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_173 = + function + | lexbuf -> + (match __sedlex_partition_96 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_174 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_174 = + function + | lexbuf -> + (match __sedlex_partition_68 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_175 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_175 = + function + | lexbuf -> + (match __sedlex_partition_97 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 35 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_177 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 96; + (match __sedlex_partition_2 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_178 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_178 = + function + | lexbuf -> + (match __sedlex_partition_3 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_179 lexbuf + | 1 -> __sedlex_state_183 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_179 = + function + | lexbuf -> + (match __sedlex_partition_4 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_180 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_180 = + function + | lexbuf -> + (match __sedlex_partition_4 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_181 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_181 = + function + | lexbuf -> + (match __sedlex_partition_4 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 97 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_183 = + function + | lexbuf -> + (match __sedlex_partition_4 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_184 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_184 = + function + | lexbuf -> + (match __sedlex_partition_5 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_184 lexbuf + | 1 -> 97 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_186 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 87; + (match __sedlex_partition_52 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 74 + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_190 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 85; + (match __sedlex_partition_99 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 73 + | 1 -> __sedlex_state_192 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_192 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 52; + (match __sedlex_partition_52 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 77 + | _ -> Sedlexing.backtrack lexbuf)) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> let env = new_line env lexbuf in Continue env + | 1 -> Continue env + | 2 -> + let start_pos = start_pos_of_lexbuf env lexbuf in + let buf = Buffer.create 127 in + let (env, end_pos) = comment env buf lexbuf in + Comment (env, (mk_comment env start_pos end_pos buf true)) + | 3 -> + let pattern = lexeme lexbuf in + if not (is_comment_syntax_enabled env) + then + let start_pos = start_pos_of_lexbuf env lexbuf in + let buf = Buffer.create 127 in + (Buffer.add_string buf + (String.sub pattern 2 ((String.length pattern) - 2)); + (let (env, end_pos) = comment env buf lexbuf in + Comment (env, (mk_comment env start_pos end_pos buf true)))) + else + (let env = + if is_in_comment_syntax env + then + let loc = loc_of_lexbuf env lexbuf in + unexpected_error env loc pattern + else env in + let env = in_comment_syntax true env in + let len = Sedlexing.lexeme_length lexbuf in + if + ((Sedlexing.Utf8.sub_lexeme lexbuf (len - 1) 1) = ":") && + ((Sedlexing.Utf8.sub_lexeme lexbuf (len - 2) 1) <> ":") + then Token (env, T_COLON) + else Continue env) + | 4 -> + if is_in_comment_syntax env + then let env = in_comment_syntax false env in Continue env + else + (Sedlexing.rollback lexbuf; + (let __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_23 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 0 + | _ -> Sedlexing.backtrack lexbuf) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> Token (env, T_MULT) + | _ -> failwith "expected *"))) + | 5 -> + let start_pos = start_pos_of_lexbuf env lexbuf in + let buf = Buffer.create 127 in + let (env, end_pos) = line_comment env buf lexbuf in + Comment (env, (mk_comment env start_pos end_pos buf false)) + | 6 -> + if (Sedlexing.lexeme_start lexbuf) = 0 + then + let (env, _) = line_comment env (Buffer.create 127) lexbuf in + Continue env + else Token (env, (T_ERROR "#!")) + | 7 -> + let quote = lexeme lexbuf in + let start = start_pos_of_lexbuf env lexbuf in + let buf = Buffer.create 127 in + let raw = Buffer.create 127 in + (Buffer.add_string raw quote; + (let octal = false in + let (env, _end, octal) = + string_quote env quote buf raw octal lexbuf in + let loc = { Loc.source = (Lex_env.source env); start; _end } in + Token + (env, + (T_STRING + (loc, (Buffer.contents buf), (Buffer.contents raw), octal))))) + | 8 -> + let cooked = Buffer.create 127 in + let raw = Buffer.create 127 in + let literal = Buffer.create 127 in + (lexeme_to_buffer lexbuf literal; + (let start = start_pos_of_lexbuf env lexbuf in + let (env, is_tail) = template_part env cooked raw literal lexbuf in + let _end = end_pos_of_lexbuf env lexbuf in + let loc = { Loc.source = (Lex_env.source env); start; _end } in + Token + (env, + (T_TEMPLATE_PART + (loc, + { + cooked = (Buffer.contents cooked); + raw = (Buffer.contents raw); + literal = (Buffer.contents literal) + }, is_tail))))) + | 9 -> + recover env lexbuf + ~f:(fun env -> + fun lexbuf -> + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_24 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_1 = + function + | lexbuf -> + (match __sedlex_partition_25 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_2 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_2 = + function + | lexbuf -> + (match __sedlex_partition_26 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_3 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_3 = + function + | lexbuf -> + (match __sedlex_partition_27 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_3 lexbuf + | 1 -> __sedlex_state_4 lexbuf + | 2 -> 0 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_4 = + function + | lexbuf -> + (match __sedlex_partition_26 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_5 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_5 = + function + | lexbuf -> + (match __sedlex_partition_27 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_5 lexbuf + | 1 -> __sedlex_state_4 lexbuf + | 2 -> 0 + | _ -> Sedlexing.backtrack lexbuf) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> + Token + (env, + (T_BIGINT + { kind = BIG_BINARY; raw = (lexeme lexbuf) })) + | _ -> failwith "unreachable token bigint")) + | 10 -> + Token (env, (T_BIGINT { kind = BIG_BINARY; raw = (lexeme lexbuf) })) + | 11 -> + recover env lexbuf + ~f:(fun env -> + fun lexbuf -> + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_24 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_1 = + function + | lexbuf -> + (match __sedlex_partition_25 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_2 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_2 = + function + | lexbuf -> + (match __sedlex_partition_26 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_3 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_3 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_28 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_3 lexbuf + | 1 -> __sedlex_state_4 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_4 = + function + | lexbuf -> + (match __sedlex_partition_26 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_5 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_5 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_28 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_5 lexbuf + | 1 -> __sedlex_state_4 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> + Token + (env, + (T_NUMBER { kind = BINARY; raw = (lexeme lexbuf) })) + | _ -> failwith "unreachable token bignumber")) + | 12 -> Token (env, (T_NUMBER { kind = BINARY; raw = (lexeme lexbuf) })) + | 13 -> + recover env lexbuf + ~f:(fun env -> + fun lexbuf -> + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_24 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_1 = + function + | lexbuf -> + (match __sedlex_partition_29 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_2 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_2 = + function + | lexbuf -> + (match __sedlex_partition_17 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_3 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_3 = + function + | lexbuf -> + (match __sedlex_partition_30 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_3 lexbuf + | 1 -> __sedlex_state_4 lexbuf + | 2 -> 0 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_4 = + function + | lexbuf -> + (match __sedlex_partition_17 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_5 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_5 = + function + | lexbuf -> + (match __sedlex_partition_30 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_5 lexbuf + | 1 -> __sedlex_state_4 lexbuf + | 2 -> 0 + | _ -> Sedlexing.backtrack lexbuf) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> + Token + (env, + (T_BIGINT + { kind = BIG_OCTAL; raw = (lexeme lexbuf) })) + | _ -> failwith "unreachable token octbigint")) + | 14 -> + Token (env, (T_BIGINT { kind = BIG_OCTAL; raw = (lexeme lexbuf) })) + | 15 -> + recover env lexbuf + ~f:(fun env -> + fun lexbuf -> + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_24 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_1 = + function + | lexbuf -> + (match __sedlex_partition_29 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_2 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_2 = + function + | lexbuf -> + (match __sedlex_partition_17 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_3 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_3 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_31 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_3 lexbuf + | 1 -> __sedlex_state_4 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_4 = + function + | lexbuf -> + (match __sedlex_partition_17 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_5 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_5 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_31 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_5 lexbuf + | 1 -> __sedlex_state_4 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> + Token + (env, + (T_NUMBER { kind = OCTAL; raw = (lexeme lexbuf) })) + | _ -> failwith "unreachable token octnumber")) + | 16 -> Token (env, (T_NUMBER { kind = OCTAL; raw = (lexeme lexbuf) })) + | 17 -> + recover env lexbuf + ~f:(fun env -> + fun lexbuf -> + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_24 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_1 = + function + | lexbuf -> + (match __sedlex_partition_32 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | 1 -> __sedlex_state_2 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_2 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_33 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_2 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> + Token + (env, + (T_NUMBER + { + kind = LEGACY_NON_OCTAL; + raw = (lexeme lexbuf) + })) + | _ -> failwith "unreachable token legacynonoctnumber")) + | 18 -> + Token + (env, + (T_NUMBER { kind = LEGACY_NON_OCTAL; raw = (lexeme lexbuf) })) + | 19 -> + recover env lexbuf + ~f:(fun env -> + fun lexbuf -> + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_24 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_1 = + function + | lexbuf -> + (match __sedlex_partition_17 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_2 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_2 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_17 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_2 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> + Token + (env, + (T_NUMBER + { kind = LEGACY_OCTAL; raw = (lexeme lexbuf) })) + | _ -> failwith "unreachable token legacyoctnumber")) + | 20 -> + Token + (env, (T_NUMBER { kind = LEGACY_OCTAL; raw = (lexeme lexbuf) })) + | 21 -> + recover env lexbuf + ~f:(fun env -> + fun lexbuf -> + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_24 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_1 = + function + | lexbuf -> + (match __sedlex_partition_34 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_2 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_2 = + function + | lexbuf -> + (match __sedlex_partition_4 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_3 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_3 = + function + | lexbuf -> + (match __sedlex_partition_35 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_3 lexbuf + | 1 -> __sedlex_state_4 lexbuf + | 2 -> 0 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_4 = + function + | lexbuf -> + (match __sedlex_partition_4 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_5 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_5 = + function + | lexbuf -> + (match __sedlex_partition_35 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_5 lexbuf + | 1 -> __sedlex_state_4 lexbuf + | 2 -> 0 + | _ -> Sedlexing.backtrack lexbuf) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> + Token + (env, + (T_BIGINT + { kind = BIG_NORMAL; raw = (lexeme lexbuf) })) + | _ -> failwith "unreachable token hexbigint")) + | 22 -> + Token (env, (T_BIGINT { kind = BIG_NORMAL; raw = (lexeme lexbuf) })) + | 23 -> + recover env lexbuf + ~f:(fun env -> + fun lexbuf -> + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_24 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_1 = + function + | lexbuf -> + (match __sedlex_partition_34 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_2 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_2 = + function + | lexbuf -> + (match __sedlex_partition_4 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_3 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_3 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_36 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_3 lexbuf + | 1 -> __sedlex_state_4 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_4 = + function + | lexbuf -> + (match __sedlex_partition_4 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_5 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_5 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_36 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_5 lexbuf + | 1 -> __sedlex_state_4 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> + Token + (env, + (T_NUMBER { kind = NORMAL; raw = (lexeme lexbuf) })) + | _ -> failwith "unreachable token hexnumber")) + | 24 -> Token (env, (T_NUMBER { kind = NORMAL; raw = (lexeme lexbuf) })) + | 25 -> + recover env lexbuf + ~f:(fun env -> + fun lexbuf -> + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_37 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | 1 -> __sedlex_state_12 lexbuf + | 2 -> __sedlex_state_17 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_1 = + function + | lexbuf -> + (match __sedlex_partition_33 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_2 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_2 = + function + | lexbuf -> + (match __sedlex_partition_38 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_2 lexbuf + | 1 -> __sedlex_state_3 lexbuf + | 2 -> __sedlex_state_10 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_3 = + function + | lexbuf -> + (match __sedlex_partition_39 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_4 lexbuf + | 1 -> __sedlex_state_5 lexbuf + | 2 -> __sedlex_state_7 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_4 = + function + | lexbuf -> + (match __sedlex_partition_40 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_5 lexbuf + | 1 -> __sedlex_state_7 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_5 = + function + | lexbuf -> + (match __sedlex_partition_41 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_5 lexbuf + | 1 -> 0 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_7 = + function + | lexbuf -> + (match __sedlex_partition_42 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_7 lexbuf + | 1 -> __sedlex_state_8 lexbuf + | 2 -> 0 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_8 = + function + | lexbuf -> + (match __sedlex_partition_33 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_9 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_9 = + function + | lexbuf -> + (match __sedlex_partition_42 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_9 lexbuf + | 1 -> __sedlex_state_8 lexbuf + | 2 -> 0 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_10 = + function + | lexbuf -> + (match __sedlex_partition_33 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_11 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_11 = + function + | lexbuf -> + (match __sedlex_partition_38 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_11 lexbuf + | 1 -> __sedlex_state_3 lexbuf + | 2 -> __sedlex_state_10 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_12 = + function + | lexbuf -> + (match __sedlex_partition_43 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_13 lexbuf + | 1 -> __sedlex_state_3 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_13 = + function + | lexbuf -> + (match __sedlex_partition_44 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_14 lexbuf + | 1 -> __sedlex_state_3 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_14 = + function + | lexbuf -> + (match __sedlex_partition_38 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_14 lexbuf + | 1 -> __sedlex_state_3 lexbuf + | 2 -> __sedlex_state_15 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_15 = + function + | lexbuf -> + (match __sedlex_partition_33 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_16 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_16 = + function + | lexbuf -> + (match __sedlex_partition_38 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_16 lexbuf + | 1 -> __sedlex_state_3 lexbuf + | 2 -> __sedlex_state_15 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_17 = + function + | lexbuf -> + (match __sedlex_partition_45 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_13 lexbuf + | 1 -> __sedlex_state_17 lexbuf + | 2 -> __sedlex_state_3 lexbuf + | _ -> Sedlexing.backtrack lexbuf) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> + let loc = loc_of_lexbuf env lexbuf in + let env = + lex_error env loc Parse_error.InvalidSciBigInt in + Token + (env, + (T_BIGINT + { kind = BIG_NORMAL; raw = (lexeme lexbuf) })) + | _ -> failwith "unreachable token scibigint")) + | 26 -> + let loc = loc_of_lexbuf env lexbuf in + let env = lex_error env loc Parse_error.InvalidSciBigInt in + Token (env, (T_BIGINT { kind = BIG_NORMAL; raw = (lexeme lexbuf) })) + | 27 -> + recover env lexbuf + ~f:(fun env -> + fun lexbuf -> + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_37 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | 1 -> __sedlex_state_11 lexbuf + | 2 -> __sedlex_state_16 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_1 = + function + | lexbuf -> + (match __sedlex_partition_33 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_2 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_2 = + function + | lexbuf -> + (match __sedlex_partition_38 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_2 lexbuf + | 1 -> __sedlex_state_3 lexbuf + | 2 -> __sedlex_state_9 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_3 = + function + | lexbuf -> + (match __sedlex_partition_39 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_4 lexbuf + | 1 -> __sedlex_state_5 lexbuf + | 2 -> __sedlex_state_6 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_4 = + function + | lexbuf -> + (match __sedlex_partition_40 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_5 lexbuf + | 1 -> __sedlex_state_6 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_5 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_33 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_5 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_6 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_46 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_6 lexbuf + | 1 -> __sedlex_state_7 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_7 = + function + | lexbuf -> + (match __sedlex_partition_33 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_8 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_8 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_46 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_8 lexbuf + | 1 -> __sedlex_state_7 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_9 = + function + | lexbuf -> + (match __sedlex_partition_33 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_10 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_10 = + function + | lexbuf -> + (match __sedlex_partition_38 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_10 lexbuf + | 1 -> __sedlex_state_3 lexbuf + | 2 -> __sedlex_state_9 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_11 = + function + | lexbuf -> + (match __sedlex_partition_43 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_12 lexbuf + | 1 -> __sedlex_state_3 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_12 = + function + | lexbuf -> + (match __sedlex_partition_44 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_13 lexbuf + | 1 -> __sedlex_state_3 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_13 = + function + | lexbuf -> + (match __sedlex_partition_38 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_13 lexbuf + | 1 -> __sedlex_state_3 lexbuf + | 2 -> __sedlex_state_14 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_14 = + function + | lexbuf -> + (match __sedlex_partition_33 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_15 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_15 = + function + | lexbuf -> + (match __sedlex_partition_38 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_15 lexbuf + | 1 -> __sedlex_state_3 lexbuf + | 2 -> __sedlex_state_14 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_16 = + function + | lexbuf -> + (match __sedlex_partition_45 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_12 lexbuf + | 1 -> __sedlex_state_16 lexbuf + | 2 -> __sedlex_state_3 lexbuf + | _ -> Sedlexing.backtrack lexbuf) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> + Token + (env, + (T_NUMBER { kind = NORMAL; raw = (lexeme lexbuf) })) + | _ -> failwith "unreachable token scinumber")) + | 28 -> Token (env, (T_NUMBER { kind = NORMAL; raw = (lexeme lexbuf) })) + | 29 -> + recover env lexbuf + ~f:(fun env -> + fun lexbuf -> + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_37 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | 1 -> __sedlex_state_6 lexbuf + | 2 -> __sedlex_state_8 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_1 = + function + | lexbuf -> + (match __sedlex_partition_33 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_2 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_2 = + function + | lexbuf -> + (match __sedlex_partition_42 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_2 lexbuf + | 1 -> __sedlex_state_3 lexbuf + | 2 -> 0 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_3 = + function + | lexbuf -> + (match __sedlex_partition_33 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_4 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_4 = + function + | lexbuf -> + (match __sedlex_partition_42 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_4 lexbuf + | 1 -> __sedlex_state_3 lexbuf + | 2 -> 0 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_6 = + function + | lexbuf -> + (match __sedlex_partition_47 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_7 lexbuf + | 1 -> __sedlex_state_6 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_7 = + function + | lexbuf -> + (match __sedlex_partition_41 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_2 lexbuf + | 1 -> 0 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_8 = + function + | lexbuf -> + (match __sedlex_partition_48 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_7 lexbuf + | 1 -> __sedlex_state_8 lexbuf + | 2 -> __sedlex_state_9 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_9 = + function + | lexbuf -> + (match __sedlex_partition_33 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_10 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_10 = + function + | lexbuf -> + (match __sedlex_partition_48 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_7 lexbuf + | 1 -> __sedlex_state_10 lexbuf + | 2 -> __sedlex_state_9 lexbuf + | _ -> Sedlexing.backtrack lexbuf) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> + let loc = loc_of_lexbuf env lexbuf in + let env = + lex_error env loc Parse_error.InvalidFloatBigInt in + Token + (env, + (T_BIGINT + { kind = BIG_NORMAL; raw = (lexeme lexbuf) })) + | _ -> failwith "unreachable token floatbigint")) + | 30 -> + recover env lexbuf + ~f:(fun env -> + fun lexbuf -> + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_40 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | 1 -> __sedlex_state_3 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_1 = + function + | lexbuf -> + (match __sedlex_partition_41 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | 1 -> 0 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_3 = + function + | lexbuf -> + (match __sedlex_partition_42 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_3 lexbuf + | 1 -> __sedlex_state_4 lexbuf + | 2 -> 0 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_4 = + function + | lexbuf -> + (match __sedlex_partition_33 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_5 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_5 = + function + | lexbuf -> + (match __sedlex_partition_42 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_5 lexbuf + | 1 -> __sedlex_state_4 lexbuf + | 2 -> 0 + | _ -> Sedlexing.backtrack lexbuf) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> + Token + (env, + (T_BIGINT + { kind = BIG_NORMAL; raw = (lexeme lexbuf) })) + | _ -> failwith "unreachable token wholebigint")) + | 31 -> + let loc = loc_of_lexbuf env lexbuf in + let env = lex_error env loc Parse_error.InvalidFloatBigInt in + Token (env, (T_BIGINT { kind = BIG_NORMAL; raw = (lexeme lexbuf) })) + | 32 -> + Token (env, (T_BIGINT { kind = BIG_NORMAL; raw = (lexeme lexbuf) })) + | 33 -> + recover env lexbuf + ~f:(fun env -> + fun lexbuf -> + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_37 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | 1 -> __sedlex_state_5 lexbuf + | 2 -> __sedlex_state_7 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_1 = + function + | lexbuf -> + (match __sedlex_partition_33 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_2 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_2 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_46 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_2 lexbuf + | 1 -> __sedlex_state_3 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_3 = + function + | lexbuf -> + (match __sedlex_partition_33 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_4 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_4 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_46 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_4 lexbuf + | 1 -> __sedlex_state_3 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_5 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_47 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_6 lexbuf + | 1 -> __sedlex_state_5 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_6 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_33 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_2 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_7 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_48 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_6 lexbuf + | 1 -> __sedlex_state_7 lexbuf + | 2 -> __sedlex_state_8 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_8 = + function + | lexbuf -> + (match __sedlex_partition_33 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_9 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_9 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_48 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_6 lexbuf + | 1 -> __sedlex_state_9 lexbuf + | 2 -> __sedlex_state_8 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> + Token + (env, + (T_NUMBER { kind = NORMAL; raw = (lexeme lexbuf) })) + | _ -> failwith "unreachable token wholenumber")) + | 34 -> Token (env, (T_NUMBER { kind = NORMAL; raw = (lexeme lexbuf) })) + | 35 -> + let loc = loc_of_lexbuf env lexbuf in + let raw = lexeme lexbuf in + Token (env, (T_IDENTIFIER { loc; value = raw; raw })) + | 36 -> Token (env, T_LCURLY) + | 37 -> Token (env, T_RCURLY) + | 38 -> Token (env, T_LPAREN) + | 39 -> Token (env, T_RPAREN) + | 40 -> Token (env, T_LBRACKET) + | 41 -> Token (env, T_RBRACKET) + | 42 -> Token (env, T_ELLIPSIS) + | 43 -> Token (env, T_PERIOD) + | 44 -> Token (env, T_SEMICOLON) + | 45 -> Token (env, T_COMMA) + | 46 -> Token (env, T_COLON) + | 47 -> + (Sedlexing.rollback lexbuf; + (let __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_49 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 0 + | _ -> Sedlexing.backtrack lexbuf) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> Token (env, T_PLING) + | _ -> failwith "expected ?"))) + | 48 -> Token (env, T_PLING_PERIOD) + | 49 -> Token (env, T_PLING_PLING) + | 50 -> Token (env, T_PLING) + | 51 -> Token (env, T_AND) + | 52 -> Token (env, T_OR) + | 53 -> Token (env, T_STRICT_EQUAL) + | 54 -> Token (env, T_STRICT_NOT_EQUAL) + | 55 -> Token (env, T_LESS_THAN_EQUAL) + | 56 -> Token (env, T_GREATER_THAN_EQUAL) + | 57 -> Token (env, T_EQUAL) + | 58 -> Token (env, T_NOT_EQUAL) + | 59 -> Token (env, T_INCR) + | 60 -> Token (env, T_DECR) + | 61 -> Token (env, T_LSHIFT_ASSIGN) + | 62 -> Token (env, T_LSHIFT) + | 63 -> Token (env, T_RSHIFT_ASSIGN) + | 64 -> Token (env, T_RSHIFT3_ASSIGN) + | 65 -> Token (env, T_RSHIFT3) + | 66 -> Token (env, T_RSHIFT) + | 67 -> Token (env, T_PLUS_ASSIGN) + | 68 -> Token (env, T_MINUS_ASSIGN) + | 69 -> Token (env, T_MULT_ASSIGN) + | 70 -> Token (env, T_EXP_ASSIGN) + | 71 -> Token (env, T_MOD_ASSIGN) + | 72 -> Token (env, T_BIT_AND_ASSIGN) + | 73 -> Token (env, T_BIT_OR_ASSIGN) + | 74 -> Token (env, T_BIT_XOR_ASSIGN) + | 75 -> Token (env, T_NULLISH_ASSIGN) + | 76 -> Token (env, T_AND_ASSIGN) + | 77 -> Token (env, T_OR_ASSIGN) + | 78 -> Token (env, T_LESS_THAN) + | 79 -> Token (env, T_GREATER_THAN) + | 80 -> Token (env, T_PLUS) + | 81 -> Token (env, T_MINUS) + | 82 -> Token (env, T_MULT) + | 83 -> Token (env, T_EXP) + | 84 -> Token (env, T_MOD) + | 85 -> Token (env, T_BIT_OR) + | 86 -> Token (env, T_BIT_AND) + | 87 -> Token (env, T_BIT_XOR) + | 88 -> Token (env, T_NOT) + | 89 -> Token (env, T_BIT_NOT) + | 90 -> Token (env, T_ASSIGN) + | 91 -> Token (env, T_ARROW) + | 92 -> Token (env, T_DIV_ASSIGN) + | 93 -> Token (env, T_DIV) + | 94 -> Token (env, T_AT) + | 95 -> Token (env, T_POUND) + | 96 -> let env = illegal env (loc_of_lexbuf env lexbuf) in Continue env + | 97 -> + let start_offset = Sedlexing.lexeme_start lexbuf in + ((loop_id_continues lexbuf) |> ignore; + (let end_offset = Sedlexing.lexeme_end lexbuf in + let loc = loc_of_offsets env start_offset end_offset in + Sedlexing.set_lexeme_start lexbuf start_offset; + (let raw = Sedlexing.lexeme lexbuf in + let (nenv, value) = decode_identifier env raw in + match value with + | "async" -> Token (env, T_ASYNC) + | "await" -> Token (env, T_AWAIT) + | "break" -> Token (env, T_BREAK) + | "case" -> Token (env, T_CASE) + | "catch" -> Token (env, T_CATCH) + | "class" -> Token (env, T_CLASS) + | "const" -> Token (env, T_CONST) + | "continue" -> Token (env, T_CONTINUE) + | "debugger" -> Token (env, T_DEBUGGER) + | "declare" -> Token (env, T_DECLARE) + | "default" -> Token (env, T_DEFAULT) + | "delete" -> Token (env, T_DELETE) + | "do" -> Token (env, T_DO) + | "else" -> Token (env, T_ELSE) + | "enum" -> Token (env, T_ENUM) + | "export" -> Token (env, T_EXPORT) + | "extends" -> Token (env, T_EXTENDS) + | "false" -> Token (env, T_FALSE) + | "finally" -> Token (env, T_FINALLY) + | "for" -> Token (env, T_FOR) + | "function" -> Token (env, T_FUNCTION) + | "if" -> Token (env, T_IF) + | "implements" -> Token (env, T_IMPLEMENTS) + | "import" -> Token (env, T_IMPORT) + | "in" -> Token (env, T_IN) + | "instanceof" -> Token (env, T_INSTANCEOF) + | "interface" -> Token (env, T_INTERFACE) + | "let" -> Token (env, T_LET) + | "new" -> Token (env, T_NEW) + | "null" -> Token (env, T_NULL) + | "of" -> Token (env, T_OF) + | "opaque" -> Token (env, T_OPAQUE) + | "package" -> Token (env, T_PACKAGE) + | "private" -> Token (env, T_PRIVATE) + | "protected" -> Token (env, T_PROTECTED) + | "public" -> Token (env, T_PUBLIC) + | "return" -> Token (env, T_RETURN) + | "static" -> Token (env, T_STATIC) + | "super" -> Token (env, T_SUPER) + | "switch" -> Token (env, T_SWITCH) + | "this" -> Token (env, T_THIS) + | "throw" -> Token (env, T_THROW) + | "true" -> Token (env, T_TRUE) + | "try" -> Token (env, T_TRY) + | "type" -> Token (env, T_TYPE) + | "typeof" -> Token (env, T_TYPEOF) + | "var" -> Token (env, T_VAR) + | "void" -> Token (env, T_VOID) + | "while" -> Token (env, T_WHILE) + | "with" -> Token (env, T_WITH) + | "yield" -> Token (env, T_YIELD) + | _ -> + Token + (nenv, + (T_IDENTIFIER + { loc; value; raw = (Sedlexing.string_of_utf8 raw) }))))) + | 98 -> + let env = + if is_in_comment_syntax env + then + let loc = loc_of_lexbuf env lexbuf in + lex_error env loc Parse_error.UnexpectedEOS + else env in + Token (env, T_EOF) + | 99 -> + let env = illegal env (loc_of_lexbuf env lexbuf) in + Token (env, (T_ERROR (lexeme lexbuf))) + | _ -> failwith "unreachable token") : result) +let rec regexp_class env buf lexbuf = + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_100 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 0 + | 1 -> __sedlex_state_2 lexbuf + | 2 -> 4 + | 3 -> __sedlex_state_4 lexbuf + | 4 -> __sedlex_state_6 lexbuf + | 5 -> 3 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_2 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 5; + (match __sedlex_partition_101 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_2 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_4 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 4; + (match __sedlex_partition_11 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 4 + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_6 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 5; + (match __sedlex_partition_102 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 1 + | 1 -> 2 + | _ -> Sedlexing.backtrack lexbuf)) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> env + | 1 -> (Buffer.add_string buf "\\\\"; regexp_class env buf lexbuf) + | 2 -> + (Buffer.add_char buf '\\'; + Buffer.add_char buf ']'; + regexp_class env buf lexbuf) + | 3 -> (Buffer.add_char buf ']'; env) + | 4 -> + let loc = loc_of_lexbuf env lexbuf in + let env = lex_error env loc Parse_error.UnterminatedRegExp in + let env = new_line env lexbuf in env + | 5 -> + let str = lexeme lexbuf in + (Buffer.add_string buf str; regexp_class env buf lexbuf) + | _ -> failwith "unreachable regexp_class") +let rec regexp_body env buf lexbuf = + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_103 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 0 + | 1 -> __sedlex_state_2 lexbuf + | 2 -> 6 + | 3 -> __sedlex_state_4 lexbuf + | 4 -> __sedlex_state_6 lexbuf + | 5 -> 5 + | 6 -> __sedlex_state_9 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_2 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 7; + (match __sedlex_partition_104 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_2 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_4 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 6; + (match __sedlex_partition_11 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 6 + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_6 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 4; + (match __sedlex_partition_105 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_7 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_7 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 3; + (match __sedlex_partition_105 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_7 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_9 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 7; + (match __sedlex_partition_106 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 2 + | 1 -> 1 + | 2 -> __sedlex_state_12 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_12 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 1; + (match __sedlex_partition_11 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 1 + | _ -> Sedlexing.backtrack lexbuf)) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> + let loc = loc_of_lexbuf env lexbuf in + let env = lex_error env loc Parse_error.UnterminatedRegExp in + (env, "") + | 1 -> + let loc = loc_of_lexbuf env lexbuf in + let env = lex_error env loc Parse_error.UnterminatedRegExp in + let env = new_line env lexbuf in (env, "") + | 2 -> + let s = lexeme lexbuf in + (Buffer.add_string buf s; regexp_body env buf lexbuf) + | 3 -> + let flags = + let str = lexeme lexbuf in + String.sub str 1 ((String.length str) - 1) in + (env, flags) + | 4 -> (env, "") + | 5 -> + (Buffer.add_char buf '['; + (let env = regexp_class env buf lexbuf in regexp_body env buf lexbuf)) + | 6 -> + let loc = loc_of_lexbuf env lexbuf in + let env = lex_error env loc Parse_error.UnterminatedRegExp in + let env = new_line env lexbuf in (env, "") + | 7 -> + let str = lexeme lexbuf in + (Buffer.add_string buf str; regexp_body env buf lexbuf) + | _ -> failwith "unreachable regexp_body") +let regexp env lexbuf = + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_107 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 0 + | 1 -> 6 + | 2 -> __sedlex_state_3 lexbuf + | 3 -> 1 + | 4 -> __sedlex_state_6 lexbuf + | 5 -> __sedlex_state_8 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_3 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 2; + (match __sedlex_partition_51 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_4 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_4 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 2; + (match __sedlex_partition_51 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_4 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_6 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 1; + (match __sedlex_partition_11 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 1 + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_8 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 5; + (match __sedlex_partition_108 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 4 + | 1 -> 3 + | _ -> Sedlexing.backtrack lexbuf)) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> Token (env, T_EOF) + | 1 -> let env = new_line env lexbuf in Continue env + | 2 -> Continue env + | 3 -> + let start_pos = start_pos_of_lexbuf env lexbuf in + let buf = Buffer.create 127 in + let (env, end_pos) = line_comment env buf lexbuf in + Comment (env, (mk_comment env start_pos end_pos buf false)) + | 4 -> + let start_pos = start_pos_of_lexbuf env lexbuf in + let buf = Buffer.create 127 in + let (env, end_pos) = comment env buf lexbuf in + Comment (env, (mk_comment env start_pos end_pos buf true)) + | 5 -> + let start = start_pos_of_lexbuf env lexbuf in + let buf = Buffer.create 127 in + let (env, flags) = regexp_body env buf lexbuf in + let _end = end_pos_of_lexbuf env lexbuf in + let loc = { Loc.source = (Lex_env.source env); start; _end } in + Token (env, (T_REGEXP (loc, (Buffer.contents buf), flags))) + | 6 -> + let env = illegal env (loc_of_lexbuf env lexbuf) in + Token (env, (T_ERROR (lexeme lexbuf))) + | _ -> failwith "unreachable regexp") +let rec jsx_text env mode buf raw lexbuf = + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_109 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 1 + | 1 -> __sedlex_state_2 lexbuf + | 2 -> 2 + | 3 -> __sedlex_state_4 lexbuf + | 4 -> 0 + | 5 -> __sedlex_state_7 lexbuf + | 6 -> __sedlex_state_23 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_2 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 6; + (match __sedlex_partition_110 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_2 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_4 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 2; + (match __sedlex_partition_11 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 2 + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_7 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 6; + (match __sedlex_partition_111 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_8 lexbuf + | 1 -> __sedlex_state_14 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_8 = + function + | lexbuf -> + (match __sedlex_partition_112 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_9 lexbuf + | 1 -> __sedlex_state_11 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_9 = + function + | lexbuf -> + (match __sedlex_partition_113 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_9 lexbuf + | 1 -> 4 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_11 = + function + | lexbuf -> + (match __sedlex_partition_4 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_12 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_12 = + function + | lexbuf -> + (match __sedlex_partition_114 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_12 lexbuf + | 1 -> 3 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_14 = + function + | lexbuf -> + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_15 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_15 = + function + | lexbuf -> + (match __sedlex_partition_115 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_16 lexbuf + | 1 -> 5 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_16 = + function + | lexbuf -> + (match __sedlex_partition_115 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_17 lexbuf + | 1 -> 5 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_17 = + function + | lexbuf -> + (match __sedlex_partition_115 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_18 lexbuf + | 1 -> 5 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_18 = + function + | lexbuf -> + (match __sedlex_partition_115 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_19 lexbuf + | 1 -> 5 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_19 = + function + | lexbuf -> + (match __sedlex_partition_115 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_20 lexbuf + | 1 -> 5 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_20 = + function + | lexbuf -> + (match __sedlex_partition_115 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_21 lexbuf + | 1 -> 5 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_21 = + function + | lexbuf -> + (match __sedlex_partition_116 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 5 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_23 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_110 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_2 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> + let c = lexeme lexbuf in + (match (mode, c) with + | (JSX_SINGLE_QUOTED_TEXT, "'") | (JSX_DOUBLE_QUOTED_TEXT, "\"") -> + env + | (JSX_CHILD_TEXT, ("<" | "{")) -> (Sedlexing.rollback lexbuf; env) + | (JSX_CHILD_TEXT, ">") -> + unexpected_error_w_suggest env (loc_of_lexbuf env lexbuf) ">" + "{'>'}" + | (JSX_CHILD_TEXT, "}") -> + unexpected_error_w_suggest env (loc_of_lexbuf env lexbuf) "}" + "{'}'}" + | _ -> + (Buffer.add_string raw c; + Buffer.add_string buf c; + jsx_text env mode buf raw lexbuf)) + | 1 -> let env = illegal env (loc_of_lexbuf env lexbuf) in env + | 2 -> + let lt = lexeme lexbuf in + (Buffer.add_string raw lt; + Buffer.add_string buf lt; + (let env = new_line env lexbuf in jsx_text env mode buf raw lexbuf)) + | 3 -> + let s = lexeme lexbuf in + let n = String.sub s 3 ((String.length s) - 4) in + (Buffer.add_string raw s; + (let code = int_of_string ("0x" ^ n) in + Wtf8.add_wtf_8 buf code; jsx_text env mode buf raw lexbuf)) + | 4 -> + let s = lexeme lexbuf in + let n = String.sub s 2 ((String.length s) - 3) in + (Buffer.add_string raw s; + (let code = int_of_string n in + Wtf8.add_wtf_8 buf code; jsx_text env mode buf raw lexbuf)) + | 5 -> + let s = lexeme lexbuf in + let entity = String.sub s 1 ((String.length s) - 2) in + (Buffer.add_string raw s; + (let code = + match entity with + | "quot" -> Some 0x0022 + | "amp" -> Some 0x0026 + | "apos" -> Some 0x0027 + | "lt" -> Some 0x003C + | "gt" -> Some 0x003E + | "nbsp" -> Some 0x00A0 + | "iexcl" -> Some 0x00A1 + | "cent" -> Some 0x00A2 + | "pound" -> Some 0x00A3 + | "curren" -> Some 0x00A4 + | "yen" -> Some 0x00A5 + | "brvbar" -> Some 0x00A6 + | "sect" -> Some 0x00A7 + | "uml" -> Some 0x00A8 + | "copy" -> Some 0x00A9 + | "ordf" -> Some 0x00AA + | "laquo" -> Some 0x00AB + | "not" -> Some 0x00AC + | "shy" -> Some 0x00AD + | "reg" -> Some 0x00AE + | "macr" -> Some 0x00AF + | "deg" -> Some 0x00B0 + | "plusmn" -> Some 0x00B1 + | "sup2" -> Some 0x00B2 + | "sup3" -> Some 0x00B3 + | "acute" -> Some 0x00B4 + | "micro" -> Some 0x00B5 + | "para" -> Some 0x00B6 + | "middot" -> Some 0x00B7 + | "cedil" -> Some 0x00B8 + | "sup1" -> Some 0x00B9 + | "ordm" -> Some 0x00BA + | "raquo" -> Some 0x00BB + | "frac14" -> Some 0x00BC + | "frac12" -> Some 0x00BD + | "frac34" -> Some 0x00BE + | "iquest" -> Some 0x00BF + | "Agrave" -> Some 0x00C0 + | "Aacute" -> Some 0x00C1 + | "Acirc" -> Some 0x00C2 + | "Atilde" -> Some 0x00C3 + | "Auml" -> Some 0x00C4 + | "Aring" -> Some 0x00C5 + | "AElig" -> Some 0x00C6 + | "Ccedil" -> Some 0x00C7 + | "Egrave" -> Some 0x00C8 + | "Eacute" -> Some 0x00C9 + | "Ecirc" -> Some 0x00CA + | "Euml" -> Some 0x00CB + | "Igrave" -> Some 0x00CC + | "Iacute" -> Some 0x00CD + | "Icirc" -> Some 0x00CE + | "Iuml" -> Some 0x00CF + | "ETH" -> Some 0x00D0 + | "Ntilde" -> Some 0x00D1 + | "Ograve" -> Some 0x00D2 + | "Oacute" -> Some 0x00D3 + | "Ocirc" -> Some 0x00D4 + | "Otilde" -> Some 0x00D5 + | "Ouml" -> Some 0x00D6 + | "times" -> Some 0x00D7 + | "Oslash" -> Some 0x00D8 + | "Ugrave" -> Some 0x00D9 + | "Uacute" -> Some 0x00DA + | "Ucirc" -> Some 0x00DB + | "Uuml" -> Some 0x00DC + | "Yacute" -> Some 0x00DD + | "THORN" -> Some 0x00DE + | "szlig" -> Some 0x00DF + | "agrave" -> Some 0x00E0 + | "aacute" -> Some 0x00E1 + | "acirc" -> Some 0x00E2 + | "atilde" -> Some 0x00E3 + | "auml" -> Some 0x00E4 + | "aring" -> Some 0x00E5 + | "aelig" -> Some 0x00E6 + | "ccedil" -> Some 0x00E7 + | "egrave" -> Some 0x00E8 + | "eacute" -> Some 0x00E9 + | "ecirc" -> Some 0x00EA + | "euml" -> Some 0x00EB + | "igrave" -> Some 0x00EC + | "iacute" -> Some 0x00ED + | "icirc" -> Some 0x00EE + | "iuml" -> Some 0x00EF + | "eth" -> Some 0x00F0 + | "ntilde" -> Some 0x00F1 + | "ograve" -> Some 0x00F2 + | "oacute" -> Some 0x00F3 + | "ocirc" -> Some 0x00F4 + | "otilde" -> Some 0x00F5 + | "ouml" -> Some 0x00F6 + | "divide" -> Some 0x00F7 + | "oslash" -> Some 0x00F8 + | "ugrave" -> Some 0x00F9 + | "uacute" -> Some 0x00FA + | "ucirc" -> Some 0x00FB + | "uuml" -> Some 0x00FC + | "yacute" -> Some 0x00FD + | "thorn" -> Some 0x00FE + | "yuml" -> Some 0x00FF + | "OElig" -> Some 0x0152 + | "oelig" -> Some 0x0153 + | "Scaron" -> Some 0x0160 + | "scaron" -> Some 0x0161 + | "Yuml" -> Some 0x0178 + | "fnof" -> Some 0x0192 + | "circ" -> Some 0x02C6 + | "tilde" -> Some 0x02DC + | "Alpha" -> Some 0x0391 + | "Beta" -> Some 0x0392 + | "Gamma" -> Some 0x0393 + | "Delta" -> Some 0x0394 + | "Epsilon" -> Some 0x0395 + | "Zeta" -> Some 0x0396 + | "Eta" -> Some 0x0397 + | "Theta" -> Some 0x0398 + | "Iota" -> Some 0x0399 + | "Kappa" -> Some 0x039A + | "Lambda" -> Some 0x039B + | "Mu" -> Some 0x039C + | "Nu" -> Some 0x039D + | "Xi" -> Some 0x039E + | "Omicron" -> Some 0x039F + | "Pi" -> Some 0x03A0 + | "Rho" -> Some 0x03A1 + | "Sigma" -> Some 0x03A3 + | "Tau" -> Some 0x03A4 + | "Upsilon" -> Some 0x03A5 + | "Phi" -> Some 0x03A6 + | "Chi" -> Some 0x03A7 + | "Psi" -> Some 0x03A8 + | "Omega" -> Some 0x03A9 + | "alpha" -> Some 0x03B1 + | "beta" -> Some 0x03B2 + | "gamma" -> Some 0x03B3 + | "delta" -> Some 0x03B4 + | "epsilon" -> Some 0x03B5 + | "zeta" -> Some 0x03B6 + | "eta" -> Some 0x03B7 + | "theta" -> Some 0x03B8 + | "iota" -> Some 0x03B9 + | "kappa" -> Some 0x03BA + | "lambda" -> Some 0x03BB + | "mu" -> Some 0x03BC + | "nu" -> Some 0x03BD + | "xi" -> Some 0x03BE + | "omicron" -> Some 0x03BF + | "pi" -> Some 0x03C0 + | "rho" -> Some 0x03C1 + | "sigmaf" -> Some 0x03C2 + | "sigma" -> Some 0x03C3 + | "tau" -> Some 0x03C4 + | "upsilon" -> Some 0x03C5 + | "phi" -> Some 0x03C6 + | "chi" -> Some 0x03C7 + | "psi" -> Some 0x03C8 + | "omega" -> Some 0x03C9 + | "thetasym" -> Some 0x03D1 + | "upsih" -> Some 0x03D2 + | "piv" -> Some 0x03D6 + | "ensp" -> Some 0x2002 + | "emsp" -> Some 0x2003 + | "thinsp" -> Some 0x2009 + | "zwnj" -> Some 0x200C + | "zwj" -> Some 0x200D + | "lrm" -> Some 0x200E + | "rlm" -> Some 0x200F + | "ndash" -> Some 0x2013 + | "mdash" -> Some 0x2014 + | "lsquo" -> Some 0x2018 + | "rsquo" -> Some 0x2019 + | "sbquo" -> Some 0x201A + | "ldquo" -> Some 0x201C + | "rdquo" -> Some 0x201D + | "bdquo" -> Some 0x201E + | "dagger" -> Some 0x2020 + | "Dagger" -> Some 0x2021 + | "bull" -> Some 0x2022 + | "hellip" -> Some 0x2026 + | "permil" -> Some 0x2030 + | "prime" -> Some 0x2032 + | "Prime" -> Some 0x2033 + | "lsaquo" -> Some 0x2039 + | "rsaquo" -> Some 0x203A + | "oline" -> Some 0x203E + | "frasl" -> Some 0x2044 + | "euro" -> Some 0x20AC + | "image" -> Some 0x2111 + | "weierp" -> Some 0x2118 + | "real" -> Some 0x211C + | "trade" -> Some 0x2122 + | "alefsym" -> Some 0x2135 + | "larr" -> Some 0x2190 + | "uarr" -> Some 0x2191 + | "rarr" -> Some 0x2192 + | "darr" -> Some 0x2193 + | "harr" -> Some 0x2194 + | "crarr" -> Some 0x21B5 + | "lArr" -> Some 0x21D0 + | "uArr" -> Some 0x21D1 + | "rArr" -> Some 0x21D2 + | "dArr" -> Some 0x21D3 + | "hArr" -> Some 0x21D4 + | "forall" -> Some 0x2200 + | "part" -> Some 0x2202 + | "exist" -> Some 0x2203 + | "empty" -> Some 0x2205 + | "nabla" -> Some 0x2207 + | "isin" -> Some 0x2208 + | "notin" -> Some 0x2209 + | "ni" -> Some 0x220B + | "prod" -> Some 0x220F + | "sum" -> Some 0x2211 + | "minus" -> Some 0x2212 + | "lowast" -> Some 0x2217 + | "radic" -> Some 0x221A + | "prop" -> Some 0x221D + | "infin" -> Some 0x221E + | "ang" -> Some 0x2220 + | "and" -> Some 0x2227 + | "or" -> Some 0x2228 + | "cap" -> Some 0x2229 + | "cup" -> Some 0x222A + | "'int'" -> Some 0x222B + | "there4" -> Some 0x2234 + | "sim" -> Some 0x223C + | "cong" -> Some 0x2245 + | "asymp" -> Some 0x2248 + | "ne" -> Some 0x2260 + | "equiv" -> Some 0x2261 + | "le" -> Some 0x2264 + | "ge" -> Some 0x2265 + | "sub" -> Some 0x2282 + | "sup" -> Some 0x2283 + | "nsub" -> Some 0x2284 + | "sube" -> Some 0x2286 + | "supe" -> Some 0x2287 + | "oplus" -> Some 0x2295 + | "otimes" -> Some 0x2297 + | "perp" -> Some 0x22A5 + | "sdot" -> Some 0x22C5 + | "lceil" -> Some 0x2308 + | "rceil" -> Some 0x2309 + | "lfloor" -> Some 0x230A + | "rfloor" -> Some 0x230B + | "lang" -> Some 0x27E8 + | "rang" -> Some 0x27E9 + | "loz" -> Some 0x25CA + | "spades" -> Some 0x2660 + | "clubs" -> Some 0x2663 + | "hearts" -> Some 0x2665 + | "diams" -> Some 0x2666 + | _ -> None in + (match code with + | Some code -> Wtf8.add_wtf_8 buf code + | None -> Buffer.add_string buf ("&" ^ (entity ^ ";"))); + jsx_text env mode buf raw lexbuf)) + | 6 -> + let c = lexeme lexbuf in + (Buffer.add_string raw c; + Buffer.add_string buf c; + jsx_text env mode buf raw lexbuf) + | _ -> failwith "unreachable jsxtext") +let jsx_tag env lexbuf = + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_117 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 0 + | 1 -> 14 + | 2 -> __sedlex_state_3 lexbuf + | 3 -> 1 + | 4 -> __sedlex_state_6 lexbuf + | 5 -> 12 + | 6 -> 13 + | 7 -> 10 + | 8 -> __sedlex_state_11 lexbuf + | 9 -> 9 + | 10 -> 5 + | 11 -> 11 + | 12 -> 7 + | 13 -> __sedlex_state_18 lexbuf + | 14 -> 8 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_3 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 2; + (match __sedlex_partition_51 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_4 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_4 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 2; + (match __sedlex_partition_51 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_4 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_6 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 1; + (match __sedlex_partition_11 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 1 + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_11 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 6; + (match __sedlex_partition_108 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 4 + | 1 -> 3 + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_18 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 14; + (match __sedlex_partition_2 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_19 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_19 = + function + | lexbuf -> + (match __sedlex_partition_3 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_20 lexbuf + | 1 -> __sedlex_state_24 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_20 = + function + | lexbuf -> + (match __sedlex_partition_4 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_21 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_21 = + function + | lexbuf -> + (match __sedlex_partition_4 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_22 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_22 = + function + | lexbuf -> + (match __sedlex_partition_4 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 13 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_24 = + function + | lexbuf -> + (match __sedlex_partition_4 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_25 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_25 = + function + | lexbuf -> + (match __sedlex_partition_5 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_25 lexbuf + | 1 -> 13 + | _ -> Sedlexing.backtrack lexbuf) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> Token (env, T_EOF) + | 1 -> let env = new_line env lexbuf in Continue env + | 2 -> Continue env + | 3 -> + let start_pos = start_pos_of_lexbuf env lexbuf in + let buf = Buffer.create 127 in + let (env, end_pos) = line_comment env buf lexbuf in + Comment (env, (mk_comment env start_pos end_pos buf false)) + | 4 -> + let start_pos = start_pos_of_lexbuf env lexbuf in + let buf = Buffer.create 127 in + let (env, end_pos) = comment env buf lexbuf in + Comment (env, (mk_comment env start_pos end_pos buf true)) + | 5 -> Token (env, T_LESS_THAN) + | 6 -> Token (env, T_DIV) + | 7 -> Token (env, T_GREATER_THAN) + | 8 -> Token (env, T_LCURLY) + | 9 -> Token (env, T_COLON) + | 10 -> Token (env, T_PERIOD) + | 11 -> Token (env, T_ASSIGN) + | 12 -> + let quote = lexeme lexbuf in + let start = start_pos_of_lexbuf env lexbuf in + let buf = Buffer.create 127 in + let raw = Buffer.create 127 in + (Buffer.add_string raw quote; + (let mode = + if quote = "'" + then JSX_SINGLE_QUOTED_TEXT + else JSX_DOUBLE_QUOTED_TEXT in + let env = jsx_text env mode buf raw lexbuf in + let _end = end_pos_of_lexbuf env lexbuf in + Buffer.add_string raw quote; + (let value = Buffer.contents buf in + let raw = Buffer.contents raw in + let loc = { Loc.source = (Lex_env.source env); start; _end } in + Token (env, (T_JSX_TEXT (loc, value, raw)))))) + | 13 -> + let start_offset = Sedlexing.lexeme_start lexbuf in + (loop_jsx_id_continues lexbuf; + (let end_offset = Sedlexing.lexeme_end lexbuf in + Sedlexing.set_lexeme_start lexbuf start_offset; + (let raw = Sedlexing.lexeme lexbuf in + let loc = loc_of_offsets env start_offset end_offset in + Token + (env, + (T_JSX_IDENTIFIER { raw = (Sedlexing.string_of_utf8 raw); loc }))))) + | 14 -> Token (env, (T_ERROR (lexeme lexbuf))) + | _ -> failwith "unreachable jsx_tag") +let jsx_child env start buf raw lexbuf = + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_118 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 1 + | 1 -> 4 + | 2 -> 0 + | 3 -> __sedlex_state_4 lexbuf + | 4 -> 2 + | 5 -> 3 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_4 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_11 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 0 + | _ -> Sedlexing.backtrack lexbuf)) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> + let lt = lexeme lexbuf in + (Buffer.add_string raw lt; + Buffer.add_string buf lt; + (let env = new_line env lexbuf in + let env = jsx_text env JSX_CHILD_TEXT buf raw lexbuf in + let _end = end_pos_of_lexbuf env lexbuf in + let value = Buffer.contents buf in + let raw = Buffer.contents raw in + let loc = { Loc.source = (Lex_env.source env); start; _end } in + (env, (T_JSX_TEXT (loc, value, raw))))) + | 1 -> (env, T_EOF) + | 2 -> (env, T_LESS_THAN) + | 3 -> (env, T_LCURLY) + | 4 -> + (Sedlexing.rollback lexbuf; + (let env = jsx_text env JSX_CHILD_TEXT buf raw lexbuf in + let _end = end_pos_of_lexbuf env lexbuf in + let value = Buffer.contents buf in + let raw = Buffer.contents raw in + let loc = { Loc.source = (Lex_env.source env); start; _end } in + (env, (T_JSX_TEXT (loc, value, raw))))) + | _ -> failwith "unreachable jsx_child") +let template_tail env lexbuf = + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_119 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 5 + | 1 -> __sedlex_state_2 lexbuf + | 2 -> 0 + | 3 -> __sedlex_state_5 lexbuf + | 4 -> __sedlex_state_7 lexbuf + | 5 -> 4 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_2 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 1; + (match __sedlex_partition_51 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_3 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_3 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 1; + (match __sedlex_partition_51 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_3 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_5 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_11 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 0 + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_7 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 5; + (match __sedlex_partition_108 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 3 + | 1 -> 2 + | _ -> Sedlexing.backtrack lexbuf)) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> let env = new_line env lexbuf in Continue env + | 1 -> Continue env + | 2 -> + let start_pos = start_pos_of_lexbuf env lexbuf in + let buf = Buffer.create 127 in + let (env, end_pos) = line_comment env buf lexbuf in + Comment (env, (mk_comment env start_pos end_pos buf false)) + | 3 -> + let start_pos = start_pos_of_lexbuf env lexbuf in + let buf = Buffer.create 127 in + let (env, end_pos) = comment env buf lexbuf in + Comment (env, (mk_comment env start_pos end_pos buf true)) + | 4 -> + let start = start_pos_of_lexbuf env lexbuf in + let cooked = Buffer.create 127 in + let raw = Buffer.create 127 in + let literal = Buffer.create 127 in + (Buffer.add_string literal "}"; + (let (env, is_tail) = template_part env cooked raw literal lexbuf in + let _end = end_pos_of_lexbuf env lexbuf in + let loc = { Loc.source = (Lex_env.source env); start; _end } in + Token + (env, + (T_TEMPLATE_PART + (loc, + { + cooked = (Buffer.contents cooked); + raw = (Buffer.contents raw); + literal = (Buffer.contents literal) + }, is_tail))))) + | 5 -> + let env = illegal env (loc_of_lexbuf env lexbuf) in + Token + (env, + (T_TEMPLATE_PART + ((loc_of_lexbuf env lexbuf), + { cooked = ""; raw = ""; literal = "" }, true))) + | _ -> failwith "unreachable template_tail") +let type_token env lexbuf = + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_126 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 62 + | 1 -> 63 + | 2 -> __sedlex_state_3 lexbuf + | 3 -> 0 + | 4 -> __sedlex_state_6 lexbuf + | 5 -> 6 + | 6 -> 61 + | 7 -> __sedlex_state_10 lexbuf + | 8 -> 56 + | 9 -> 38 + | 10 -> 39 + | 11 -> __sedlex_state_20 lexbuf + | 12 -> 59 + | 13 -> 43 + | 14 -> __sedlex_state_24 lexbuf + | 15 -> __sedlex_state_97 lexbuf + | 16 -> __sedlex_state_100 lexbuf + | 17 -> __sedlex_state_117 lexbuf + | 18 -> __sedlex_state_118 lexbuf + | 19 -> 44 + | 20 -> 42 + | 21 -> 49 + | 22 -> __sedlex_state_122 lexbuf + | 23 -> 50 + | 24 -> __sedlex_state_125 lexbuf + | 25 -> 32 + | 26 -> __sedlex_state_128 lexbuf + | 27 -> 33 + | 28 -> __sedlex_state_137 lexbuf + | 29 -> __sedlex_state_139 lexbuf + | 30 -> 35 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_3 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 1; + (match __sedlex_partition_51 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_4 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_4 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 1; + (match __sedlex_partition_51 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_4 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_6 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_11 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 0 + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_10 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 63; + (match __sedlex_partition_73 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_11 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_11 = + function + | lexbuf -> + (match __sedlex_partition_127 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_12 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_12 = + function + | lexbuf -> + (match __sedlex_partition_75 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_13 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_13 = + function + | lexbuf -> + (match __sedlex_partition_73 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_14 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_14 = + function + | lexbuf -> + (match __sedlex_partition_128 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_15 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_15 = + function + | lexbuf -> + (match __sedlex_partition_93 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 31 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_20 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 53; + (match __sedlex_partition_13 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 4 + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_24 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 60; + (match __sedlex_partition_123 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_25 lexbuf + | 1 -> __sedlex_state_26 lexbuf + | 2 -> __sedlex_state_47 lexbuf + | 3 -> __sedlex_state_94 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_25 = + function + | lexbuf -> + (match __sedlex_partition_123 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_25 lexbuf + | 1 -> __sedlex_state_26 lexbuf + | 2 -> __sedlex_state_47 lexbuf + | 3 -> __sedlex_state_94 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_26 = + function + | lexbuf -> + (match __sedlex_partition_33 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_27 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_27 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 30; + (match __sedlex_partition_59 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_28 lexbuf + | 1 -> __sedlex_state_27 lexbuf + | 2 -> __sedlex_state_29 lexbuf + | 3 -> __sedlex_state_43 lexbuf + | 4 -> __sedlex_state_45 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_28 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 29; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_28 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_29 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 29; + (match __sedlex_partition_61 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_28 lexbuf + | 1 -> __sedlex_state_30 lexbuf + | 2 -> __sedlex_state_38 lexbuf + | 3 -> __sedlex_state_42 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_30 = + function + | lexbuf -> + (match __sedlex_partition_40 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_31 lexbuf + | 1 -> __sedlex_state_35 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_31 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 24; + (match __sedlex_partition_62 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_32 lexbuf + | 1 -> __sedlex_state_31 lexbuf + | 2 -> __sedlex_state_33 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_32 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 23; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_32 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_33 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 22; + (match __sedlex_partition_63 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_34 lexbuf + | 1 -> __sedlex_state_32 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_34 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 21; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_34 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_35 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 24; + (match __sedlex_partition_64 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_32 lexbuf + | 1 -> __sedlex_state_35 lexbuf + | 2 -> __sedlex_state_36 lexbuf + | 3 -> __sedlex_state_33 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_36 = + function + | lexbuf -> + (match __sedlex_partition_33 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_37 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_37 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 24; + (match __sedlex_partition_64 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_32 lexbuf + | 1 -> __sedlex_state_37 lexbuf + | 2 -> __sedlex_state_36 lexbuf + | 3 -> __sedlex_state_33 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_38 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 24; + (match __sedlex_partition_62 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_39 lexbuf + | 1 -> __sedlex_state_38 lexbuf + | 2 -> __sedlex_state_40 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_39 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 23; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_39 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_40 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 22; + (match __sedlex_partition_63 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_41 lexbuf + | 1 -> __sedlex_state_39 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_41 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 21; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_41 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_42 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 24; + (match __sedlex_partition_64 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_39 lexbuf + | 1 -> __sedlex_state_42 lexbuf + | 2 -> __sedlex_state_36 lexbuf + | 3 -> __sedlex_state_40 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_43 = + function + | lexbuf -> + (match __sedlex_partition_33 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_44 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_44 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 30; + (match __sedlex_partition_59 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_28 lexbuf + | 1 -> __sedlex_state_44 lexbuf + | 2 -> __sedlex_state_29 lexbuf + | 3 -> __sedlex_state_43 lexbuf + | 4 -> __sedlex_state_45 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_45 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 27; + (match __sedlex_partition_63 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_46 lexbuf + | 1 -> __sedlex_state_28 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_46 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 25; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_46 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_47 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 30; + (match __sedlex_partition_76 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_28 lexbuf + | 1 -> __sedlex_state_48 lexbuf + | 2 -> __sedlex_state_52 lexbuf + | 3 -> __sedlex_state_61 lexbuf + | 4 -> __sedlex_state_64 lexbuf + | 5 -> __sedlex_state_29 lexbuf + | 6 -> __sedlex_state_74 lexbuf + | 7 -> __sedlex_state_84 lexbuf + | 8 -> __sedlex_state_62 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_48 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 30; + (match __sedlex_partition_77 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_28 lexbuf + | 1 -> __sedlex_state_49 lexbuf + | 2 -> __sedlex_state_29 lexbuf + | 3 -> __sedlex_state_45 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_49 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 30; + (match __sedlex_partition_59 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_28 lexbuf + | 1 -> __sedlex_state_49 lexbuf + | 2 -> __sedlex_state_29 lexbuf + | 3 -> __sedlex_state_50 lexbuf + | 4 -> __sedlex_state_45 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_50 = + function + | lexbuf -> + (match __sedlex_partition_33 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_51 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_51 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 30; + (match __sedlex_partition_59 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_28 lexbuf + | 1 -> __sedlex_state_51 lexbuf + | 2 -> __sedlex_state_29 lexbuf + | 3 -> __sedlex_state_50 lexbuf + | 4 -> __sedlex_state_45 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_52 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 16; + (match __sedlex_partition_78 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_53 lexbuf + | 1 -> __sedlex_state_54 lexbuf + | 2 -> __sedlex_state_52 lexbuf + | 3 -> __sedlex_state_58 lexbuf + | 4 -> __sedlex_state_59 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_53 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 15; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_53 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_54 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 30; + (match __sedlex_partition_62 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_28 lexbuf + | 1 -> __sedlex_state_55 lexbuf + | 2 -> __sedlex_state_45 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_55 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 30; + (match __sedlex_partition_64 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_28 lexbuf + | 1 -> __sedlex_state_55 lexbuf + | 2 -> __sedlex_state_56 lexbuf + | 3 -> __sedlex_state_45 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_56 = + function + | lexbuf -> + (match __sedlex_partition_33 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_57 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_57 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 30; + (match __sedlex_partition_64 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_28 lexbuf + | 1 -> __sedlex_state_57 lexbuf + | 2 -> __sedlex_state_56 lexbuf + | 3 -> __sedlex_state_45 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_58 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 15; + (match __sedlex_partition_79 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_53 lexbuf + | 1 -> __sedlex_state_54 lexbuf + | 2 -> __sedlex_state_58 lexbuf + | 3 -> __sedlex_state_59 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_59 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 15; + (match __sedlex_partition_63 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_60 lexbuf + | 1 -> __sedlex_state_53 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_60 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 15; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_60 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_61 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 30; + (match __sedlex_partition_79 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_28 lexbuf + | 1 -> __sedlex_state_54 lexbuf + | 2 -> __sedlex_state_61 lexbuf + | 3 -> __sedlex_state_62 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_62 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 28; + (match __sedlex_partition_63 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_63 lexbuf + | 1 -> __sedlex_state_28 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_63 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 26; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_63 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_64 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 29; + (match __sedlex_partition_80 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_28 lexbuf + | 1 -> __sedlex_state_65 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_65 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 10; + (match __sedlex_partition_81 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_66 lexbuf + | 1 -> __sedlex_state_65 lexbuf + | 2 -> __sedlex_state_67 lexbuf + | 3 -> __sedlex_state_72 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_66 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 9; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_66 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_67 = + function + | lexbuf -> + (match __sedlex_partition_26 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_68 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_68 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 10; + (match __sedlex_partition_81 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_69 lexbuf + | 1 -> __sedlex_state_68 lexbuf + | 2 -> __sedlex_state_67 lexbuf + | 3 -> __sedlex_state_70 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_69 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 9; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_69 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_70 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 8; + (match __sedlex_partition_63 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_71 lexbuf + | 1 -> __sedlex_state_69 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_71 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 7; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_71 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_72 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 8; + (match __sedlex_partition_63 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_73 lexbuf + | 1 -> __sedlex_state_66 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_73 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 7; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_73 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_74 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 29; + (match __sedlex_partition_82 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_28 lexbuf + | 1 -> __sedlex_state_75 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_75 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 14; + (match __sedlex_partition_83 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_76 lexbuf + | 1 -> __sedlex_state_75 lexbuf + | 2 -> __sedlex_state_77 lexbuf + | 3 -> __sedlex_state_82 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_76 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 13; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_76 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_77 = + function + | lexbuf -> + (match __sedlex_partition_17 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_78 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_78 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 14; + (match __sedlex_partition_83 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_79 lexbuf + | 1 -> __sedlex_state_78 lexbuf + | 2 -> __sedlex_state_77 lexbuf + | 3 -> __sedlex_state_80 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_79 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 13; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_79 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_80 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 12; + (match __sedlex_partition_63 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_81 lexbuf + | 1 -> __sedlex_state_79 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_81 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 11; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_81 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_82 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 12; + (match __sedlex_partition_63 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_83 lexbuf + | 1 -> __sedlex_state_76 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_83 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 11; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_83 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_84 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 29; + (match __sedlex_partition_84 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_28 lexbuf + | 1 -> __sedlex_state_85 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_85 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 20; + (match __sedlex_partition_85 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_86 lexbuf + | 1 -> __sedlex_state_85 lexbuf + | 2 -> __sedlex_state_87 lexbuf + | 3 -> __sedlex_state_92 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_86 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 19; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_86 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_87 = + function + | lexbuf -> + (match __sedlex_partition_4 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_88 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_88 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 20; + (match __sedlex_partition_85 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_89 lexbuf + | 1 -> __sedlex_state_88 lexbuf + | 2 -> __sedlex_state_87 lexbuf + | 3 -> __sedlex_state_90 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_89 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 19; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_89 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_90 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 18; + (match __sedlex_partition_63 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_91 lexbuf + | 1 -> __sedlex_state_89 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_91 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 17; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_91 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_92 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 18; + (match __sedlex_partition_63 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_93 lexbuf + | 1 -> __sedlex_state_86 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_93 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 17; + (match __sedlex_partition_60 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_93 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_94 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 30; + (match __sedlex_partition_86 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_28 lexbuf + | 1 -> __sedlex_state_48 lexbuf + | 2 -> __sedlex_state_94 lexbuf + | 3 -> __sedlex_state_29 lexbuf + | 4 -> __sedlex_state_95 lexbuf + | 5 -> __sedlex_state_62 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_95 = + function + | lexbuf -> + (match __sedlex_partition_33 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_96 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_96 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 30; + (match __sedlex_partition_87 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_28 lexbuf + | 1 -> __sedlex_state_54 lexbuf + | 2 -> __sedlex_state_96 lexbuf + | 3 -> __sedlex_state_95 lexbuf + | 4 -> __sedlex_state_62 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_97 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 41; + (match __sedlex_partition_47 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_98 lexbuf + | 1 -> __sedlex_state_27 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_98 = + function + | lexbuf -> + (match __sedlex_partition_58 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 40 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_100 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 63; + (match __sedlex_partition_108 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_101 lexbuf + | 1 -> 5 + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_101 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 2; + (match __sedlex_partition_65 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_102 lexbuf + | 1 -> __sedlex_state_103 lexbuf + | 2 -> __sedlex_state_105 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_102 = + function + | lexbuf -> + (match __sedlex_partition_65 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_102 lexbuf + | 1 -> __sedlex_state_103 lexbuf + | 2 -> __sedlex_state_105 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_103 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 3; + (match __sedlex_partition_66 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 3 + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_105 = + function + | lexbuf -> + (match __sedlex_partition_67 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_106 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_106 = + function + | lexbuf -> + (match __sedlex_partition_68 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_107 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_107 = + function + | lexbuf -> + (match __sedlex_partition_69 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_108 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_108 = + function + | lexbuf -> + (match __sedlex_partition_70 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_109 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_109 = + function + | lexbuf -> + (match __sedlex_partition_71 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_110 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_110 = + function + | lexbuf -> + (match __sedlex_partition_72 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_111 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_111 = + function + | lexbuf -> + (match __sedlex_partition_73 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_112 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_112 = + function + | lexbuf -> + (match __sedlex_partition_67 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_113 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_113 = + function + | lexbuf -> + (match __sedlex_partition_2 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_114 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_114 = + function + | lexbuf -> + (match __sedlex_partition_74 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_115 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_115 = + function + | lexbuf -> + (match __sedlex_partition_75 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 3 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_117 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 30; + (match __sedlex_partition_76 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_28 lexbuf + | 1 -> __sedlex_state_48 lexbuf + | 2 -> __sedlex_state_52 lexbuf + | 3 -> __sedlex_state_61 lexbuf + | 4 -> __sedlex_state_64 lexbuf + | 5 -> __sedlex_state_29 lexbuf + | 6 -> __sedlex_state_74 lexbuf + | 7 -> __sedlex_state_84 lexbuf + | 8 -> __sedlex_state_62 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_118 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 30; + (match __sedlex_partition_86 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_28 lexbuf + | 1 -> __sedlex_state_48 lexbuf + | 2 -> __sedlex_state_94 lexbuf + | 3 -> __sedlex_state_29 lexbuf + | 4 -> __sedlex_state_95 lexbuf + | 5 -> __sedlex_state_62 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_122 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 51; + (match __sedlex_partition_129 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 57 + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_125 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 46; + (match __sedlex_partition_58 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 45 + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_128 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 63; + (match __sedlex_partition_2 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_129 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_129 = + function + | lexbuf -> + (match __sedlex_partition_3 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_130 lexbuf + | 1 -> __sedlex_state_134 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_130 = + function + | lexbuf -> + (match __sedlex_partition_4 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_131 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_131 = + function + | lexbuf -> + (match __sedlex_partition_4 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_132 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_132 = + function + | lexbuf -> + (match __sedlex_partition_4 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 61 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_134 = + function + | lexbuf -> + (match __sedlex_partition_4 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_135 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_135 = + function + | lexbuf -> + (match __sedlex_partition_5 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_135 lexbuf + | 1 -> 61 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_137 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 34; + (match __sedlex_partition_130 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 36 + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_139 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 55; + (match __sedlex_partition_131 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 37 + | _ -> Sedlexing.backtrack lexbuf)) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> let env = new_line env lexbuf in Continue env + | 1 -> Continue env + | 2 -> + let start_pos = start_pos_of_lexbuf env lexbuf in + let buf = Buffer.create 127 in + let (env, end_pos) = comment env buf lexbuf in + Comment (env, (mk_comment env start_pos end_pos buf true)) + | 3 -> + let pattern = lexeme lexbuf in + if not (is_comment_syntax_enabled env) + then + let start_pos = start_pos_of_lexbuf env lexbuf in + let buf = Buffer.create 127 in + (Buffer.add_string buf pattern; + (let (env, end_pos) = comment env buf lexbuf in + Comment (env, (mk_comment env start_pos end_pos buf true)))) + else + (let env = + if is_in_comment_syntax env + then + let loc = loc_of_lexbuf env lexbuf in + unexpected_error env loc pattern + else env in + let env = in_comment_syntax true env in + let len = Sedlexing.lexeme_length lexbuf in + if + ((Sedlexing.Utf8.sub_lexeme lexbuf (len - 1) 1) = ":") && + ((Sedlexing.Utf8.sub_lexeme lexbuf (len - 2) 1) <> ":") + then Token (env, T_COLON) + else Continue env) + | 4 -> + if is_in_comment_syntax env + then let env = in_comment_syntax false env in Continue env + else + (Sedlexing.rollback lexbuf; + (let __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_23 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 0 + | _ -> Sedlexing.backtrack lexbuf) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> Token (env, T_MULT) + | _ -> failwith "expected *"))) + | 5 -> + let start_pos = start_pos_of_lexbuf env lexbuf in + let buf = Buffer.create 127 in + let (env, end_pos) = line_comment env buf lexbuf in + Comment (env, (mk_comment env start_pos end_pos buf false)) + | 6 -> + let quote = lexeme lexbuf in + let start = start_pos_of_lexbuf env lexbuf in + let buf = Buffer.create 127 in + let raw = Buffer.create 127 in + (Buffer.add_string raw quote; + (let octal = false in + let (env, _end, octal) = string_quote env quote buf raw octal lexbuf in + let loc = { Loc.source = (Lex_env.source env); start; _end } in + Token + (env, + (T_STRING + (loc, (Buffer.contents buf), (Buffer.contents raw), octal))))) + | 7 -> + recover env lexbuf + ~f:(fun env -> + fun lexbuf -> + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_120 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | 1 -> __sedlex_state_2 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_1 = + function + | lexbuf -> + (match __sedlex_partition_121 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | 1 -> __sedlex_state_2 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_2 = + function + | lexbuf -> + (match __sedlex_partition_25 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_3 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_3 = + function + | lexbuf -> + (match __sedlex_partition_26 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_4 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_4 = + function + | lexbuf -> + (match __sedlex_partition_27 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_4 lexbuf + | 1 -> __sedlex_state_5 lexbuf + | 2 -> 0 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_5 = + function + | lexbuf -> + (match __sedlex_partition_26 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_6 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_6 = + function + | lexbuf -> + (match __sedlex_partition_27 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_6 lexbuf + | 1 -> __sedlex_state_5 lexbuf + | 2 -> 0 + | _ -> Sedlexing.backtrack lexbuf) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> + let num = Sedlexing.lexeme lexbuf in + Token (env, (mk_bignum_singleton BIG_BINARY num)) + | _ -> failwith "unreachable type_token bigbigint")) + | 8 -> + let num = Sedlexing.lexeme lexbuf in + Token (env, (mk_bignum_singleton BIG_BINARY num)) + | 9 -> + recover env lexbuf + ~f:(fun env -> + fun lexbuf -> + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_120 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | 1 -> __sedlex_state_2 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_1 = + function + | lexbuf -> + (match __sedlex_partition_121 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | 1 -> __sedlex_state_2 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_2 = + function + | lexbuf -> + (match __sedlex_partition_25 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_3 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_3 = + function + | lexbuf -> + (match __sedlex_partition_26 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_4 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_4 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_28 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_4 lexbuf + | 1 -> __sedlex_state_5 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_5 = + function + | lexbuf -> + (match __sedlex_partition_26 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_6 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_6 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_28 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_6 lexbuf + | 1 -> __sedlex_state_5 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> + let num = Sedlexing.lexeme lexbuf in + Token (env, (mk_num_singleton BINARY num)) + | _ -> failwith "unreachable type_token binnumber")) + | 10 -> + let num = Sedlexing.lexeme lexbuf in + Token (env, (mk_num_singleton BINARY num)) + | 11 -> + recover env lexbuf + ~f:(fun env -> + fun lexbuf -> + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_120 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | 1 -> __sedlex_state_2 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_1 = + function + | lexbuf -> + (match __sedlex_partition_121 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | 1 -> __sedlex_state_2 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_2 = + function + | lexbuf -> + (match __sedlex_partition_29 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_3 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_3 = + function + | lexbuf -> + (match __sedlex_partition_17 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_4 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_4 = + function + | lexbuf -> + (match __sedlex_partition_30 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_4 lexbuf + | 1 -> __sedlex_state_5 lexbuf + | 2 -> 0 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_5 = + function + | lexbuf -> + (match __sedlex_partition_17 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_6 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_6 = + function + | lexbuf -> + (match __sedlex_partition_30 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_6 lexbuf + | 1 -> __sedlex_state_5 lexbuf + | 2 -> 0 + | _ -> Sedlexing.backtrack lexbuf) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> + let num = Sedlexing.lexeme lexbuf in + Token (env, (mk_bignum_singleton BIG_OCTAL num)) + | _ -> failwith "unreachable type_token octbigint")) + | 12 -> + let num = Sedlexing.lexeme lexbuf in + Token (env, (mk_bignum_singleton BIG_OCTAL num)) + | 13 -> + recover env lexbuf + ~f:(fun env -> + fun lexbuf -> + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_120 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | 1 -> __sedlex_state_2 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_1 = + function + | lexbuf -> + (match __sedlex_partition_121 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | 1 -> __sedlex_state_2 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_2 = + function + | lexbuf -> + (match __sedlex_partition_29 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_3 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_3 = + function + | lexbuf -> + (match __sedlex_partition_17 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_4 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_4 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_31 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_4 lexbuf + | 1 -> __sedlex_state_5 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_5 = + function + | lexbuf -> + (match __sedlex_partition_17 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_6 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_6 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_31 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_6 lexbuf + | 1 -> __sedlex_state_5 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> + let num = Sedlexing.lexeme lexbuf in + Token (env, (mk_num_singleton OCTAL num)) + | _ -> failwith "unreachable type_token octnumber")) + | 14 -> + let num = Sedlexing.lexeme lexbuf in + Token (env, (mk_num_singleton OCTAL num)) + | 15 -> + recover env lexbuf + ~f:(fun env -> + fun lexbuf -> + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_120 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | 1 -> __sedlex_state_2 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_1 = + function + | lexbuf -> + (match __sedlex_partition_121 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | 1 -> __sedlex_state_2 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_2 = + function + | lexbuf -> + (match __sedlex_partition_17 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_3 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_3 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_17 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_3 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> + let num = Sedlexing.lexeme lexbuf in + Token (env, (mk_num_singleton LEGACY_OCTAL num)) + | _ -> failwith "unreachable type_token legacyoctnumber")) + | 16 -> + let num = Sedlexing.lexeme lexbuf in + Token (env, (mk_num_singleton LEGACY_OCTAL num)) + | 17 -> + recover env lexbuf + ~f:(fun env -> + fun lexbuf -> + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_120 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | 1 -> __sedlex_state_2 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_1 = + function + | lexbuf -> + (match __sedlex_partition_121 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | 1 -> __sedlex_state_2 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_2 = + function + | lexbuf -> + (match __sedlex_partition_34 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_3 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_3 = + function + | lexbuf -> + (match __sedlex_partition_4 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_4 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_4 = + function + | lexbuf -> + (match __sedlex_partition_35 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_4 lexbuf + | 1 -> __sedlex_state_5 lexbuf + | 2 -> 0 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_5 = + function + | lexbuf -> + (match __sedlex_partition_4 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_6 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_6 = + function + | lexbuf -> + (match __sedlex_partition_35 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_6 lexbuf + | 1 -> __sedlex_state_5 lexbuf + | 2 -> 0 + | _ -> Sedlexing.backtrack lexbuf) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> + let num = Sedlexing.lexeme lexbuf in + Token (env, (mk_bignum_singleton BIG_NORMAL num)) + | _ -> failwith "unreachable type_token hexbigint")) + | 18 -> + let num = Sedlexing.lexeme lexbuf in + Token (env, (mk_bignum_singleton BIG_NORMAL num)) + | 19 -> + recover env lexbuf + ~f:(fun env -> + fun lexbuf -> + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_120 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | 1 -> __sedlex_state_2 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_1 = + function + | lexbuf -> + (match __sedlex_partition_121 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | 1 -> __sedlex_state_2 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_2 = + function + | lexbuf -> + (match __sedlex_partition_34 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_3 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_3 = + function + | lexbuf -> + (match __sedlex_partition_4 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_4 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_4 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_36 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_4 lexbuf + | 1 -> __sedlex_state_5 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_5 = + function + | lexbuf -> + (match __sedlex_partition_4 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_6 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_6 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_36 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_6 lexbuf + | 1 -> __sedlex_state_5 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> + let num = Sedlexing.lexeme lexbuf in + Token (env, (mk_num_singleton NORMAL num)) + | _ -> failwith "unreachable type_token hexnumber")) + | 20 -> + let num = Sedlexing.lexeme lexbuf in + Token (env, (mk_num_singleton NORMAL num)) + | 21 -> + recover env lexbuf + ~f:(fun env -> + fun lexbuf -> + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_122 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | 1 -> __sedlex_state_2 lexbuf + | 2 -> __sedlex_state_13 lexbuf + | 3 -> __sedlex_state_18 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_1 = + function + | lexbuf -> + (match __sedlex_partition_123 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | 1 -> __sedlex_state_2 lexbuf + | 2 -> __sedlex_state_13 lexbuf + | 3 -> __sedlex_state_18 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_2 = + function + | lexbuf -> + (match __sedlex_partition_33 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_3 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_3 = + function + | lexbuf -> + (match __sedlex_partition_38 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_3 lexbuf + | 1 -> __sedlex_state_4 lexbuf + | 2 -> __sedlex_state_11 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_4 = + function + | lexbuf -> + (match __sedlex_partition_39 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_5 lexbuf + | 1 -> __sedlex_state_6 lexbuf + | 2 -> __sedlex_state_8 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_5 = + function + | lexbuf -> + (match __sedlex_partition_40 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_6 lexbuf + | 1 -> __sedlex_state_8 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_6 = + function + | lexbuf -> + (match __sedlex_partition_41 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_6 lexbuf + | 1 -> 0 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_8 = + function + | lexbuf -> + (match __sedlex_partition_42 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_8 lexbuf + | 1 -> __sedlex_state_9 lexbuf + | 2 -> 0 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_9 = + function + | lexbuf -> + (match __sedlex_partition_33 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_10 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_10 = + function + | lexbuf -> + (match __sedlex_partition_42 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_10 lexbuf + | 1 -> __sedlex_state_9 lexbuf + | 2 -> 0 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_11 = + function + | lexbuf -> + (match __sedlex_partition_33 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_12 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_12 = + function + | lexbuf -> + (match __sedlex_partition_38 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_12 lexbuf + | 1 -> __sedlex_state_4 lexbuf + | 2 -> __sedlex_state_11 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_13 = + function + | lexbuf -> + (match __sedlex_partition_43 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_14 lexbuf + | 1 -> __sedlex_state_4 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_14 = + function + | lexbuf -> + (match __sedlex_partition_44 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_15 lexbuf + | 1 -> __sedlex_state_4 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_15 = + function + | lexbuf -> + (match __sedlex_partition_38 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_15 lexbuf + | 1 -> __sedlex_state_4 lexbuf + | 2 -> __sedlex_state_16 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_16 = + function + | lexbuf -> + (match __sedlex_partition_33 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_17 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_17 = + function + | lexbuf -> + (match __sedlex_partition_38 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_17 lexbuf + | 1 -> __sedlex_state_4 lexbuf + | 2 -> __sedlex_state_16 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_18 = + function + | lexbuf -> + (match __sedlex_partition_45 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_14 lexbuf + | 1 -> __sedlex_state_18 lexbuf + | 2 -> __sedlex_state_4 lexbuf + | _ -> Sedlexing.backtrack lexbuf) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> + let num = Sedlexing.lexeme lexbuf in + let loc = loc_of_lexbuf env lexbuf in + let env = + lex_error env loc Parse_error.InvalidSciBigInt in + Token (env, (mk_bignum_singleton BIG_NORMAL num)) + | _ -> failwith "unreachable type_token scibigint")) + | 22 -> + let num = Sedlexing.lexeme lexbuf in + let loc = loc_of_lexbuf env lexbuf in + let env = lex_error env loc Parse_error.InvalidSciBigInt in + Token (env, (mk_bignum_singleton BIG_NORMAL num)) + | 23 -> + recover env lexbuf + ~f:(fun env -> + fun lexbuf -> + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_122 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | 1 -> __sedlex_state_2 lexbuf + | 2 -> __sedlex_state_12 lexbuf + | 3 -> __sedlex_state_17 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_1 = + function + | lexbuf -> + (match __sedlex_partition_123 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | 1 -> __sedlex_state_2 lexbuf + | 2 -> __sedlex_state_12 lexbuf + | 3 -> __sedlex_state_17 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_2 = + function + | lexbuf -> + (match __sedlex_partition_33 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_3 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_3 = + function + | lexbuf -> + (match __sedlex_partition_38 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_3 lexbuf + | 1 -> __sedlex_state_4 lexbuf + | 2 -> __sedlex_state_10 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_4 = + function + | lexbuf -> + (match __sedlex_partition_39 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_5 lexbuf + | 1 -> __sedlex_state_6 lexbuf + | 2 -> __sedlex_state_7 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_5 = + function + | lexbuf -> + (match __sedlex_partition_40 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_6 lexbuf + | 1 -> __sedlex_state_7 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_6 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_33 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_6 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_7 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_46 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_7 lexbuf + | 1 -> __sedlex_state_8 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_8 = + function + | lexbuf -> + (match __sedlex_partition_33 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_9 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_9 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_46 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_9 lexbuf + | 1 -> __sedlex_state_8 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_10 = + function + | lexbuf -> + (match __sedlex_partition_33 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_11 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_11 = + function + | lexbuf -> + (match __sedlex_partition_38 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_11 lexbuf + | 1 -> __sedlex_state_4 lexbuf + | 2 -> __sedlex_state_10 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_12 = + function + | lexbuf -> + (match __sedlex_partition_43 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_13 lexbuf + | 1 -> __sedlex_state_4 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_13 = + function + | lexbuf -> + (match __sedlex_partition_44 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_14 lexbuf + | 1 -> __sedlex_state_4 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_14 = + function + | lexbuf -> + (match __sedlex_partition_38 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_14 lexbuf + | 1 -> __sedlex_state_4 lexbuf + | 2 -> __sedlex_state_15 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_15 = + function + | lexbuf -> + (match __sedlex_partition_33 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_16 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_16 = + function + | lexbuf -> + (match __sedlex_partition_38 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_16 lexbuf + | 1 -> __sedlex_state_4 lexbuf + | 2 -> __sedlex_state_15 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_17 = + function + | lexbuf -> + (match __sedlex_partition_45 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_13 lexbuf + | 1 -> __sedlex_state_17 lexbuf + | 2 -> __sedlex_state_4 lexbuf + | _ -> Sedlexing.backtrack lexbuf) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> + let num = Sedlexing.lexeme lexbuf in + Token (env, (mk_num_singleton NORMAL num)) + | _ -> failwith "unreachable type_token scinumber")) + | 24 -> + let num = Sedlexing.lexeme lexbuf in + Token (env, (mk_num_singleton NORMAL num)) + | 25 -> + recover env lexbuf + ~f:(fun env -> + fun lexbuf -> + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_122 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | 1 -> __sedlex_state_2 lexbuf + | 2 -> __sedlex_state_7 lexbuf + | 3 -> __sedlex_state_9 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_1 = + function + | lexbuf -> + (match __sedlex_partition_123 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | 1 -> __sedlex_state_2 lexbuf + | 2 -> __sedlex_state_7 lexbuf + | 3 -> __sedlex_state_9 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_2 = + function + | lexbuf -> + (match __sedlex_partition_33 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_3 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_3 = + function + | lexbuf -> + (match __sedlex_partition_42 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_3 lexbuf + | 1 -> __sedlex_state_4 lexbuf + | 2 -> 0 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_4 = + function + | lexbuf -> + (match __sedlex_partition_33 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_5 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_5 = + function + | lexbuf -> + (match __sedlex_partition_42 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_5 lexbuf + | 1 -> __sedlex_state_4 lexbuf + | 2 -> 0 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_7 = + function + | lexbuf -> + (match __sedlex_partition_47 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_8 lexbuf + | 1 -> __sedlex_state_7 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_8 = + function + | lexbuf -> + (match __sedlex_partition_41 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_3 lexbuf + | 1 -> 0 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_9 = + function + | lexbuf -> + (match __sedlex_partition_48 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_8 lexbuf + | 1 -> __sedlex_state_9 lexbuf + | 2 -> __sedlex_state_10 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_10 = + function + | lexbuf -> + (match __sedlex_partition_33 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_11 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_11 = + function + | lexbuf -> + (match __sedlex_partition_48 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_8 lexbuf + | 1 -> __sedlex_state_11 lexbuf + | 2 -> __sedlex_state_10 lexbuf + | _ -> Sedlexing.backtrack lexbuf) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> + let num = Sedlexing.lexeme lexbuf in + let loc = loc_of_lexbuf env lexbuf in + let env = + lex_error env loc Parse_error.InvalidFloatBigInt in + Token (env, (mk_bignum_singleton BIG_NORMAL num)) + | _ -> failwith "unreachable type_token floatbigint")) + | 26 -> + recover env lexbuf + ~f:(fun env -> + fun lexbuf -> + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_124 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | 1 -> __sedlex_state_2 lexbuf + | 2 -> __sedlex_state_4 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_1 = + function + | lexbuf -> + (match __sedlex_partition_125 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | 1 -> __sedlex_state_2 lexbuf + | 2 -> __sedlex_state_4 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_2 = + function + | lexbuf -> + (match __sedlex_partition_41 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_2 lexbuf + | 1 -> 0 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_4 = + function + | lexbuf -> + (match __sedlex_partition_42 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_4 lexbuf + | 1 -> __sedlex_state_5 lexbuf + | 2 -> 0 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_5 = + function + | lexbuf -> + (match __sedlex_partition_33 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_6 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_6 = + function + | lexbuf -> + (match __sedlex_partition_42 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_6 lexbuf + | 1 -> __sedlex_state_5 lexbuf + | 2 -> 0 + | _ -> Sedlexing.backtrack lexbuf) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> + let num = Sedlexing.lexeme lexbuf in + Token (env, (mk_bignum_singleton BIG_NORMAL num)) + | _ -> failwith "unreachable type_token wholebigint")) + | 27 -> + let num = Sedlexing.lexeme lexbuf in + let loc = loc_of_lexbuf env lexbuf in + let env = lex_error env loc Parse_error.InvalidFloatBigInt in + Token (env, (mk_bignum_singleton BIG_NORMAL num)) + | 28 -> + let num = Sedlexing.lexeme lexbuf in + Token (env, (mk_bignum_singleton BIG_NORMAL num)) + | 29 -> + recover env lexbuf + ~f:(fun env -> + fun lexbuf -> + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_122 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | 1 -> __sedlex_state_7 lexbuf + | 2 -> __sedlex_state_11 lexbuf + | 3 -> __sedlex_state_13 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_1 = + function + | lexbuf -> + (match __sedlex_partition_125 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_1 lexbuf + | 1 -> __sedlex_state_2 lexbuf + | 2 -> __sedlex_state_4 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_2 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_47 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 0 + | 1 -> __sedlex_state_2 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_4 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_48 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 0 + | 1 -> __sedlex_state_4 lexbuf + | 2 -> __sedlex_state_5 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_5 = + function + | lexbuf -> + (match __sedlex_partition_33 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_6 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_6 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_48 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 0 + | 1 -> __sedlex_state_6 lexbuf + | 2 -> __sedlex_state_5 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_7 = + function + | lexbuf -> + (match __sedlex_partition_33 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_8 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_8 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_46 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_8 lexbuf + | 1 -> __sedlex_state_9 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_9 = + function + | lexbuf -> + (match __sedlex_partition_33 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_10 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_10 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_46 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_10 lexbuf + | 1 -> __sedlex_state_9 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_11 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_47 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_12 lexbuf + | 1 -> __sedlex_state_11 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_12 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_33 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_8 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_13 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_48 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_12 lexbuf + | 1 -> __sedlex_state_13 lexbuf + | 2 -> __sedlex_state_14 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) + and __sedlex_state_14 = + function + | lexbuf -> + (match __sedlex_partition_33 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_15 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_15 = + function + | lexbuf -> + (Sedlexing.mark lexbuf 0; + (match __sedlex_partition_48 + (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_12 lexbuf + | 1 -> __sedlex_state_15 lexbuf + | 2 -> __sedlex_state_14 lexbuf + | _ -> Sedlexing.backtrack lexbuf)) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> + let num = Sedlexing.lexeme lexbuf in + Token (env, (mk_num_singleton NORMAL num)) + | _ -> failwith "unreachable type_token wholenumber")) + | 30 -> + let num = Sedlexing.lexeme lexbuf in + Token (env, (mk_num_singleton NORMAL num)) + | 31 -> Token (env, T_CHECKS) + | 32 -> Token (env, T_LBRACKET) + | 33 -> Token (env, T_RBRACKET) + | 34 -> Token (env, T_LCURLY) + | 35 -> Token (env, T_RCURLY) + | 36 -> Token (env, T_LCURLYBAR) + | 37 -> Token (env, T_RCURLYBAR) + | 38 -> Token (env, T_LPAREN) + | 39 -> Token (env, T_RPAREN) + | 40 -> Token (env, T_ELLIPSIS) + | 41 -> Token (env, T_PERIOD) + | 42 -> Token (env, T_SEMICOLON) + | 43 -> Token (env, T_COMMA) + | 44 -> Token (env, T_COLON) + | 45 -> Token (env, T_PLING_PERIOD) + | 46 -> Token (env, T_PLING) + | 47 -> Token (env, T_LBRACKET) + | 48 -> Token (env, T_RBRACKET) + | 49 -> Token (env, T_LESS_THAN) + | 50 -> Token (env, T_GREATER_THAN) + | 51 -> Token (env, T_ASSIGN) + | 52 -> Token (env, T_PLING) + | 53 -> Token (env, T_MULT) + | 54 -> Token (env, T_COLON) + | 55 -> Token (env, T_BIT_OR) + | 56 -> Token (env, T_BIT_AND) + | 57 -> Token (env, T_ARROW) + | 58 -> Token (env, T_ASSIGN) + | 59 -> Token (env, T_PLUS) + | 60 -> Token (env, T_MINUS) + | 61 -> + let start_offset = Sedlexing.lexeme_start lexbuf in + ((loop_id_continues lexbuf) |> ignore; + (let end_offset = Sedlexing.lexeme_end lexbuf in + let loc = loc_of_offsets env start_offset end_offset in + Sedlexing.set_lexeme_start lexbuf start_offset; + (let raw = Sedlexing.lexeme lexbuf in + let (env, value) = decode_identifier env raw in + match value with + | "any" -> Token (env, T_ANY_TYPE) + | "bool" -> Token (env, (T_BOOLEAN_TYPE BOOL)) + | "boolean" -> Token (env, (T_BOOLEAN_TYPE BOOLEAN)) + | "empty" -> Token (env, T_EMPTY_TYPE) + | "extends" -> Token (env, T_EXTENDS) + | "false" -> Token (env, T_FALSE) + | "interface" -> Token (env, T_INTERFACE) + | "mixed" -> Token (env, T_MIXED_TYPE) + | "null" -> Token (env, T_NULL) + | "number" -> Token (env, T_NUMBER_TYPE) + | "bigint" -> Token (env, T_BIGINT_TYPE) + | "static" -> Token (env, T_STATIC) + | "string" -> Token (env, T_STRING_TYPE) + | "true" -> Token (env, T_TRUE) + | "typeof" -> Token (env, T_TYPEOF) + | "void" -> Token (env, T_VOID_TYPE) + | "symbol" -> Token (env, T_SYMBOL_TYPE) + | _ -> + Token + (env, + (T_IDENTIFIER + { loc; value; raw = (Sedlexing.string_of_utf8 raw) }))))) + | 62 -> + let env = + if is_in_comment_syntax env + then + let loc = loc_of_lexbuf env lexbuf in + lex_error env loc Parse_error.UnexpectedEOS + else env in + Token (env, T_EOF) + | 63 -> Token (env, (T_ERROR (lexeme lexbuf))) + | _ -> failwith "unreachable type_token") +let jsx_child env = + let start = end_pos_of_lexbuf env env.lex_lb in + let buf = Buffer.create 127 in + let raw = Buffer.create 127 in + let (env, child) = jsx_child env start buf raw env.lex_lb in + let loc = loc_of_token env child in + let lex_errors_acc = (env.lex_state).lex_errors_acc in + if lex_errors_acc = [] + then + (env, + { + Lex_result.lex_token = child; + lex_loc = loc; + lex_comments = []; + lex_errors = [] + }) + else + ({ env with lex_state = { lex_errors_acc = [] } }, + { + Lex_result.lex_token = child; + lex_loc = loc; + lex_comments = []; + lex_errors = (List.rev lex_errors_acc) + }) +let wrap f = + let rec helper comments env = + match f env env.lex_lb with + | Token (env, t) -> + let loc = loc_of_token env t in + let lex_comments = if comments = [] then [] else List.rev comments in + let lex_token = t in + let lex_errors_acc = (env.lex_state).lex_errors_acc in + if lex_errors_acc = [] + then + ({ env with lex_last_loc = loc }, + { + Lex_result.lex_token = lex_token; + lex_loc = loc; + lex_comments; + lex_errors = [] + }) + else + ({ env with lex_last_loc = loc; lex_state = Lex_env.empty_lex_state + }, + { + Lex_result.lex_token = lex_token; + lex_loc = loc; + lex_comments; + lex_errors = (List.rev lex_errors_acc) + }) + | Comment (env, ((loc, _) as comment)) -> + let env = { env with lex_last_loc = loc } in + helper (comment :: comments) env + | Continue env -> helper comments env in + fun env -> helper [] env +let regexp = wrap regexp +let jsx_tag = wrap jsx_tag +let template_tail = wrap template_tail +let type_token = wrap type_token +let token = wrap token +let is_valid_identifier_name lexbuf = + let rec __sedlex_state_0 = + function + | lexbuf -> + (match __sedlex_partition_132 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 0 + | 1 -> __sedlex_state_2 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_2 = + function + | lexbuf -> + (match __sedlex_partition_2 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_3 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_3 = + function + | lexbuf -> + (match __sedlex_partition_3 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_4 lexbuf + | 1 -> __sedlex_state_7 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_4 = + function + | lexbuf -> + (match __sedlex_partition_4 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_5 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_5 = + function + | lexbuf -> + (match __sedlex_partition_4 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_6 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_6 = + function + | lexbuf -> + (match __sedlex_partition_4 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> 0 + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_7 = + function + | lexbuf -> + (match __sedlex_partition_4 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_8 lexbuf + | _ -> Sedlexing.backtrack lexbuf) + and __sedlex_state_8 = + function + | lexbuf -> + (match __sedlex_partition_5 (Sedlexing.__private__next_int lexbuf) + with + | 0 -> __sedlex_state_8 lexbuf + | 1 -> 0 + | _ -> Sedlexing.backtrack lexbuf) in + Sedlexing.start lexbuf; + (match __sedlex_state_0 lexbuf with + | 0 -> loop_id_continues lexbuf + | _ -> false) \ No newline at end of file diff --git a/analysis/vendor/js_parser/flow_lexer.mli b/analysis/vendor/js_parser/flow_lexer.mli new file mode 100644 index 000000000..8609d2245 --- /dev/null +++ b/analysis/vendor/js_parser/flow_lexer.mli @@ -0,0 +1,20 @@ +(* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) + +val jsx_child : Lex_env.t -> Lex_env.t * Lex_result.t + +val regexp : Lex_env.t -> Lex_env.t * Lex_result.t + +val jsx_tag : Lex_env.t -> Lex_env.t * Lex_result.t + +val template_tail : Lex_env.t -> Lex_env.t * Lex_result.t + +val type_token : Lex_env.t -> Lex_env.t * Lex_result.t + +val token : Lex_env.t -> Lex_env.t * Lex_result.t + +val is_valid_identifier_name : Flow_sedlexing.lexbuf -> bool diff --git a/analysis/vendor/js_parser/flow_sedlexing.ml b/analysis/vendor/js_parser/flow_sedlexing.ml new file mode 100644 index 000000000..1aec0e2ee --- /dev/null +++ b/analysis/vendor/js_parser/flow_sedlexing.ml @@ -0,0 +1,287 @@ +(* The package sedlex is released under the terms of an MIT-like license. *) +(* See the attached LICENSE file. *) +(* Copyright 2005, 2013 by Alain Frisch and LexiFi. *) +external ( .!()<- ) : int array -> int -> int -> unit = "%array_unsafe_set" +external ( .!() ) : int array -> int -> int = "%array_unsafe_get" +external ( .![] ) : string -> int -> char = "%string_unsafe_get" +external ( .![]<- ) : bytes -> int -> char -> unit = "%bytes_unsafe_set" + +exception InvalidCodepoint of int + +exception MalFormed + +(* Absolute position from the beginning of the stream *) +type apos = int + +(* critical states: + [pos] [curr_bol] [curr_line] + The state of [curr_bol] and [curr_line] only changes when we hit a newline + [marked_pos] [marked_bol] [marked_line] + [start_pos] [start_bol] [start_line] + get reset whenever we get a new token +*) +type lexbuf = { + buf: int array; + (* Number of meaningful char in buffer *) + len: int; + (* pos is the index in the buffer *) + mutable pos: int; + (* bol is the index in the input stream but not buffer *) + mutable curr_bol: int; + (* start from 1, if it is 0, we would not track postion info for you *) + mutable curr_line: int; + (* First char we need to keep visible *) + mutable start_pos: int; + mutable start_bol: int; + mutable start_line: int; + mutable marked_pos: int; + mutable marked_bol: int; + mutable marked_line: int; + mutable marked_val: int; +} + + +let lexbuf_clone (x : lexbuf) : lexbuf = + { + buf = x.buf; + len = x.len; + pos = x.pos; + curr_bol = x.curr_bol; + curr_line = x.curr_line; + start_pos = x.start_pos; + start_bol = x.start_bol; + start_line = x.start_line; + marked_pos = x.marked_pos; + marked_bol = x.marked_bol; + marked_line = x.marked_line; + marked_val = x.marked_val; + } + +let empty_lexbuf = + { + buf = [||]; + len = 0; + pos = 0; + curr_bol = 0; + curr_line = 0; + start_pos = 0; + start_bol = 0; + start_line = 0; + marked_pos = 0; + marked_bol = 0; + marked_line = 0; + marked_val = 0; + } + +let from_int_array a = + let len = Array.length a in + { empty_lexbuf with buf = a; len } + +let from_int_sub_array a len = + { empty_lexbuf with buf = a; len } + +let new_line lexbuf = + if lexbuf.curr_line != 0 then lexbuf.curr_line <- lexbuf.curr_line + 1; + lexbuf.curr_bol <- lexbuf.pos + +let next lexbuf : Stdlib.Uchar.t option = + if lexbuf.pos = lexbuf.len then + None + else + let ret = lexbuf.buf.!(lexbuf.pos) in + lexbuf.pos <- lexbuf.pos + 1; + if ret = 10 then new_line lexbuf; + Some (Stdlib.Uchar.unsafe_of_int ret) + +let __private__next_int lexbuf : int = + if lexbuf.pos = lexbuf.len then + -1 + else + let ret = lexbuf.buf.!(lexbuf.pos) in + lexbuf.pos <- lexbuf.pos + 1; + if ret = 10 then new_line lexbuf; + ret + +let mark lexbuf i = + lexbuf.marked_pos <- lexbuf.pos; + lexbuf.marked_bol <- lexbuf.curr_bol; + lexbuf.marked_line <- lexbuf.curr_line; + lexbuf.marked_val <- i + +let start lexbuf = + lexbuf.start_pos <- lexbuf.pos; + lexbuf.start_bol <- lexbuf.curr_bol; + lexbuf.start_line <- lexbuf.curr_line; + mark lexbuf (-1) + +let backtrack lexbuf = + lexbuf.pos <- lexbuf.marked_pos; + lexbuf.curr_bol <- lexbuf.marked_bol; + lexbuf.curr_line <- lexbuf.marked_line; + lexbuf.marked_val + +let rollback lexbuf = + lexbuf.pos <- lexbuf.start_pos; + lexbuf.curr_bol <- lexbuf.start_bol; + lexbuf.curr_line <- lexbuf.start_line + +let lexeme_start lexbuf = lexbuf.start_pos +let set_lexeme_start lexbuf pos = lexbuf.start_pos <- pos +let lexeme_end lexbuf = lexbuf.pos + +let loc lexbuf = (lexbuf.start_pos , lexbuf.pos ) + +let lexeme_length lexbuf = lexbuf.pos - lexbuf.start_pos + +let sub_lexeme lexbuf pos len = Array.sub lexbuf.buf (lexbuf.start_pos + pos) len + +let lexeme lexbuf = Array.sub lexbuf.buf lexbuf.start_pos (lexbuf.pos - lexbuf.start_pos) + +let current_code_point lexbuf = lexbuf.buf.(lexbuf.start_pos) +(* Decode UTF-8 encoded [s] into codepoints in [a], returning the length of the + * decoded string. + * + * To call this function safely: + * - ensure that [slen] is not greater than the length of [s] + * - ensure that [a] has enough capacity to hold the decoded value + *) +let unsafe_utf8_of_string (s : string) slen (a : int array) : int = + let spos = ref 0 in + let apos = ref 0 in + while !spos < slen do + let spos_code = s.![!spos] in + (match spos_code with + | '\000' .. '\127' as c -> + (* U+0000 - U+007F: 0xxxxxxx *) + a.!(!apos) <- Char.code c; + incr spos + | '\192' .. '\223' as c -> + (* U+0080 - U+07FF: 110xxxxx 10xxxxxx *) + let n1 = Char.code c in + let n2 = Char.code s.![!spos + 1] in + if n2 lsr 6 != 0b10 then raise MalFormed; + a.!(!apos) <- ((n1 land 0x1f) lsl 6) lor (n2 land 0x3f); + spos := !spos + 2 + | '\224' .. '\239' as c -> + (* U+0800 - U+FFFF: 1110xxxx 10xxxxxx 10xxxxxx + U+D800 - U+DFFF are reserved for surrogate halves (RFC 3629) *) + let n1 = Char.code c in + let n2 = Char.code s.![!spos + 1] in + let n3 = Char.code s.![!spos + 2] in + let p = ((n1 land 0x0f) lsl 12) lor ((n2 land 0x3f) lsl 6) lor (n3 land 0x3f) in + if (n2 lsr 6 != 0b10 || n3 lsr 6 != 0b10) || (p >= 0xd800 && p <= 0xdfff) then raise MalFormed; + a.!(!apos) <- p; + spos := !spos + 3 + | '\240' .. '\247' as c -> + (* U+10000 - U+1FFFFF: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx + > U+10FFFF are invalid (RFC 3629) *) + let n1 = Char.code c in + let n2 = Char.code s.![!spos + 1] in + let n3 = Char.code s.![!spos + 2] in + let n4 = Char.code s.![!spos + 3] in + if n2 lsr 6 != 0b10 || n3 lsr 6 != 0b10 || n4 lsr 6 != 0b10 then raise MalFormed; + let p = + ((n1 land 0x07) lsl 18) + lor ((n2 land 0x3f) lsl 12) + lor ((n3 land 0x3f) lsl 6) + lor (n4 land 0x3f) + in + if p > 0x10ffff then raise MalFormed; + a.!(!apos) <- p; + spos := !spos + 4 + | _ -> raise MalFormed); + incr apos + done; + !apos + +(* Encode the decoded codepoints in [a] as UTF-8 into [b], returning the length + * of the encoded string. + * + * To call this function safely: + * - ensure that [offset + len] is not greater than the length of [a] + * - ensure that [b] has sufficient capacity to hold the encoded value + *) +let unsafe_string_of_utf8 (a : int array) ~(offset : int) ~(len : int) (b : bytes) : int = + let apos = ref offset in + let len = ref len in + let i = ref 0 in + while !len > 0 do + let u = a.!(!apos) in + if u < 0 then + raise MalFormed + else if u <= 0x007F then begin + b.![!i] <- Char.unsafe_chr u; + incr i + end else if u <= 0x07FF then ( + b.![!i] <- Char.unsafe_chr (0xC0 lor (u lsr 6)); + b.![!i + 1] <- Char.unsafe_chr (0x80 lor (u land 0x3F)); + i := !i + 2 + ) else if u <= 0xFFFF then ( + b.![!i] <- Char.unsafe_chr (0xE0 lor (u lsr 12)); + b.![!i + 1] <- Char.unsafe_chr (0x80 lor ((u lsr 6) land 0x3F)); + b.![!i + 2] <- Char.unsafe_chr (0x80 lor (u land 0x3F)); + i := !i + 3 + ) else if u <= 0x10FFFF then ( + b.![!i] <- Char.unsafe_chr (0xF0 lor (u lsr 18)); + b.![!i + 1] <- Char.unsafe_chr (0x80 lor ((u lsr 12) land 0x3F)); + b.![!i + 2] <- Char.unsafe_chr (0x80 lor ((u lsr 6) land 0x3F)); + b.![!i + 3] <- Char.unsafe_chr (0x80 lor (u land 0x3F)); + i := !i + 4 + ) else + raise MalFormed; + incr apos; + decr len + done; + !i + +module Utf8 = struct + let from_string s = + let slen = String.length s in + let a = Array.make slen 0 in + let len = unsafe_utf8_of_string s slen a in + from_int_sub_array a len + + let sub_lexeme lexbuf pos len : string = + let offset = lexbuf.start_pos + pos in + let b = Bytes.create (len * 4) in + let buf = lexbuf.buf in + (* Assertion needed, since we make use of unsafe API below *) + assert (offset + len <= Array.length buf); + let i = unsafe_string_of_utf8 buf ~offset ~len b in + Bytes.sub_string b 0 i + + let lexeme lexbuf : string = + let offset = lexbuf.start_pos in + let len = lexbuf.pos - offset in + let b = Bytes.create (len * 4) in + let buf = lexbuf.buf in + let i = unsafe_string_of_utf8 buf ~offset ~len b in + Bytes.sub_string b 0 i + + let lexeme_to_buffer lexbuf buffer : unit = + let offset = lexbuf.start_pos in + let len = lexbuf.pos - offset in + let b = Bytes.create (len * 4) in + let buf = lexbuf.buf in + let i = unsafe_string_of_utf8 buf ~offset ~len b in + Buffer.add_subbytes buffer b 0 i + + let lexeme_to_buffer2 lexbuf buf1 buf2 : unit = + let offset = lexbuf.start_pos in + let len = lexbuf.pos - offset in + let b = Bytes.create (len * 4) in + let buf = lexbuf.buf in + let i = unsafe_string_of_utf8 buf ~offset ~len b in + Buffer.add_subbytes buf1 b 0 i; + Buffer.add_subbytes buf2 b 0 i +end + +let string_of_utf8 (lexbuf : int array) : string = + let offset = 0 in + let len = Array.length lexbuf in + let b = Bytes.create (len * 4) in + let i = unsafe_string_of_utf8 lexbuf ~offset ~len b in + Bytes.sub_string b 0 i + +let backoff lexbuf npos = + lexbuf.pos <- lexbuf.pos - npos diff --git a/analysis/vendor/js_parser/flow_sedlexing.mli b/analysis/vendor/js_parser/flow_sedlexing.mli new file mode 100644 index 000000000..c0d82db37 --- /dev/null +++ b/analysis/vendor/js_parser/flow_sedlexing.mli @@ -0,0 +1,47 @@ + +(** This is a module provides the minimal Sedlexing suppport + It is mostly a subset of Sedlexing with two functions for performance reasons: + - Utf8.lexeme_to_buffer + - Utf8.lexeme_to_buffer2 +*) +exception InvalidCodepoint of int +exception MalFormed +type apos = int +type lexbuf +val lexbuf_clone : lexbuf -> lexbuf + +val from_int_array : int array -> lexbuf +val new_line : lexbuf -> unit +val next : lexbuf -> Uchar.t option + +(**/**) +val __private__next_int : lexbuf -> int +(**/**) + +val mark : lexbuf -> int -> unit +val start : lexbuf -> unit +val backtrack : lexbuf -> int +val rollback : lexbuf -> unit +val lexeme_start : lexbuf -> int +val lexeme_end : lexbuf -> int +val loc : lexbuf -> int * int +val lexeme_length : lexbuf -> int +val sub_lexeme : lexbuf -> int -> int -> int array +val lexeme : lexbuf -> int array +module Utf8 : sig + val from_string : string -> lexbuf + val sub_lexeme : lexbuf -> int -> int -> string + val lexeme : lexbuf -> string + (** This API avoids another allocation *) + val lexeme_to_buffer : lexbuf -> Buffer.t -> unit + val lexeme_to_buffer2 : lexbuf -> Buffer.t -> Buffer.t -> unit +end + +val string_of_utf8 : int array -> string + +(** Two APIs used when we want to do customize lexing + instead of using the regex based engine +*) +val current_code_point : lexbuf -> int +val backoff : lexbuf -> int -> unit +val set_lexeme_start : lexbuf -> int -> unit diff --git a/analysis/vendor/js_parser/js_id.ml b/analysis/vendor/js_parser/js_id.ml new file mode 100644 index 000000000..c5da8d8eb --- /dev/null +++ b/analysis/vendor/js_parser/js_id.ml @@ -0,0 +1,24 @@ +(* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) + +external ( .!() ) : (int * int) array -> int -> int * int = "%array_unsafe_get" + +let rec search (arr : _ array) (start : int) (finish : int) target = + if start > finish then + false + else + let mid = start + ((finish - start) / 2) in + let (a, b) = arr.!(mid) in + if target < a then + search arr start (mid - 1) target + else if target >= b then + search arr (mid + 1) finish target + else + true + +let is_valid_unicode_id (i : int) = + search Js_id_unicode.id_continue 0 (Array.length Js_id_unicode.id_continue - 1) i diff --git a/analysis/vendor/js_parser/js_id.mli b/analysis/vendor/js_parser/js_id.mli new file mode 100644 index 000000000..8bcea4ee4 --- /dev/null +++ b/analysis/vendor/js_parser/js_id.mli @@ -0,0 +1,9 @@ +(* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) + +(* This test is applied to non-start unicode points *) +val is_valid_unicode_id : int -> bool diff --git a/analysis/vendor/js_parser/js_id_unicode.ml b/analysis/vendor/js_parser/js_id_unicode.ml new file mode 100644 index 000000000..0c990437d --- /dev/null +++ b/analysis/vendor/js_parser/js_id_unicode.ml @@ -0,0 +1,21 @@ +(* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) + +(* This lists two valid unicode point ranges in tuple format. + see more details in https://mathiasbynens.be/notes/javascript-identifiers-es6 + TODO: store it in a flat array + add more docs +*) +[@@@ocamlformat "disable"] + +(* JS has stricter rules with start id *) +let id_start = [|36,37;65,91;95,96;97,123;170,171;181,182;186,187;192,215;216,247;248,706;710,722;736,741;748,749;750,751;880,885;886,888;890,894;895,896;902,903;904,907;908,909;910,930;931,1014;1015,1154;1162,1328;1329,1367;1369,1370;1376,1417;1488,1515;1519,1523;1568,1611;1646,1648;1649,1748;1749,1750;1765,1767;1774,1776;1786,1789;1791,1792;1808,1809;1810,1840;1869,1958;1969,1970;1994,2027;2036,2038;2042,2043;2048,2070;2074,2075;2084,2085;2088,2089;2112,2137;2144,2155;2208,2229;2230,2238;2308,2362;2365,2366;2384,2385;2392,2402;2417,2433;2437,2445;2447,2449;2451,2473;2474,2481;2482,2483;2486,2490;2493,2494;2510,2511;2524,2526;2527,2530;2544,2546;2556,2557;2565,2571;2575,2577;2579,2601;2602,2609;2610,2612;2613,2615;2616,2618;2649,2653;2654,2655;2674,2677;2693,2702;2703,2706;2707,2729;2730,2737;2738,2740;2741,2746;2749,2750;2768,2769;2784,2786;2809,2810;2821,2829;2831,2833;2835,2857;2858,2865;2866,2868;2869,2874;2877,2878;2908,2910;2911,2914;2929,2930;2947,2948;2949,2955;2958,2961;2962,2966;2969,2971;2972,2973;2974,2976;2979,2981;2984,2987;2990,3002;3024,3025;3077,3085;3086,3089;3090,3113;3114,3130;3133,3134;3160,3163;3168,3170;3200,3201;3205,3213;3214,3217;3218,3241;3242,3252;3253,3258;3261,3262;3294,3295;3296,3298;3313,3315;3333,3341;3342,3345;3346,3387;3389,3390;3406,3407;3412,3415;3423,3426;3450,3456;3461,3479;3482,3506;3507,3516;3517,3518;3520,3527;3585,3633;3634,3636;3648,3655;3713,3715;3716,3717;3718,3723;3724,3748;3749,3750;3751,3761;3762,3764;3773,3774;3776,3781;3782,3783;3804,3808;3840,3841;3904,3912;3913,3949;3976,3981;4096,4139;4159,4160;4176,4182;4186,4190;4193,4194;4197,4199;4206,4209;4213,4226;4238,4239;4256,4294;4295,4296;4301,4302;4304,4347;4348,4681;4682,4686;4688,4695;4696,4697;4698,4702;4704,4745;4746,4750;4752,4785;4786,4790;4792,4799;4800,4801;4802,4806;4808,4823;4824,4881;4882,4886;4888,4955;4992,5008;5024,5110;5112,5118;5121,5741;5743,5760;5761,5787;5792,5867;5870,5881;5888,5901;5902,5906;5920,5938;5952,5970;5984,5997;5998,6001;6016,6068;6103,6104;6108,6109;6176,6265;6272,6313;6314,6315;6320,6390;6400,6431;6480,6510;6512,6517;6528,6572;6576,6602;6656,6679;6688,6741;6823,6824;6917,6964;6981,6988;7043,7073;7086,7088;7098,7142;7168,7204;7245,7248;7258,7294;7296,7305;7312,7355;7357,7360;7401,7405;7406,7412;7413,7415;7418,7419;7424,7616;7680,7958;7960,7966;7968,8006;8008,8014;8016,8024;8025,8026;8027,8028;8029,8030;8031,8062;8064,8117;8118,8125;8126,8127;8130,8133;8134,8141;8144,8148;8150,8156;8160,8173;8178,8181;8182,8189;8305,8306;8319,8320;8336,8349;8450,8451;8455,8456;8458,8468;8469,8470;8472,8478;8484,8485;8486,8487;8488,8489;8490,8506;8508,8512;8517,8522;8526,8527;8544,8585;11264,11311;11312,11359;11360,11493;11499,11503;11506,11508;11520,11558;11559,11560;11565,11566;11568,11624;11631,11632;11648,11671;11680,11687;11688,11695;11696,11703;11704,11711;11712,11719;11720,11727;11728,11735;11736,11743;12293,12296;12321,12330;12337,12342;12344,12349;12353,12439;12443,12448;12449,12539;12540,12544;12549,12592;12593,12687;12704,12731;12784,12800;13312,19894;19968,40944;40960,42125;42192,42238;42240,42509;42512,42528;42538,42540;42560,42607;42623,42654;42656,42736;42775,42784;42786,42889;42891,42944;42946,42951;42999,43010;43011,43014;43015,43019;43020,43043;43072,43124;43138,43188;43250,43256;43259,43260;43261,43263;43274,43302;43312,43335;43360,43389;43396,43443;43471,43472;43488,43493;43494,43504;43514,43519;43520,43561;43584,43587;43588,43596;43616,43639;43642,43643;43646,43696;43697,43698;43701,43703;43705,43710;43712,43713;43714,43715;43739,43742;43744,43755;43762,43765;43777,43783;43785,43791;43793,43799;43808,43815;43816,43823;43824,43867;43868,43880;43888,44003;44032,55204;55216,55239;55243,55292;63744,64110;64112,64218;64256,64263;64275,64280;64285,64286;64287,64297;64298,64311;64312,64317;64318,64319;64320,64322;64323,64325;64326,64434;64467,64830;64848,64912;64914,64968;65008,65020;65136,65141;65142,65277;65313,65339;65345,65371;65382,65471;65474,65480;65482,65488;65490,65496;65498,65501;65536,65548;65549,65575;65576,65595;65596,65598;65599,65614;65616,65630;65664,65787;65856,65909;66176,66205;66208,66257;66304,66336;66349,66379;66384,66422;66432,66462;66464,66500;66504,66512;66513,66518;66560,66718;66736,66772;66776,66812;66816,66856;66864,66916;67072,67383;67392,67414;67424,67432;67584,67590;67592,67593;67594,67638;67639,67641;67644,67645;67647,67670;67680,67703;67712,67743;67808,67827;67828,67830;67840,67862;67872,67898;67968,68024;68030,68032;68096,68097;68112,68116;68117,68120;68121,68150;68192,68221;68224,68253;68288,68296;68297,68325;68352,68406;68416,68438;68448,68467;68480,68498;68608,68681;68736,68787;68800,68851;68864,68900;69376,69405;69415,69416;69424,69446;69600,69623;69635,69688;69763,69808;69840,69865;69891,69927;69956,69957;69968,70003;70006,70007;70019,70067;70081,70085;70106,70107;70108,70109;70144,70162;70163,70188;70272,70279;70280,70281;70282,70286;70287,70302;70303,70313;70320,70367;70405,70413;70415,70417;70419,70441;70442,70449;70450,70452;70453,70458;70461,70462;70480,70481;70493,70498;70656,70709;70727,70731;70751,70752;70784,70832;70852,70854;70855,70856;71040,71087;71128,71132;71168,71216;71236,71237;71296,71339;71352,71353;71424,71451;71680,71724;71840,71904;71935,71936;72096,72104;72106,72145;72161,72162;72163,72164;72192,72193;72203,72243;72250,72251;72272,72273;72284,72330;72349,72350;72384,72441;72704,72713;72714,72751;72768,72769;72818,72848;72960,72967;72968,72970;72971,73009;73030,73031;73056,73062;73063,73065;73066,73098;73112,73113;73440,73459;73728,74650;74752,74863;74880,75076;77824,78895;82944,83527;92160,92729;92736,92767;92880,92910;92928,92976;92992,92996;93027,93048;93053,93072;93760,93824;93952,94027;94032,94033;94099,94112;94176,94178;94179,94180;94208,100344;100352,101107;110592,110879;110928,110931;110948,110952;110960,111356;113664,113771;113776,113789;113792,113801;113808,113818;119808,119893;119894,119965;119966,119968;119970,119971;119973,119975;119977,119981;119982,119994;119995,119996;119997,120004;120005,120070;120071,120075;120077,120085;120086,120093;120094,120122;120123,120127;120128,120133;120134,120135;120138,120145;120146,120486;120488,120513;120514,120539;120540,120571;120572,120597;120598,120629;120630,120655;120656,120687;120688,120713;120714,120745;120746,120771;120772,120780;123136,123181;123191,123198;123214,123215;123584,123628;124928,125125;125184,125252;125259,125260;126464,126468;126469,126496;126497,126499;126500,126501;126503,126504;126505,126515;126516,126520;126521,126522;126523,126524;126530,126531;126535,126536;126537,126538;126539,126540;126541,126544;126545,126547;126548,126549;126551,126552;126553,126554;126555,126556;126557,126558;126559,126560;126561,126563;126564,126565;126567,126571;126572,126579;126580,126584;126585,126589;126590,126591;126592,126602;126603,126620;126625,126628;126629,126634;126635,126652;131072,173783;173824,177973;177984,178206;178208,183970;183984,191457;194560,195102|] + +(* The followed ID restriction is relaxed, this one + is used in our customized unicode lexing. + *) +let id_continue = [|36,37;48,58;65,91;95,96;97,123;170,171;181,182;183,184;186,187;192,215;216,247;248,706;710,722;736,741;748,749;750,751;768,885;886,888;890,894;895,896;902,907;908,909;910,930;931,1014;1015,1154;1155,1160;1162,1328;1329,1367;1369,1370;1376,1417;1425,1470;1471,1472;1473,1475;1476,1478;1479,1480;1488,1515;1519,1523;1552,1563;1568,1642;1646,1748;1749,1757;1759,1769;1770,1789;1791,1792;1808,1867;1869,1970;1984,2038;2042,2043;2045,2046;2048,2094;2112,2140;2144,2155;2208,2229;2230,2238;2259,2274;2275,2404;2406,2416;2417,2436;2437,2445;2447,2449;2451,2473;2474,2481;2482,2483;2486,2490;2492,2501;2503,2505;2507,2511;2519,2520;2524,2526;2527,2532;2534,2546;2556,2557;2558,2559;2561,2564;2565,2571;2575,2577;2579,2601;2602,2609;2610,2612;2613,2615;2616,2618;2620,2621;2622,2627;2631,2633;2635,2638;2641,2642;2649,2653;2654,2655;2662,2678;2689,2692;2693,2702;2703,2706;2707,2729;2730,2737;2738,2740;2741,2746;2748,2758;2759,2762;2763,2766;2768,2769;2784,2788;2790,2800;2809,2816;2817,2820;2821,2829;2831,2833;2835,2857;2858,2865;2866,2868;2869,2874;2876,2885;2887,2889;2891,2894;2902,2904;2908,2910;2911,2916;2918,2928;2929,2930;2946,2948;2949,2955;2958,2961;2962,2966;2969,2971;2972,2973;2974,2976;2979,2981;2984,2987;2990,3002;3006,3011;3014,3017;3018,3022;3024,3025;3031,3032;3046,3056;3072,3085;3086,3089;3090,3113;3114,3130;3133,3141;3142,3145;3146,3150;3157,3159;3160,3163;3168,3172;3174,3184;3200,3204;3205,3213;3214,3217;3218,3241;3242,3252;3253,3258;3260,3269;3270,3273;3274,3278;3285,3287;3294,3295;3296,3300;3302,3312;3313,3315;3328,3332;3333,3341;3342,3345;3346,3397;3398,3401;3402,3407;3412,3416;3423,3428;3430,3440;3450,3456;3458,3460;3461,3479;3482,3506;3507,3516;3517,3518;3520,3527;3530,3531;3535,3541;3542,3543;3544,3552;3558,3568;3570,3572;3585,3643;3648,3663;3664,3674;3713,3715;3716,3717;3718,3723;3724,3748;3749,3750;3751,3774;3776,3781;3782,3783;3784,3790;3792,3802;3804,3808;3840,3841;3864,3866;3872,3882;3893,3894;3895,3896;3897,3898;3902,3912;3913,3949;3953,3973;3974,3992;3993,4029;4038,4039;4096,4170;4176,4254;4256,4294;4295,4296;4301,4302;4304,4347;4348,4681;4682,4686;4688,4695;4696,4697;4698,4702;4704,4745;4746,4750;4752,4785;4786,4790;4792,4799;4800,4801;4802,4806;4808,4823;4824,4881;4882,4886;4888,4955;4957,4960;4969,4978;4992,5008;5024,5110;5112,5118;5121,5741;5743,5760;5761,5787;5792,5867;5870,5881;5888,5901;5902,5909;5920,5941;5952,5972;5984,5997;5998,6001;6002,6004;6016,6100;6103,6104;6108,6110;6112,6122;6155,6158;6160,6170;6176,6265;6272,6315;6320,6390;6400,6431;6432,6444;6448,6460;6470,6510;6512,6517;6528,6572;6576,6602;6608,6619;6656,6684;6688,6751;6752,6781;6783,6794;6800,6810;6823,6824;6832,6846;6912,6988;6992,7002;7019,7028;7040,7156;7168,7224;7232,7242;7245,7294;7296,7305;7312,7355;7357,7360;7376,7379;7380,7419;7424,7674;7675,7958;7960,7966;7968,8006;8008,8014;8016,8024;8025,8026;8027,8028;8029,8030;8031,8062;8064,8117;8118,8125;8126,8127;8130,8133;8134,8141;8144,8148;8150,8156;8160,8173;8178,8181;8182,8189;8204,8206;8255,8257;8276,8277;8305,8306;8319,8320;8336,8349;8400,8413;8417,8418;8421,8433;8450,8451;8455,8456;8458,8468;8469,8470;8472,8478;8484,8485;8486,8487;8488,8489;8490,8506;8508,8512;8517,8522;8526,8527;8544,8585;11264,11311;11312,11359;11360,11493;11499,11508;11520,11558;11559,11560;11565,11566;11568,11624;11631,11632;11647,11671;11680,11687;11688,11695;11696,11703;11704,11711;11712,11719;11720,11727;11728,11735;11736,11743;11744,11776;12293,12296;12321,12336;12337,12342;12344,12349;12353,12439;12441,12448;12449,12539;12540,12544;12549,12592;12593,12687;12704,12731;12784,12800;13312,19894;19968,40944;40960,42125;42192,42238;42240,42509;42512,42540;42560,42608;42612,42622;42623,42738;42775,42784;42786,42889;42891,42944;42946,42951;42999,43048;43072,43124;43136,43206;43216,43226;43232,43256;43259,43260;43261,43310;43312,43348;43360,43389;43392,43457;43471,43482;43488,43519;43520,43575;43584,43598;43600,43610;43616,43639;43642,43715;43739,43742;43744,43760;43762,43767;43777,43783;43785,43791;43793,43799;43808,43815;43816,43823;43824,43867;43868,43880;43888,44011;44012,44014;44016,44026;44032,55204;55216,55239;55243,55292;63744,64110;64112,64218;64256,64263;64275,64280;64285,64297;64298,64311;64312,64317;64318,64319;64320,64322;64323,64325;64326,64434;64467,64830;64848,64912;64914,64968;65008,65020;65024,65040;65056,65072;65075,65077;65101,65104;65136,65141;65142,65277;65296,65306;65313,65339;65343,65344;65345,65371;65382,65471;65474,65480;65482,65488;65490,65496;65498,65501;65536,65548;65549,65575;65576,65595;65596,65598;65599,65614;65616,65630;65664,65787;65856,65909;66045,66046;66176,66205;66208,66257;66272,66273;66304,66336;66349,66379;66384,66427;66432,66462;66464,66500;66504,66512;66513,66518;66560,66718;66720,66730;66736,66772;66776,66812;66816,66856;66864,66916;67072,67383;67392,67414;67424,67432;67584,67590;67592,67593;67594,67638;67639,67641;67644,67645;67647,67670;67680,67703;67712,67743;67808,67827;67828,67830;67840,67862;67872,67898;67968,68024;68030,68032;68096,68100;68101,68103;68108,68116;68117,68120;68121,68150;68152,68155;68159,68160;68192,68221;68224,68253;68288,68296;68297,68327;68352,68406;68416,68438;68448,68467;68480,68498;68608,68681;68736,68787;68800,68851;68864,68904;68912,68922;69376,69405;69415,69416;69424,69457;69600,69623;69632,69703;69734,69744;69759,69819;69840,69865;69872,69882;69888,69941;69942,69952;69956,69959;69968,70004;70006,70007;70016,70085;70089,70093;70096,70107;70108,70109;70144,70162;70163,70200;70206,70207;70272,70279;70280,70281;70282,70286;70287,70302;70303,70313;70320,70379;70384,70394;70400,70404;70405,70413;70415,70417;70419,70441;70442,70449;70450,70452;70453,70458;70459,70469;70471,70473;70475,70478;70480,70481;70487,70488;70493,70500;70502,70509;70512,70517;70656,70731;70736,70746;70750,70752;70784,70854;70855,70856;70864,70874;71040,71094;71096,71105;71128,71134;71168,71233;71236,71237;71248,71258;71296,71353;71360,71370;71424,71451;71453,71468;71472,71482;71680,71739;71840,71914;71935,71936;72096,72104;72106,72152;72154,72162;72163,72165;72192,72255;72263,72264;72272,72346;72349,72350;72384,72441;72704,72713;72714,72759;72760,72769;72784,72794;72818,72848;72850,72872;72873,72887;72960,72967;72968,72970;72971,73015;73018,73019;73020,73022;73023,73032;73040,73050;73056,73062;73063,73065;73066,73103;73104,73106;73107,73113;73120,73130;73440,73463;73728,74650;74752,74863;74880,75076;77824,78895;82944,83527;92160,92729;92736,92767;92768,92778;92880,92910;92912,92917;92928,92983;92992,92996;93008,93018;93027,93048;93053,93072;93760,93824;93952,94027;94031,94088;94095,94112;94176,94178;94179,94180;94208,100344;100352,101107;110592,110879;110928,110931;110948,110952;110960,111356;113664,113771;113776,113789;113792,113801;113808,113818;113821,113823;119141,119146;119149,119155;119163,119171;119173,119180;119210,119214;119362,119365;119808,119893;119894,119965;119966,119968;119970,119971;119973,119975;119977,119981;119982,119994;119995,119996;119997,120004;120005,120070;120071,120075;120077,120085;120086,120093;120094,120122;120123,120127;120128,120133;120134,120135;120138,120145;120146,120486;120488,120513;120514,120539;120540,120571;120572,120597;120598,120629;120630,120655;120656,120687;120688,120713;120714,120745;120746,120771;120772,120780;120782,120832;121344,121399;121403,121453;121461,121462;121476,121477;121499,121504;121505,121520;122880,122887;122888,122905;122907,122914;122915,122917;122918,122923;123136,123181;123184,123198;123200,123210;123214,123215;123584,123642;124928,125125;125136,125143;125184,125260;125264,125274;126464,126468;126469,126496;126497,126499;126500,126501;126503,126504;126505,126515;126516,126520;126521,126522;126523,126524;126530,126531;126535,126536;126537,126538;126539,126540;126541,126544;126545,126547;126548,126549;126551,126552;126553,126554;126555,126556;126557,126558;126559,126560;126561,126563;126564,126565;126567,126571;126572,126579;126580,126584;126585,126589;126590,126591;126592,126602;126603,126620;126625,126628;126629,126634;126635,126652;131072,173783;173824,177973;177984,178206;178208,183970;183984,191457;194560,195102;917760,918000|] diff --git a/analysis/vendor/js_parser/jsx_parser.ml b/analysis/vendor/js_parser/jsx_parser.ml new file mode 100644 index 000000000..f2e2fefaf --- /dev/null +++ b/analysis/vendor/js_parser/jsx_parser.ml @@ -0,0 +1,457 @@ +(* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) + +module Ast = Flow_ast +open Token +open Parser_common +open Parser_env +open Flow_ast + +module JSX (Parse : Parser_common.PARSER) = struct + (* Consumes and returns the trailing comments after the end of a JSX tag name, + attribute, or spread attribute. + + If the component is followed by the end of the JSX tag, then all trailing + comments are returned. If the component is instead followed by another tag + component on another line, only trailing comments on the same line are + returned. If the component is followed by another tag component on the same + line, all trailing comments will instead be leading the next component. *) + let tag_component_trailing_comments env = + match Peek.token env with + | T_EOF + | T_DIV + | T_GREATER_THAN -> + Eat.trailing_comments env + | _ when Peek.is_line_terminator env -> Eat.comments_until_next_line env + | _ -> [] + + let spread_attribute env = + let leading = Peek.comments env in + Eat.push_lex_mode env Lex_mode.NORMAL; + let (loc, argument) = + with_loc + (fun env -> + Expect.token env T_LCURLY; + Expect.token env T_ELLIPSIS; + let argument = Parse.assignment env in + Expect.token env T_RCURLY; + argument) + env + in + Eat.pop_lex_mode env; + let trailing = tag_component_trailing_comments env in + ( loc, + { + JSX.SpreadAttribute.argument; + comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing (); + } + ) + + let expression_container_contents env = + if Peek.token env = T_RCURLY then + JSX.ExpressionContainer.EmptyExpression + else + JSX.ExpressionContainer.Expression (Parse.expression env) + + let expression_container env = + let leading = Peek.comments env in + Eat.push_lex_mode env Lex_mode.NORMAL; + let (loc, expression) = + with_loc + (fun env -> + Expect.token env T_LCURLY; + let expression = expression_container_contents env in + Expect.token env T_RCURLY; + expression) + env + in + Eat.pop_lex_mode env; + let trailing = tag_component_trailing_comments env in + ( loc, + { + JSX.ExpressionContainer.expression; + comments = Flow_ast_utils.mk_comments_with_internal_opt ~leading ~trailing ~internal:[] (); + } + ) + + let expression_container_or_spread_child env = + Eat.push_lex_mode env Lex_mode.NORMAL; + let (loc, result) = + with_loc + (fun env -> + Expect.token env T_LCURLY; + let result = + match Peek.token env with + | T_ELLIPSIS -> + let leading = Peek.comments env in + Expect.token env T_ELLIPSIS; + let expression = Parse.assignment env in + JSX.SpreadChild + { + JSX.SpreadChild.expression; + comments = Flow_ast_utils.mk_comments_opt ~leading (); + } + | _ -> + let expression = expression_container_contents env in + let internal = + match expression with + | JSX.ExpressionContainer.EmptyExpression -> Peek.comments env + | _ -> [] + in + JSX.ExpressionContainer + { + JSX.ExpressionContainer.expression; + comments = Flow_ast_utils.mk_comments_with_internal_opt ~internal (); + } + in + Expect.token env T_RCURLY; + result) + env + in + Eat.pop_lex_mode env; + (loc, result) + + let identifier env = + let loc = Peek.loc env in + let name = + match Peek.token env with + | T_JSX_IDENTIFIER { raw; _ } -> raw + | _ -> + error_unexpected ~expected:"an identifier" env; + "" + in + let leading = Peek.comments env in + Eat.token env; + (* Unless this identifier is the first part of a namespaced name, member + expression, or attribute name, it is the end of a tag component. *) + let trailing = + match Peek.token env with + (* Namespaced name *) + | T_COLON + (* Member expression *) + | T_PERIOD + (* Attribute name *) + | T_ASSIGN -> + Eat.trailing_comments env + | _ -> tag_component_trailing_comments env + in + (loc, JSX.Identifier.{ name; comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing () }) + + let name = + let rec member_expression env member = + match Peek.token env with + | T_PERIOD -> + let (start_loc, _) = member in + let member = + with_loc + ~start_loc + (fun env -> + Expect.token env T_PERIOD; + let property = identifier env in + { + JSX.MemberExpression._object = JSX.MemberExpression.MemberExpression member; + property; + }) + env + in + member_expression env member + | _ -> member + in + fun env -> + match Peek.ith_token ~i:1 env with + | T_COLON -> + let namespaced_name = + with_loc + (fun env -> + let namespace = identifier env in + Expect.token env T_COLON; + let name = identifier env in + { JSX.NamespacedName.namespace; name }) + env + in + JSX.NamespacedName namespaced_name + | T_PERIOD -> + let member = + with_loc + (fun env -> + let _object = JSX.MemberExpression.Identifier (identifier env) in + Expect.token env T_PERIOD; + let property = identifier env in + { JSX.MemberExpression._object; property }) + env + in + JSX.MemberExpression (member_expression env member) + | _ -> + let name = identifier env in + JSX.Identifier name + + let attribute env = + with_loc + (fun env -> + let name = + match Peek.ith_token ~i:1 env with + | T_COLON -> + let namespaced_name = + with_loc + (fun env -> + let namespace = identifier env in + Expect.token env T_COLON; + let name = identifier env in + { JSX.NamespacedName.namespace; name }) + env + in + JSX.Attribute.NamespacedName namespaced_name + | _ -> + let name = identifier env in + JSX.Attribute.Identifier name + in + let value = + match Peek.token env with + | T_ASSIGN -> + Expect.token env T_ASSIGN; + let leading = Peek.comments env in + let tkn = Peek.token env in + begin + match tkn with + | T_LCURLY -> + let (loc, expression_container) = expression_container env in + JSX.ExpressionContainer.( + match expression_container.expression with + | EmptyExpression -> + error_at env (loc, Parse_error.JSXAttributeValueEmptyExpression) + | _ -> () + ); + Some (JSX.Attribute.ExpressionContainer (loc, expression_container)) + | T_JSX_TEXT (loc, value, raw) as token -> + Expect.token env token; + let value = Ast.Literal.String value in + let trailing = tag_component_trailing_comments env in + Some + (JSX.Attribute.Literal + ( loc, + { + Ast.Literal.value; + raw; + comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing (); + } + ) + ) + | _ -> + error env Parse_error.InvalidJSXAttributeValue; + let loc = Peek.loc env in + let raw = "" in + let value = Ast.Literal.String "" in + Some (JSX.Attribute.Literal (loc, { Ast.Literal.value; raw; comments = None })) + end + | _ -> None + in + { JSX.Attribute.name; value }) + env + + let opening_element = + let rec attributes env acc = + match Peek.token env with + | T_JSX_IDENTIFIER _ -> + let attribute = JSX.Opening.Attribute (attribute env) in + attributes env (attribute :: acc) + | T_LCURLY -> + let attribute = JSX.Opening.SpreadAttribute (spread_attribute env) in + attributes env (attribute :: acc) + | _ -> List.rev acc + in + fun env -> + with_loc + (fun env -> + Expect.token env T_LESS_THAN; + match Peek.token env with + | T_GREATER_THAN -> + Eat.token env; + Ok `Fragment + | T_JSX_IDENTIFIER _ -> + let name = name env in + let attributes = attributes env [] in + let self_closing = Eat.maybe env T_DIV in + let element = `Element { JSX.Opening.name; self_closing; attributes } in + if Eat.maybe env T_GREATER_THAN then + Ok element + else ( + Expect.error env T_GREATER_THAN; + Error element + ) + | _ -> + (* TODO: also say that we could expect an identifier, or if we're in a JSX child + then suggest escaping the < as `{'<'}` *) + Expect.error env T_GREATER_THAN; + Error `Fragment) + env + + let closing_element env = + with_loc + (fun env -> + Expect.token env T_LESS_THAN; + Expect.token env T_DIV; + match Peek.token env with + | T_GREATER_THAN -> + Eat.token env; + `Fragment + | T_JSX_IDENTIFIER _ -> + let name = name env in + Expect.token_opt env T_GREATER_THAN; + `Element { JSX.Closing.name } + | _ -> + Expect.error env T_GREATER_THAN; + `Fragment) + env + + let rec child env = + match Peek.token env with + | T_LCURLY -> expression_container_or_spread_child env + | T_JSX_TEXT (loc, value, raw) as token -> + Expect.token env token; + (loc, JSX.Text { JSX.Text.value; raw }) + | _ -> + (match element_or_fragment env with + | (loc, `Element element) -> (loc, JSX.Element element) + | (loc, `Fragment fragment) -> (loc, JSX.Fragment fragment)) + + and element = + let children_and_closing = + let rec children_and_closing env acc = + let previous_loc = last_loc env in + match Peek.token env with + | T_LESS_THAN -> + Eat.push_lex_mode env Lex_mode.JSX_TAG; + begin + match (Peek.token env, Peek.ith_token ~i:1 env) with + | (T_LESS_THAN, T_EOF) + | (T_LESS_THAN, T_DIV) -> + let closing = + match closing_element env with + | (loc, `Element ec) -> `Element (loc, ec) + | (loc, `Fragment) -> `Fragment loc + in + (* We double pop to avoid going back to childmode and re-lexing the + * lookahead *) + Eat.double_pop_lex_mode env; + (List.rev acc, previous_loc, closing) + | _ -> + let child = + match element env with + | (loc, `Element e) -> (loc, JSX.Element e) + | (loc, `Fragment f) -> (loc, JSX.Fragment f) + in + children_and_closing env (child :: acc) + end + | T_EOF -> + error_unexpected env; + (List.rev acc, previous_loc, `None) + | _ -> children_and_closing env (child env :: acc) + in + fun env -> + let start_loc = Peek.loc env in + let (children, last_child_loc, closing) = children_and_closing env [] in + let last_child_loc = + match last_child_loc with + | Some x -> x + | None -> start_loc + in + (* It's a little bit tricky to untangle the parsing of the child elements from the parsing + * of the closing element, so we can't easily use `with_loc` here. Instead, we'll use the + * same logic that `with_loc` uses, but manipulate the locations explicitly. *) + let children_loc = Loc.btwn start_loc last_child_loc in + ((children_loc, children), closing) + in + let rec normalize name = + JSX.( + match name with + | Identifier (_, { Identifier.name; comments = _ }) -> name + | NamespacedName (_, { NamespacedName.namespace; name }) -> + (snd namespace).Identifier.name ^ ":" ^ (snd name).Identifier.name + | MemberExpression (_, { MemberExpression._object; property }) -> + let _object = + match _object with + | MemberExpression.Identifier (_, { Identifier.name = id; _ }) -> id + | MemberExpression.MemberExpression e -> normalize (JSX.MemberExpression e) + in + _object ^ "." ^ (snd property).Identifier.name + ) + in + let is_self_closing = function + | (_, Ok (`Element e)) -> e.JSX.Opening.self_closing + | (_, Ok `Fragment) -> false + | (_, Error _) -> true + in + fun env -> + let leading = Peek.comments env in + let opening_element = opening_element env in + Eat.pop_lex_mode env; + let (children, closing_element) = + if is_self_closing opening_element then + (with_loc (fun _ -> []) env, `None) + else ( + Eat.push_lex_mode env Lex_mode.JSX_CHILD; + children_and_closing env + ) + in + let trailing = Eat.trailing_comments env in + let end_loc = + match closing_element with + | `Element (loc, { JSX.Closing.name }) -> + (match snd opening_element with + | Ok (`Element { JSX.Opening.name = opening_name; _ }) -> + let opening_name = normalize opening_name in + if normalize name <> opening_name then + error env (Parse_error.ExpectedJSXClosingTag opening_name) + | Ok `Fragment -> error env (Parse_error.ExpectedJSXClosingTag "JSX fragment") + | Error _ -> ()); + loc + | `Fragment loc -> + (match snd opening_element with + | Ok (`Element { JSX.Opening.name = opening_name; _ }) -> + error env (Parse_error.ExpectedJSXClosingTag (normalize opening_name)) + | Ok `Fragment -> () + | Error _ -> ()); + loc + | _ -> fst opening_element + in + let result = + match opening_element with + | (start_loc, Ok (`Element e)) + | (start_loc, Error (`Element e)) -> + `Element + JSX. + { + opening_element = (start_loc, e); + closing_element = + (match closing_element with + | `Element e -> Some e + | _ -> None); + children; + comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing (); + } + | (start_loc, Ok `Fragment) + | (start_loc, Error `Fragment) -> + `Fragment + { + JSX.frag_opening_element = start_loc; + frag_closing_element = + (match closing_element with + | `Fragment loc -> loc + (* the following are parse erros *) + | `Element (loc, _) -> loc + | _ -> end_loc); + frag_children = children; + frag_comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing (); + } + in + + (Loc.btwn (fst opening_element) end_loc, result) + + and element_or_fragment env = + Eat.push_lex_mode env Lex_mode.JSX_TAG; + element env +end diff --git a/analysis/vendor/js_parser/lex_env.ml b/analysis/vendor/js_parser/lex_env.ml new file mode 100644 index 000000000..00c36c428 --- /dev/null +++ b/analysis/vendor/js_parser/lex_env.ml @@ -0,0 +1,87 @@ +(* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) + +module Sedlexing = Flow_sedlexing + +(* bol = Beginning Of Line *) +type bol = { + line: int; + offset: int; +} + +type lex_state = { lex_errors_acc: (Loc.t * Parse_error.t) list } [@@ocaml.unboxed] + +type t = { + lex_source: File_key.t option; + lex_lb: Sedlexing.lexbuf; + lex_bol: bol; + lex_in_comment_syntax: bool; + lex_enable_comment_syntax: bool; + lex_state: lex_state; + lex_last_loc: Loc.t; +} + +let empty_lex_state = { lex_errors_acc = [] } + +(* The lex_last_loc should initially be set to the beginning of the first line, so that + comments on the first line are reported as not being on a new line. *) +let initial_last_loc = + { Loc.source = None; start = { Loc.line = 1; column = 0 }; _end = { Loc.line = 1; column = 0 } } + +let new_lex_env lex_source lex_lb ~enable_types_in_comments = + { + lex_source; + lex_lb; + lex_bol = { line = 1; offset = 0 }; + lex_in_comment_syntax = false; + lex_enable_comment_syntax = enable_types_in_comments; + lex_state = empty_lex_state; + lex_last_loc = initial_last_loc; + } + +(* copy all the mutable things so that we have a distinct lexing environment + that does not interfere with ordinary lexer operations *) +let clone env = + let lex_lb = Sedlexing.lexbuf_clone env.lex_lb in + { env with lex_lb } + +let lexbuf env = env.lex_lb + +let source env = env.lex_source + +let state env = env.lex_state + +let line env = env.lex_bol.line + +let bol_offset env = env.lex_bol.offset + +let is_in_comment_syntax env = env.lex_in_comment_syntax + +let is_comment_syntax_enabled env = env.lex_enable_comment_syntax + +let in_comment_syntax is_in env = + if is_in <> env.lex_in_comment_syntax then + { env with lex_in_comment_syntax = is_in } + else + env + +(* TODO *) +let debug_string_of_lexbuf _lb = "" + +let debug_string_of_lex_env (env : t) = + let source = + match source env with + | None -> "None" + | Some x -> Printf.sprintf "Some %S" (File_key.to_string x) + in + Printf.sprintf + "{\n lex_source = %s\n lex_lb = %s\n lex_in_comment_syntax = %b\n lex_enable_comment_syntax = %b\n lex_state = {errors = (count = %d)}\n}" + source + (debug_string_of_lexbuf env.lex_lb) + (is_in_comment_syntax env) + (is_comment_syntax_enabled env) + (List.length (state env).lex_errors_acc) diff --git a/analysis/vendor/js_parser/lex_result.ml b/analysis/vendor/js_parser/lex_result.ml new file mode 100644 index 000000000..06ca89984 --- /dev/null +++ b/analysis/vendor/js_parser/lex_result.ml @@ -0,0 +1,29 @@ +(* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) + +type t = { + lex_token: Token.t; + lex_loc: Loc.t; + lex_errors: (Loc.t * Parse_error.t) list; + lex_comments: Loc.t Flow_ast.Comment.t list; +} + +let token result = result.lex_token + +let loc result = result.lex_loc + +let comments result = result.lex_comments + +let errors result = result.lex_errors + +let debug_string_of_lex_result lex_result = + Printf.sprintf + "{\n lex_token = %s\n lex_value = %S\n lex_errors = (length = %d)\n lex_comments = (length = %d)\n}" + (Token.token_to_string lex_result.lex_token) + (Token.value_of_token lex_result.lex_token) + (List.length lex_result.lex_errors) + (List.length lex_result.lex_comments) diff --git a/analysis/vendor/js_parser/loc.ml b/analysis/vendor/js_parser/loc.ml new file mode 100644 index 000000000..143f0671c --- /dev/null +++ b/analysis/vendor/js_parser/loc.ml @@ -0,0 +1,187 @@ +(* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) +open Primitive_deriving + +(* line numbers are 1-indexed; column numbers are 0-indexed *) +type position = { + line: int; + column: int; +} +[@@deriving_inline equal] +let _ = fun (_ : position) -> () +let equal_position = + (fun a__001_ -> + fun b__002_ -> + if Ppx_compare_lib.phys_equal a__001_ b__002_ + then true + else + Ppx_compare_lib.(&&) (equal_int a__001_.line b__002_.line) + (equal_int a__001_.column b__002_.column) : position -> + position -> bool) +let _ = equal_position +[@@@end] +(* start is inclusive; end is exclusive *) +(* If you are modifying this record, go look at ALoc.ml and make sure you understand the + * representation there. *) +type t = { + source: File_key.t option; + start: position; + _end: position; +} + +let none = { source = None; start = { line = 0; column = 0 }; _end = { line = 0; column = 0 } } + +let is_none (x : t) = + x == none + || + match x with + | { source = None; start = { line = 0; column = 0 }; _end = { line = 0; column = 0 } } -> true + | _ -> false + +let is_none_ignore_source (x : t) = + x == none + || + match x with + | { source = _; start = { line = 0; column = 0 }; _end = { line = 0; column = 0 } } -> true + | _ -> false + +let btwn loc1 loc2 = { source = loc1.source; start = loc1.start; _end = loc2._end } + +(* Returns the position immediately before the start of the given loc. If the + given loc is at the beginning of a line, return the position of the first + char on the same line. *) +let char_before loc = + let start = + let { line; column } = loc.start in + let column = + if column > 0 then + column - 1 + else + column + in + { line; column } + in + let _end = loc.start in + { loc with start; _end } + +(* Returns the location of the first character in the given loc. Not accurate if the + * first line is a newline character, but is still consistent with loc orderings. *) +let first_char loc = + let start = loc.start in + let _end = { start with column = start.column + 1 } in + { loc with _end } + +let pos_cmp a b = + let k = a.line - b.line in + if k = 0 then + a.column - b.column + else + k + +(** + * If `a` spans (completely contains) `b`, then returns 0. + * If `b` starts before `a` (even if it ends inside), returns < 0. + * If `b` ends after `a` (even if it starts inside), returns > 0. + *) +let span_compare a b = + let k = File_key.compare_opt a.source b.source in + if k = 0 then + let k = pos_cmp a.start b.start in + if k <= 0 then + let k = pos_cmp a._end b._end in + if k >= 0 then + 0 + else + -1 + else + 1 + else + k + +(** [contains loc1 loc2] returns true if [loc1] entirely overlaps [loc2] *) +let contains loc1 loc2 = span_compare loc1 loc2 = 0 + +(** [intersects loc1 loc2] returns true if [loc1] intersects [loc2] at all *) +let intersects loc1 loc2 = + File_key.compare_opt loc1.source loc2.source = 0 + && not (pos_cmp loc1._end loc2.start < 0 || pos_cmp loc1.start loc2._end > 0) + +(** [lines_intersect loc1 loc2] returns true if [loc1] and [loc2] cover any part of + the same line, even if they don't actually intersect. + + For example, if [loc1] ends and then [loc2] begins later on the same line, + [intersects loc1 loc2] is false, but [lines_intersect loc1 loc2] is true. *) +let lines_intersect loc1 loc2 = + File_key.compare_opt loc1.source loc2.source = 0 + && not (loc1._end.line < loc2.start.line || loc1.start.line > loc2._end.line) + +let compare_ignore_source loc1 loc2 = + match pos_cmp loc1.start loc2.start with + | 0 -> pos_cmp loc1._end loc2._end + | k -> k + +let compare loc1 loc2 = + let k = File_key.compare_opt loc1.source loc2.source in + if k = 0 then + compare_ignore_source loc1 loc2 + else + k + +let equal loc1 loc2 = compare loc1 loc2 = 0 + +(** + * This is mostly useful for debugging purposes. + * Please don't dead-code delete this! + *) +let debug_to_string ?(include_source = false) loc = + let source = + if include_source then + Printf.sprintf + "%S: " + (match loc.source with + | Some src -> File_key.to_string src + | None -> "") + else + "" + in + let pos = + Printf.sprintf + "(%d, %d) to (%d, %d)" + loc.start.line + loc.start.column + loc._end.line + loc._end.column + in + source ^ pos + +let to_string_no_source loc = + let line = loc.start.line in + let start = loc.start.column + 1 in + let end_ = loc._end.column in + if line <= 0 then + "0:0" + else if line = loc._end.line && start = end_ then + Printf.sprintf "%d:%d" line start + else if line != loc._end.line then + Printf.sprintf "%d:%d,%d:%d" line start loc._end.line end_ + else + Printf.sprintf "%d:%d-%d" line start end_ + +let mk_loc ?source (start_line, start_column) (end_line, end_column) = + { + source; + start = { line = start_line; column = start_column }; + _end = { line = end_line; column = end_column }; + } + +let source loc = loc.source + +(** Produces a zero-width Loc.t, where start = end *) +let cursor source line column = { source; start = { line; column }; _end = { line; column } } + +let start_loc loc = { loc with _end = loc.start } +let end_loc loc = { loc with start = loc._end } diff --git a/analysis/vendor/js_parser/loc.mli b/analysis/vendor/js_parser/loc.mli new file mode 100644 index 000000000..4102338a0 --- /dev/null +++ b/analysis/vendor/js_parser/loc.mli @@ -0,0 +1,77 @@ +(* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) + +type position = { + line: int; + column: int; +} +[@@deriving_inline equal] +include + sig + [@@@warning "-32"] + val equal_position : position -> position -> bool + end[@@ocaml.doc "@inline"] +[@@@end] +type t = { + source: File_key.t option; + start: position; + _end: position; +} + + +val none : t + +val is_none : t -> bool + +val is_none_ignore_source : t -> bool + +val btwn : t -> t -> t + +val char_before : t -> t + +val first_char : t -> t + +(** [contains loc1 loc2] returns true if [loc1] entirely overlaps [loc2] *) +val contains : t -> t -> bool + +(** [intersects loc1 loc2] returns true if [loc1] intersects [loc2] at all *) +val intersects : t -> t -> bool + +(** [lines_intersect loc1 loc2] returns true if [loc1] and [loc2] cover any part of + the same line, even if they don't actually intersect. + + For example, if [loc1] ends and then [loc2] begins later on the same line, + [intersects loc1 loc2] is false, but [lines_intersect loc1 loc2] is true. *) +val lines_intersect : t -> t -> bool + +val pos_cmp : position -> position -> int + +val span_compare : t -> t -> int + +val compare_ignore_source : t -> t -> int + +val compare : t -> t -> int + +val equal : t -> t -> bool + +val debug_to_string : ?include_source:bool -> t -> string + +(* Relatively compact; suitable for use as a unique string identifier *) +val to_string_no_source : t -> string + +val mk_loc : ?source:File_key.t -> int * int -> int * int -> t + +val source : t -> File_key.t option + +(** Produces a zero-width Loc.t, where start = end *) +val cursor : File_key.t option -> int -> int -> t + +(* Produces a location at the start of the input location *) +val start_loc : t -> t + +(* Produces a location at the end of the input location *) +val end_loc : t -> t diff --git a/analysis/vendor/js_parser/object_parser.ml b/analysis/vendor/js_parser/object_parser.ml new file mode 100644 index 000000000..b5ece9e38 --- /dev/null +++ b/analysis/vendor/js_parser/object_parser.ml @@ -0,0 +1,1087 @@ +(* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) + +module Ast = Flow_ast +open Token +open Parser_env +open Flow_ast +module SMap = Map.Make (String) +open Parser_common +open Comment_attachment + +(* A module for parsing various object related things, like object literals + * and classes *) + +module type OBJECT = sig + val key : ?class_body:bool -> env -> Loc.t * (Loc.t, Loc.t) Ast.Expression.Object.Property.key + val _initializer : env -> Loc.t * (Loc.t, Loc.t) Ast.Expression.Object.t * pattern_errors + + val class_declaration : + env -> (Loc.t, Loc.t) Ast.Class.Decorator.t list -> (Loc.t, Loc.t) Ast.Statement.t + + val class_expression : env -> (Loc.t, Loc.t) Ast.Expression.t + val class_implements : env -> attach_leading:bool -> (Loc.t, Loc.t) Ast.Class.Implements.t + val decorator_list : env -> (Loc.t, Loc.t) Ast.Class.Decorator.t list +end + +module Object + (Parse : Parser_common.PARSER) + (Type : Type_parser.TYPE) + (Declaration : Declaration_parser.DECLARATION) + (Expression : Expression_parser.EXPRESSION) + (Pattern_cover : Pattern_cover.COVER) : OBJECT = struct + let decorator_list = + let expression env = + let expression = Expression.left_hand_side env in + let { remove_trailing; _ } = + if Peek.is_line_terminator env then + trailing_and_remover_after_last_line env + else + trailing_and_remover_after_last_loc env + in + remove_trailing expression (fun remover expression -> remover#expression expression) + in + let decorator env = + let leading = Peek.comments env in + Eat.token env; + { + Ast.Class.Decorator.expression = expression env; + comments = Flow_ast_utils.mk_comments_opt ~leading (); + } + in + let rec decorator_list_helper env decorators = + match Peek.token env with + | T_AT -> decorator_list_helper env (with_loc decorator env :: decorators) + | _ -> decorators + in + fun env -> + if (parse_options env).esproposal_decorators then + List.rev (decorator_list_helper env []) + else + [] + + let key ?(class_body = false) env = + let open Ast.Expression.Object.Property in + let leading = Peek.comments env in + let tkn = Peek.token env in + match tkn with + | T_STRING (loc, value, raw, octal) -> + if octal then strict_error env Parse_error.StrictOctalLiteral; + Expect.token env (T_STRING (loc, value, raw, octal)); + let value = Literal.String value in + let trailing = Eat.trailing_comments env in + ( loc, + Literal + ( loc, + { Literal.value; raw; comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing () } + ) + ) + | T_NUMBER { kind; raw } -> + let loc = Peek.loc env in + let value = Expression.number env kind raw in + let value = Literal.Number value in + let trailing = Eat.trailing_comments env in + ( loc, + Literal + ( loc, + { Literal.value; raw; comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing () } + ) + ) + | T_LBRACKET -> + let (loc, key) = + with_loc + (fun env -> + let leading = Peek.comments env in + Expect.token env T_LBRACKET; + let expr = Parse.assignment (env |> with_no_in false) in + Expect.token env T_RBRACKET; + let trailing = Eat.trailing_comments env in + { + ComputedKey.expression = expr; + comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing (); + }) + env + in + (loc, Ast.Expression.Object.Property.Computed (loc, key)) + | T_POUND when class_body -> + let ((loc, { PrivateName.name; _ }) as id) = private_identifier env in + add_declared_private env name; + (loc, PrivateName id) + | T_POUND -> + let (loc, id) = + with_loc + (fun env -> + Eat.token env; + Identifier (identifier_name env)) + env + in + error_at env (loc, Parse_error.PrivateNotInClass); + (loc, id) + | _ -> + let ((loc, _) as id) = identifier_name env in + (loc, Identifier id) + + let getter_or_setter env ~in_class_body is_getter = + (* this is a getter or setter, it cannot be async *) + let async = false in + let (generator, leading) = Declaration.generator env in + let (key_loc, key) = key ~class_body:in_class_body env in + let key = object_key_remove_trailing env key in + let value = + with_loc + (fun env -> + (* #sec-function-definitions-static-semantics-early-errors *) + let env = env |> with_allow_super Super_prop in + let (sig_loc, (tparams, params, return)) = + with_loc + (fun env -> + (* It's not clear how type params on getters & setters would make sense + * in Flow's type system. Since this is a Flow syntax extension, we might + * as well disallow it until we need it *) + let tparams = None in + let params = + let params = Declaration.function_params ~await:false ~yield:false env in + if Peek.token env = T_COLON then + params + else + function_params_remove_trailing env params + in + begin + match (is_getter, params) with + | (true, (_, { Ast.Function.Params.this_ = Some _; _ })) -> + error_at env (key_loc, Parse_error.GetterMayNotHaveThisParam) + | (false, (_, { Ast.Function.Params.this_ = Some _; _ })) -> + error_at env (key_loc, Parse_error.SetterMayNotHaveThisParam) + | ( true, + ( _, + { Ast.Function.Params.params = []; rest = None; this_ = None; comments = _ } + ) + ) -> + () + | (false, (_, { Ast.Function.Params.rest = Some _; _ })) -> + (* rest params don't make sense on a setter *) + error_at env (key_loc, Parse_error.SetterArity) + | ( false, + ( _, + { + Ast.Function.Params.params = [_]; + rest = None; + this_ = None; + comments = _; + } + ) + ) -> + () + | (true, _) -> error_at env (key_loc, Parse_error.GetterArity) + | (false, _) -> error_at env (key_loc, Parse_error.SetterArity) + end; + let return = type_annotation_hint_remove_trailing env (Type.annotation_opt env) in + (tparams, params, return)) + env + in + let simple_params = is_simple_parameter_list params in + let (body, contains_use_strict) = + Declaration.function_body env ~async ~generator ~expression:false ~simple_params + in + Declaration.strict_post_check env ~contains_use_strict None params; + { + Function.id = None; + params; + body; + generator; + async; + predicate = None; + (* setters/getter are not predicates *) + return; + tparams; + sig_loc; + comments = Flow_ast_utils.mk_comments_opt ~leading (); + }) + env + in + (key, value) + + let _initializer = + let parse_assignment_cover env = + match Expression.assignment_cover env with + | Cover_expr expr -> (expr, Pattern_cover.empty_errors) + | Cover_patt (expr, errs) -> (expr, errs) + in + let get env start_loc leading = + let (loc, (key, value)) = + with_loc ~start_loc (fun env -> getter_or_setter env ~in_class_body:false true) env + in + let open Ast.Expression.Object in + Property + (loc, Property.Get { key; value; comments = Flow_ast_utils.mk_comments_opt ~leading () }) + in + let set env start_loc leading = + let (loc, (key, value)) = + with_loc ~start_loc (fun env -> getter_or_setter env ~in_class_body:false false) env + in + let open Ast.Expression.Object in + Property + (loc, Property.Set { key; value; comments = Flow_ast_utils.mk_comments_opt ~leading () }) + in + (* #prod-PropertyDefinition *) + let init = + let open Ast.Expression.Object.Property in + (* #prod-IdentifierReference *) + let parse_shorthand env key = + match key with + | Literal (loc, lit) -> + error_at env (loc, Parse_error.LiteralShorthandProperty); + (loc, Ast.Expression.Literal lit) + | Identifier ((loc, { Identifier.name; comments = _ }) as id) -> + (* #sec-identifiers-static-semantics-early-errors *) + if is_reserved name && name <> "yield" && name <> "await" then + (* it is a syntax error if `name` is a reserved word other than await or yield *) + error_at env (loc, Parse_error.UnexpectedReserved) + else if is_strict_reserved name then + (* it is a syntax error if `name` is a strict reserved word, in strict mode *) + strict_error_at env (loc, Parse_error.StrictReservedWord); + (loc, Ast.Expression.Identifier id) + | PrivateName _ -> failwith "Internal Error: private name found in object props" + | Computed (_, { ComputedKey.expression = expr; comments = _ }) -> + error_at env (fst expr, Parse_error.ComputedShorthandProperty); + expr + in + (* #prod-MethodDefinition *) + let parse_method ~async ~generator ~leading = + with_loc (fun env -> + (* #sec-function-definitions-static-semantics-early-errors *) + let env = env |> with_allow_super Super_prop in + let (sig_loc, (tparams, params, return)) = + with_loc + (fun env -> + let tparams = type_params_remove_trailing env (Type.type_params env) in + let params = + let (yield, await) = + match (async, generator) with + | (true, true) -> + (true, true) (* proposal-async-iteration/#prod-AsyncGeneratorMethod *) + | (true, false) -> (false, allow_await env) (* #prod-AsyncMethod *) + | (false, true) -> (true, false) (* #prod-GeneratorMethod *) + | (false, false) -> (false, false) + (* #prod-MethodDefinition *) + in + let params = Declaration.function_params ~await ~yield env in + if Peek.token env = T_COLON then + params + else + function_params_remove_trailing env params + in + let return = type_annotation_hint_remove_trailing env (Type.annotation_opt env) in + (tparams, params, return)) + env + in + let simple_params = is_simple_parameter_list params in + let (body, contains_use_strict) = + Declaration.function_body env ~async ~generator ~expression:false ~simple_params + in + Declaration.strict_post_check env ~contains_use_strict None params; + { + Function.id = None; + params; + body; + generator; + async; + (* TODO: add support for object method predicates *) + predicate = None; + return; + tparams; + sig_loc; + comments = Flow_ast_utils.mk_comments_opt ~leading (); + } + ) + in + (* PropertyName `:` AssignmentExpression *) + let parse_value env = + Expect.token env T_COLON; + parse_assignment_cover env + in + (* #prod-CoverInitializedName *) + let parse_assignment_pattern ~key env = + let open Ast.Expression.Object in + match key with + | Property.Identifier id -> + let assignment_loc = Peek.loc env in + let ast = + with_loc + ~start_loc:(fst id) + (fun env -> + let leading = Peek.comments env in + Expect.token env T_ASSIGN; + let trailing = Eat.trailing_comments env in + let left = Parse.pattern_from_expr env (fst id, Ast.Expression.Identifier id) in + let right = Parse.assignment env in + let comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing () in + Ast.Expression.Assignment + { Ast.Expression.Assignment.operator = None; left; right; comments }) + env + in + let errs = + { + if_expr = [(assignment_loc, Parse_error.Unexpected (Token.quote_token_value "="))]; + if_patt = []; + } + in + (ast, errs) + | Property.Literal _ + | Property.PrivateName _ + | Property.Computed _ -> + parse_value env + in + let parse_init ~key ~async ~generator ~leading env = + if async || generator then + let key = object_key_remove_trailing env key in + (* the `async` and `*` modifiers are only valid on methods *) + let value = parse_method env ~async ~generator ~leading in + let prop = Method { key; value } in + (prop, Pattern_cover.empty_errors) + else + match Peek.token env with + | T_RCURLY + | T_COMMA -> + let value = parse_shorthand env key in + let prop = Init { key; value; shorthand = true } in + (prop, Pattern_cover.empty_errors) + | T_LESS_THAN + | T_LPAREN -> + let key = object_key_remove_trailing env key in + let value = parse_method env ~async ~generator ~leading in + let prop = Method { key; value } in + (prop, Pattern_cover.empty_errors) + | T_ASSIGN -> + let (value, errs) = parse_assignment_pattern ~key env in + let prop = Init { key; value; shorthand = true } in + (prop, errs) + | T_COLON -> + let (value, errs) = parse_value env in + let prop = Init { key; value; shorthand = false } in + (prop, errs) + | _ -> + (* error. we recover by treating it as a shorthand property so as to not + consume any more tokens and make the error worse. we don't error here + because we'll expect a comma before the next token. *) + let value = parse_shorthand env key in + let prop = Init { key; value; shorthand = true } in + (prop, Pattern_cover.empty_errors) + in + fun env start_loc key async generator leading -> + let (loc, (prop, errs)) = + with_loc ~start_loc (parse_init ~key ~async ~generator ~leading) env + in + (Ast.Expression.Object.Property (loc, prop), errs) + in + let property env = + let open Ast.Expression.Object in + if Peek.token env = T_ELLIPSIS then + (* Spread property *) + let leading = Peek.comments env in + let (loc, (argument, errs)) = + with_loc + (fun env -> + Expect.token env T_ELLIPSIS; + parse_assignment_cover env) + env + in + ( SpreadProperty + (loc, { SpreadProperty.argument; comments = Flow_ast_utils.mk_comments_opt ~leading () }), + errs + ) + else + let start_loc = Peek.loc env in + let (async, leading_async) = + match Peek.ith_token ~i:1 env with + | T_ASSIGN + (* { async = true } (destructuring) *) + | T_COLON + (* { async: true } *) + | T_LESS_THAN + (* { async() {} } *) + | T_LPAREN + (* { async() {} } *) + | T_COMMA + (* { async, other, shorthand } *) + | T_RCURLY (* { async } *) -> + (false, []) + | _ -> Declaration.async env + in + let (generator, leading_generator) = Declaration.generator env in + let leading = leading_async @ leading_generator in + match (async, generator, Peek.token env) with + | (false, false, T_IDENTIFIER { raw = "get"; _ }) -> + let leading = Peek.comments env in + let (_, key) = key env in + begin + match Peek.token env with + | T_ASSIGN + | T_COLON + | T_LESS_THAN + | T_LPAREN + | T_COMMA + | T_RCURLY -> + init env start_loc key false false [] + | _ -> + ignore (Comment_attachment.object_key_remove_trailing env key); + (get env start_loc leading, Pattern_cover.empty_errors) + end + | (false, false, T_IDENTIFIER { raw = "set"; _ }) -> + let leading = Peek.comments env in + let (_, key) = key env in + begin + match Peek.token env with + | T_ASSIGN + | T_COLON + | T_LESS_THAN + | T_LPAREN + | T_COMMA + | T_RCURLY -> + init env start_loc key false false [] + | _ -> + ignore (Comment_attachment.object_key_remove_trailing env key); + (set env start_loc leading, Pattern_cover.empty_errors) + end + | (async, generator, _) -> + let (_, key) = key env in + init env start_loc key async generator leading + in + let rec properties env ~rest_trailing_comma (props, errs) = + match Peek.token env with + | T_EOF + | T_RCURLY -> + let errs = + match rest_trailing_comma with + | Some loc -> + { errs with if_patt = (loc, Parse_error.TrailingCommaAfterRestElement) :: errs.if_patt } + | None -> errs + in + (List.rev props, Pattern_cover.rev_errors errs) + | _ -> + let (prop, new_errs) = property env in + let rest_trailing_comma = + match prop with + | Ast.Expression.Object.SpreadProperty _ when Peek.token env = T_COMMA -> + Some (Peek.loc env) + | _ -> None + in + let errs = Pattern_cover.rev_append_errors new_errs errs in + let errs = + match Peek.token env with + | T_RCURLY + | T_EOF -> + errs + | T_COMMA -> + Eat.token env; + errs + | _ -> + (* we could use [Expect.error env T_COMMA], but we're in a weird + cover grammar situation where we're storing errors in + [Pattern_cover]. if we used [Expect.error], the errors would + end up out of order. *) + let err = Expect.get_error env T_COMMA in + (* if the unexpected token is a semicolon, consume it to aid + recovery. using a semicolon instead of a comma is a common + mistake. *) + let _ = Eat.maybe env T_SEMICOLON in + Pattern_cover.cons_error err errs + in + properties env ~rest_trailing_comma (prop :: props, errs) + in + fun env -> + let (loc, (expr, errs)) = + with_loc + (fun env -> + let leading = Peek.comments env in + Expect.token env T_LCURLY; + let (props, errs) = + properties env ~rest_trailing_comma:None ([], Pattern_cover.empty_errors) + in + let internal = Peek.comments env in + Expect.token env T_RCURLY; + let trailing = Eat.trailing_comments env in + ( { + Ast.Expression.Object.properties = props; + comments = + Flow_ast_utils.mk_comments_with_internal_opt ~leading ~trailing ~internal (); + }, + errs + )) + env + in + (loc, expr, errs) + + let check_property_name env loc name static = + if String.equal name "constructor" || (String.equal name "prototype" && static) then + error_at + env + (loc, Parse_error.InvalidClassMemberName { name; static; method_ = false; private_ = false }) + + let check_private_names + env seen_names private_name (kind : [ `Method | `Field | `Getter | `Setter ]) = + let (loc, { PrivateName.name; comments = _ }) = private_name in + if String.equal name "constructor" then + let () = + error_at + env + ( loc, + Parse_error.InvalidClassMemberName + { name; static = false; method_ = kind = `Method; private_ = true } + ) + in + seen_names + else + match SMap.find_opt name seen_names with + | Some seen -> + begin + match (kind, seen) with + | (`Getter, `Setter) + | (`Setter, `Getter) -> + (* one getter and one setter are allowed as long as it's not used as a field *) + () + | _ -> error_at env (loc, Parse_error.DuplicatePrivateFields name) + end; + SMap.add name `Field seen_names + | None -> SMap.add name kind seen_names + + let class_implements env ~attach_leading = + let rec interfaces env acc = + let interface = + with_loc + (fun env -> + let id = + let id = Type.type_identifier env in + if Peek.token env <> T_LESS_THAN then + id + else + let { remove_trailing; _ } = trailing_and_remover env in + remove_trailing id (fun remover id -> remover#identifier id) + in + let targs = Type.type_args env in + { Ast.Class.Implements.Interface.id; targs }) + env + in + let acc = interface :: acc in + match Peek.token env with + | T_COMMA -> + Expect.token env T_COMMA; + interfaces env acc + | _ -> List.rev acc + in + with_loc + (fun env -> + let leading = + if attach_leading then + Peek.comments env + else + [] + in + Expect.token env T_IMPLEMENTS; + let interfaces = interfaces env [] in + { Ast.Class.Implements.interfaces; comments = Flow_ast_utils.mk_comments_opt ~leading () }) + env + + let class_extends ~leading = + with_loc (fun env -> + let expr = + let expr = Expression.left_hand_side (env |> with_allow_yield false) in + if Peek.token env <> T_LESS_THAN then + expr + else + let { remove_trailing; _ } = trailing_and_remover env in + remove_trailing expr (fun remover expr -> remover#expression expr) + in + let targs = Type.type_args env in + { Class.Extends.expr; targs; comments = Flow_ast_utils.mk_comments_opt ~leading () } + ) + + (* https://tc39.es/ecma262/#prod-ClassHeritage *) + let class_heritage env = + let extends = + let leading = Peek.comments env in + if Eat.maybe env T_EXTENDS then + let (loc, extends) = class_extends ~leading env in + let { remove_trailing; _ } = trailing_and_remover env in + Some + (loc, remove_trailing extends (fun remover extends -> remover#class_extends loc extends)) + else + None + in + let implements = + if Peek.token env = T_IMPLEMENTS then ( + if not (should_parse_types env) then error env Parse_error.UnexpectedTypeInterface; + Some (class_implements_remove_trailing env (class_implements env ~attach_leading:true)) + ) else + None + in + (extends, implements) + + (* In the ES6 draft, all elements are methods. No properties (though there + * are getter and setters allowed *) + let class_element = + let get env start_loc decorators static leading = + let (loc, (key, value)) = + with_loc ~start_loc (fun env -> getter_or_setter env ~in_class_body:true true) env + in + let open Ast.Class in + Body.Method + ( loc, + { + Method.key; + value; + kind = Method.Get; + static; + decorators; + comments = Flow_ast_utils.mk_comments_opt ~leading (); + } + ) + in + let set env start_loc decorators static leading = + let (loc, (key, value)) = + with_loc ~start_loc (fun env -> getter_or_setter env ~in_class_body:true false) env + in + let open Ast.Class in + Body.Method + ( loc, + { + Method.key; + value; + kind = Method.Set; + static; + decorators; + comments = Flow_ast_utils.mk_comments_opt ~leading (); + } + ) + in + let error_unsupported_variance env = function + | Some (loc, _) -> error_at env (loc, Parse_error.UnexpectedVariance) + | None -> () + (* Class property with annotation *) + in + let error_unsupported_declare env = function + | Some loc -> error_at env (loc, Parse_error.DeclareClassElement) + | None -> () + in + let property_end_and_semicolon env key annot value = + match Peek.token env with + | T_LBRACKET + | T_LPAREN -> + error_unexpected env; + (key, annot, value, []) + | T_SEMICOLON -> + Eat.token env; + let trailing = + match Peek.token env with + | T_EOF + | T_RCURLY -> + Eat.trailing_comments env + | _ when Peek.is_line_terminator env -> Eat.comments_until_next_line env + | _ -> [] + in + (key, annot, value, trailing) + | _ -> + let remover = + match Peek.token env with + | T_EOF + | T_RCURLY -> + { trailing = []; remove_trailing = (fun x _ -> x) } + | _ when Peek.is_line_terminator env -> + Comment_attachment.trailing_and_remover_after_last_line env + | _ -> Comment_attachment.trailing_and_remover_after_last_loc env + in + (* Remove trailing comments from the last node in this property *) + let (key, annot, value) = + match (annot, value) with + (* prop = init *) + | (_, Class.Property.Initialized expr) -> + ( key, + annot, + Class.Property.Initialized + (remover.remove_trailing expr (fun remover expr -> remover#expression expr)) + ) + (* prop: annot *) + | (Ast.Type.Available annot, _) -> + ( key, + Ast.Type.Available + (remover.remove_trailing annot (fun remover annot -> remover#type_annotation annot)), + value + ) + (* prop *) + | _ -> + (remover.remove_trailing key (fun remover key -> remover#object_key key), annot, value) + in + (key, annot, value, []) + in + let property env start_loc key static declare variance leading = + let (loc, (key, annot, value, comments)) = + with_loc + ~start_loc + (fun env -> + let annot = Type.annotation_opt env in + let value = + match (declare, Peek.token env) with + | (None, T_ASSIGN) -> + Eat.token env; + Ast.Class.Property.Initialized + (Parse.expression (env |> with_allow_super Super_prop)) + | (Some _, T_ASSIGN) -> + error env Parse_error.DeclareClassFieldInitializer; + Eat.token env; + Ast.Class.Property.Declared + | (None, _) -> Ast.Class.Property.Uninitialized + | (Some _, _) -> Ast.Class.Property.Declared + in + let (key, annot, value, trailing) = property_end_and_semicolon env key annot value in + (key, annot, value, Flow_ast_utils.mk_comments_opt ~leading ~trailing ())) + env + in + match key with + | Ast.Expression.Object.Property.PrivateName private_name -> + let open Ast.Class in + Body.PrivateField + (loc, { PrivateField.key = private_name; value; annot; static; variance; comments }) + | _ -> + Ast.Class.(Body.Property (loc, { Property.key; value; annot; static; variance; comments })) + in + let is_asi env = + match Peek.token env with + | T_LESS_THAN -> false + | T_LPAREN -> false + | _ when Peek.is_implicit_semicolon env -> true + | _ -> false + in + let rec init env start_loc decorators key ~async ~generator ~static ~declare variance leading = + match Peek.token env with + | T_COLON + | T_ASSIGN + | T_SEMICOLON + | T_RCURLY + when (not async) && not generator -> + property env start_loc key static declare variance leading + | T_PLING -> + (* TODO: add support for optional class properties *) + error_unexpected env; + Eat.token env; + init env start_loc decorators key ~async ~generator ~static ~declare variance leading + | _ when is_asi env -> + (* an uninitialized, unannotated property *) + property env start_loc key static declare variance leading + | _ -> + error_unsupported_declare env declare; + error_unsupported_variance env variance; + let (kind, env) = + match (static, key) with + | ( false, + Ast.Expression.Object.Property.Identifier + (_, { Identifier.name = "constructor"; comments = _ }) + ) + | ( false, + Ast.Expression.Object.Property.Literal + (_, { Literal.value = Literal.String "constructor"; _ }) + ) -> + (Ast.Class.Method.Constructor, env |> with_allow_super Super_prop_or_call) + | _ -> (Ast.Class.Method.Method, env |> with_allow_super Super_prop) + in + let key = object_key_remove_trailing env key in + let value = + with_loc + (fun env -> + let (sig_loc, (tparams, params, return)) = + with_loc + (fun env -> + let tparams = type_params_remove_trailing env (Type.type_params env) in + let params = + let (yield, await) = + match (async, generator) with + | (true, true) -> + (true, true) (* proposal-async-iteration/#prod-AsyncGeneratorMethod *) + | (true, false) -> (false, allow_await env) (* #prod-AsyncMethod *) + | (false, true) -> (true, false) (* #prod-GeneratorMethod *) + | (false, false) -> (false, false) + (* #prod-MethodDefinition *) + in + let params = Declaration.function_params ~await ~yield env in + let params = + if Peek.token env = T_COLON then + params + else + function_params_remove_trailing env params + in + Ast.Function.Params.( + match params with + | (loc, ({ this_ = Some (this_loc, _); _ } as params)) + when kind = Ast.Class.Method.Constructor -> + (* Disallow this param annotations for constructors *) + error_at env (this_loc, Parse_error.ThisParamBannedInConstructor); + (loc, { params with this_ = None }) + | params -> params + ) + in + let return = + type_annotation_hint_remove_trailing env (Type.annotation_opt env) + in + (tparams, params, return)) + env + in + let simple_params = is_simple_parameter_list params in + let (body, contains_use_strict) = + Declaration.function_body env ~async ~generator ~expression:false ~simple_params + in + Declaration.strict_post_check env ~contains_use_strict None params; + { + Function.id = None; + params; + body; + generator; + async; + (* TODO: add support for method predicates *) + predicate = None; + return; + tparams; + sig_loc; + comments = None; + }) + env + in + let open Ast.Class in + Body.Method + ( Loc.btwn start_loc (fst value), + { + Method.key; + value; + kind; + static; + decorators; + comments = Flow_ast_utils.mk_comments_opt ~leading (); + } + ) + in + let ith_implies_identifier ~i env = + match Peek.ith_token ~i env with + | T_LESS_THAN + | T_COLON + | T_ASSIGN + | T_SEMICOLON + | T_LPAREN + | T_RCURLY -> + true + | _ -> false + in + let implies_identifier = ith_implies_identifier ~i:0 in + fun env -> + let start_loc = Peek.loc env in + let decorators = decorator_list env in + let (declare, leading_declare) = + match Peek.token env with + | T_DECLARE when not (ith_implies_identifier ~i:1 env) -> + let ret = Some (Peek.loc env) in + let leading = Peek.comments env in + Eat.token env; + (ret, leading) + | _ -> (None, []) + in + let static = + Peek.ith_token ~i:1 env <> T_LPAREN + && Peek.ith_token ~i:1 env <> T_LESS_THAN + && Peek.token env = T_STATIC + in + let leading_static = + if static then ( + let leading = Peek.comments env in + Eat.token env; + leading + ) else + [] + in + let async = + Peek.token env = T_ASYNC + && (not (ith_implies_identifier ~i:1 env)) + && not (Peek.ith_is_line_terminator ~i:1 env) + in + (* consume `async` *) + let leading_async = + if async then ( + let leading = Peek.comments env in + Eat.token env; + leading + ) else + [] + in + let (generator, leading_generator) = Declaration.generator env in + let variance = Declaration.variance env async generator in + let (generator, leading_generator) = + match (generator, variance) with + | (false, Some _) -> Declaration.generator env + | _ -> (generator, leading_generator) + in + let leading = + List.concat [leading_declare; leading_static; leading_async; leading_generator] + in + match (async, generator, Peek.token env) with + | (false, false, T_IDENTIFIER { raw = "get"; _ }) -> + let leading_get = Peek.comments env in + let (_, key) = key ~class_body:true env in + if implies_identifier env then + init env start_loc decorators key ~async ~generator ~static ~declare variance leading + else ( + error_unsupported_declare env declare; + error_unsupported_variance env variance; + ignore (object_key_remove_trailing env key); + get env start_loc decorators static (leading @ leading_get) + ) + | (false, false, T_IDENTIFIER { raw = "set"; _ }) -> + let leading_set = Peek.comments env in + let (_, key) = key ~class_body:true env in + if implies_identifier env then + init env start_loc decorators key ~async ~generator ~static ~declare variance leading + else ( + error_unsupported_declare env declare; + error_unsupported_variance env variance; + ignore (object_key_remove_trailing env key); + set env start_loc decorators static (leading @ leading_set) + ) + | (_, _, _) -> + let (_, key) = key ~class_body:true env in + init env start_loc decorators key ~async ~generator ~static ~declare variance leading + + let class_body = + let rec elements env seen_constructor private_names acc = + match Peek.token env with + | T_EOF + | T_RCURLY -> + List.rev acc + | T_SEMICOLON -> + (* Skip empty elements *) + Expect.token env T_SEMICOLON; + elements env seen_constructor private_names acc + | _ -> + let element = class_element env in + let (seen_constructor', private_names') = + match element with + | Ast.Class.Body.Method (loc, m) -> + let open Ast.Class.Method in + (match m.kind with + | Constructor -> + if m.static then + (seen_constructor, private_names) + else ( + if seen_constructor then error_at env (loc, Parse_error.DuplicateConstructor); + (true, private_names) + ) + | Method -> + let private_names = + match m.key with + | Ast.Expression.Object.Property.PrivateName name -> + check_private_names env private_names name `Method + | _ -> private_names + in + (seen_constructor, private_names) + | Get -> + let open Ast.Expression.Object.Property in + let private_names = + match m.key with + | PrivateName name -> check_private_names env private_names name `Getter + | _ -> private_names + in + (seen_constructor, private_names) + | Set -> + let open Ast.Expression.Object.Property in + let private_names = + match m.key with + | PrivateName name -> check_private_names env private_names name `Setter + | _ -> private_names + in + (seen_constructor, private_names)) + | Ast.Class.Body.Property (_, { Ast.Class.Property.key; static; _ }) -> + let open Ast.Expression.Object.Property in + begin + match key with + | Identifier (loc, { Identifier.name; comments = _ }) + | Literal (loc, { Literal.value = Literal.String name; _ }) -> + check_property_name env loc name static + | Literal _ + | Computed _ -> + () + | PrivateName _ -> + failwith "unexpected PrivateName in Property, expected a PrivateField" + end; + (seen_constructor, private_names) + | Ast.Class.Body.PrivateField (_, { Ast.Class.PrivateField.key; _ }) -> + let private_names = check_private_names env private_names key `Field in + (seen_constructor, private_names) + in + elements env seen_constructor' private_names' (element :: acc) + in + fun ~expression env -> + with_loc + (fun env -> + let leading = Peek.comments env in + if Eat.maybe env T_LCURLY then ( + enter_class env; + let body = elements env false SMap.empty [] in + exit_class env; + Expect.token env T_RCURLY; + let trailing = + match (expression, Peek.token env) with + | (true, _) + | (_, (T_RCURLY | T_EOF)) -> + Eat.trailing_comments env + | _ when Peek.is_line_terminator env -> Eat.comments_until_next_line env + | _ -> [] + in + { Ast.Class.Body.body; comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing () } + ) else ( + Expect.error env T_LCURLY; + { Ast.Class.Body.body = []; comments = None } + )) + env + + let _class ?(decorators = []) env ~optional_id ~expression = + (* 10.2.1 says all parts of a class definition are strict *) + let env = env |> with_strict true in + let decorators = decorators @ decorator_list env in + let leading = Peek.comments env in + Expect.token env T_CLASS; + let id = + let tmp_env = env |> with_no_let true in + match (optional_id, Peek.token tmp_env) with + | (true, (T_EXTENDS | T_IMPLEMENTS | T_LESS_THAN | T_LCURLY)) -> None + | _ when Peek.is_identifier env -> + let id = Parse.identifier tmp_env in + let { remove_trailing; _ } = trailing_and_remover env in + let id = remove_trailing id (fun remover id -> remover#identifier id) in + Some id + | _ -> + (* error, but don't consume a token like Parse.identifier does. this helps + with recovery, and the parser won't get stuck because we consumed the + `class` token above. *) + error_nameless_declaration env "class"; + Some (Peek.loc env, { Identifier.name = ""; comments = None }) + in + let tparams = + match Type.type_params env with + | None -> None + | Some tparams -> + let { remove_trailing; _ } = trailing_and_remover env in + Some (remove_trailing tparams (fun remover tparams -> remover#type_params tparams)) + in + let (extends, implements) = class_heritage env in + let body = class_body env ~expression in + let comments = Flow_ast_utils.mk_comments_opt ~leading () in + { Class.id; body; tparams; extends; implements; class_decorators = decorators; comments } + + let class_declaration env decorators = + with_loc + (fun env -> + let optional_id = in_export_default env in + Ast.Statement.ClassDeclaration (_class env ~decorators ~optional_id ~expression:false)) + env + + let class_expression = + with_loc (fun env -> Ast.Expression.Class (_class env ~optional_id:true ~expression:true)) +end diff --git a/analysis/vendor/js_parser/parse_error.ml b/analysis/vendor/js_parser/parse_error.ml new file mode 100644 index 000000000..93381483a --- /dev/null +++ b/analysis/vendor/js_parser/parse_error.ml @@ -0,0 +1,941 @@ +(* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) +open Primitive_deriving + +type t = + | EnumBooleanMemberNotInitialized of { + enum_name: string; + member_name: string; + } + | EnumDuplicateMemberName of { + enum_name: string; + member_name: string; + } + | EnumInconsistentMemberValues of { enum_name: string } + | EnumInvalidExplicitType of { + enum_name: string; + supplied_type: string option; + } + | EnumInvalidExport + | EnumInvalidInitializerSeparator of { member_name: string } + | EnumInvalidMemberInitializer of { + enum_name: string; + explicit_type: Enum_common.explicit_type option; + member_name: string; + } + | EnumInvalidMemberName of { + enum_name: string; + member_name: string; + } + | EnumInvalidMemberSeparator + | EnumInvalidEllipsis of { trailing_comma: bool } + | EnumNumberMemberNotInitialized of { + enum_name: string; + member_name: string; + } + | EnumStringMemberInconsistentlyInitailized of { enum_name: string } + | Unexpected of string + | UnexpectedWithExpected of string * string + | UnexpectedTokenWithSuggestion of string * string + | UnexpectedReserved + | UnexpectedReservedType + | UnexpectedSuper + | UnexpectedSuperCall + | UnexpectedEOS + | UnexpectedVariance + | UnexpectedStatic + | UnexpectedProto + | UnexpectedTypeAlias + | UnexpectedOpaqueTypeAlias + | UnexpectedTypeAnnotation + | UnexpectedTypeDeclaration + | UnexpectedTypeImport + | UnexpectedTypeExport + | UnexpectedTypeInterface + | UnexpectedSpreadType + | UnexpectedExplicitInexactInObject + | InexactInsideExact + | InexactInsideNonObject + | NewlineAfterThrow + | InvalidFloatBigInt + | InvalidSciBigInt + | InvalidRegExp + | InvalidRegExpFlags of string + | UnterminatedRegExp + | InvalidLHSInAssignment + | InvalidLHSInExponentiation + | InvalidLHSInForIn + | InvalidLHSInForOf + | InvalidIndexedAccess of { has_bracket: bool } + | InvalidOptionalIndexedAccess + | ExpectedPatternFoundExpression + | MultipleDefaultsInSwitch + | NoCatchOrFinally + | UnknownLabel of string + | Redeclaration of string * string + | IllegalContinue + | IllegalBreak + | IllegalReturn + | IllegalUnicodeEscape + | StrictModeWith + | StrictCatchVariable + | StrictVarName + | StrictParamName + | StrictParamDupe + | StrictParamNotSimple + | StrictFunctionName + | StrictOctalLiteral + | StrictNonOctalLiteral + | StrictDelete + | StrictDuplicateProperty + | AccessorDataProperty + | AccessorGetSet + | InvalidTypeof + | StrictLHSAssignment + | StrictLHSPostfix + | StrictLHSPrefix + | StrictReservedWord + | JSXAttributeValueEmptyExpression + | InvalidJSXAttributeValue + | ExpectedJSXClosingTag of string + | NoUninitializedConst + | NoUninitializedDestructuring + | NewlineBeforeArrow + | FunctionAsStatement of { in_strict_mode: bool } + | AsyncFunctionAsStatement + | GeneratorFunctionAsStatement + | AdjacentJSXElements + | ParameterAfterRestParameter + | ElementAfterRestElement + | PropertyAfterRestElement + | DeclareAsync + | DeclareClassElement + | DeclareClassFieldInitializer + | DeclareOpaqueTypeInitializer + | DeclareExportLet + | DeclareExportConst + | DeclareExportType + | DeclareExportInterface + | DuplicateExport of string + | UnsupportedDecorator + | MissingTypeParamDefault + | DuplicateDeclareModuleExports + | AmbiguousDeclareModuleKind + | GetterArity + | SetterArity + | InvalidNonTypeImportInDeclareModule + | ImportTypeShorthandOnlyInPureImport + | ImportSpecifierMissingComma + | ExportSpecifierMissingComma + | MalformedUnicode + | DuplicateConstructor + | DuplicatePrivateFields of string + | InvalidClassMemberName of { + name: string; + static: bool; + method_: bool; + private_: bool; + } + | PrivateDelete + | UnboundPrivate of string + | PrivateNotInClass + | SuperPrivate + | YieldInFormalParameters + | AwaitAsIdentifierReference + | YieldAsIdentifierReference + | AmbiguousLetBracket + | LiteralShorthandProperty + | ComputedShorthandProperty + | MethodInDestructuring + | TrailingCommaAfterRestElement + | OptionalChainNew + | OptionalChainTemplate + | NullishCoalescingUnexpectedLogical of string + | WhitespaceInPrivateName + | ThisParamAnnotationRequired + | ThisParamMustBeFirst + | ThisParamMayNotBeOptional + | GetterMayNotHaveThisParam + | SetterMayNotHaveThisParam + | ThisParamBannedInArrowFunctions + | ThisParamBannedInConstructor +[@@deriving_inline compare] +let _ = fun (_ : t) -> () +let compare = + (fun a__001_ -> + fun b__002_ -> + if Ppx_compare_lib.phys_equal a__001_ b__002_ + then 0 + else + (match (a__001_, b__002_) with + | (EnumBooleanMemberNotInitialized _a__003_, + EnumBooleanMemberNotInitialized _b__004_) -> + (match compare_string _a__003_.enum_name _b__004_.enum_name + with + | 0 -> + compare_string _a__003_.member_name _b__004_.member_name + | n -> n) + | (EnumBooleanMemberNotInitialized _, _) -> (-1) + | (_, EnumBooleanMemberNotInitialized _) -> 1 + | (EnumDuplicateMemberName _a__005_, EnumDuplicateMemberName + _b__006_) -> + (match compare_string _a__005_.enum_name _b__006_.enum_name + with + | 0 -> + compare_string _a__005_.member_name _b__006_.member_name + | n -> n) + | (EnumDuplicateMemberName _, _) -> (-1) + | (_, EnumDuplicateMemberName _) -> 1 + | (EnumInconsistentMemberValues _a__007_, + EnumInconsistentMemberValues _b__008_) -> + compare_string _a__007_.enum_name _b__008_.enum_name + | (EnumInconsistentMemberValues _, _) -> (-1) + | (_, EnumInconsistentMemberValues _) -> 1 + | (EnumInvalidExplicitType _a__009_, EnumInvalidExplicitType + _b__010_) -> + (match compare_string _a__009_.enum_name _b__010_.enum_name + with + | 0 -> + compare_option compare_string _a__009_.supplied_type + _b__010_.supplied_type + | n -> n) + | (EnumInvalidExplicitType _, _) -> (-1) + | (_, EnumInvalidExplicitType _) -> 1 + | (EnumInvalidExport, EnumInvalidExport) -> 0 + | (EnumInvalidExport, _) -> (-1) + | (_, EnumInvalidExport) -> 1 + | (EnumInvalidInitializerSeparator _a__013_, + EnumInvalidInitializerSeparator _b__014_) -> + compare_string _a__013_.member_name _b__014_.member_name + | (EnumInvalidInitializerSeparator _, _) -> (-1) + | (_, EnumInvalidInitializerSeparator _) -> 1 + | (EnumInvalidMemberInitializer _a__015_, + EnumInvalidMemberInitializer _b__016_) -> + (match compare_string _a__015_.enum_name _b__016_.enum_name + with + | 0 -> + (match compare_option Enum_common.compare_explicit_type + _a__015_.explicit_type _b__016_.explicit_type + with + | 0 -> + compare_string _a__015_.member_name + _b__016_.member_name + | n -> n) + | n -> n) + | (EnumInvalidMemberInitializer _, _) -> (-1) + | (_, EnumInvalidMemberInitializer _) -> 1 + | (EnumInvalidMemberName _a__019_, EnumInvalidMemberName _b__020_) + -> + (match compare_string _a__019_.enum_name _b__020_.enum_name + with + | 0 -> + compare_string _a__019_.member_name _b__020_.member_name + | n -> n) + | (EnumInvalidMemberName _, _) -> (-1) + | (_, EnumInvalidMemberName _) -> 1 + | (EnumInvalidMemberSeparator, EnumInvalidMemberSeparator) -> 0 + | (EnumInvalidMemberSeparator, _) -> (-1) + | (_, EnumInvalidMemberSeparator) -> 1 + | (EnumInvalidEllipsis _a__021_, EnumInvalidEllipsis _b__022_) -> + compare_bool _a__021_.trailing_comma _b__022_.trailing_comma + | (EnumInvalidEllipsis _, _) -> (-1) + | (_, EnumInvalidEllipsis _) -> 1 + | (EnumNumberMemberNotInitialized _a__023_, + EnumNumberMemberNotInitialized _b__024_) -> + (match compare_string _a__023_.enum_name _b__024_.enum_name + with + | 0 -> + compare_string _a__023_.member_name _b__024_.member_name + | n -> n) + | (EnumNumberMemberNotInitialized _, _) -> (-1) + | (_, EnumNumberMemberNotInitialized _) -> 1 + | (EnumStringMemberInconsistentlyInitailized _a__025_, + EnumStringMemberInconsistentlyInitailized _b__026_) -> + compare_string _a__025_.enum_name _b__026_.enum_name + | (EnumStringMemberInconsistentlyInitailized _, _) -> (-1) + | (_, EnumStringMemberInconsistentlyInitailized _) -> 1 + | (Unexpected _a__027_, Unexpected _b__028_) -> + compare_string _a__027_ _b__028_ + | (Unexpected _, _) -> (-1) + | (_, Unexpected _) -> 1 + | (UnexpectedWithExpected (_a__029_, _a__031_), + UnexpectedWithExpected (_b__030_, _b__032_)) -> + (match compare_string _a__029_ _b__030_ with + | 0 -> compare_string _a__031_ _b__032_ + | n -> n) + | (UnexpectedWithExpected _, _) -> (-1) + | (_, UnexpectedWithExpected _) -> 1 + | (UnexpectedTokenWithSuggestion (_a__033_, _a__035_), + UnexpectedTokenWithSuggestion (_b__034_, _b__036_)) -> + (match compare_string _a__033_ _b__034_ with + | 0 -> compare_string _a__035_ _b__036_ + | n -> n) + | (UnexpectedTokenWithSuggestion _, _) -> (-1) + | (_, UnexpectedTokenWithSuggestion _) -> 1 + | (UnexpectedReserved, UnexpectedReserved) -> 0 + | (UnexpectedReserved, _) -> (-1) + | (_, UnexpectedReserved) -> 1 + | (UnexpectedReservedType, UnexpectedReservedType) -> 0 + | (UnexpectedReservedType, _) -> (-1) + | (_, UnexpectedReservedType) -> 1 + | (UnexpectedSuper, UnexpectedSuper) -> 0 + | (UnexpectedSuper, _) -> (-1) + | (_, UnexpectedSuper) -> 1 + | (UnexpectedSuperCall, UnexpectedSuperCall) -> 0 + | (UnexpectedSuperCall, _) -> (-1) + | (_, UnexpectedSuperCall) -> 1 + | (UnexpectedEOS, UnexpectedEOS) -> 0 + | (UnexpectedEOS, _) -> (-1) + | (_, UnexpectedEOS) -> 1 + | (UnexpectedVariance, UnexpectedVariance) -> 0 + | (UnexpectedVariance, _) -> (-1) + | (_, UnexpectedVariance) -> 1 + | (UnexpectedStatic, UnexpectedStatic) -> 0 + | (UnexpectedStatic, _) -> (-1) + | (_, UnexpectedStatic) -> 1 + | (UnexpectedProto, UnexpectedProto) -> 0 + | (UnexpectedProto, _) -> (-1) + | (_, UnexpectedProto) -> 1 + | (UnexpectedTypeAlias, UnexpectedTypeAlias) -> 0 + | (UnexpectedTypeAlias, _) -> (-1) + | (_, UnexpectedTypeAlias) -> 1 + | (UnexpectedOpaqueTypeAlias, UnexpectedOpaqueTypeAlias) -> 0 + | (UnexpectedOpaqueTypeAlias, _) -> (-1) + | (_, UnexpectedOpaqueTypeAlias) -> 1 + | (UnexpectedTypeAnnotation, UnexpectedTypeAnnotation) -> 0 + | (UnexpectedTypeAnnotation, _) -> (-1) + | (_, UnexpectedTypeAnnotation) -> 1 + | (UnexpectedTypeDeclaration, UnexpectedTypeDeclaration) -> 0 + | (UnexpectedTypeDeclaration, _) -> (-1) + | (_, UnexpectedTypeDeclaration) -> 1 + | (UnexpectedTypeImport, UnexpectedTypeImport) -> 0 + | (UnexpectedTypeImport, _) -> (-1) + | (_, UnexpectedTypeImport) -> 1 + | (UnexpectedTypeExport, UnexpectedTypeExport) -> 0 + | (UnexpectedTypeExport, _) -> (-1) + | (_, UnexpectedTypeExport) -> 1 + | (UnexpectedTypeInterface, UnexpectedTypeInterface) -> 0 + | (UnexpectedTypeInterface, _) -> (-1) + | (_, UnexpectedTypeInterface) -> 1 + | (UnexpectedSpreadType, UnexpectedSpreadType) -> 0 + | (UnexpectedSpreadType, _) -> (-1) + | (_, UnexpectedSpreadType) -> 1 + | (UnexpectedExplicitInexactInObject, + UnexpectedExplicitInexactInObject) -> 0 + | (UnexpectedExplicitInexactInObject, _) -> (-1) + | (_, UnexpectedExplicitInexactInObject) -> 1 + | (InexactInsideExact, InexactInsideExact) -> 0 + | (InexactInsideExact, _) -> (-1) + | (_, InexactInsideExact) -> 1 + | (InexactInsideNonObject, InexactInsideNonObject) -> 0 + | (InexactInsideNonObject, _) -> (-1) + | (_, InexactInsideNonObject) -> 1 + | (NewlineAfterThrow, NewlineAfterThrow) -> 0 + | (NewlineAfterThrow, _) -> (-1) + | (_, NewlineAfterThrow) -> 1 + | (InvalidFloatBigInt, InvalidFloatBigInt) -> 0 + | (InvalidFloatBigInt, _) -> (-1) + | (_, InvalidFloatBigInt) -> 1 + | (InvalidSciBigInt, InvalidSciBigInt) -> 0 + | (InvalidSciBigInt, _) -> (-1) + | (_, InvalidSciBigInt) -> 1 + | (InvalidRegExp, InvalidRegExp) -> 0 + | (InvalidRegExp, _) -> (-1) + | (_, InvalidRegExp) -> 1 + | (InvalidRegExpFlags _a__037_, InvalidRegExpFlags _b__038_) -> + compare_string _a__037_ _b__038_ + | (InvalidRegExpFlags _, _) -> (-1) + | (_, InvalidRegExpFlags _) -> 1 + | (UnterminatedRegExp, UnterminatedRegExp) -> 0 + | (UnterminatedRegExp, _) -> (-1) + | (_, UnterminatedRegExp) -> 1 + | (InvalidLHSInAssignment, InvalidLHSInAssignment) -> 0 + | (InvalidLHSInAssignment, _) -> (-1) + | (_, InvalidLHSInAssignment) -> 1 + | (InvalidLHSInExponentiation, InvalidLHSInExponentiation) -> 0 + | (InvalidLHSInExponentiation, _) -> (-1) + | (_, InvalidLHSInExponentiation) -> 1 + | (InvalidLHSInForIn, InvalidLHSInForIn) -> 0 + | (InvalidLHSInForIn, _) -> (-1) + | (_, InvalidLHSInForIn) -> 1 + | (InvalidLHSInForOf, InvalidLHSInForOf) -> 0 + | (InvalidLHSInForOf, _) -> (-1) + | (_, InvalidLHSInForOf) -> 1 + | (InvalidIndexedAccess _a__039_, InvalidIndexedAccess _b__040_) -> + compare_bool _a__039_.has_bracket _b__040_.has_bracket + | (InvalidIndexedAccess _, _) -> (-1) + | (_, InvalidIndexedAccess _) -> 1 + | (InvalidOptionalIndexedAccess, InvalidOptionalIndexedAccess) -> 0 + | (InvalidOptionalIndexedAccess, _) -> (-1) + | (_, InvalidOptionalIndexedAccess) -> 1 + | (ExpectedPatternFoundExpression, ExpectedPatternFoundExpression) + -> 0 + | (ExpectedPatternFoundExpression, _) -> (-1) + | (_, ExpectedPatternFoundExpression) -> 1 + | (MultipleDefaultsInSwitch, MultipleDefaultsInSwitch) -> 0 + | (MultipleDefaultsInSwitch, _) -> (-1) + | (_, MultipleDefaultsInSwitch) -> 1 + | (NoCatchOrFinally, NoCatchOrFinally) -> 0 + | (NoCatchOrFinally, _) -> (-1) + | (_, NoCatchOrFinally) -> 1 + | (UnknownLabel _a__041_, UnknownLabel _b__042_) -> + compare_string _a__041_ _b__042_ + | (UnknownLabel _, _) -> (-1) + | (_, UnknownLabel _) -> 1 + | (Redeclaration (_a__043_, _a__045_), Redeclaration + (_b__044_, _b__046_)) -> + (match compare_string _a__043_ _b__044_ with + | 0 -> compare_string _a__045_ _b__046_ + | n -> n) + | (Redeclaration _, _) -> (-1) + | (_, Redeclaration _) -> 1 + | (IllegalContinue, IllegalContinue) -> 0 + | (IllegalContinue, _) -> (-1) + | (_, IllegalContinue) -> 1 + | (IllegalBreak, IllegalBreak) -> 0 + | (IllegalBreak, _) -> (-1) + | (_, IllegalBreak) -> 1 + | (IllegalReturn, IllegalReturn) -> 0 + | (IllegalReturn, _) -> (-1) + | (_, IllegalReturn) -> 1 + | (IllegalUnicodeEscape, IllegalUnicodeEscape) -> 0 + | (IllegalUnicodeEscape, _) -> (-1) + | (_, IllegalUnicodeEscape) -> 1 + | (StrictModeWith, StrictModeWith) -> 0 + | (StrictModeWith, _) -> (-1) + | (_, StrictModeWith) -> 1 + | (StrictCatchVariable, StrictCatchVariable) -> 0 + | (StrictCatchVariable, _) -> (-1) + | (_, StrictCatchVariable) -> 1 + | (StrictVarName, StrictVarName) -> 0 + | (StrictVarName, _) -> (-1) + | (_, StrictVarName) -> 1 + | (StrictParamName, StrictParamName) -> 0 + | (StrictParamName, _) -> (-1) + | (_, StrictParamName) -> 1 + | (StrictParamDupe, StrictParamDupe) -> 0 + | (StrictParamDupe, _) -> (-1) + | (_, StrictParamDupe) -> 1 + | (StrictParamNotSimple, StrictParamNotSimple) -> 0 + | (StrictParamNotSimple, _) -> (-1) + | (_, StrictParamNotSimple) -> 1 + | (StrictFunctionName, StrictFunctionName) -> 0 + | (StrictFunctionName, _) -> (-1) + | (_, StrictFunctionName) -> 1 + | (StrictOctalLiteral, StrictOctalLiteral) -> 0 + | (StrictOctalLiteral, _) -> (-1) + | (_, StrictOctalLiteral) -> 1 + | (StrictNonOctalLiteral, StrictNonOctalLiteral) -> 0 + | (StrictNonOctalLiteral, _) -> (-1) + | (_, StrictNonOctalLiteral) -> 1 + | (StrictDelete, StrictDelete) -> 0 + | (StrictDelete, _) -> (-1) + | (_, StrictDelete) -> 1 + | (StrictDuplicateProperty, StrictDuplicateProperty) -> 0 + | (StrictDuplicateProperty, _) -> (-1) + | (_, StrictDuplicateProperty) -> 1 + | (AccessorDataProperty, AccessorDataProperty) -> 0 + | (AccessorDataProperty, _) -> (-1) + | (_, AccessorDataProperty) -> 1 + | (AccessorGetSet, AccessorGetSet) -> 0 + | (AccessorGetSet, _) -> (-1) + | (_, AccessorGetSet) -> 1 + | (InvalidTypeof, InvalidTypeof) -> 0 + | (InvalidTypeof, _) -> (-1) + | (_, InvalidTypeof) -> 1 + | (StrictLHSAssignment, StrictLHSAssignment) -> 0 + | (StrictLHSAssignment, _) -> (-1) + | (_, StrictLHSAssignment) -> 1 + | (StrictLHSPostfix, StrictLHSPostfix) -> 0 + | (StrictLHSPostfix, _) -> (-1) + | (_, StrictLHSPostfix) -> 1 + | (StrictLHSPrefix, StrictLHSPrefix) -> 0 + | (StrictLHSPrefix, _) -> (-1) + | (_, StrictLHSPrefix) -> 1 + | (StrictReservedWord, StrictReservedWord) -> 0 + | (StrictReservedWord, _) -> (-1) + | (_, StrictReservedWord) -> 1 + | (JSXAttributeValueEmptyExpression, + JSXAttributeValueEmptyExpression) -> 0 + | (JSXAttributeValueEmptyExpression, _) -> (-1) + | (_, JSXAttributeValueEmptyExpression) -> 1 + | (InvalidJSXAttributeValue, InvalidJSXAttributeValue) -> 0 + | (InvalidJSXAttributeValue, _) -> (-1) + | (_, InvalidJSXAttributeValue) -> 1 + | (ExpectedJSXClosingTag _a__047_, ExpectedJSXClosingTag _b__048_) + -> compare_string _a__047_ _b__048_ + | (ExpectedJSXClosingTag _, _) -> (-1) + | (_, ExpectedJSXClosingTag _) -> 1 + | (NoUninitializedConst, NoUninitializedConst) -> 0 + | (NoUninitializedConst, _) -> (-1) + | (_, NoUninitializedConst) -> 1 + | (NoUninitializedDestructuring, NoUninitializedDestructuring) -> 0 + | (NoUninitializedDestructuring, _) -> (-1) + | (_, NoUninitializedDestructuring) -> 1 + | (NewlineBeforeArrow, NewlineBeforeArrow) -> 0 + | (NewlineBeforeArrow, _) -> (-1) + | (_, NewlineBeforeArrow) -> 1 + | (FunctionAsStatement _a__049_, FunctionAsStatement _b__050_) -> + compare_bool _a__049_.in_strict_mode _b__050_.in_strict_mode + | (FunctionAsStatement _, _) -> (-1) + | (_, FunctionAsStatement _) -> 1 + | (AsyncFunctionAsStatement, AsyncFunctionAsStatement) -> 0 + | (AsyncFunctionAsStatement, _) -> (-1) + | (_, AsyncFunctionAsStatement) -> 1 + | (GeneratorFunctionAsStatement, GeneratorFunctionAsStatement) -> 0 + | (GeneratorFunctionAsStatement, _) -> (-1) + | (_, GeneratorFunctionAsStatement) -> 1 + | (AdjacentJSXElements, AdjacentJSXElements) -> 0 + | (AdjacentJSXElements, _) -> (-1) + | (_, AdjacentJSXElements) -> 1 + | (ParameterAfterRestParameter, ParameterAfterRestParameter) -> 0 + | (ParameterAfterRestParameter, _) -> (-1) + | (_, ParameterAfterRestParameter) -> 1 + | (ElementAfterRestElement, ElementAfterRestElement) -> 0 + | (ElementAfterRestElement, _) -> (-1) + | (_, ElementAfterRestElement) -> 1 + | (PropertyAfterRestElement, PropertyAfterRestElement) -> 0 + | (PropertyAfterRestElement, _) -> (-1) + | (_, PropertyAfterRestElement) -> 1 + | (DeclareAsync, DeclareAsync) -> 0 + | (DeclareAsync, _) -> (-1) + | (_, DeclareAsync) -> 1 + | (DeclareClassElement, DeclareClassElement) -> 0 + | (DeclareClassElement, _) -> (-1) + | (_, DeclareClassElement) -> 1 + | (DeclareClassFieldInitializer, DeclareClassFieldInitializer) -> 0 + | (DeclareClassFieldInitializer, _) -> (-1) + | (_, DeclareClassFieldInitializer) -> 1 + | (DeclareOpaqueTypeInitializer, DeclareOpaqueTypeInitializer) -> 0 + | (DeclareOpaqueTypeInitializer, _) -> (-1) + | (_, DeclareOpaqueTypeInitializer) -> 1 + | (DeclareExportLet, DeclareExportLet) -> 0 + | (DeclareExportLet, _) -> (-1) + | (_, DeclareExportLet) -> 1 + | (DeclareExportConst, DeclareExportConst) -> 0 + | (DeclareExportConst, _) -> (-1) + | (_, DeclareExportConst) -> 1 + | (DeclareExportType, DeclareExportType) -> 0 + | (DeclareExportType, _) -> (-1) + | (_, DeclareExportType) -> 1 + | (DeclareExportInterface, DeclareExportInterface) -> 0 + | (DeclareExportInterface, _) -> (-1) + | (_, DeclareExportInterface) -> 1 + | (DuplicateExport _a__051_, DuplicateExport _b__052_) -> + compare_string _a__051_ _b__052_ + | (DuplicateExport _, _) -> (-1) + | (_, DuplicateExport _) -> 1 + | (UnsupportedDecorator, UnsupportedDecorator) -> 0 + | (UnsupportedDecorator, _) -> (-1) + | (_, UnsupportedDecorator) -> 1 + | (MissingTypeParamDefault, MissingTypeParamDefault) -> 0 + | (MissingTypeParamDefault, _) -> (-1) + | (_, MissingTypeParamDefault) -> 1 + | (DuplicateDeclareModuleExports, DuplicateDeclareModuleExports) -> + 0 + | (DuplicateDeclareModuleExports, _) -> (-1) + | (_, DuplicateDeclareModuleExports) -> 1 + | (AmbiguousDeclareModuleKind, AmbiguousDeclareModuleKind) -> 0 + | (AmbiguousDeclareModuleKind, _) -> (-1) + | (_, AmbiguousDeclareModuleKind) -> 1 + | (GetterArity, GetterArity) -> 0 + | (GetterArity, _) -> (-1) + | (_, GetterArity) -> 1 + | (SetterArity, SetterArity) -> 0 + | (SetterArity, _) -> (-1) + | (_, SetterArity) -> 1 + | (InvalidNonTypeImportInDeclareModule, + InvalidNonTypeImportInDeclareModule) -> 0 + | (InvalidNonTypeImportInDeclareModule, _) -> (-1) + | (_, InvalidNonTypeImportInDeclareModule) -> 1 + | (ImportTypeShorthandOnlyInPureImport, + ImportTypeShorthandOnlyInPureImport) -> 0 + | (ImportTypeShorthandOnlyInPureImport, _) -> (-1) + | (_, ImportTypeShorthandOnlyInPureImport) -> 1 + | (ImportSpecifierMissingComma, ImportSpecifierMissingComma) -> 0 + | (ImportSpecifierMissingComma, _) -> (-1) + | (_, ImportSpecifierMissingComma) -> 1 + | (ExportSpecifierMissingComma, ExportSpecifierMissingComma) -> 0 + | (ExportSpecifierMissingComma, _) -> (-1) + | (_, ExportSpecifierMissingComma) -> 1 + | (MalformedUnicode, MalformedUnicode) -> 0 + | (MalformedUnicode, _) -> (-1) + | (_, MalformedUnicode) -> 1 + | (DuplicateConstructor, DuplicateConstructor) -> 0 + | (DuplicateConstructor, _) -> (-1) + | (_, DuplicateConstructor) -> 1 + | (DuplicatePrivateFields _a__053_, DuplicatePrivateFields + _b__054_) -> compare_string _a__053_ _b__054_ + | (DuplicatePrivateFields _, _) -> (-1) + | (_, DuplicatePrivateFields _) -> 1 + | (InvalidClassMemberName _a__055_, InvalidClassMemberName + _b__056_) -> + (match compare_string _a__055_.name _b__056_.name with + | 0 -> + (match compare_bool _a__055_.static _b__056_.static with + | 0 -> + (match compare_bool _a__055_.method_ _b__056_.method_ + with + | 0 -> + compare_bool _a__055_.private_ _b__056_.private_ + | n -> n) + | n -> n) + | n -> n) + | (InvalidClassMemberName _, _) -> (-1) + | (_, InvalidClassMemberName _) -> 1 + | (PrivateDelete, PrivateDelete) -> 0 + | (PrivateDelete, _) -> (-1) + | (_, PrivateDelete) -> 1 + | (UnboundPrivate _a__057_, UnboundPrivate _b__058_) -> + compare_string _a__057_ _b__058_ + | (UnboundPrivate _, _) -> (-1) + | (_, UnboundPrivate _) -> 1 + | (PrivateNotInClass, PrivateNotInClass) -> 0 + | (PrivateNotInClass, _) -> (-1) + | (_, PrivateNotInClass) -> 1 + | (SuperPrivate, SuperPrivate) -> 0 + | (SuperPrivate, _) -> (-1) + | (_, SuperPrivate) -> 1 + | (YieldInFormalParameters, YieldInFormalParameters) -> 0 + | (YieldInFormalParameters, _) -> (-1) + | (_, YieldInFormalParameters) -> 1 + | (AwaitAsIdentifierReference, AwaitAsIdentifierReference) -> 0 + | (AwaitAsIdentifierReference, _) -> (-1) + | (_, AwaitAsIdentifierReference) -> 1 + | (YieldAsIdentifierReference, YieldAsIdentifierReference) -> 0 + | (YieldAsIdentifierReference, _) -> (-1) + | (_, YieldAsIdentifierReference) -> 1 + | (AmbiguousLetBracket, AmbiguousLetBracket) -> 0 + | (AmbiguousLetBracket, _) -> (-1) + | (_, AmbiguousLetBracket) -> 1 + | (LiteralShorthandProperty, LiteralShorthandProperty) -> 0 + | (LiteralShorthandProperty, _) -> (-1) + | (_, LiteralShorthandProperty) -> 1 + | (ComputedShorthandProperty, ComputedShorthandProperty) -> 0 + | (ComputedShorthandProperty, _) -> (-1) + | (_, ComputedShorthandProperty) -> 1 + | (MethodInDestructuring, MethodInDestructuring) -> 0 + | (MethodInDestructuring, _) -> (-1) + | (_, MethodInDestructuring) -> 1 + | (TrailingCommaAfterRestElement, TrailingCommaAfterRestElement) -> + 0 + | (TrailingCommaAfterRestElement, _) -> (-1) + | (_, TrailingCommaAfterRestElement) -> 1 + | (OptionalChainNew, OptionalChainNew) -> 0 + | (OptionalChainNew, _) -> (-1) + | (_, OptionalChainNew) -> 1 + | (OptionalChainTemplate, OptionalChainTemplate) -> 0 + | (OptionalChainTemplate, _) -> (-1) + | (_, OptionalChainTemplate) -> 1 + | (NullishCoalescingUnexpectedLogical _a__059_, + NullishCoalescingUnexpectedLogical _b__060_) -> + compare_string _a__059_ _b__060_ + | (NullishCoalescingUnexpectedLogical _, _) -> (-1) + | (_, NullishCoalescingUnexpectedLogical _) -> 1 + | (WhitespaceInPrivateName, WhitespaceInPrivateName) -> 0 + | (WhitespaceInPrivateName, _) -> (-1) + | (_, WhitespaceInPrivateName) -> 1 + | (ThisParamAnnotationRequired, ThisParamAnnotationRequired) -> 0 + | (ThisParamAnnotationRequired, _) -> (-1) + | (_, ThisParamAnnotationRequired) -> 1 + | (ThisParamMustBeFirst, ThisParamMustBeFirst) -> 0 + | (ThisParamMustBeFirst, _) -> (-1) + | (_, ThisParamMustBeFirst) -> 1 + | (ThisParamMayNotBeOptional, ThisParamMayNotBeOptional) -> 0 + | (ThisParamMayNotBeOptional, _) -> (-1) + | (_, ThisParamMayNotBeOptional) -> 1 + | (GetterMayNotHaveThisParam, GetterMayNotHaveThisParam) -> 0 + | (GetterMayNotHaveThisParam, _) -> (-1) + | (_, GetterMayNotHaveThisParam) -> 1 + | (SetterMayNotHaveThisParam, SetterMayNotHaveThisParam) -> 0 + | (SetterMayNotHaveThisParam, _) -> (-1) + | (_, SetterMayNotHaveThisParam) -> 1 + | (ThisParamBannedInArrowFunctions, + ThisParamBannedInArrowFunctions) -> 0 + | (ThisParamBannedInArrowFunctions, _) -> (-1) + | (_, ThisParamBannedInArrowFunctions) -> 1 + | (ThisParamBannedInConstructor, ThisParamBannedInConstructor) -> 0) : + t -> t -> int) +let _ = compare +[@@@end] +exception Error of (Loc.t * t) * (Loc.t * t) list + +let error loc e = raise (Error ((loc, e), [])) + +module PP = struct + let error = function + | EnumBooleanMemberNotInitialized { enum_name; member_name } -> + Printf.sprintf + "Boolean enum members need to be initialized. Use either `%s = true,` or `%s = false,` in enum `%s`." + member_name + member_name + enum_name + | EnumDuplicateMemberName { enum_name; member_name } -> + Printf.sprintf + "Enum member names need to be unique, but the name `%s` has already been used before in enum `%s`." + member_name + enum_name + | EnumInconsistentMemberValues { enum_name } -> + Printf.sprintf + "Enum `%s` has inconsistent member initializers. Either use no initializers, or consistently use literals (either booleans, numbers, or strings) for all member initializers." + enum_name + | EnumInvalidExplicitType { enum_name; supplied_type } -> + let suggestion = + Printf.sprintf + "Use one of `boolean`, `number`, `string`, or `symbol` in enum `%s`." + enum_name + in + begin + match supplied_type with + | Some supplied_type -> + Printf.sprintf "Enum type `%s` is not valid. %s" supplied_type suggestion + | None -> Printf.sprintf "Supplied enum type is not valid. %s" suggestion + end + | EnumInvalidExport -> + "Cannot export an enum with `export type`, try `export enum E {}` or `module.exports = E;` instead." + | EnumInvalidInitializerSeparator { member_name } -> + Printf.sprintf + "Enum member names and initializers are separated with `=`. Replace `%s:` with `%s =`." + member_name + member_name + | EnumInvalidMemberInitializer { enum_name; explicit_type; member_name } -> begin + match explicit_type with + | Some (Enum_common.Boolean as explicit_type) + | Some (Enum_common.Number as explicit_type) + | Some (Enum_common.String as explicit_type) -> + let explicit_type_str = Enum_common.string_of_explicit_type explicit_type in + Printf.sprintf + "Enum `%s` has type `%s`, so the initializer of `%s` needs to be a %s literal." + enum_name + explicit_type_str + member_name + explicit_type_str + | Some Enum_common.Symbol -> + Printf.sprintf + "Symbol enum members cannot be initialized. Use `%s,` in enum `%s`." + member_name + enum_name + | None -> + Printf.sprintf + "The enum member initializer for `%s` needs to be a literal (either a boolean, number, or string) in enum `%s`." + member_name + enum_name + end + | EnumInvalidMemberName { enum_name; member_name } -> + (* Based on the error condition, we will only receive member names starting with [a-z] *) + let suggestion = String.capitalize_ascii member_name in + Printf.sprintf + "Enum member names cannot start with lowercase 'a' through 'z'. Instead of using `%s`, consider using `%s`, in enum `%s`." + member_name + suggestion + enum_name + | EnumInvalidMemberSeparator -> "Enum members are separated with `,`. Replace `;` with `,`." + | EnumInvalidEllipsis { trailing_comma } -> + if trailing_comma then + "The `...` must come at the end of the enum body. Remove the trailing comma." + else + "The `...` must come after all enum members. Move it to the end of the enum body." + | EnumNumberMemberNotInitialized { enum_name; member_name } -> + Printf.sprintf + "Number enum members need to be initialized, e.g. `%s = 1,` in enum `%s`." + member_name + enum_name + | EnumStringMemberInconsistentlyInitailized { enum_name } -> + Printf.sprintf + "String enum members need to consistently either all use initializers, or use no initializers, in enum %s." + enum_name + | Unexpected unexpected -> Printf.sprintf "Unexpected %s" unexpected + | UnexpectedWithExpected (unexpected, expected) -> + Printf.sprintf "Unexpected %s, expected %s" unexpected expected + | UnexpectedTokenWithSuggestion (token, suggestion) -> + Printf.sprintf "Unexpected token `%s`. Did you mean `%s`?" token suggestion + | UnexpectedReserved -> "Unexpected reserved word" + | UnexpectedReservedType -> "Unexpected reserved type" + | UnexpectedSuper -> "Unexpected `super` outside of a class method" + | UnexpectedSuperCall -> "`super()` is only valid in a class constructor" + | UnexpectedEOS -> "Unexpected end of input" + | UnexpectedVariance -> "Unexpected variance sigil" + | UnexpectedStatic -> "Unexpected static modifier" + | UnexpectedProto -> "Unexpected proto modifier" + | UnexpectedTypeAlias -> "Type aliases are not allowed in untyped mode" + | UnexpectedOpaqueTypeAlias -> "Opaque type aliases are not allowed in untyped mode" + | UnexpectedTypeAnnotation -> "Type annotations are not allowed in untyped mode" + | UnexpectedTypeDeclaration -> "Type declarations are not allowed in untyped mode" + | UnexpectedTypeImport -> "Type imports are not allowed in untyped mode" + | UnexpectedTypeExport -> "Type exports are not allowed in untyped mode" + | UnexpectedTypeInterface -> "Interfaces are not allowed in untyped mode" + | UnexpectedSpreadType -> "Spreading a type is only allowed inside an object type" + | UnexpectedExplicitInexactInObject -> + "Explicit inexact syntax must come at the end of an object type" + | InexactInsideExact -> + "Explicit inexact syntax cannot appear inside an explicit exact object type" + | InexactInsideNonObject -> "Explicit inexact syntax can only appear inside an object type" + | NewlineAfterThrow -> "Illegal newline after throw" + | InvalidFloatBigInt -> "A bigint literal must be an integer" + | InvalidSciBigInt -> "A bigint literal cannot use exponential notation" + | InvalidRegExp -> "Invalid regular expression" + | InvalidRegExpFlags flags -> "Invalid flags supplied to RegExp constructor '" ^ flags ^ "'" + | UnterminatedRegExp -> "Invalid regular expression: missing /" + | InvalidLHSInAssignment -> "Invalid left-hand side in assignment" + | InvalidLHSInExponentiation -> "Invalid left-hand side in exponentiation expression" + | InvalidLHSInForIn -> "Invalid left-hand side in for-in" + | InvalidLHSInForOf -> "Invalid left-hand side in for-of" + | InvalidIndexedAccess { has_bracket } -> + let msg = + if has_bracket then + "Remove the period." + else + "Indexed access uses bracket notation." + in + Printf.sprintf "Invalid indexed access. %s Use the format `T[K]`." msg + | InvalidOptionalIndexedAccess -> + "Invalid optional indexed access. Indexed access uses bracket notation. Use the format `T?.[K]`." + | ExpectedPatternFoundExpression -> + "Expected an object pattern, array pattern, or an identifier but " + ^ "found an expression instead" + | MultipleDefaultsInSwitch -> "More than one default clause in switch statement" + | NoCatchOrFinally -> "Missing catch or finally after try" + | UnknownLabel label -> "Undefined label '" ^ label ^ "'" + | Redeclaration (what, name) -> what ^ " '" ^ name ^ "' has already been declared" + | IllegalContinue -> "Illegal continue statement" + | IllegalBreak -> "Illegal break statement" + | IllegalReturn -> "Illegal return statement" + | IllegalUnicodeEscape -> "Illegal Unicode escape" + | StrictModeWith -> "Strict mode code may not include a with statement" + | StrictCatchVariable -> "Catch variable may not be eval or arguments in strict mode" + | StrictVarName -> "Variable name may not be eval or arguments in strict mode" + | StrictParamName -> "Parameter name eval or arguments is not allowed in strict mode" + | StrictParamDupe -> "Strict mode function may not have duplicate parameter names" + | StrictParamNotSimple -> + "Illegal \"use strict\" directive in function with non-simple parameter list" + | StrictFunctionName -> "Function name may not be eval or arguments in strict mode" + | StrictOctalLiteral -> "Octal literals are not allowed in strict mode." + | StrictNonOctalLiteral -> "Number literals with leading zeros are not allowed in strict mode." + | StrictDelete -> "Delete of an unqualified identifier in strict mode." + | StrictDuplicateProperty -> + "Duplicate data property in object literal not allowed in strict mode" + | AccessorDataProperty -> + "Object literal may not have data and accessor property with the same name" + | AccessorGetSet -> "Object literal may not have multiple get/set accessors with the same name" + | StrictLHSAssignment -> "Assignment to eval or arguments is not allowed in strict mode" + | StrictLHSPostfix -> + "Postfix increment/decrement may not have eval or arguments operand in strict mode" + | StrictLHSPrefix -> + "Prefix increment/decrement may not have eval or arguments operand in strict mode" + | StrictReservedWord -> "Use of future reserved word in strict mode" + | JSXAttributeValueEmptyExpression -> + "JSX attributes must only be assigned a non-empty expression" + | InvalidJSXAttributeValue -> "JSX value should be either an expression or a quoted JSX text" + | ExpectedJSXClosingTag name -> "Expected corresponding JSX closing tag for " ^ name + | NoUninitializedConst -> "Const must be initialized" + | NoUninitializedDestructuring -> "Destructuring assignment must be initialized" + | NewlineBeforeArrow -> "Illegal newline before arrow" + | FunctionAsStatement { in_strict_mode } -> + if in_strict_mode then + "In strict mode code, functions can only be declared at top level or " + ^ "immediately within another function." + else + "In non-strict mode code, functions can only be declared at top level, " + ^ "inside a block, or as the body of an if statement." + | AsyncFunctionAsStatement -> + "Async functions can only be declared at top level or " + ^ "immediately within another function." + | GeneratorFunctionAsStatement -> + "Generators can only be declared at top level or " ^ "immediately within another function." + | AdjacentJSXElements -> + "Unexpected token <. Remember, adjacent JSX " + ^ "elements must be wrapped in an enclosing parent tag" + | ParameterAfterRestParameter -> "Rest parameter must be final parameter of an argument list" + | ElementAfterRestElement -> "Rest element must be final element of an array pattern" + | PropertyAfterRestElement -> "Rest property must be final property of an object pattern" + | DeclareAsync -> + "async is an implementation detail and isn't necessary for your declare function statement. It is sufficient for your declare function to just have a Promise return type." + | DeclareClassElement -> "`declare` modifier can only appear on class fields." + | DeclareClassFieldInitializer -> + "Unexpected token `=`. Initializers are not allowed in a `declare`." + | DeclareOpaqueTypeInitializer -> + "Unexpected token `=`. Initializers are not allowed in a `declare opaque type`." + | DeclareExportLet -> "`declare export let` is not supported. Use `declare export var` instead." + | DeclareExportConst -> + "`declare export const` is not supported. Use `declare export var` instead." + | DeclareExportType -> "`declare export type` is not supported. Use `export type` instead." + | DeclareExportInterface -> + "`declare export interface` is not supported. Use `export interface` instead." + | DuplicateExport export -> Printf.sprintf "Duplicate export for `%s`" export + | UnsupportedDecorator -> "Found a decorator in an unsupported position." + | MissingTypeParamDefault -> + "Type parameter declaration needs a default, since a preceding type parameter declaration has a default." + | DuplicateDeclareModuleExports -> "Duplicate `declare module.exports` statement!" + | AmbiguousDeclareModuleKind -> + "Found both `declare module.exports` and `declare export` in the same module. Modules can only have 1 since they are either an ES module xor they are a CommonJS module." + | GetterArity -> "Getter should have zero parameters" + | SetterArity -> "Setter should have exactly one parameter" + | InvalidNonTypeImportInDeclareModule -> + "Imports within a `declare module` body must always be " ^ "`import type` or `import typeof`!" + | ImportTypeShorthandOnlyInPureImport -> + "The `type` and `typeof` keywords on named imports can only be used on regular `import` statements. It cannot be used with `import type` or `import typeof` statements" + | ImportSpecifierMissingComma -> "Missing comma between import specifiers" + | ExportSpecifierMissingComma -> "Missing comma between export specifiers" + | MalformedUnicode -> "Malformed unicode" + | DuplicateConstructor -> "Classes may only have one constructor" + | DuplicatePrivateFields name -> + "Private fields may only be declared once. `#" ^ name ^ "` is declared more than once." + | InvalidClassMemberName { name; static; method_; private_ } -> + let static_modifier = + if static then + "static " + else + "" + in + let name = + if private_ then + "#" ^ name + else + name + in + let category = + if method_ then + "methods" + else + "fields" + in + "Classes may not have " ^ static_modifier ^ category ^ " named `" ^ name ^ "`." + | PrivateDelete -> "Private fields may not be deleted." + | UnboundPrivate name -> + "Private fields must be declared before they can be referenced. `#" + ^ name + ^ "` has not been declared." + | PrivateNotInClass -> "Private fields can only be referenced from within a class." + | SuperPrivate -> "You may not access a private field through the `super` keyword." + | YieldInFormalParameters -> "Yield expression not allowed in formal parameter" + | AwaitAsIdentifierReference -> "`await` is an invalid identifier in async functions" + | YieldAsIdentifierReference -> "`yield` is an invalid identifier in generators" + | AmbiguousLetBracket -> + "`let [` is ambiguous in this position because it is " + ^ "either a `let` binding pattern, or a member expression." + | LiteralShorthandProperty -> "Literals cannot be used as shorthand properties." + | ComputedShorthandProperty -> "Computed properties must have a value." + | MethodInDestructuring -> "Object pattern can't contain methods" + | TrailingCommaAfterRestElement -> "A trailing comma is not permitted after the rest element" + | OptionalChainNew -> "An optional chain may not be used in a `new` expression." + | OptionalChainTemplate -> "Template literals may not be used in an optional chain." + | NullishCoalescingUnexpectedLogical operator -> + Printf.sprintf + "Unexpected token `%s`. Parentheses are required to combine `??` with `&&` or `||` expressions." + operator + | WhitespaceInPrivateName -> "Unexpected whitespace between `#` and identifier" + | ThisParamAnnotationRequired -> "A type annotation is required for the `this` parameter." + | ThisParamMustBeFirst -> "The `this` parameter must be the first function parameter." + | ThisParamMayNotBeOptional -> "The `this` parameter cannot be optional." + | GetterMayNotHaveThisParam -> "A getter cannot have a `this` parameter." + | SetterMayNotHaveThisParam -> "A setter cannot have a `this` parameter." + | ThisParamBannedInArrowFunctions -> + "Arrow functions cannot have a `this` parameter; arrow functions automatically bind `this` when declared." + | ThisParamBannedInConstructor -> + "Constructors cannot have a `this` parameter; constructors don't bind `this` like other functions." + | InvalidTypeof -> "`typeof` can only be used to get the type of variables." +end diff --git a/analysis/vendor/js_parser/parser_common.ml b/analysis/vendor/js_parser/parser_common.ml new file mode 100644 index 000000000..8da6dae3f --- /dev/null +++ b/analysis/vendor/js_parser/parser_common.ml @@ -0,0 +1,232 @@ +(* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) + +open Parser_env +open Flow_ast + +type pattern_errors = { + if_expr: (Loc.t * Parse_error.t) list; + if_patt: (Loc.t * Parse_error.t) list; +} + +type pattern_cover = + | Cover_expr of (Loc.t, Loc.t) Expression.t + | Cover_patt of (Loc.t, Loc.t) Expression.t * pattern_errors + +module type PARSER = sig + val program : env -> (Loc.t, Loc.t) Program.t + + val statement : env -> (Loc.t, Loc.t) Statement.t + + val statement_list_item : + ?decorators:(Loc.t, Loc.t) Class.Decorator.t list -> env -> (Loc.t, Loc.t) Statement.t + + val statement_list : term_fn:(Token.t -> bool) -> env -> (Loc.t, Loc.t) Statement.t list + + val statement_list_with_directives : + term_fn:(Token.t -> bool) -> env -> (Loc.t, Loc.t) Statement.t list * bool + + val module_body : term_fn:(Token.t -> bool) -> env -> (Loc.t, Loc.t) Statement.t list + + val expression : env -> (Loc.t, Loc.t) Expression.t + + val expression_or_pattern : env -> pattern_cover + + val conditional : env -> (Loc.t, Loc.t) Expression.t + + val assignment : env -> (Loc.t, Loc.t) Expression.t + + val left_hand_side : env -> (Loc.t, Loc.t) Expression.t + + val object_initializer : env -> Loc.t * (Loc.t, Loc.t) Expression.Object.t * pattern_errors + + val identifier : ?restricted_error:Parse_error.t -> env -> (Loc.t, Loc.t) Identifier.t + + val identifier_with_type : + env -> ?no_optional:bool -> Parse_error.t -> Loc.t * (Loc.t, Loc.t) Pattern.Identifier.t + + val block_body : env -> Loc.t * (Loc.t, Loc.t) Statement.Block.t + + val function_block_body : + expression:bool -> env -> (Loc.t * (Loc.t, Loc.t) Statement.Block.t) * bool + + val jsx_element_or_fragment : + env -> + Loc.t * [ `Element of (Loc.t, Loc.t) JSX.element | `Fragment of (Loc.t, Loc.t) JSX.fragment ] + + val pattern : env -> Parse_error.t -> (Loc.t, Loc.t) Pattern.t + + val pattern_from_expr : env -> (Loc.t, Loc.t) Expression.t -> (Loc.t, Loc.t) Pattern.t + + val object_key : ?class_body:bool -> env -> Loc.t * (Loc.t, Loc.t) Expression.Object.Property.key + + val class_declaration : env -> (Loc.t, Loc.t) Class.Decorator.t list -> (Loc.t, Loc.t) Statement.t + + val class_expression : env -> (Loc.t, Loc.t) Expression.t + + val is_assignable_lhs : (Loc.t, Loc.t) Expression.t -> bool + + val number : env -> Token.number_type -> string -> float + + val annot : env -> (Loc.t, Loc.t) Type.annotation +end + +let identifier_name_raw env = + let open Token in + let name = + match Peek.token env with + (* obviously, Identifier is a valid IdentifierName *) + | T_IDENTIFIER { value; _ } -> value + (* keywords are also IdentifierNames *) + | T_AWAIT -> "await" + | T_BREAK -> "break" + | T_CASE -> "case" + | T_CATCH -> "catch" + | T_CLASS -> "class" + | T_CONST -> "const" + | T_CONTINUE -> "continue" + | T_DEBUGGER -> "debugger" + | T_DEFAULT -> "default" + | T_DELETE -> "delete" + | T_DO -> "do" + | T_ELSE -> "else" + | T_EXPORT -> "export" + | T_EXTENDS -> "extends" + | T_FINALLY -> "finally" + | T_FOR -> "for" + | T_FUNCTION -> "function" + | T_IF -> "if" + | T_IMPORT -> "import" + | T_IN -> "in" + | T_INSTANCEOF -> "instanceof" + | T_NEW -> "new" + | T_RETURN -> "return" + | T_SUPER -> "super" + | T_SWITCH -> "switch" + | T_THIS -> "this" + | T_THROW -> "throw" + | T_TRY -> "try" + | T_TYPEOF -> "typeof" + | T_VAR -> "var" + | T_VOID -> "void" + | T_WHILE -> "while" + | T_WITH -> "with" + | T_YIELD -> "yield" + (* FutureReservedWord *) + | T_ENUM -> "enum" + | T_LET -> "let" + | T_STATIC -> "static" + | T_INTERFACE -> "interface" + | T_IMPLEMENTS -> "implements" + | T_PACKAGE -> "package" + | T_PRIVATE -> "private" + | T_PROTECTED -> "protected" + | T_PUBLIC -> "public" + (* NullLiteral *) + | T_NULL -> "null" + (* BooleanLiteral *) + | T_TRUE -> "true" + | T_FALSE -> "false" + (* Flow-specific stuff *) + | T_DECLARE -> "declare" + | T_TYPE -> "type" + | T_OPAQUE -> "opaque" + | T_ANY_TYPE -> "any" + | T_MIXED_TYPE -> "mixed" + | T_EMPTY_TYPE -> "empty" + | T_BOOLEAN_TYPE BOOL -> "bool" + | T_BOOLEAN_TYPE BOOLEAN -> "boolean" + | T_NUMBER_TYPE -> "number" + | T_BIGINT_TYPE -> "bigint" + | T_STRING_TYPE -> "string" + | T_VOID_TYPE -> "void" + | T_SYMBOL_TYPE -> "symbol" + (* Contextual stuff *) + | T_OF -> "of" + | T_ASYNC -> "async" + (* punctuators, types, literals, etc are not identifiers *) + | _ -> + error_unexpected ~expected:"an identifier" env; + "" + in + Eat.token env; + name + +(* IdentifierName - https://tc39.github.io/ecma262/#prod-IdentifierName *) +let identifier_name env = + let loc = Peek.loc env in + let leading = Peek.comments env in + let name = identifier_name_raw env in + let trailing = Eat.trailing_comments env in + let comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing () in + (loc, { Identifier.name; comments }) + +(** PrivateIdentifier - https://tc39.es/ecma262/#prod-PrivateIdentifier + + N.B.: whitespace, line terminators, and comments are not allowed + between the # and IdentifierName because PrivateIdentifier is a + CommonToken which is considered a single token. See also + https://tc39.es/ecma262/#prod-InputElementDiv *) +let private_identifier env = + let start_loc = Peek.loc env in + let leading = Peek.comments env in + Expect.token env Token.T_POUND; + let name_loc = Peek.loc env in + let name = identifier_name_raw env in + let trailing = Eat.trailing_comments env in + let comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing () in + let loc = Loc.btwn start_loc name_loc in + if not (Loc.equal_position start_loc.Loc._end name_loc.Loc.start) then + error_at env (loc, Parse_error.WhitespaceInPrivateName); + (loc, { PrivateName.name; comments }) + +(** The operation IsSimpleParamterList + https://tc39.es/ecma262/#sec-static-semantics-issimpleparameterlist *) +let is_simple_parameter_list = + let is_simple_param = function + | (_, { Flow_ast.Function.Param.argument = (_, Pattern.Identifier _); default = None }) -> true + | _ -> false + in + fun (_, { Flow_ast.Function.Params.params; rest; comments = _; this_ = _ }) -> + rest = None && List.for_all is_simple_param params + +(** + * The abstract operation IsLabelledFunction + * + * https://tc39.github.io/ecma262/#sec-islabelledfunction + *) +let rec is_labelled_function = function + | (_, Flow_ast.Statement.Labeled { Flow_ast.Statement.Labeled.body; _ }) -> + begin + match body with + | (_, Flow_ast.Statement.FunctionDeclaration _) -> true + | _ -> is_labelled_function body + end + | _ -> false + +let with_loc ?start_loc fn env = + let start_loc = + match start_loc with + | Some x -> x + | None -> Peek.loc env + in + let result = fn env in + let loc = + match last_loc env with + | Some end_loc -> Loc.btwn start_loc end_loc + | None -> start_loc + in + (loc, result) + +let with_loc_opt ?start_loc fn env = + match with_loc ?start_loc fn env with + | (loc, Some x) -> Some (loc, x) + | (_, None) -> None + +let with_loc_extra ?start_loc fn env = + let (loc, (x, extra)) = with_loc ?start_loc fn env in + ((loc, x), extra) diff --git a/analysis/vendor/js_parser/parser_env.ml b/analysis/vendor/js_parser/parser_env.ml new file mode 100644 index 000000000..939761d31 --- /dev/null +++ b/analysis/vendor/js_parser/parser_env.ml @@ -0,0 +1,1184 @@ +(* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) + +module Sedlexing = Flow_sedlexing +open Flow_ast +module SSet = Set.Make (String) + +module Lex_mode = struct + type t = + | NORMAL + | TYPE + | JSX_TAG + | JSX_CHILD + | TEMPLATE + | REGEXP + + let debug_string_of_lex_mode (mode : t) = + match mode with + | NORMAL -> "NORMAL" + | TYPE -> "TYPE" + | JSX_TAG -> "JSX_TAG" + | JSX_CHILD -> "JSX_CHILD" + | TEMPLATE -> "TEMPLATE" + | REGEXP -> "REGEXP" +end + +(* READ THIS BEFORE YOU MODIFY: + * + * The current implementation for lookahead beyond a single token is + * inefficient. If you believe you need to increase this constant, do one of the + * following: + * - Find another way + * - Benchmark your change and provide convincing evidence that it doesn't + * actually have a significant perf impact. + * - Refactor this to memoize all requested lookahead, so we aren't lexing the + * same token multiple times. + *) + +module Lookahead : sig + type t + + val create : Lex_env.t -> Lex_mode.t -> t + val peek_0 : t -> Lex_result.t + val peek_1 : t -> Lex_result.t + val lex_env_0 : t -> Lex_env.t + val junk : t -> unit +end = struct + type la_result = (Lex_env.t * Lex_result.t) option + + type t = { + mutable la_results_0: la_result; + mutable la_results_1: la_result; + la_lex_mode: Lex_mode.t; + mutable la_lex_env: Lex_env.t; + } + + let create lex_env mode = + let lex_env = Lex_env.clone lex_env in + { la_results_0 = None; la_results_1 = None; la_lex_mode = mode; la_lex_env = lex_env } + + (* precondition: there is enough room in t.la_results for the result *) + let lex t = + let lex_env = t.la_lex_env in + let (lex_env, lex_result) = + match t.la_lex_mode with + | Lex_mode.NORMAL -> Flow_lexer.token lex_env + | Lex_mode.TYPE -> Flow_lexer.type_token lex_env + | Lex_mode.JSX_TAG -> Flow_lexer.jsx_tag lex_env + | Lex_mode.JSX_CHILD -> Flow_lexer.jsx_child lex_env + | Lex_mode.TEMPLATE -> Flow_lexer.template_tail lex_env + | Lex_mode.REGEXP -> Flow_lexer.regexp lex_env + in + let cloned_env = Lex_env.clone lex_env in + let result = (cloned_env, lex_result) in + t.la_lex_env <- lex_env; + begin + match t.la_results_0 with + | None -> t.la_results_0 <- Some result + | Some _ -> t.la_results_1 <- Some result + end; + result + + let peek_0 t = + match t.la_results_0 with + | Some (_, result) -> result + | None -> snd (lex t) + + let peek_1 t = + (match t.la_results_0 with + | None -> ignore (lex t) + | Some _ -> ()); + match t.la_results_1 with + | None -> snd (lex t) + | Some (_, result) -> result + + let lex_env_0 t = + match t.la_results_0 with + | Some (lex_env, _) -> lex_env + | None -> fst (lex t) + + (* Throws away the first peeked-at token, shifting any subsequent tokens up *) + let junk t = + match t.la_results_1 with + | None -> + ignore (peek_0 t); + t.la_results_0 <- None + | Some _ -> + t.la_results_0 <- t.la_results_1; + t.la_results_1 <- None +end + +type token_sink_result = { + token_loc: Loc.t; + token: Token.t; + token_context: Lex_mode.t; +} + +type parse_options = { + enums: bool; (** enable parsing of Flow enums *) + esproposal_decorators: bool; (** enable parsing of decorators *) + types: bool; (** enable parsing of Flow types *) + use_strict: bool; (** treat the file as strict, without needing a "use strict" directive *) +} + +let default_parse_options = + { enums = false; esproposal_decorators = false; types = true; use_strict = false } + +type allowed_super = + | No_super + | Super_prop + | Super_prop_or_call + +type env = { + errors: (Loc.t * Parse_error.t) list ref; + comments: Loc.t Comment.t list ref; + labels: SSet.t; + last_lex_result: Lex_result.t option ref; + in_strict_mode: bool; + in_export: bool; + in_export_default: bool; + in_loop: bool; + in_switch: bool; + in_formal_parameters: bool; + in_function: bool; + no_in: bool; + no_call: bool; + no_let: bool; + no_anon_function_type: bool; + no_new: bool; + allow_yield: bool; + allow_await: bool; + allow_directive: bool; + has_simple_parameters: bool; + allow_super: allowed_super; + error_callback: (env -> Parse_error.t -> unit) option; + lex_mode_stack: Lex_mode.t list ref; + (* lex_env is the lex_env after the single lookahead has been lexed *) + lex_env: Lex_env.t ref; + (* This needs to be cleared whenever we advance. *) + lookahead: Lookahead.t ref; + token_sink: (token_sink_result -> unit) option ref; + parse_options: parse_options; + source: File_key.t option; + (* It is a syntax error to reference private fields not in scope. In order to enforce this, + * we keep track of the privates we've seen declared and used. *) + privates: (SSet.t * (string * Loc.t) list) list ref; + (* The position up to which comments have been consumed, exclusive. *) + consumed_comments_pos: Loc.position ref; +} + +(* constructor *) +let init_env ?(token_sink = None) ?(parse_options = None) source content = + (* let lb = Sedlexing.Utf16.from_string + content (Some Sedlexing.Utf16.Little_endian) in *) + let (lb, errors) = + try (Sedlexing.Utf8.from_string content, []) with + | Sedlexing.MalFormed -> + (Sedlexing.Utf8.from_string "", [({ Loc.none with Loc.source }, Parse_error.MalformedUnicode)]) + in + let parse_options = + match parse_options with + | Some opts -> opts + | None -> default_parse_options + in + let enable_types_in_comments = parse_options.types in + let lex_env = Lex_env.new_lex_env source lb ~enable_types_in_comments in + { + errors = ref errors; + comments = ref []; + labels = SSet.empty; + last_lex_result = ref None; + has_simple_parameters = true; + in_strict_mode = parse_options.use_strict; + in_export = false; + in_export_default = false; + in_loop = false; + in_switch = false; + in_formal_parameters = false; + in_function = false; + no_in = false; + no_call = false; + no_let = false; + no_anon_function_type = false; + no_new = false; + allow_yield = false; + allow_await = false; + allow_directive = false; + allow_super = No_super; + error_callback = None; + lex_mode_stack = ref [Lex_mode.NORMAL]; + lex_env = ref lex_env; + lookahead = ref (Lookahead.create lex_env Lex_mode.NORMAL); + token_sink = ref token_sink; + parse_options; + source; + privates = ref []; + consumed_comments_pos = ref { Loc.line = 0; column = 0 }; + } + +(* getters: *) +let in_strict_mode env = env.in_strict_mode +let lex_mode env = List.hd !(env.lex_mode_stack) +let in_export env = env.in_export +let in_export_default env = env.in_export_default +let comments env = !(env.comments) +let labels env = env.labels +let in_loop env = env.in_loop +let in_switch env = env.in_switch +let in_formal_parameters env = env.in_formal_parameters +let in_function env = env.in_function +let allow_yield env = env.allow_yield +let allow_await env = env.allow_await +let allow_directive env = env.allow_directive +let allow_super env = env.allow_super +let has_simple_parameters env = env.has_simple_parameters +let no_in env = env.no_in +let no_call env = env.no_call +let no_let env = env.no_let +let no_anon_function_type env = env.no_anon_function_type +let no_new env = env.no_new +let errors env = !(env.errors) +let parse_options env = env.parse_options +let source env = env.source +let should_parse_types env = env.parse_options.types + +(* mutators: *) +let error_at env (loc, e) = + env.errors := (loc, e) :: !(env.errors); + match env.error_callback with + | None -> () + | Some callback -> callback env e + +(* Since private fields out of scope are a parse error, we keep track of the declared and used + * private fields. + * + * Whenever we enter a class, we push new empty lists of declared and used privates. + * When we encounter a new declared private, we add it to the top of the declared_privates list + * via add_declared_private. We do the same with used_privates via add_used_private. + * + * When we exit a class, we look for all the unbound private variables. Since class fields + * are hoisted to the scope of the class, we may need to look further before we conclude that + * a field is out of scope. To do that, we add all of the unbound private fields to the + * next used_private list. Once we run out of declared private lists, any leftover used_privates + * are unbound private variables. *) +let enter_class env = env.privates := (SSet.empty, []) :: !(env.privates) + +let exit_class env = + let get_unbound_privates declared_privates used_privates = + List.filter (fun x -> not (SSet.mem (fst x) declared_privates)) used_privates + in + match !(env.privates) with + | [(declared_privates, used_privates)] -> + let unbound_privates = get_unbound_privates declared_privates used_privates in + List.iter + (fun (name, loc) -> error_at env (loc, Parse_error.UnboundPrivate name)) + unbound_privates; + env.privates := [] + | (loc_declared_privates, loc_used_privates) :: privates -> + let unbound_privates = get_unbound_privates loc_declared_privates loc_used_privates in + let (decl_head, used_head) = List.hd privates in + env.privates := (decl_head, used_head @ unbound_privates) :: List.tl privates + | _ -> failwith "Internal Error: `exit_class` called before a matching `enter_class`" + +let add_declared_private env name = + match !(env.privates) with + | [] -> failwith "Internal Error: Tried to add_declared_private with outside of class scope." + | (declared, used) :: xs -> env.privates := (SSet.add name declared, used) :: xs + +let add_used_private env name loc = + match !(env.privates) with + | [] -> error_at env (loc, Parse_error.PrivateNotInClass) + | (declared, used) :: xs -> env.privates := (declared, (name, loc) :: used) :: xs + +let consume_comments_until env pos = env.consumed_comments_pos := pos + +(* lookahead: *) +let lookahead_0 env = Lookahead.peek_0 !(env.lookahead) +let lookahead_1 env = Lookahead.peek_1 !(env.lookahead) + +let lookahead ~i env = + match i with + | 0 -> lookahead_0 env + | 1 -> lookahead_1 env + | _ -> assert false + +(* functional operations: *) +let with_strict in_strict_mode env = + if in_strict_mode = env.in_strict_mode then + env + else + { env with in_strict_mode } + +let with_in_formal_parameters in_formal_parameters env = + if in_formal_parameters = env.in_formal_parameters then + env + else + { env with in_formal_parameters } + +let with_in_function in_function env = + if in_function = env.in_function then + env + else + { env with in_function } + +let with_allow_yield allow_yield env = + if allow_yield = env.allow_yield then + env + else + { env with allow_yield } + +let with_allow_await allow_await env = + if allow_await = env.allow_await then + env + else + { env with allow_await } + +let with_allow_directive allow_directive env = + if allow_directive = env.allow_directive then + env + else + { env with allow_directive } + +let with_allow_super allow_super env = + if allow_super = env.allow_super then + env + else + { env with allow_super } + +let with_no_let no_let env = + if no_let = env.no_let then + env + else + { env with no_let } + +let with_in_loop in_loop env = + if in_loop = env.in_loop then + env + else + { env with in_loop } + +let with_no_in no_in env = + if no_in = env.no_in then + env + else + { env with no_in } + +let with_no_anon_function_type no_anon_function_type env = + if no_anon_function_type = env.no_anon_function_type then + env + else + { env with no_anon_function_type } + +let with_no_new no_new env = + if no_new = env.no_new then + env + else + { env with no_new } + +let with_in_switch in_switch env = + if in_switch = env.in_switch then + env + else + { env with in_switch } + +let with_in_export in_export env = + if in_export = env.in_export then + env + else + { env with in_export } + +let with_in_export_default in_export_default env = + if in_export_default = env.in_export_default then + env + else + { env with in_export_default } + +let with_no_call no_call env = + if no_call = env.no_call then + env + else + { env with no_call } + +let with_error_callback error_callback env = { env with error_callback = Some error_callback } + +(* other helper functions: *) +let error_list env = List.iter (error_at env) + +let last_loc env = + match !(env.last_lex_result) with + | Some lex_result -> Some (Lex_result.loc lex_result) + | None -> None + +let last_token env = + match !(env.last_lex_result) with + | Some lex_result -> Some (Lex_result.token lex_result) + | None -> None + +let without_error_callback env = { env with error_callback = None } +let add_label env label = { env with labels = SSet.add label env.labels } + +let enter_function env ~async ~generator ~simple_params = + { + env with + in_formal_parameters = false; + has_simple_parameters = simple_params; + in_function = true; + in_loop = false; + in_switch = false; + in_export = false; + in_export_default = false; + labels = SSet.empty; + allow_await = async; + allow_yield = generator; + } + +(* #sec-keywords *) +let is_keyword = function + | "await" + | "break" + | "case" + | "catch" + | "class" + | "const" + | "continue" + | "debugger" + | "default" + | "delete" + | "do" + | "else" + | "export" + | "extends" + | "finally" + | "for" + | "function" + | "if" + | "import" + | "in" + | "instanceof" + | "new" + | "return" + | "super" + | "switch" + | "this" + | "throw" + | "try" + | "typeof" + | "var" + | "void" + | "while" + | "with" + | "yield" -> + true + | _ -> false + +let token_is_keyword = + Token.( + function + | T_IDENTIFIER { raw; _ } when is_keyword raw -> true + | T_AWAIT + | T_BREAK + | T_CASE + | T_CATCH + | T_CLASS + | T_CONST + | T_CONTINUE + | T_DEBUGGER + | T_DEFAULT + | T_DELETE + | T_DO + | T_ELSE + | T_EXPORT + | T_EXTENDS + | T_FINALLY + | T_FOR + | T_FUNCTION + | T_IF + | T_IMPORT + | T_IN + | T_INSTANCEOF + | T_NEW + | T_RETURN + | T_SUPER + | T_SWITCH + | T_THIS + | T_THROW + | T_TRY + | T_TYPEOF + | T_VAR + | T_VOID + | T_WHILE + | T_WITH + | T_YIELD -> + true + | _ -> false + ) + +(* #sec-future-reserved-words *) +let is_future_reserved = function + | "enum" -> true + | _ -> false + +let token_is_future_reserved = + Token.( + function + | T_IDENTIFIER { raw; _ } when is_future_reserved raw -> true + | T_ENUM -> true + | _ -> false + ) + +(* #sec-strict-mode-of-ecmascript *) +let is_strict_reserved = function + | "interface" + | "implements" + | "package" + | "private" + | "protected" + | "public" + | "static" + | "yield" -> + true + | _ -> false + +let token_is_strict_reserved = + Token.( + function + | T_IDENTIFIER { raw; _ } when is_strict_reserved raw -> true + | T_INTERFACE + | T_IMPLEMENTS + | T_PACKAGE + | T_PRIVATE + | T_PROTECTED + | T_PUBLIC + | T_STATIC + | T_YIELD -> + true + | _ -> false + ) + +(* #sec-strict-mode-of-ecmascript *) +let is_restricted = function + | "eval" + | "arguments" -> + true + | _ -> false + +let token_is_restricted = + Token.( + function + | T_IDENTIFIER { raw; _ } when is_restricted raw -> true + | _ -> false + ) + +(* #sec-reserved-words *) +let is_reserved str_val = + is_keyword str_val + || is_future_reserved str_val + || + match str_val with + | "null" + | "true" + | "false" -> + true + | _ -> false + +let token_is_reserved t = + token_is_keyword t + || token_is_future_reserved t + || + match t with + | Token.T_IDENTIFIER { raw = "null" | "true" | "false"; _ } + | Token.T_NULL + | Token.T_TRUE + | Token.T_FALSE -> + true + | _ -> false + +let is_reserved_type str_val = + match str_val with + | "any" + | "bool" + | "boolean" + | "empty" + | "false" + | "mixed" + | "null" + | "number" + | "bigint" + | "static" + | "string" + | "true" + | "typeof" + | "void" + | "interface" + | "extends" + | "_" -> + true + | _ -> false + +(* Answer questions about what comes next *) +module Peek = struct + open Loc + open Token + + let ith_token ~i env = Lex_result.token (lookahead ~i env) + let ith_loc ~i env = Lex_result.loc (lookahead ~i env) + let ith_errors ~i env = Lex_result.errors (lookahead ~i env) + + let ith_comments ~i env = + let comments = Lex_result.comments (lookahead ~i env) in + match comments with + | [] -> [] + | _ -> + List.filter + (fun ({ Loc.start; _ }, _) -> Loc.pos_cmp !(env.consumed_comments_pos) start <= 0) + comments + + let token env = ith_token ~i:0 env + let loc env = ith_loc ~i:0 env + + (* loc_skip_lookahead is used to give a loc hint to optional tokens such as type annotations *) + let loc_skip_lookahead env = + let loc = + match last_loc env with + | Some loc -> loc + | None -> failwith "Peeking current location when not available" + in + Loc.{ loc with start = loc._end } + + let errors env = ith_errors ~i:0 env + let comments env = ith_comments ~i:0 env + + let has_eaten_comments env = + let comments = Lex_result.comments (lookahead ~i:0 env) in + List.exists + (fun ({ Loc.start; _ }, _) -> Loc.pos_cmp start !(env.consumed_comments_pos) < 0) + comments + + let lex_env env = Lookahead.lex_env_0 !(env.lookahead) + + (* True if there is a line terminator before the next token *) + let ith_is_line_terminator ~i env = + let loc = + if i > 0 then + Some (ith_loc ~i:(i - 1) env) + else + last_loc env + in + match loc with + | None -> false + | Some loc' -> (ith_loc ~i env).start.line > loc'.start.line + + let is_line_terminator env = ith_is_line_terminator ~i:0 env + + let ith_is_implicit_semicolon ~i env = + match ith_token ~i env with + | T_EOF + | T_RCURLY -> + true + | T_SEMICOLON -> false + | _ -> ith_is_line_terminator ~i env + + let is_implicit_semicolon env = ith_is_implicit_semicolon ~i:0 env + + let ith_is_identifier ~i env = + match ith_token ~i env with + | t when token_is_strict_reserved t -> true + | t when token_is_future_reserved t -> true + | t when token_is_restricted t -> true + | T_LET + | T_TYPE + | T_OPAQUE + | T_OF + | T_DECLARE + | T_ASYNC + | T_AWAIT + | T_POUND + | T_IDENTIFIER _ -> + true + | _ -> false + + let ith_is_type_identifier ~i env = + match lex_mode env with + | Lex_mode.TYPE -> begin + match ith_token ~i env with + | T_IDENTIFIER _ -> true + | _ -> false + end + | Lex_mode.NORMAL -> begin + (* Sometimes we peek at type identifiers while in normal lex mode. For + example, when deciding whether a `type` token is an identifier or the + start of a type declaration, based on whether the following token + `is_type_identifier`. *) + match ith_token ~i env with + | T_IDENTIFIER { raw; _ } when is_reserved_type raw -> false + (* reserved type identifiers, but these don't appear in NORMAL mode *) + | T_ANY_TYPE + | T_MIXED_TYPE + | T_EMPTY_TYPE + | T_NUMBER_TYPE + | T_BIGINT_TYPE + | T_STRING_TYPE + | T_VOID_TYPE + | T_SYMBOL_TYPE + | T_BOOLEAN_TYPE _ + | T_NUMBER_SINGLETON_TYPE _ + | T_BIGINT_SINGLETON_TYPE _ + (* identifier-ish *) + | T_ASYNC + | T_AWAIT + | T_BREAK + | T_CASE + | T_CATCH + | T_CLASS + | T_CONST + | T_CONTINUE + | T_DEBUGGER + | T_DECLARE + | T_DEFAULT + | T_DELETE + | T_DO + | T_ELSE + | T_ENUM + | T_EXPORT + | T_EXTENDS + | T_FALSE + | T_FINALLY + | T_FOR + | T_FUNCTION + | T_IDENTIFIER _ + | T_IF + | T_IMPLEMENTS + | T_IMPORT + | T_IN + | T_INSTANCEOF + | T_INTERFACE + | T_LET + | T_NEW + | T_NULL + | T_OF + | T_OPAQUE + | T_PACKAGE + | T_PRIVATE + | T_PROTECTED + | T_PUBLIC + | T_RETURN + | T_SUPER + | T_SWITCH + | T_THIS + | T_THROW + | T_TRUE + | T_TRY + | T_TYPE + | T_VAR + | T_WHILE + | T_WITH + | T_YIELD -> + true + (* identifier-ish, but not valid types *) + | T_STATIC + | T_TYPEOF + | T_VOID -> + false + (* syntax *) + | T_LCURLY + | T_RCURLY + | T_LCURLYBAR + | T_RCURLYBAR + | T_LPAREN + | T_RPAREN + | T_LBRACKET + | T_RBRACKET + | T_SEMICOLON + | T_COMMA + | T_PERIOD + | T_ARROW + | T_ELLIPSIS + | T_AT + | T_POUND + | T_CHECKS + | T_RSHIFT3_ASSIGN + | T_RSHIFT_ASSIGN + | T_LSHIFT_ASSIGN + | T_BIT_XOR_ASSIGN + | T_BIT_OR_ASSIGN + | T_BIT_AND_ASSIGN + | T_MOD_ASSIGN + | T_DIV_ASSIGN + | T_MULT_ASSIGN + | T_EXP_ASSIGN + | T_MINUS_ASSIGN + | T_PLUS_ASSIGN + | T_NULLISH_ASSIGN + | T_AND_ASSIGN + | T_OR_ASSIGN + | T_ASSIGN + | T_PLING_PERIOD + | T_PLING_PLING + | T_PLING + | T_COLON + | T_OR + | T_AND + | T_BIT_OR + | T_BIT_XOR + | T_BIT_AND + | T_EQUAL + | T_NOT_EQUAL + | T_STRICT_EQUAL + | T_STRICT_NOT_EQUAL + | T_LESS_THAN_EQUAL + | T_GREATER_THAN_EQUAL + | T_LESS_THAN + | T_GREATER_THAN + | T_LSHIFT + | T_RSHIFT + | T_RSHIFT3 + | T_PLUS + | T_MINUS + | T_DIV + | T_MULT + | T_EXP + | T_MOD + | T_NOT + | T_BIT_NOT + | T_INCR + | T_DECR + | T_EOF -> + false + (* literals *) + | T_NUMBER _ + | T_BIGINT _ + | T_STRING _ + | T_TEMPLATE_PART _ + | T_REGEXP _ + (* misc that shouldn't appear in NORMAL mode *) + | T_JSX_IDENTIFIER _ + | T_JSX_TEXT _ + | T_ERROR _ -> + false + end + | Lex_mode.JSX_TAG + | Lex_mode.JSX_CHILD + | Lex_mode.TEMPLATE + | Lex_mode.REGEXP -> + false + + let ith_is_identifier_name ~i env = ith_is_identifier ~i env || ith_is_type_identifier ~i env + + (* This returns true if the next token is identifier-ish (even if it is an + error) *) + let is_identifier env = ith_is_identifier ~i:0 env + let is_identifier_name env = ith_is_identifier_name ~i:0 env + let is_type_identifier env = ith_is_type_identifier ~i:0 env + + let is_function env = + token env = T_FUNCTION + || token env = T_ASYNC + && ith_token ~i:1 env = T_FUNCTION + && (loc env)._end.line = (ith_loc ~i:1 env).start.line + + let is_class env = + match token env with + | T_CLASS + | T_AT -> + true + | _ -> false +end + +(*****************************************************************************) +(* Errors *) +(*****************************************************************************) + +(* Complains about an error at the location of the lookahead *) +let error env e = + let loc = Peek.loc env in + error_at env (loc, e) + +let get_unexpected_error ?expected token = + if token_is_future_reserved token then + Parse_error.UnexpectedReserved + else if token_is_strict_reserved token then + Parse_error.StrictReservedWord + else + let unexpected = Token.explanation_of_token token in + match expected with + | Some expected_msg -> Parse_error.UnexpectedWithExpected (unexpected, expected_msg) + | None -> Parse_error.Unexpected unexpected + +let error_unexpected ?expected env = + (* So normally we consume the lookahead lex result when Eat.token calls + * Parser_env.advance, which will add any lexing errors to our list of errors. + * However, raising an unexpected error for a lookahead is kind of like + * consuming that token, so we should process any lexing errors before + * complaining about the unexpected token *) + error_list env (Peek.errors env); + error env (get_unexpected_error ?expected (Peek.token env)) + +let error_on_decorators env = + List.iter (fun decorator -> error_at env (fst decorator, Parse_error.UnsupportedDecorator)) + +let error_nameless_declaration env kind = + let expected = + if in_export env then + Printf.sprintf + "an identifier. When exporting a %s as a named export, you must specify a %s name. Did you mean `export default %s ...`?" + kind + kind + kind + else + "an identifier" + in + error_unexpected ~expected env + +let strict_error env e = if in_strict_mode env then error env e +let strict_error_at env (loc, e) = if in_strict_mode env then error_at env (loc, e) + +let function_as_statement_error_at env loc = + error_at env (loc, Parse_error.FunctionAsStatement { in_strict_mode = in_strict_mode env }) + +(* Consume zero or more tokens *) +module Eat = struct + (* Consume a single token *) + let token env = + (* If there's a token_sink, emit the lexed token before moving forward *) + (match !(env.token_sink) with + | None -> () + | Some token_sink -> + token_sink + { + token_loc = Peek.loc env; + token = Peek.token env; + (* + * The lex mode is useful because it gives context to some + * context-sensitive tokens. + * + * Some examples of such tokens include: + * + * `=>` - Part of an arrow function? or part of a type annotation? + * `<` - A less-than? Or an opening to a JSX element? + * ...etc... + *) + token_context = lex_mode env; + }); + + env.lex_env := Peek.lex_env env; + + error_list env (Peek.errors env); + env.comments := List.rev_append (Lex_result.comments (lookahead ~i:0 env)) !(env.comments); + env.last_lex_result := Some (lookahead ~i:0 env); + + Lookahead.junk !(env.lookahead) + + (** [maybe env t] eats the next token and returns [true] if it is [t], else return [false] *) + let maybe env t = + let is_t = Token.equal (Peek.token env) t in + if is_t then token env; + is_t + + let push_lex_mode env mode = + env.lex_mode_stack := mode :: !(env.lex_mode_stack); + env.lookahead := Lookahead.create !(env.lex_env) (lex_mode env) + + let pop_lex_mode env = + let new_stack = + match !(env.lex_mode_stack) with + | _mode :: stack -> stack + | _ -> failwith "Popping lex mode from empty stack" + in + env.lex_mode_stack := new_stack; + env.lookahead := Lookahead.create !(env.lex_env) (lex_mode env) + + let double_pop_lex_mode env = + let new_stack = + match !(env.lex_mode_stack) with + | _ :: _ :: stack -> stack + | _ -> failwith "Popping lex mode from empty stack" + in + env.lex_mode_stack := new_stack; + env.lookahead := Lookahead.create !(env.lex_env) (lex_mode env) + + let trailing_comments env = + let open Loc in + let loc = Peek.loc env in + if Peek.token env = Token.T_COMMA && Peek.ith_is_line_terminator ~i:1 env then ( + let trailing_before_comma = Peek.comments env in + let trailing_after_comma = + List.filter + (fun (comment_loc, _) -> comment_loc.start.line <= loc._end.line) + (Lex_result.comments (lookahead ~i:1 env)) + in + let trailing = trailing_before_comma @ trailing_after_comma in + consume_comments_until env { Loc.line = loc._end.line + 1; column = 0 }; + trailing + ) else + let trailing = Peek.comments env in + consume_comments_until env loc._end; + trailing + + let comments_until_next_line env = + let open Loc in + match !(env.last_lex_result) with + | None -> [] + | Some { Lex_result.lex_loc = last_loc; _ } -> + let comments = Peek.comments env in + let comments = List.filter (fun (loc, _) -> loc.start.line <= last_loc._end.line) comments in + consume_comments_until env { line = last_loc._end.line + 1; column = 0 }; + comments + + let program_comments env = + let open Flow_ast.Comment in + let comments = Peek.comments env in + let flow_directive = "@flow" in + let flow_directive_length = String.length flow_directive in + let contains_flow_directive { text; _ } = + let text_length = String.length text in + let rec contains_flow_directive_after_offset off = + if off + flow_directive_length > text_length then + false + else + String.sub text off flow_directive_length = flow_directive + || contains_flow_directive_after_offset (off + 1) + in + contains_flow_directive_after_offset 0 + in + (* Comments up through the last comment with an @flow directive are considered program comments *) + let rec flow_directive_comments comments = + match comments with + | [] -> [] + | (loc, comment) :: rest -> + if contains_flow_directive comment then ( + (env.consumed_comments_pos := Loc.(loc._end)); + List.rev ((loc, comment) :: rest) + ) else + flow_directive_comments rest + in + let program_comments = flow_directive_comments (List.rev comments) in + let program_comments = + if program_comments <> [] then + program_comments + else + (* If there is no @flow directive, consider the first block comment a program comment if + it starts with "/**" *) + match comments with + | ((loc, { kind = Block; text; _ }) as first_comment) :: _ + when String.length text >= 1 && text.[0] = '*' -> + (env.consumed_comments_pos := Loc.(loc._end)); + [first_comment] + | _ -> [] + in + program_comments +end + +module Expect = struct + let get_error env t = + let expected = Token.explanation_of_token ~use_article:true t in + (Peek.loc env, get_unexpected_error ~expected (Peek.token env)) + + let error env t = + let expected = Token.explanation_of_token ~use_article:true t in + error_unexpected ~expected env + + let token env t = + if not (Token.equal (Peek.token env) t) then error env t; + Eat.token env + + (** [token_maybe env T_FOO] eats a token if it is [T_FOO], and errors without consuming if + not. Returns whether it consumed a token, like [Eat.maybe]. *) + let token_maybe env t = + let ate = Eat.maybe env t in + if not ate then error env t; + ate + + (** [token_opt env T_FOO] eats a token if it is [T_FOO], and errors without consuming if not. + This differs from [token], which always consumes. Only use [token_opt] when it's ok for + the parser to not advance, like if you are guaranteed that something else has eaten a + token. *) + let token_opt env t = ignore (token_maybe env t) + + let identifier env name = + let t = Peek.token env in + begin + match t with + | Token.T_IDENTIFIER { raw; _ } when raw = name -> () + | _ -> + let expected = Printf.sprintf "the identifier `%s`" name in + error_unexpected ~expected env + end; + Eat.token env +end + +(* This module allows you to try parsing and rollback if you need. This is not + * cheap and its usage is strongly discouraged *) +module Try = struct + type 'a parse_result = + | ParsedSuccessfully of 'a + | FailedToParse + + exception Rollback + + type saved_state = { + saved_errors: (Loc.t * Parse_error.t) list; + saved_comments: Loc.t Flow_ast.Comment.t list; + saved_last_lex_result: Lex_result.t option; + saved_lex_mode_stack: Lex_mode.t list; + saved_lex_env: Lex_env.t; + saved_consumed_comments_pos: Loc.position; + token_buffer: ((token_sink_result -> unit) * token_sink_result Queue.t) option; + } + + let save_state env = + let token_buffer = + match !(env.token_sink) with + | None -> None + | Some orig_token_sink -> + let buffer = Queue.create () in + env.token_sink := Some (fun token_data -> Queue.add token_data buffer); + Some (orig_token_sink, buffer) + in + { + saved_errors = !(env.errors); + saved_comments = !(env.comments); + saved_last_lex_result = !(env.last_lex_result); + saved_lex_mode_stack = !(env.lex_mode_stack); + saved_lex_env = !(env.lex_env); + saved_consumed_comments_pos = !(env.consumed_comments_pos); + token_buffer; + } + + let reset_token_sink ~flush env token_buffer_info = + match token_buffer_info with + | None -> () + | Some (orig_token_sink, token_buffer) -> + env.token_sink := Some orig_token_sink; + if flush then Queue.iter orig_token_sink token_buffer + + let rollback_state env saved_state = + reset_token_sink ~flush:false env saved_state.token_buffer; + env.errors := saved_state.saved_errors; + env.comments := saved_state.saved_comments; + env.last_lex_result := saved_state.saved_last_lex_result; + env.lex_mode_stack := saved_state.saved_lex_mode_stack; + env.lex_env := saved_state.saved_lex_env; + env.consumed_comments_pos := saved_state.saved_consumed_comments_pos; + env.lookahead := Lookahead.create !(env.lex_env) (lex_mode env); + + FailedToParse + + let success env saved_state result = + reset_token_sink ~flush:true env saved_state.token_buffer; + ParsedSuccessfully result + + let to_parse env parse = + let saved_state = save_state env in + try success env saved_state (parse env) with + | Rollback -> rollback_state env saved_state + + let or_else env ~fallback parse = + match to_parse env parse with + | ParsedSuccessfully result -> result + | FailedToParse -> fallback +end diff --git a/analysis/vendor/js_parser/parser_env.mli b/analysis/vendor/js_parser/parser_env.mli new file mode 100644 index 000000000..7cc424ef8 --- /dev/null +++ b/analysis/vendor/js_parser/parser_env.mli @@ -0,0 +1,283 @@ +(* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) + +(* This module provides a layer between the lexer and the parser which includes + * some parser state and some lexer state *) + +module SSet : Set.S with type elt = string + +module Lex_mode : sig + type t = + | NORMAL + | TYPE + | JSX_TAG + | JSX_CHILD + | TEMPLATE + | REGEXP + + val debug_string_of_lex_mode : t -> string +end + +type token_sink_result = { + token_loc: Loc.t; + token: Token.t; + token_context: Lex_mode.t; +} + +type parse_options = { + enums: bool; (** enable parsing of Flow enums *) + esproposal_decorators: bool; (** enable parsing of decorators *) + types: bool; (** enable parsing of Flow types *) + use_strict: bool; (** treat the file as strict, without needing a "use strict" directive *) +} + +val default_parse_options : parse_options + +type env + +type allowed_super = + | No_super + | Super_prop + | Super_prop_or_call + +(* constructor: *) +val init_env : + ?token_sink:(token_sink_result -> unit) option -> + ?parse_options:parse_options option -> + File_key.t option -> + string -> + env + +(* getters: *) +val in_strict_mode : env -> bool + +val last_loc : env -> Loc.t option + +val last_token : env -> Token.t option + +val in_export : env -> bool + +val in_export_default : env -> bool + +val labels : env -> SSet.t + +val comments : env -> Loc.t Flow_ast.Comment.t list + +val in_loop : env -> bool + +val in_switch : env -> bool + +val in_formal_parameters : env -> bool + +val in_function : env -> bool + +val allow_yield : env -> bool + +val allow_await : env -> bool + +val allow_directive : env -> bool + +val allow_super : env -> allowed_super + +val has_simple_parameters : env -> bool + +val no_in : env -> bool + +val no_call : env -> bool + +val no_let : env -> bool + +val no_anon_function_type : env -> bool + +val no_new : env -> bool + +val errors : env -> (Loc.t * Parse_error.t) list + +val parse_options : env -> parse_options + +val source : env -> File_key.t option + +val should_parse_types : env -> bool + +val get_unexpected_error : ?expected:string -> Token.t -> Parse_error.t + +(* mutators: *) +val error_at : env -> Loc.t * Parse_error.t -> unit + +val error : env -> Parse_error.t -> unit + +val error_unexpected : ?expected:string -> env -> unit + +val error_on_decorators : env -> (Loc.t * 'a) list -> unit + +val error_nameless_declaration : env -> string -> unit + +val strict_error : env -> Parse_error.t -> unit + +val strict_error_at : env -> Loc.t * Parse_error.t -> unit + +val function_as_statement_error_at : env -> Loc.t -> unit + +val error_list : env -> (Loc.t * Parse_error.t) list -> unit + +val enter_class : env -> unit + +val exit_class : env -> unit + +val add_declared_private : env -> string -> unit + +val add_used_private : env -> string -> Loc.t -> unit + +val consume_comments_until : env -> Loc.position -> unit + +(* functional operations -- these return shallow copies, so future mutations to + * the returned env will also affect the original: *) +val with_strict : bool -> env -> env + +val with_in_formal_parameters : bool -> env -> env + +val with_in_function : bool -> env -> env + +val with_allow_yield : bool -> env -> env + +val with_allow_await : bool -> env -> env + +val with_allow_directive : bool -> env -> env + +val with_allow_super : allowed_super -> env -> env + +val with_no_let : bool -> env -> env + +val with_in_loop : bool -> env -> env + +val with_no_in : bool -> env -> env + +val with_no_anon_function_type : bool -> env -> env + +val with_no_new : bool -> env -> env + +val with_in_switch : bool -> env -> env + +val with_in_export : bool -> env -> env + +val with_in_export_default : bool -> env -> env + +val with_no_call : bool -> env -> env + +val with_error_callback : (env -> Parse_error.t -> unit) -> env -> env + +val without_error_callback : env -> env + +val add_label : env -> string -> env + +val enter_function : env -> async:bool -> generator:bool -> simple_params:bool -> env + +val is_reserved : string -> bool + +val token_is_reserved : Token.t -> bool + +val is_future_reserved : string -> bool + +val is_strict_reserved : string -> bool + +val token_is_strict_reserved : Token.t -> bool + +val is_restricted : string -> bool + +val is_reserved_type : string -> bool + +val token_is_restricted : Token.t -> bool + +module Peek : sig + val token : env -> Token.t + + val loc : env -> Loc.t + + val loc_skip_lookahead : env -> Loc.t + + val errors : env -> (Loc.t * Parse_error.t) list + + val comments : env -> Loc.t Flow_ast.Comment.t list + + val has_eaten_comments : env -> bool + + val is_line_terminator : env -> bool + + val is_implicit_semicolon : env -> bool + + val is_identifier : env -> bool + + val is_type_identifier : env -> bool + + val is_identifier_name : env -> bool + + val is_function : env -> bool + + val is_class : env -> bool + + val ith_token : i:int -> env -> Token.t + + val ith_loc : i:int -> env -> Loc.t + + val ith_errors : i:int -> env -> (Loc.t * Parse_error.t) list + + val ith_comments : i:int -> env -> Loc.t Flow_ast.Comment.t list + + val ith_is_line_terminator : i:int -> env -> bool + + val ith_is_implicit_semicolon : i:int -> env -> bool + + val ith_is_identifier : i:int -> env -> bool + + val ith_is_identifier_name : i:int -> env -> bool + + val ith_is_type_identifier : i:int -> env -> bool +end + +module Eat : sig + val token : env -> unit + + val maybe : env -> Token.t -> bool + + val push_lex_mode : env -> Lex_mode.t -> unit + + val pop_lex_mode : env -> unit + + val double_pop_lex_mode : env -> unit + + val trailing_comments : env -> Loc.t Flow_ast.Comment.t list + + val comments_until_next_line : env -> Loc.t Flow_ast.Comment.t list + + val program_comments : env -> Loc.t Flow_ast.Comment.t list +end + +module Expect : sig + val get_error : env -> Token.t -> Loc.t * Parse_error.t + + val error : env -> Token.t -> unit + + val token : env -> Token.t -> unit + + val token_opt : env -> Token.t -> unit + + val token_maybe : env -> Token.t -> bool + + val identifier : env -> string -> unit +end + +module Try : sig + type 'a parse_result = + | ParsedSuccessfully of 'a + | FailedToParse + + exception Rollback + + val to_parse : env -> (env -> 'a) -> 'a parse_result + + val or_else : env -> fallback:'a -> (env -> 'a) -> 'a +end diff --git a/analysis/vendor/js_parser/parser_flow.ml b/analysis/vendor/js_parser/parser_flow.ml new file mode 100644 index 000000000..f31f7c797 --- /dev/null +++ b/analysis/vendor/js_parser/parser_flow.ml @@ -0,0 +1,588 @@ +(* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) + +module Sedlexing = Flow_sedlexing +module Ast = Flow_ast +open Token +open Parser_env +open Parser_common + +(* Sometimes we add the same error for multiple different reasons. This is hard + to avoid, so instead we just filter the duplicates out. This function takes + a reversed list of errors and returns the list in forward order with dupes + removed. This differs from a set because the original order is preserved. *) +let filter_duplicate_errors = + let module PrintableErrorSet = Set.Make (struct + type t = Loc.t * Parse_error.t + + let compare (a_loc, a_error) (b_loc, b_error) = + let loc = Loc.compare a_loc b_loc in + if loc = 0 then + Parse_error.compare a_error b_error + else + loc + end) in + fun errs -> + let errs = List.rev errs in + let (_, deduped) = + List.fold_left + (fun (set, deduped) err -> + if PrintableErrorSet.mem err set then + (set, deduped) + else + (PrintableErrorSet.add err set, err :: deduped)) + (PrintableErrorSet.empty, []) + errs + in + List.rev deduped + +let check_for_duplicate_exports = + let open Ast in + let record_export env seen (loc, { Identifier.name = export_name; comments = _ }) = + if export_name = "" then + (* empty identifiers signify an error, don't export it *) + seen + else if SSet.mem export_name seen then ( + error_at env (loc, Parse_error.DuplicateExport export_name); + seen + ) else + SSet.add export_name seen + in + let extract_pattern_binding_names = + let rec fold acc = + let open Pattern in + function + | (_, Object { Object.properties; _ }) -> + List.fold_left + (fun acc prop -> + match prop with + | Object.Property (_, { Object.Property.pattern; _ }) + | Object.RestElement (_, { RestElement.argument = pattern; comments = _ }) -> + fold acc pattern) + acc + properties + | (_, Array { Array.elements; _ }) -> + List.fold_left + (fun acc elem -> + match elem with + | Array.Element (_, { Array.Element.argument = pattern; default = _ }) + | Array.RestElement (_, { RestElement.argument = pattern; comments = _ }) -> + fold acc pattern + | Array.Hole _ -> acc) + acc + elements + | (_, Identifier { Pattern.Identifier.name; _ }) -> name :: acc + | (_, Expression _) -> failwith "Parser error: No such thing as an expression pattern!" + in + List.fold_left fold + in + let record_export_of_statement env seen decl = + match decl with + | (_, Statement.ExportDefaultDeclaration { Statement.ExportDefaultDeclaration.default; _ }) -> + record_export env seen (Flow_ast_utils.ident_of_source (default, "default")) + | ( _, + Statement.ExportNamedDeclaration + { Statement.ExportNamedDeclaration.specifiers = Some specifiers; declaration = None; _ } + ) -> + let open Statement.ExportNamedDeclaration in + (match specifiers with + | ExportSpecifiers specifiers -> + List.fold_left + (fun seen (_, { Statement.ExportNamedDeclaration.ExportSpecifier.local; exported }) -> + match exported with + | Some exported -> record_export env seen exported + | None -> record_export env seen local) + seen + specifiers + | ExportBatchSpecifier _ -> + (* doesn't export specific names *) + seen) + | ( _, + Statement.ExportNamedDeclaration + { Statement.ExportNamedDeclaration.specifiers = None; declaration = Some declaration; _ } + ) -> + (match declaration with + | ( loc, + ( Statement.TypeAlias { Statement.TypeAlias.id; _ } + | Statement.OpaqueType { Statement.OpaqueType.id; _ } + | Statement.InterfaceDeclaration { Statement.Interface.id; _ } + | Statement.ClassDeclaration { Class.id = Some id; _ } + | Statement.FunctionDeclaration { Function.id = Some id; _ } + | Statement.EnumDeclaration { Statement.EnumDeclaration.id; _ } ) + ) -> + record_export + env + seen + (Flow_ast_utils.ident_of_source (loc, Flow_ast_utils.name_of_ident id)) + | (_, Statement.VariableDeclaration { Statement.VariableDeclaration.declarations; _ }) -> + declarations + |> List.fold_left + (fun names (_, { Statement.VariableDeclaration.Declarator.id; _ }) -> + extract_pattern_binding_names names [id]) + [] + |> List.fold_left (record_export env) seen + | ( _, + Statement.( + ( Block _ | Break _ + | ClassDeclaration { Class.id = None; _ } + | Continue _ | Debugger _ | DeclareClass _ | DeclareExportDeclaration _ + | DeclareFunction _ | DeclareInterface _ | DeclareModule _ | DeclareModuleExports _ + | DeclareTypeAlias _ | DeclareOpaqueType _ | DeclareVariable _ | DoWhile _ | Empty _ + | ExportDefaultDeclaration _ | ExportNamedDeclaration _ | Expression _ | For _ | ForIn _ + | ForOf _ + | FunctionDeclaration { Function.id = None; _ } + | If _ | ImportDeclaration _ | Labeled _ | Return _ | Switch _ | Throw _ | Try _ + | While _ | With _ )) + ) -> + (* these don't export names -- some are invalid, but the AST allows them *) + seen) + | ( _, + Statement.ExportNamedDeclaration + { Statement.ExportNamedDeclaration.declaration = None; specifiers = None; _ } + ) + | ( _, + Statement.ExportNamedDeclaration + { Statement.ExportNamedDeclaration.declaration = Some _; specifiers = Some _; _ } + ) -> + (* impossible *) + seen + | ( _, + Statement.( + ( Block _ | Break _ | ClassDeclaration _ | Continue _ | Debugger _ | DeclareClass _ + | DeclareExportDeclaration _ | DeclareFunction _ | DeclareInterface _ | DeclareModule _ + | DeclareModuleExports _ | DeclareTypeAlias _ | DeclareOpaqueType _ | DeclareVariable _ + | DoWhile _ | Empty _ | EnumDeclaration _ | Expression _ | For _ | ForIn _ | ForOf _ + | FunctionDeclaration _ | If _ | ImportDeclaration _ | InterfaceDeclaration _ | Labeled _ + | Return _ | Switch _ | Throw _ | Try _ | TypeAlias _ | OpaqueType _ + | VariableDeclaration _ | While _ | With _ )) + ) -> + seen + in + (fun env stmts -> ignore (List.fold_left (record_export_of_statement env) SSet.empty stmts)) + +module rec Parse : PARSER = struct + module Type = Type_parser.Type (Parse) + module Declaration = Declaration_parser.Declaration (Parse) (Type) + module Pattern_cover = Pattern_cover.Cover (Parse) + module Expression = Expression_parser.Expression (Parse) (Type) (Declaration) (Pattern_cover) + module Object = Object_parser.Object (Parse) (Type) (Declaration) (Expression) (Pattern_cover) + + module Statement = + Statement_parser.Statement (Parse) (Type) (Declaration) (Object) (Pattern_cover) + + module Pattern = Pattern_parser.Pattern (Parse) (Type) + module JSX = Jsx_parser.JSX (Parse) + + let annot = Type.annotation + + let identifier ?restricted_error env = + (match Peek.token env with + (* "let" is disallowed as an identifier in a few situations. 11.6.2.1 + lists them out. It is always disallowed in strict mode *) + | T_LET when in_strict_mode env -> error env Parse_error.StrictReservedWord + | T_LET when no_let env -> error_unexpected env + | T_LET -> () + (* `allow_await` means that `await` is allowed to be a keyword, + which makes it illegal to use as an identifier. + https://tc39.github.io/ecma262/#sec-identifiers-static-semantics-early-errors *) + | T_AWAIT when allow_await env -> error env Parse_error.UnexpectedReserved + | T_AWAIT -> () + (* `allow_yield` means that `yield` is allowed to be a keyword, + which makes it illegal to use as an identifier. + https://tc39.github.io/ecma262/#sec-identifiers-static-semantics-early-errors *) + | T_YIELD when allow_yield env -> error env Parse_error.UnexpectedReserved + | T_YIELD when in_strict_mode env -> error env Parse_error.StrictReservedWord + | T_YIELD -> () + | t when token_is_strict_reserved t -> strict_error env Parse_error.StrictReservedWord + | t when token_is_reserved t -> error_unexpected env + | t -> + (match restricted_error with + | Some err when token_is_restricted t -> strict_error env err + | _ -> ())); + identifier_name env + + let rec program env = + let leading = Eat.program_comments env in + let stmts = module_body_with_directives env (fun _ -> false) in + let end_loc = Peek.loc env in + Expect.token env T_EOF; + check_for_duplicate_exports env stmts; + let loc = + match stmts with + | [] -> end_loc + | _ -> Loc.btwn (fst (List.hd stmts)) (fst (List.hd (List.rev stmts))) + in + let all_comments = List.rev (comments env) in + ( loc, + { + Ast.Program.statements = stmts; + comments = Flow_ast_utils.mk_comments_opt ~leading (); + all_comments; + } + ) + + and directives = + let check env token = + match token with + | T_STRING (loc, _, _, octal) -> + if octal then strict_error_at env (loc, Parse_error.StrictOctalLiteral) + | _ -> failwith ("Nooo: " ^ token_to_string token ^ "\n") + in + let rec statement_list env term_fn item_fn (string_tokens, stmts, contains_use_strict) = + match Peek.token env with + | T_EOF -> (env, string_tokens, stmts, contains_use_strict) + | t when term_fn t -> (env, string_tokens, stmts, contains_use_strict) + | T_STRING _ as string_token -> + let possible_directive = item_fn env in + let stmts = possible_directive :: stmts in + (match possible_directive with + | (loc, Ast.Statement.Expression { Ast.Statement.Expression.directive = Some raw; _ }) -> + (* 14.1.1 says that it has to be "use strict" without any + escapes, so "use\x20strict" is disallowed. *) + let strict = raw = "use strict" in + if strict && not (has_simple_parameters env) then + error_at env (loc, Parse_error.StrictParamNotSimple); + let env = + if strict then + with_strict true env + else + env + in + let string_tokens = string_token :: string_tokens in + statement_list env term_fn item_fn (string_tokens, stmts, contains_use_strict || strict) + | _ -> (env, string_tokens, stmts, contains_use_strict)) + | _ -> (env, string_tokens, stmts, contains_use_strict) + in + fun env term_fn item_fn -> + let env = with_allow_directive true env in + let (env, string_tokens, stmts, contains_use_strict) = + statement_list env term_fn item_fn ([], [], false) + in + let env = with_allow_directive false env in + List.iter (check env) (List.rev string_tokens); + (env, stmts, contains_use_strict) + + (* 15.2 *) + and module_item env = + let decorators = Object.decorator_list env in + match Peek.token env with + | T_EXPORT -> Statement.export_declaration ~decorators env + | T_IMPORT -> + error_on_decorators env decorators; + let statement = + match Peek.ith_token ~i:1 env with + | T_LPAREN (* import(...) *) + | T_PERIOD (* import.meta *) -> + Statement.expression env + | _ -> Statement.import_declaration env + in + statement + | T_DECLARE when Peek.ith_token ~i:1 env = T_EXPORT -> + error_on_decorators env decorators; + Statement.declare_export_declaration env + | _ -> statement_list_item env ~decorators + + and module_body_with_directives env term_fn = + let (env, directives, _contains_use_strict) = directives env term_fn module_item in + let stmts = module_body ~term_fn env in + (* Prepend the directives *) + List.fold_left (fun acc stmt -> stmt :: acc) stmts directives + + and module_body = + let rec module_item_list env term_fn acc = + match Peek.token env with + | T_EOF -> List.rev acc + | t when term_fn t -> List.rev acc + | _ -> module_item_list env term_fn (module_item env :: acc) + in + (fun ~term_fn env -> module_item_list env term_fn []) + + and statement_list_with_directives ~term_fn env = + let (env, directives, contains_use_strict) = directives env term_fn statement_list_item in + let stmts = statement_list ~term_fn env in + (* Prepend the directives *) + let stmts = List.fold_left (fun acc stmt -> stmt :: acc) stmts directives in + (stmts, contains_use_strict) + + and statement_list = + let rec statements env term_fn acc = + match Peek.token env with + | T_EOF -> List.rev acc + | t when term_fn t -> List.rev acc + | _ -> statements env term_fn (statement_list_item env :: acc) + in + (fun ~term_fn env -> statements env term_fn []) + + and statement_list_item ?(decorators = []) env = + if not (Peek.is_class env) then error_on_decorators env decorators; + let open Statement in + match Peek.token env with + (* Remember kids, these look like statements but they're not + * statements... (see section 13) *) + | T_LET -> let_ env + | T_CONST -> const env + | _ when Peek.is_function env -> Declaration._function env + | _ when Peek.is_class env -> class_declaration env decorators + | T_INTERFACE -> interface env + | T_DECLARE -> declare env + | T_TYPE -> type_alias env + | T_OPAQUE -> opaque_type env + | T_ENUM when (parse_options env).enums -> Declaration.enum_declaration env + | _ -> statement env + + and statement env = + let open Statement in + match Peek.token env with + | T_EOF -> + error_unexpected ~expected:"the start of a statement" env; + (Peek.loc env, Ast.Statement.Empty { Ast.Statement.Empty.comments = None }) + | T_SEMICOLON -> empty env + | T_LCURLY -> block env + | T_VAR -> var env + | T_BREAK -> break env + | T_CONTINUE -> continue env + | T_DEBUGGER -> debugger env + | T_DO -> do_while env + | T_FOR -> for_ env + | T_IF -> if_ env + | T_RETURN -> return env + | T_SWITCH -> switch env + | T_THROW -> throw env + | T_TRY -> try_ env + | T_WHILE -> while_ env + | T_WITH -> with_ env + (* If we see an else then it's definitely an error, but we can probably + * assume that this is a malformed if statement that is missing the if *) + | T_ELSE -> if_ env + (* There are a bunch of tokens that aren't the start of any valid + * statement. We list them here in order to skip over them, rather than + * getting stuck *) + | T_COLON + | T_RPAREN + | T_RCURLY + | T_RBRACKET + | T_COMMA + | T_PERIOD + | T_PLING_PERIOD + | T_ARROW + | T_IN + | T_INSTANCEOF + | T_CATCH + | T_FINALLY + | T_CASE + | T_DEFAULT + | T_EXTENDS + | T_STATIC + | T_EXPORT + (* TODO *) + | T_ELLIPSIS -> + error_unexpected ~expected:"the start of a statement" env; + Eat.token env; + statement env + (* The rest of these patterns handle ExpressionStatement and its negative + lookaheads, which prevent ambiguities. + See https://tc39.github.io/ecma262/#sec-expression-statement *) + | _ when Peek.is_function env -> + let func = Declaration._function env in + function_as_statement_error_at env (fst func); + func + | T_LET when Peek.ith_token ~i:1 env = T_LBRACKET -> + (* `let [foo]` is ambiguous: either a let binding pattern, or a + member expression, so it is banned. *) + let loc = Loc.btwn (Peek.loc env) (Peek.ith_loc ~i:1 env) in + error_at env (loc, Parse_error.AmbiguousLetBracket); + Statement.expression env + (* recover as a member expression *) + | _ when Peek.is_identifier env -> maybe_labeled env + | _ when Peek.is_class env -> + error_unexpected env; + Eat.token env; + Statement.expression env + | _ -> Statement.expression env + + and expression env = + let start_loc = Peek.loc env in + let expr = Expression.assignment env in + match Peek.token env with + | T_COMMA -> Expression.sequence env ~start_loc [expr] + | _ -> expr + + and expression_or_pattern env = + let start_loc = Peek.loc env in + let expr_or_pattern = Expression.assignment_cover env in + match Peek.token env with + | T_COMMA -> + let expr = Pattern_cover.as_expression env expr_or_pattern in + let seq = Expression.sequence env ~start_loc [expr] in + Cover_expr seq + | _ -> expr_or_pattern + + and conditional = Expression.conditional + and assignment = Expression.assignment + and left_hand_side = Expression.left_hand_side + and object_initializer = Object._initializer + and object_key = Object.key + and class_declaration = Object.class_declaration + and class_expression = Object.class_expression + and is_assignable_lhs = Expression.is_assignable_lhs + and number = Expression.number + + and identifier_with_type = + let with_loc_helper no_optional restricted_error env = + let name = identifier ~restricted_error env in + let optional = (not no_optional) && Peek.token env = T_PLING in + if optional then ( + if not (should_parse_types env) then error env Parse_error.UnexpectedTypeAnnotation; + Expect.token env T_PLING + ); + let annot = Type.annotation_opt env in + Ast.Pattern.Identifier.{ name; optional; annot } + in + fun env ?(no_optional = false) restricted_error -> + with_loc (with_loc_helper no_optional restricted_error) env + + and block_body env = + let start_loc = Peek.loc env in + let leading = Peek.comments env in + Expect.token env T_LCURLY; + let term_fn t = t = T_RCURLY in + let body = statement_list ~term_fn env in + let end_loc = Peek.loc env in + let internal = + if body = [] then + Peek.comments env + else + [] + in + Expect.token env T_RCURLY; + let trailing = Eat.trailing_comments env in + ( Loc.btwn start_loc end_loc, + { + Ast.Statement.Block.body; + comments = Flow_ast_utils.mk_comments_with_internal_opt ~leading ~trailing ~internal (); + } + ) + + and function_block_body ~expression = + with_loc_extra (fun env -> + let leading = Peek.comments env in + Expect.token env T_LCURLY; + let term_fn t = t = T_RCURLY in + let (body, contains_use_strict) = statement_list_with_directives ~term_fn env in + let internal = + if body = [] then + Peek.comments env + else + [] + in + Expect.token env T_RCURLY; + let trailing = + match (expression, Peek.token env) with + | (true, _) + | (_, (T_RCURLY | T_EOF)) -> + Eat.trailing_comments env + | _ when Peek.is_line_terminator env -> Eat.comments_until_next_line env + | _ -> [] + in + let comments = + Flow_ast_utils.mk_comments_with_internal_opt ~leading ~trailing ~internal () + in + ({ Ast.Statement.Block.body; comments }, contains_use_strict) + ) + + and jsx_element_or_fragment = JSX.element_or_fragment + and pattern = Pattern.pattern + and pattern_from_expr = Pattern.from_expr +end + +(*****************************************************************************) +(* Entry points *) +(*****************************************************************************) +let do_parse env parser fail = + let ast = parser env in + let error_list = filter_duplicate_errors (errors env) in + match error_list with + | e :: es when fail -> raise (Parse_error.Error (e, es)) + | _ -> (ast, error_list) + +(* Makes the input parser expect EOF at the end. Use this to error on trailing + * junk when parsing non-Program nodes. *) +let with_eof parser env = + let ast = parser env in + Expect.token env T_EOF; + ast + +let parse_statement env fail = do_parse env (with_eof Parse.statement_list_item) fail +let parse_expression env fail = do_parse env (with_eof Parse.expression) fail + +let parse_program fail ?(token_sink = None) ?(parse_options = None) filename content = + let env = init_env ~token_sink ~parse_options filename content in + do_parse env Parse.program fail + +let program ?(fail = true) ?(token_sink = None) ?(parse_options = None) content = + parse_program fail ~token_sink ~parse_options None content + +let program_file ?(fail = true) ?(token_sink = None) ?(parse_options = None) content filename = + parse_program fail ~token_sink ~parse_options filename content + +let parse_annot ?(parse_options = None) filename content = + let env = init_env ~token_sink:None ~parse_options filename content in + do_parse env Parse.annot false + +let package_json_file = + let parser env = + let (loc, obj, { if_expr; _ }) = Parse.object_initializer env in + List.iter (error_at env) if_expr; + (loc, obj) + in + fun ?(fail = true) ?(token_sink = None) ?(parse_options = None) content filename -> + let env = init_env ~token_sink ~parse_options filename content in + do_parse env parser fail + +(* even if fail=false, still raises an error on a totally invalid token, since + there's no legitimate fallback. *) +let json_file = + let null_fallback _env = + Ast.Expression.Literal { Ast.Literal.value = Ast.Literal.Null; raw = "null"; comments = None } + in + let parser env = + match Peek.token env with + | T_LBRACKET + | T_LCURLY + | T_STRING _ + | T_NUMBER _ + | T_TRUE + | T_FALSE + | T_NULL -> + Parse.expression env + | T_MINUS -> + (match Peek.ith_token ~i:1 env with + | T_NUMBER _ -> Parse.expression env + | _ -> + error_unexpected ~expected:"a number" env; + with_loc null_fallback env) + | _ -> + error_unexpected ~expected:"a valid JSON value" env; + with_loc null_fallback env + in + fun ?(fail = true) ?(token_sink = None) ?(parse_options = None) content filename -> + let env = init_env ~token_sink ~parse_options filename content in + do_parse env parser fail + +let jsx_pragma_expression = + let left_hand_side env = + let ast = Parse.left_hand_side (with_no_new true env) in + Expect.token env T_EOF; + ast + in + fun content filename -> + let env = init_env ~token_sink:None ~parse_options:None filename content in + do_parse env left_hand_side true + +let string_is_valid_identifier_name str = + let lexbuf = Sedlexing.Utf8.from_string str in + Flow_lexer.is_valid_identifier_name lexbuf diff --git a/analysis/vendor/js_parser/pattern_cover.ml b/analysis/vendor/js_parser/pattern_cover.ml new file mode 100644 index 000000000..bf307e4b5 --- /dev/null +++ b/analysis/vendor/js_parser/pattern_cover.ml @@ -0,0 +1,59 @@ +(* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) + +open Flow_ast +open Parser_common +open Parser_env + +module type COVER = sig + val as_expression : env -> pattern_cover -> (Loc.t, Loc.t) Expression.t + + val as_pattern : ?err:Parse_error.t -> env -> pattern_cover -> (Loc.t, Loc.t) Pattern.t + + val empty_errors : pattern_errors + + val cons_error : Loc.t * Parse_error.t -> pattern_errors -> pattern_errors + + val rev_append_errors : pattern_errors -> pattern_errors -> pattern_errors + + val rev_errors : pattern_errors -> pattern_errors +end + +module Cover (Parse : PARSER) : COVER = struct + let as_expression env = function + | Cover_expr expr -> expr + | Cover_patt (expr, { if_expr; if_patt = _ }) -> + List.iter (error_at env) if_expr; + expr + + let as_pattern ?(err = Parse_error.InvalidLHSInAssignment) env cover = + let expr = + match cover with + | Cover_expr expr -> expr + | Cover_patt (expr, { if_expr = _; if_patt }) -> + List.iter (error_at env) if_patt; + expr + in + if not (Parse.is_assignable_lhs expr) then error_at env (fst expr, err); + + (match expr with + | (loc, Flow_ast.Expression.Identifier (_, { Flow_ast.Identifier.name; comments = _ })) + when is_restricted name -> + strict_error_at env (loc, Parse_error.StrictLHSAssignment) + | _ -> ()); + + Parse.pattern_from_expr env expr + + let empty_errors = { if_patt = []; if_expr = [] } + + let cons_error err { if_patt; if_expr } = { if_patt = err :: if_patt; if_expr = err :: if_expr } + + let rev_append_errors a b = + { if_patt = List.rev_append a.if_patt b.if_patt; if_expr = List.rev_append a.if_expr b.if_expr } + + let rev_errors a = { if_patt = List.rev a.if_patt; if_expr = List.rev a.if_expr } +end diff --git a/analysis/vendor/js_parser/pattern_parser.ml b/analysis/vendor/js_parser/pattern_parser.ml new file mode 100644 index 000000000..74a4abac2 --- /dev/null +++ b/analysis/vendor/js_parser/pattern_parser.ml @@ -0,0 +1,397 @@ +(* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) + +module Ast = Flow_ast +open Token +open Parser_common +open Parser_env +open Flow_ast + +let missing_annot env = Ast.Type.Missing (Peek.loc_skip_lookahead env) + +module Pattern (Parse : Parser_common.PARSER) (Type : Type_parser.TYPE) = struct + (* Reinterpret various expressions as patterns. + * This is not the correct thing to do and is only used for assignment + * expressions. This should be removed and replaced ASAP. + *) + let rec object_from_expr = + let rec properties env acc = + let open Ast.Expression.Object in + function + | [] -> List.rev acc + | Property (loc, prop) :: remaining -> + let acc = + match prop with + | Property.Init { key; value; shorthand } -> + let open Ast.Expression in + let key = + match key with + | Property.Literal lit -> Pattern.Object.Property.Literal lit + | Property.Identifier id -> Pattern.Object.Property.Identifier id + | Property.PrivateName _ -> failwith "Internal Error: Found object private prop" + | Property.Computed key -> Pattern.Object.Property.Computed key + in + let (pattern, default) = + match value with + | (_loc, Assignment { Assignment.operator = None; left; right; comments = _ }) -> + (left, Some right) + | _ -> (from_expr env value, None) + in + Pattern.Object.Property + (loc, { Pattern.Object.Property.key; pattern; default; shorthand }) + :: acc + | Property.Method { key = _; value = (loc, _) } -> + error_at env (loc, Parse_error.MethodInDestructuring); + acc + | Property.Get { key = _; value = (loc, _); comments = _ } + | Property.Set { key = _; value = (loc, _); comments = _ } -> + (* these should never happen *) + error_at env (loc, Parse_error.Unexpected "identifier"); + acc + in + properties env acc remaining + | [SpreadProperty (loc, { SpreadProperty.argument; comments })] -> + let acc = + Pattern.Object.RestElement + (loc, { Pattern.RestElement.argument = from_expr env argument; comments }) + :: acc + in + properties env acc [] + | SpreadProperty (loc, _) :: remaining -> + error_at env (loc, Parse_error.PropertyAfterRestElement); + properties env acc remaining + in + fun env (loc, { Ast.Expression.Object.properties = props; comments }) -> + ( loc, + Pattern.( + Object + { Object.properties = properties env [] props; annot = missing_annot env; comments } + ) + ) + + and array_from_expr = + (* Convert an Expression to a Pattern if it is a valid + DestructuringAssignmentTarget, which must be an Object, Array or + IsValidSimpleAssignmentTarget. + #sec-destructuring-assignment-static-semantics-early-errors *) + let assignment_target env ((loc, _) as expr) = + if Parse.is_assignable_lhs expr then + Some (from_expr env expr) + else ( + error_at env (loc, Parse_error.InvalidLHSInAssignment); + None + ) + in + let rec elements env acc = + let open Ast.Expression in + function + | [] -> List.rev acc + | [Array.Spread (loc, { SpreadElement.argument; comments })] -> + (* AssignmentRestElement is a DestructuringAssignmentTarget, see + #prod-AssignmentRestElement *) + let acc = + match assignment_target env argument with + | Some argument -> + Pattern.Array.RestElement (loc, { Pattern.RestElement.argument; comments }) :: acc + | None -> acc + in + elements env acc [] + | Array.Spread (loc, _) :: remaining -> + error_at env (loc, Parse_error.ElementAfterRestElement); + elements env acc remaining + | Array.Expression (loc, Assignment { Assignment.operator = None; left; right; comments = _ }) + :: remaining -> + (* AssignmentElement is a `DestructuringAssignmentTarget Initializer`, see + #prod-AssignmentElement *) + let acc = + Pattern.Array.Element + (loc, { Pattern.Array.Element.argument = left; default = Some right }) + :: acc + in + elements env acc remaining + | Array.Expression expr :: remaining -> + (* AssignmentElement is a DestructuringAssignmentTarget, see + #prod-AssignmentElement *) + let acc = + match assignment_target env expr with + | Some ((loc, _) as expr) -> + let element = + Pattern.Array.Element (loc, { Pattern.Array.Element.argument = expr; default = None }) + in + element :: acc + | None -> acc + in + elements env acc remaining + | Array.Hole loc :: remaining -> elements env (Pattern.Array.Hole loc :: acc) remaining + in + fun env (loc, { Ast.Expression.Array.elements = elems; comments }) -> + ( loc, + Pattern.Array + { Pattern.Array.elements = elements env [] elems; annot = missing_annot env; comments } + ) + + and from_expr env (loc, expr) = + let open Ast.Expression in + match expr with + | Object obj -> object_from_expr env (loc, obj) + | Array arr -> array_from_expr env (loc, arr) + | Identifier ((id_loc, { Identifier.name = string_val; comments = _ }) as name) -> + (* per #sec-destructuring-assignment-static-semantics-early-errors, + it is a syntax error if IsValidSimpleAssignmentTarget of this + IdentifierReference is false. That happens when `string_val` is + "eval" or "arguments" in strict mode. *) + if in_strict_mode env && is_restricted string_val then + error_at env (id_loc, Parse_error.StrictLHSAssignment) + (* per #prod-IdentifierReference, yield is only a valid + IdentifierReference when [~Yield], and await is only valid + when [~Await]. but per #sec-identifiers-static-semantics-early-errors, + they are already invalid in strict mode, which we should have + already errored about when parsing the expression that we're now + converting into a pattern. *) + else if not (in_strict_mode env) then + if allow_yield env && string_val = "yield" then + error_at env (id_loc, Parse_error.YieldAsIdentifierReference) + else if allow_await env && string_val = "await" then + error_at env (id_loc, Parse_error.AwaitAsIdentifierReference); + ( loc, + Pattern.Identifier { Pattern.Identifier.name; annot = missing_annot env; optional = false } + ) + | expr -> (loc, Pattern.Expression (loc, expr)) + + (* Parse object destructuring pattern *) + let rec object_ restricted_error = + let rest_property env = + let leading = Peek.comments env in + let (loc, argument) = + with_loc + (fun env -> + Expect.token env T_ELLIPSIS; + pattern env restricted_error) + env + in + Pattern.Object.RestElement + ( loc, + { Pattern.RestElement.argument; comments = Flow_ast_utils.mk_comments_opt ~leading () } + ) + in + let property_default env = + match Peek.token env with + | T_ASSIGN -> + Expect.token env T_ASSIGN; + Some (Parse.assignment env) + | _ -> None + in + let rec property env = + if Peek.token env = T_ELLIPSIS then + Some (rest_property env) + else + let start_loc = Peek.loc env in + let raw_key = Parse.object_key env in + match Peek.token env with + | T_COLON -> + Expect.token env T_COLON; + let (loc, (pattern, default)) = + with_loc + ~start_loc + (fun env -> + let pattern = pattern env restricted_error in + let default = property_default env in + (pattern, default)) + env + in + let key = + let open Ast.Expression.Object.Property in + match raw_key with + | (_, Literal lit) -> Pattern.Object.Property.Literal lit + | (_, Identifier id) -> Pattern.Object.Property.Identifier id + | (_, PrivateName _) -> failwith "Internal Error: Found object private prop" + | (_, Computed key) -> Pattern.Object.Property.Computed key + in + Some + Pattern.Object.(Property (loc, Property.{ key; pattern; default; shorthand = false })) + | _ -> + (match raw_key with + | ( _, + Ast.Expression.Object.Property.Identifier + ((id_loc, { Identifier.name = string_val; comments = _ }) as name) + ) -> + (* #sec-identifiers-static-semantics-early-errors *) + if is_reserved string_val && string_val <> "yield" && string_val <> "await" then + (* it is a syntax error if `name` is a reserved word other than await or yield *) + error_at env (id_loc, Parse_error.UnexpectedReserved) + else if is_strict_reserved string_val then + (* it is a syntax error if `name` is a strict reserved word, in strict mode *) + strict_error_at env (id_loc, Parse_error.StrictReservedWord); + let (loc, (pattern, default)) = + with_loc + ~start_loc + (fun env -> + let pattern = + ( id_loc, + Pattern.Identifier + { Pattern.Identifier.name; annot = missing_annot env; optional = false } + ) + in + let default = property_default env in + (pattern, default)) + env + in + Some + Pattern.Object.( + Property + ( loc, + { Property.key = Property.Identifier name; pattern; default; shorthand = true } + ) + ) + | _ -> + error_unexpected ~expected:"an identifier" env; + + (* invalid shorthand destructuring *) + None) + (* seen_rest is true when we've seen a rest element. rest_trailing_comma is the location of + * the rest element's trailing command + * Trailing comma: `let { ...rest, } = obj` + * Still invalid, but not a trailing comma: `let { ...rest, x } = obj` *) + and properties env ~seen_rest ~rest_trailing_comma acc = + match Peek.token env with + | T_EOF + | T_RCURLY -> + begin + match rest_trailing_comma with + | Some loc -> error_at env (loc, Parse_error.TrailingCommaAfterRestElement) + | None -> () + end; + List.rev acc + | _ -> + (match property env with + | Some ((Pattern.Object.Property (loc, _) | Pattern.Object.RestElement (loc, _)) as prop) -> + let rest_trailing_comma = + if seen_rest then ( + error_at env (loc, Parse_error.PropertyAfterRestElement); + None + ) else + rest_trailing_comma + in + let (seen_rest, rest_trailing_comma) = + match prop with + | Pattern.Object.RestElement _ -> + ( true, + if Peek.token env = T_COMMA then + Some (Peek.loc env) + else + None + ) + | _ -> (seen_rest, rest_trailing_comma) + in + if Peek.token env <> T_RCURLY then Expect.token env T_COMMA; + properties env ~seen_rest ~rest_trailing_comma (prop :: acc) + | None -> properties env ~seen_rest ~rest_trailing_comma acc) + in + with_loc (fun env -> + let leading = Peek.comments env in + Expect.token env T_LCURLY; + let properties = properties env ~seen_rest:false ~rest_trailing_comma:None [] in + let internal = Peek.comments env in + Expect.token env T_RCURLY; + let trailing = Eat.trailing_comments env in + let annot = + if Peek.token env = T_COLON then + Ast.Type.Available (Type.annotation env) + else + missing_annot env + in + Pattern.Object + { + Pattern.Object.properties; + annot; + comments = Flow_ast_utils.mk_comments_with_internal_opt ~leading ~trailing ~internal (); + } + ) + + (* Parse array destructuring pattern *) + and array_ restricted_error = + let rec elements env acc = + match Peek.token env with + | T_EOF + | T_RBRACKET -> + List.rev acc + | T_COMMA -> + let loc = Peek.loc env in + Expect.token env T_COMMA; + elements env (Pattern.Array.Hole loc :: acc) + | T_ELLIPSIS -> + let leading = Peek.comments env in + let (loc, argument) = + with_loc + (fun env -> + Expect.token env T_ELLIPSIS; + pattern env restricted_error) + env + in + let element = + Pattern.Array.RestElement + ( loc, + { + Pattern.RestElement.argument; + comments = Flow_ast_utils.mk_comments_opt ~leading (); + } + ) + in + (* rest elements are always last, the closing ] should be next. but if not, + error and keep going so we recover gracefully by parsing the rest of the + elements. *) + if Peek.token env <> T_RBRACKET then ( + error_at env (loc, Parse_error.ElementAfterRestElement); + if Peek.token env = T_COMMA then Eat.token env + ); + elements env (element :: acc) + | _ -> + let (loc, (pattern, default)) = + with_loc + (fun env -> + let pattern = pattern env restricted_error in + let default = + match Peek.token env with + | T_ASSIGN -> + Expect.token env T_ASSIGN; + Some (Parse.assignment env) + | _ -> None + in + (pattern, default)) + env + in + let element = Pattern.Array.(Element (loc, { Element.argument = pattern; default })) in + if Peek.token env <> T_RBRACKET then Expect.token env T_COMMA; + elements env (element :: acc) + in + with_loc (fun env -> + let leading = Peek.comments env in + Expect.token env T_LBRACKET; + let elements = elements env [] in + let internal = Peek.comments env in + Expect.token env T_RBRACKET; + let annot = + if Peek.token env = T_COLON then + Ast.Type.Available (Type.annotation env) + else + missing_annot env + in + let trailing = Eat.trailing_comments env in + let comments = + Flow_ast_utils.mk_comments_with_internal_opt ~leading ~trailing ~internal () + in + Pattern.Array { Pattern.Array.elements; annot; comments } + ) + + and pattern env restricted_error = + match Peek.token env with + | T_LCURLY -> object_ restricted_error env + | T_LBRACKET -> array_ restricted_error env + | _ -> + let (loc, id) = Parse.identifier_with_type env restricted_error in + (loc, Pattern.Identifier id) +end diff --git a/analysis/vendor/js_parser/primitive_deriving.ml b/analysis/vendor/js_parser/primitive_deriving.ml new file mode 100644 index 000000000..db77258f9 --- /dev/null +++ b/analysis/vendor/js_parser/primitive_deriving.ml @@ -0,0 +1,39 @@ +let equal_int (x : int) y = x = y +let equal_string (x : string) y = x = y +let equal_bool (x : bool) y = x = y +let equal_float (x : float) y = x = y +let equal_int64 (x : int64) y = x = y + +let equal_option f x y = + match x with + | None -> y = None + | Some x -> begin + match y with + | None -> false + | Some y -> f x y + end + +let compare_string (x : string) y = compare x y + +let compare_option cmp x y = + match x with + | None -> + (match y with + | None -> 0 + | Some _ -> -1) + | Some x -> + (match y with + | None -> 1 + | Some y -> cmp x y) + +let compare_bool (x : bool) (y : bool) = compare x y +(* TODO : turn it into externals *) +module Ppx_compare_lib = struct + external polymorphic_compare : 'a -> 'a -> int = "%compare" + external phys_equal : 'a -> 'a -> bool = "%eq" + + external ( && ) : bool -> bool -> bool = "%sequand" + + external polymorphic_equal : 'a -> 'a -> bool = "%equal" +end + diff --git a/analysis/vendor/js_parser/sedlex_LICENSE b/analysis/vendor/js_parser/sedlex_LICENSE new file mode 100644 index 000000000..630eb99d8 --- /dev/null +++ b/analysis/vendor/js_parser/sedlex_LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright 2005, 2014 by Alain Frisch and LexiFi. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/analysis/vendor/js_parser/statement_parser.ml b/analysis/vendor/js_parser/statement_parser.ml new file mode 100644 index 000000000..d9d41beb9 --- /dev/null +++ b/analysis/vendor/js_parser/statement_parser.ml @@ -0,0 +1,2189 @@ +(* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) + +module Ast = Flow_ast +open Token +open Parser_env +open Flow_ast +open Parser_common +open Comment_attachment + +module type STATEMENT = sig + val for_ : env -> (Loc.t, Loc.t) Statement.t + + val if_ : env -> (Loc.t, Loc.t) Statement.t + + val let_ : env -> (Loc.t, Loc.t) Statement.t + + val try_ : env -> (Loc.t, Loc.t) Statement.t + + val while_ : env -> (Loc.t, Loc.t) Statement.t + + val with_ : env -> (Loc.t, Loc.t) Statement.t + + val block : env -> (Loc.t, Loc.t) Statement.t + + val break : env -> (Loc.t, Loc.t) Statement.t + + val continue : env -> (Loc.t, Loc.t) Statement.t + + val debugger : env -> (Loc.t, Loc.t) Statement.t + + val declare : ?in_module:bool -> env -> (Loc.t, Loc.t) Statement.t + + val declare_export_declaration : ?allow_export_type:bool -> env -> (Loc.t, Loc.t) Statement.t + + val declare_opaque_type : env -> (Loc.t, Loc.t) Statement.t + + val do_while : env -> (Loc.t, Loc.t) Statement.t + + val empty : env -> (Loc.t, Loc.t) Statement.t + + val export_declaration : + decorators:(Loc.t, Loc.t) Class.Decorator.t list -> env -> (Loc.t, Loc.t) Statement.t + + val expression : env -> (Loc.t, Loc.t) Statement.t + + val import_declaration : env -> (Loc.t, Loc.t) Statement.t + + val interface : env -> (Loc.t, Loc.t) Statement.t + + val maybe_labeled : env -> (Loc.t, Loc.t) Statement.t + + val opaque_type : env -> (Loc.t, Loc.t) Statement.t + + val return : env -> (Loc.t, Loc.t) Statement.t + + val switch : env -> (Loc.t, Loc.t) Statement.t + + val throw : env -> (Loc.t, Loc.t) Statement.t + + val type_alias : env -> (Loc.t, Loc.t) Statement.t + + val var : env -> (Loc.t, Loc.t) Statement.t + + val const : env -> (Loc.t, Loc.t) Statement.t +end + +module Statement + (Parse : PARSER) + (Type : Type_parser.TYPE) + (Declaration : Declaration_parser.DECLARATION) + (Object : Object_parser.OBJECT) + (Pattern_cover : Pattern_cover.COVER) : STATEMENT = struct + type for_lhs = + | For_expression of pattern_cover + | For_declaration of (Loc.t * (Loc.t, Loc.t) Ast.Statement.VariableDeclaration.t) + + type semicolon_type = + | Explicit of Loc.t Comment.t list + | Implicit of Comment_attachment.trailing_and_remover_result + + (* FunctionDeclaration is not a valid Statement, but Annex B sometimes allows it. + However, AsyncFunctionDeclaration and GeneratorFunctionDeclaration are never + allowed as statements. We still parse them as statements (and raise an error) to + recover gracefully. *) + let function_as_statement env = + let func = Declaration._function env in + ( if in_strict_mode env then + function_as_statement_error_at env (fst func) + else + let open Ast.Statement in + match func with + | (loc, FunctionDeclaration { Ast.Function.async = true; _ }) -> + error_at env (loc, Parse_error.AsyncFunctionAsStatement) + | (loc, FunctionDeclaration { Ast.Function.generator = true; _ }) -> + error_at env (loc, Parse_error.GeneratorFunctionAsStatement) + | _ -> () + ); + func + + (* https://tc39.es/ecma262/#sec-exports-static-semantics-early-errors *) + let assert_identifier_name_is_identifier + ?restricted_error env (loc, { Ast.Identifier.name; comments = _ }) = + match name with + | "let" -> + (* "let" is disallowed as an identifier in a few situations. 11.6.2.1 + lists them out. It is always disallowed in strict mode *) + if in_strict_mode env then + strict_error_at env (loc, Parse_error.StrictReservedWord) + else if no_let env then + error_at env (loc, Parse_error.Unexpected (Token.quote_token_value name)) + | "await" -> + (* `allow_await` means that `await` is allowed to be a keyword, + which makes it illegal to use as an identifier. + https://tc39.github.io/ecma262/#sec-identifiers-static-semantics-early-errors *) + if allow_await env then error_at env (loc, Parse_error.UnexpectedReserved) + | "yield" -> + (* `allow_yield` means that `yield` is allowed to be a keyword, + which makes it illegal to use as an identifier. + https://tc39.github.io/ecma262/#sec-identifiers-static-semantics-early-errors *) + if allow_yield env then + error_at env (loc, Parse_error.UnexpectedReserved) + else + strict_error_at env (loc, Parse_error.StrictReservedWord) + | _ when is_strict_reserved name -> strict_error_at env (loc, Parse_error.StrictReservedWord) + | _ when is_reserved name -> + error_at env (loc, Parse_error.Unexpected (Token.quote_token_value name)) + | _ -> + begin + match restricted_error with + | Some err when is_restricted name -> strict_error_at env (loc, err) + | _ -> () + end + + let string_literal env (loc, value, raw, octal) = + if octal then strict_error env Parse_error.StrictOctalLiteral; + let leading = Peek.comments env in + Expect.token env (T_STRING (loc, value, raw, octal)); + let trailing = Eat.trailing_comments env in + ( loc, + { StringLiteral.value; raw; comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing () } + ) + + (* Semicolon insertion is handled here :(. There seem to be 2 cases where + * semicolons are inserted. First, if we reach the EOF. Second, if the next + * token is } or is separated by a LineTerminator. + *) + let semicolon ?(expected = "the token `;`") ?(required = true) env = + match Peek.token env with + | T_EOF + | T_RCURLY -> + Implicit { trailing = Eat.trailing_comments env; remove_trailing = (fun x _ -> x) } + | T_SEMICOLON -> + Eat.token env; + (match Peek.token env with + | T_EOF + | T_RCURLY -> + Explicit (Eat.trailing_comments env) + | _ when Peek.is_line_terminator env -> Explicit (Eat.comments_until_next_line env) + | _ -> Explicit []) + | _ when Peek.is_line_terminator env -> + Implicit (Comment_attachment.trailing_and_remover_after_last_line env) + | _ -> + if required then error_unexpected ~expected env; + Explicit [] + + (* Consumes and returns the trailing comments after the end of a statement. Also returns + a remover that can remove all comments that are not trailing the previous token. + + If a statement is the end of a block or file, all comments are trailing. + Otherwise, if a statement is followed by a new line, only comments on the current + line are trailing. If a statement is not followed by a new line, it does not have + trailing comments as they are instead leading comments for the next statement. *) + let statement_end_trailing_comments env = + match Peek.token env with + | T_EOF + | T_RCURLY -> + { trailing = Eat.trailing_comments env; remove_trailing = (fun x _ -> x) } + | _ when Peek.is_line_terminator env -> + Comment_attachment.trailing_and_remover_after_last_line env + | _ -> Comment_attachment.trailing_and_remover_after_last_loc env + + let variable_declaration_end ~kind env declarations = + match semicolon env with + | Explicit comments -> (comments, declarations) + | Implicit { remove_trailing; _ } -> + (* Remove trailing comments from the last declarator *) + let declarations = + match List.rev declarations with + | [] -> [] + | decl :: decls -> + let decl' = + remove_trailing decl (fun remover decl -> remover#variable_declarator ~kind decl) + in + List.rev (decl' :: decls) + in + ([], declarations) + + let rec empty env = + let loc = Peek.loc env in + let leading = Peek.comments env in + Expect.token env T_SEMICOLON; + let { trailing; _ } = statement_end_trailing_comments env in + ( loc, + Statement.Empty + { Statement.Empty.comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing () } + ) + + and break env = + let leading = Peek.comments env in + let (loc, (label, trailing)) = + with_loc + (fun env -> + Expect.token env T_BREAK; + let label = + if Peek.token env = T_SEMICOLON || Peek.is_implicit_semicolon env then + None + else + let ((_, { Identifier.name; comments = _ }) as label) = Parse.identifier env in + if not (SSet.mem name (labels env)) then error env (Parse_error.UnknownLabel name); + Some label + in + let (trailing, label) = + match (semicolon env, label) with + | (Explicit trailing, _) + | (Implicit { trailing; _ }, None) -> + (trailing, label) + | (Implicit { remove_trailing; _ }, Some label) -> + ([], Some (remove_trailing label (fun remover label -> remover#identifier label))) + in + (label, trailing)) + env + in + if label = None && not (in_loop env || in_switch env) then + error_at env (loc, Parse_error.IllegalBreak); + let comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing () in + (loc, Statement.Break { Statement.Break.label; comments }) + + and continue env = + let leading = Peek.comments env in + let (loc, (label, trailing)) = + with_loc + (fun env -> + Expect.token env T_CONTINUE; + let label = + if Peek.token env = T_SEMICOLON || Peek.is_implicit_semicolon env then + None + else + let ((_, { Identifier.name; comments = _ }) as label) = Parse.identifier env in + if not (SSet.mem name (labels env)) then error env (Parse_error.UnknownLabel name); + Some label + in + let (trailing, label) = + match (semicolon env, label) with + | (Explicit trailing, _) + | (Implicit { trailing; _ }, None) -> + (trailing, label) + | (Implicit { remove_trailing; _ }, Some label) -> + ([], Some (remove_trailing label (fun remover label -> remover#identifier label))) + in + (label, trailing)) + env + in + if not (in_loop env) then error_at env (loc, Parse_error.IllegalContinue); + ( loc, + Statement.Continue + { + Statement.Continue.label; + comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing (); + } + ) + + and debugger = + with_loc (fun env -> + let leading = Peek.comments env in + Expect.token env T_DEBUGGER; + let pre_semicolon_trailing = + if Peek.token env = T_SEMICOLON then + Eat.trailing_comments env + else + [] + in + let trailing = + match semicolon env with + | Explicit trailing + | Implicit { trailing; _ } -> + pre_semicolon_trailing @ trailing + in + Statement.Debugger + { Statement.Debugger.comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing () } + ) + + and do_while = + with_loc (fun env -> + let leading = Peek.comments env in + Expect.token env T_DO; + let body = Parse.statement (env |> with_in_loop true) in + (* Annex B allows labelled FunctionDeclarations (see + sec-labelled-function-declarations), but not in IterationStatement + (see sec-semantics-static-semantics-early-errors). *) + if (not (in_strict_mode env)) && is_labelled_function body then + function_as_statement_error_at env (fst body); + let pre_keyword_trailing = Eat.trailing_comments env in + Expect.token env T_WHILE; + let pre_cond_trailing = Eat.trailing_comments env in + Expect.token env T_LPAREN; + let test = Parse.expression env in + Expect.token env T_RPAREN; + let past_cond_trailing = + if Peek.token env = T_SEMICOLON then + Eat.trailing_comments env + else + [] + in + (* The rules of automatic semicolon insertion in ES5 don't mention this, + * but the semicolon after a do-while loop is optional. This is properly + * specified in ES6 *) + let past_cond_trailing = + match semicolon ~required:false env with + | Explicit trailing -> past_cond_trailing @ trailing + | Implicit { trailing; _ } -> trailing + in + let trailing = pre_keyword_trailing @ pre_cond_trailing @ past_cond_trailing in + Statement.DoWhile + { + Statement.DoWhile.body; + test; + comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing (); + } + ) + + and for_ = + let assert_can_be_forin_or_forof env err = function + | (loc, { Statement.VariableDeclaration.declarations; _ }) -> + (* Only a single declarator is allowed, without an init. So + * something like + * + * for (var x in y) {} + * + * is allowed, but we disallow + * + * for (var x, y in z) {} + * for (var x = 42 in y) {} + *) + (match declarations with + | [(_, { Statement.VariableDeclaration.Declarator.init = None; _ })] -> () + | _ -> error_at env (loc, err)) + in + (* Annex B allows labelled FunctionDeclarations (see + sec-labelled-function-declarations), but not in IterationStatement + (see sec-semantics-static-semantics-early-errors). *) + let assert_not_labelled_function env body = + if (not (in_strict_mode env)) && is_labelled_function body then + function_as_statement_error_at env (fst body) + else + () + in + with_loc (fun env -> + let leading = Peek.comments env in + Expect.token env T_FOR; + let async = allow_await env && Eat.maybe env T_AWAIT in + let leading = leading @ Peek.comments env in + Expect.token env T_LPAREN; + let comments = Flow_ast_utils.mk_comments_opt ~leading () in + let (init, errs) = + let env = env |> with_no_in true in + match Peek.token env with + | T_SEMICOLON -> (None, []) + | T_LET -> + let (loc, (declarations, leading, errs)) = with_loc Declaration.let_ env in + ( Some + (For_declaration + ( loc, + { + Statement.VariableDeclaration.kind = Statement.VariableDeclaration.Let; + declarations; + comments = Flow_ast_utils.mk_comments_opt ~leading (); + } + ) + ), + errs + ) + | T_CONST -> + let (loc, (declarations, leading, errs)) = with_loc Declaration.const env in + ( Some + (For_declaration + ( loc, + { + Statement.VariableDeclaration.kind = Statement.VariableDeclaration.Const; + declarations; + comments = Flow_ast_utils.mk_comments_opt ~leading (); + } + ) + ), + errs + ) + | T_VAR -> + let (loc, (declarations, leading, errs)) = with_loc Declaration.var env in + ( Some + (For_declaration + ( loc, + { + Statement.VariableDeclaration.kind = Statement.VariableDeclaration.Var; + declarations; + comments = Flow_ast_utils.mk_comments_opt ~leading (); + } + ) + ), + errs + ) + | _ -> + let expr = Parse.expression_or_pattern (env |> with_no_let true) in + (Some (For_expression expr), []) + in + match Peek.token env with + | T_OF -> + (* This is a for of loop *) + let left = + match init with + | Some (For_declaration decl) -> + assert_can_be_forin_or_forof env Parse_error.InvalidLHSInForOf decl; + Statement.ForOf.LeftDeclaration decl + | Some (For_expression expr) -> + (* #sec-for-in-and-for-of-statements-static-semantics-early-errors *) + let patt = Pattern_cover.as_pattern ~err:Parse_error.InvalidLHSInForOf env expr in + Statement.ForOf.LeftPattern patt + | None -> assert false + in + Expect.token env T_OF; + let right = Parse.assignment env in + Expect.token env T_RPAREN; + let body = Parse.statement (env |> with_in_loop true) in + assert_not_labelled_function env body; + Statement.ForOf { Statement.ForOf.left; right; body; await = async; comments } + | T_IN -> + (* This is a for in loop *) + let left = + match init with + | Some (For_declaration decl) -> + assert_can_be_forin_or_forof env Parse_error.InvalidLHSInForIn decl; + Statement.ForIn.LeftDeclaration decl + | Some (For_expression expr) -> + (* #sec-for-in-and-for-of-statements-static-semantics-early-errors *) + let patt = Pattern_cover.as_pattern ~err:Parse_error.InvalidLHSInForIn env expr in + Statement.ForIn.LeftPattern patt + | None -> assert false + in + if async then + (* If `async` is true, this should have been a for-await-of loop, but we + recover by trying to parse like a for-in loop. *) + Expect.token env T_OF + else + Expect.token env T_IN; + let right = Parse.expression env in + Expect.token env T_RPAREN; + let body = Parse.statement (env |> with_in_loop true) in + assert_not_labelled_function env body; + Statement.ForIn { Statement.ForIn.left; right; body; each = false; comments } + | _ -> + (* This is a for loop *) + errs |> List.iter (error_at env); + if async then + (* If `async` is true, this should have been a for-await-of loop, but we + recover by trying to parse like a normal loop. *) + Expect.token env T_OF + else + Expect.token env T_SEMICOLON; + let init = + match init with + | Some (For_declaration decl) -> Some (Statement.For.InitDeclaration decl) + | Some (For_expression expr) -> + Some (Statement.For.InitExpression (Pattern_cover.as_expression env expr)) + | None -> None + in + let test = + match Peek.token env with + | T_SEMICOLON -> None + | _ -> Some (Parse.expression env) + in + Expect.token env T_SEMICOLON; + let update = + match Peek.token env with + | T_RPAREN -> None + | _ -> Some (Parse.expression env) + in + Expect.token env T_RPAREN; + let body = Parse.statement (env |> with_in_loop true) in + assert_not_labelled_function env body; + Statement.For { Statement.For.init; test; update; body; comments } + ) + + and if_ = + (* + * Either the consequent or alternate of an if statement + *) + let if_branch env = + (* Normally this would just be a Statement, but Annex B allows + FunctionDeclarations in non-strict mode. See + sec-functiondeclarations-in-ifstatement-statement-clauses *) + let stmt = + if Peek.is_function env then + function_as_statement env + else + Parse.statement env + in + (* Annex B allows labelled FunctionDeclarations in non-strict mode + (see sec-labelled-function-declarations), but not in IfStatement + (see sec-if-statement-static-semantics-early-errors). *) + if (not (in_strict_mode env)) && is_labelled_function stmt then + function_as_statement_error_at env (fst stmt); + + stmt + in + let alternate env = + let leading = Peek.comments env in + Expect.token env T_ELSE; + let body = if_branch env in + { Statement.If.Alternate.body; comments = Flow_ast_utils.mk_comments_opt ~leading () } + in + with_loc (fun env -> + let pre_if_leading = Peek.comments env in + Expect.token env T_IF; + let pre_cond_leading = Peek.comments env in + let leading = pre_if_leading @ pre_cond_leading in + Expect.token env T_LPAREN; + let test = Parse.expression env in + Expect.token env T_RPAREN; + let consequent = if_branch env in + let alternate = + if Peek.token env = T_ELSE then + Some (with_loc alternate env) + else + None + in + Statement.If + { + Statement.If.test; + consequent; + alternate; + comments = Flow_ast_utils.mk_comments_opt ~leading (); + } + ) + + and return = + with_loc (fun env -> + if not (in_function env) then error env Parse_error.IllegalReturn; + let leading = Peek.comments env in + let start_loc = Peek.loc env in + Expect.token env T_RETURN; + let trailing = + if Peek.token env = T_SEMICOLON then + Eat.trailing_comments env + else + [] + in + let argument = + if Peek.token env = T_SEMICOLON || Peek.is_implicit_semicolon env then + None + else + Some (Parse.expression env) + in + let return_out = Loc.btwn start_loc (Peek.loc env) in + let (trailing, argument) = + match (semicolon env, argument) with + | (Explicit comments, _) + | (Implicit { trailing = comments; _ }, None) -> + (trailing @ comments, argument) + | (Implicit { remove_trailing; _ }, Some arg) -> + (trailing, Some (remove_trailing arg (fun remover arg -> remover#expression arg))) + in + Statement.Return + { + Statement.Return.argument; + return_out; + comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing (); + } + ) + + and switch = + let case ~seen_default env = + let leading = Peek.comments env in + let (test, trailing) = + match Peek.token env with + | T_DEFAULT -> + if seen_default then error env Parse_error.MultipleDefaultsInSwitch; + Expect.token env T_DEFAULT; + (None, Eat.trailing_comments env) + | _ -> + Expect.token env T_CASE; + (Some (Parse.expression env), []) + in + let seen_default = seen_default || test = None in + Expect.token env T_COLON; + let { trailing = line_end_trailing; _ } = statement_end_trailing_comments env in + let trailing = trailing @ line_end_trailing in + let term_fn = function + | T_RCURLY + | T_DEFAULT + | T_CASE -> + true + | _ -> false + in + let consequent = Parse.statement_list ~term_fn (env |> with_in_switch true) in + let comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing () in + let case = { Statement.Switch.Case.test; consequent; comments } in + (case, seen_default) + in + let rec case_list env (seen_default, acc) = + match Peek.token env with + | T_EOF + | T_RCURLY -> + List.rev acc + | _ -> + let (case_, seen_default) = with_loc_extra (case ~seen_default) env in + let acc = case_ :: acc in + case_list env (seen_default, acc) + in + with_loc (fun env -> + let leading = Peek.comments env in + Expect.token env T_SWITCH; + Expect.token env T_LPAREN; + let discriminant = Parse.expression env in + Expect.token env T_RPAREN; + Expect.token env T_LCURLY; + let cases = case_list env (false, []) in + Expect.token env T_RCURLY; + let { trailing; _ } = statement_end_trailing_comments env in + Statement.Switch + { + Statement.Switch.discriminant; + cases; + comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing (); + exhaustive_out = fst discriminant; + } + ) + + and throw = + with_loc (fun env -> + let leading = Peek.comments env in + let start_loc = Peek.loc env in + Expect.token env T_THROW; + if Peek.is_line_terminator env then error_at env (start_loc, Parse_error.NewlineAfterThrow); + let argument = Parse.expression env in + let (trailing, argument) = + match semicolon env with + | Explicit trailing -> (trailing, argument) + | Implicit { remove_trailing; _ } -> + ([], remove_trailing argument (fun remover arg -> remover#expression arg)) + in + let open Statement in + Throw { Throw.argument; comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing () } + ) + + and try_ = + with_loc (fun env -> + let leading = Peek.comments env in + Expect.token env T_TRY; + let block = + let block = Parse.block_body env in + if Peek.token env = T_CATCH then + block_remove_trailing env block + else + block + in + let handler = + match Peek.token env with + | T_CATCH -> + let catch = + with_loc + (fun env -> + let leading = Peek.comments env in + Expect.token env T_CATCH; + let trailing = Eat.trailing_comments env in + let param = + if Peek.token env = T_LPAREN then ( + Expect.token env T_LPAREN; + let p = Some (Parse.pattern env Parse_error.StrictCatchVariable) in + Expect.token env T_RPAREN; + p + ) else + None + in + let body = Parse.block_body env in + (* Fix trailing comment attachment if catch block is end of statement *) + let body = + if Peek.token env <> T_FINALLY then + let { remove_trailing; _ } = statement_end_trailing_comments env in + remove_trailing body (fun remover (loc, body) -> (loc, remover#block loc body)) + else + body + in + { + Ast.Statement.Try.CatchClause.param; + body; + comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing (); + }) + env + in + Some catch + | _ -> None + in + let finalizer = + match Peek.token env with + | T_FINALLY -> + Expect.token env T_FINALLY; + let (loc, body) = Parse.block_body env in + let { remove_trailing; _ } = statement_end_trailing_comments env in + let body = remove_trailing body (fun remover body -> remover#block loc body) in + Some (loc, body) + | _ -> None + in + (* No catch or finally? That's an error! *) + if handler = None && finalizer = None then + error_at env (fst block, Parse_error.NoCatchOrFinally); + + Statement.Try + { + Statement.Try.block; + handler; + finalizer; + comments = Flow_ast_utils.mk_comments_opt ~leading (); + } + ) + + and var = + with_loc (fun env -> + let kind = Statement.VariableDeclaration.Var in + let (declarations, leading, errs) = Declaration.var env in + let (trailing, declarations) = variable_declaration_end ~kind env declarations in + errs |> List.iter (error_at env); + Statement.VariableDeclaration + { + Statement.VariableDeclaration.kind; + declarations; + comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing (); + } + ) + + and const = + with_loc (fun env -> + let kind = Statement.VariableDeclaration.Const in + let (declarations, leading, errs) = Declaration.const env in + let (trailing, declarations) = variable_declaration_end ~kind env declarations in + errs |> List.iter (error_at env); + Statement.VariableDeclaration + { + Statement.VariableDeclaration.kind; + declarations; + comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing (); + } + ) + + and let_ = + with_loc (fun env -> + let kind = Statement.VariableDeclaration.Let in + let (declarations, leading, errs) = Declaration.let_ env in + let (trailing, declarations) = variable_declaration_end ~kind env declarations in + errs |> List.iter (error_at env); + Statement.VariableDeclaration + { + Statement.VariableDeclaration.kind; + declarations; + comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing (); + } + ) + + and while_ = + with_loc (fun env -> + let leading = Peek.comments env in + Expect.token env T_WHILE; + let leading = leading @ Peek.comments env in + Expect.token env T_LPAREN; + let test = Parse.expression env in + Expect.token env T_RPAREN; + let body = Parse.statement (env |> with_in_loop true) in + (* Annex B allows labelled FunctionDeclarations in non-strict mode + (see sec-labelled-function-declarations), but not in IterationStatement + (see sec-semantics-static-semantics-early-errors). *) + if (not (in_strict_mode env)) && is_labelled_function body then + function_as_statement_error_at env (fst body); + Statement.While + { Statement.While.test; body; comments = Flow_ast_utils.mk_comments_opt ~leading () } + ) + + and with_ env = + let (loc, stmt) = + with_loc + (fun env -> + let leading = Peek.comments env in + Expect.token env T_WITH; + let leading = leading @ Peek.comments env in + Expect.token env T_LPAREN; + let _object = Parse.expression env in + Expect.token env T_RPAREN; + let body = Parse.statement env in + (* Annex B allows labelled FunctionDeclarations in non-strict mode + (see sec-labelled-function-declarations), but not in WithStatement + (see sec-with-statement-static-semantics-early-errors). *) + if (not (in_strict_mode env)) && is_labelled_function body then + function_as_statement_error_at env (fst body); + Statement.With + { Statement.With._object; body; comments = Flow_ast_utils.mk_comments_opt ~leading () }) + env + in + strict_error_at env (loc, Parse_error.StrictModeWith); + (loc, stmt) + + and block env = + let (loc, block) = Parse.block_body env in + let { remove_trailing; _ } = statement_end_trailing_comments env in + let block = remove_trailing block (fun remover block -> remover#block loc block) in + (loc, Statement.Block block) + + and maybe_labeled = + with_loc (fun env -> + let leading = Peek.comments env in + match (Parse.expression env, Peek.token env) with + | ((loc, Ast.Expression.Identifier label), T_COLON) -> + let (_, { Identifier.name; comments = _ }) = label in + Expect.token env T_COLON; + if SSet.mem name (labels env) then + error_at env (loc, Parse_error.Redeclaration ("Label", name)); + let env = add_label env name in + let body = + (* labelled FunctionDeclarations are allowed in non-strict mode + (see #sec-labelled-function-declarations) *) + if Peek.is_function env then + function_as_statement env + else + Parse.statement env + in + Statement.Labeled + { Statement.Labeled.label; body; comments = Flow_ast_utils.mk_comments_opt ~leading () } + | (expression, _) -> + let (trailing, expression) = + match semicolon ~expected:"the end of an expression statement (`;`)" env with + | Explicit comments -> (comments, expression) + | Implicit { remove_trailing; _ } -> + ([], remove_trailing expression (fun remover expr -> remover#expression expr)) + in + let open Statement in + Expression + { + Expression.expression; + directive = None; + comments = Flow_ast_utils.mk_comments_opt ~trailing (); + } + ) + + and expression = + with_loc (fun env -> + let expression = Parse.expression env in + let (trailing, expression) = + match semicolon ~expected:"the end of an expression statement (`;`)" env with + | Explicit comments -> (comments, expression) + | Implicit { remove_trailing; _ } -> + ([], remove_trailing expression (fun remover expr -> remover#expression expr)) + in + let directive = + if allow_directive env then + match expression with + | (_, Ast.Expression.Literal { Ast.Literal.value = Ast.Literal.String _; raw; _ }) -> + (* the parser may recover from errors and generate unclosed strings, where + the opening quote should be reliable but the closing one might not exist. + be defensive. *) + if String.length raw > 1 && raw.[0] = raw.[String.length raw - 1] then + Some (String.sub raw 1 (String.length raw - 2)) + else + None + | _ -> None + else + None + in + Statement.Expression + { + Statement.Expression.expression; + directive; + comments = Flow_ast_utils.mk_comments_opt ~trailing (); + } + ) + + and type_alias_helper ~leading env = + if not (should_parse_types env) then error env Parse_error.UnexpectedTypeAlias; + let leading = leading @ Peek.comments env in + Expect.token env T_TYPE; + Eat.push_lex_mode env Lex_mode.TYPE; + let id = + let id = Type.type_identifier env in + if Peek.token env = T_LESS_THAN then + id_remove_trailing env id + else + id + in + let tparams = Type.type_params env in + Expect.token env T_ASSIGN; + let right = Type._type env in + Eat.pop_lex_mode env; + let (trailing, right) = + match semicolon env with + | Explicit comments -> (comments, right) + | Implicit { remove_trailing; _ } -> + ([], remove_trailing right (fun remover right -> remover#type_ right)) + in + + { + Statement.TypeAlias.id; + tparams; + right; + comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing (); + } + + and declare_type_alias env = + with_loc + (fun env -> + let leading = Peek.comments env in + Expect.token env T_DECLARE; + let type_alias = type_alias_helper ~leading env in + Statement.DeclareTypeAlias type_alias) + env + + (** Type aliases squeeze into an unambiguous unused portion of the grammar: `type` is not a + reserved word, so `type T` is otherwise two identifiers in a row and that's never valid JS. + However, if there's a line separator between the two, ASI makes it valid JS, so line + separators are disallowed. *) + and type_alias env = + if Peek.ith_is_identifier ~i:1 env && not (Peek.ith_is_implicit_semicolon ~i:1 env) then + let (loc, type_alias) = with_loc (type_alias_helper ~leading:[]) env in + (loc, Statement.TypeAlias type_alias) + else + Parse.statement env + + and opaque_type_helper ?(declare = false) ~leading env = + if not (should_parse_types env) then error env Parse_error.UnexpectedOpaqueTypeAlias; + let leading_opaque = leading @ Peek.comments env in + Expect.token env T_OPAQUE; + let leading_type = Peek.comments env in + Expect.token env T_TYPE; + let leading = leading_opaque @ leading_type in + Eat.push_lex_mode env Lex_mode.TYPE; + let id = + let id = Type.type_identifier env in + if Peek.token env = T_LESS_THAN then + id_remove_trailing env id + else + id + in + let tparams = Type.type_params env in + let supertype = + match Peek.token env with + | T_COLON -> + Expect.token env T_COLON; + Some (Type._type env) + | _ -> None + in + let impltype = + if declare then + match Peek.token env with + | T_ASSIGN -> + error env Parse_error.DeclareOpaqueTypeInitializer; + Eat.token env; + if Peek.token env = T_SEMICOLON || Peek.is_implicit_semicolon env then + None + else + Some (Type._type env) + | _ -> None + else ( + Expect.token env T_ASSIGN; + Some (Type._type env) + ) + in + Eat.pop_lex_mode env; + let (trailing, id, tparams, supertype, impltype) = + match (semicolon env, tparams, supertype, impltype) with + (* opaque type Foo = Bar; *) + | (Explicit comments, _, _, _) -> (comments, id, tparams, supertype, impltype) + (* opaque type Foo = Bar *) + | (Implicit { remove_trailing; _ }, _, _, Some impl) -> + ( [], + id, + tparams, + supertype, + Some (remove_trailing impl (fun remover impl -> remover#type_ impl)) + ) + (* opaque type Foo: Super *) + | (Implicit { remove_trailing; _ }, _, Some super, None) -> + ( [], + id, + tparams, + Some (remove_trailing super (fun remover super -> remover#type_ super)), + None + ) + (* opaque type Foo *) + | (Implicit { remove_trailing; _ }, Some tparams, None, None) -> + ( [], + id, + Some (remove_trailing tparams (fun remover tparams -> remover#type_params tparams)), + None, + None + ) + (* declare opaque type Foo *) + | (Implicit { remove_trailing; _ }, None, None, None) -> + ([], remove_trailing id (fun remover id -> remover#identifier id), None, None, None) + in + + { + Statement.OpaqueType.id; + tparams; + impltype; + supertype; + comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing (); + } + + and declare_opaque_type env = + with_loc + (fun env -> + let leading = Peek.comments env in + Expect.token env T_DECLARE; + let opaque_t = opaque_type_helper ~declare:true ~leading env in + Statement.DeclareOpaqueType opaque_t) + env + + and opaque_type env = + match Peek.ith_token ~i:1 env with + | T_TYPE -> + let (loc, opaque_t) = with_loc (opaque_type_helper ~declare:false ~leading:[]) env in + (loc, Statement.OpaqueType opaque_t) + | _ -> Parse.statement env + + and interface_helper ~leading env = + if not (should_parse_types env) then error env Parse_error.UnexpectedTypeInterface; + let leading = leading @ Peek.comments env in + Expect.token env T_INTERFACE; + let id = + let id = Type.type_identifier env in + if Peek.token env = T_EXTENDS then + id + else + id_remove_trailing env id + in + let tparams = + let tparams = Type.type_params env in + if Peek.token env = T_EXTENDS then + tparams + else + type_params_remove_trailing env tparams + in + let (extends, body) = Type.interface_helper env in + let { remove_trailing; _ } = statement_end_trailing_comments env in + let body = + remove_trailing body (fun remover (loc, body) -> (loc, remover#object_type loc body)) + in + + { + Statement.Interface.id; + tparams; + body; + extends; + comments = Flow_ast_utils.mk_comments_opt ~leading (); + } + + and declare_interface env = + with_loc + (fun env -> + let leading = Peek.comments env in + Expect.token env T_DECLARE; + let iface = interface_helper ~leading env in + Statement.DeclareInterface iface) + env + + and interface env = + (* disambiguate between a value named `interface`, like `var interface = 1; interface++`, + and an interface declaration like `interface Foo {}`.` *) + if Peek.ith_is_identifier_name ~i:1 env then + let (loc, iface) = with_loc (interface_helper ~leading:[]) env in + (loc, Statement.InterfaceDeclaration iface) + else + expression env + + and declare_class = + let rec mixins env acc = + let super = Type.generic env in + let acc = super :: acc in + match Peek.token env with + | T_COMMA -> + Expect.token env T_COMMA; + mixins env acc + | _ -> List.rev acc + (* This is identical to `interface`, except that mixins are allowed *) + in + fun ~leading env -> + let env = env |> with_strict true in + let leading = leading @ Peek.comments env in + Expect.token env T_CLASS; + let id = + let id = Parse.identifier env in + match Peek.token env with + | T_LESS_THAN + | T_LCURLY -> + id_remove_trailing env id + | _ -> id + in + let tparams = + let tparams = Type.type_params env in + match Peek.token env with + | T_LCURLY -> type_params_remove_trailing env tparams + | _ -> tparams + in + let extends = + if Eat.maybe env T_EXTENDS then + let extends = Type.generic env in + match Peek.token env with + | T_LCURLY -> Some (generic_type_remove_trailing env extends) + | _ -> Some extends + else + None + in + let mixins = + match Peek.token env with + | T_IDENTIFIER { raw = "mixins"; _ } -> + Eat.token env; + let mixins = mixins env [] in + (match Peek.token env with + | T_LCURLY -> generic_type_list_remove_trailing env mixins + | _ -> mixins) + | _ -> [] + in + let implements = + match Peek.token env with + | T_IMPLEMENTS -> + let implements = Object.class_implements env ~attach_leading:false in + (match Peek.token env with + | T_LCURLY -> Some (class_implements_remove_trailing env implements) + | _ -> Some implements) + | _ -> None + in + let body = Type._object ~is_class:true env in + let { remove_trailing; _ } = statement_end_trailing_comments env in + let body = + remove_trailing body (fun remover (loc, body) -> (loc, remover#object_type loc body)) + in + let comments = Flow_ast_utils.mk_comments_opt ~leading () in + Statement.DeclareClass.{ id; tparams; body; extends; mixins; implements; comments } + + and declare_class_statement env = + with_loc + (fun env -> + let leading = Peek.comments env in + Expect.token env T_DECLARE; + let fn = declare_class ~leading env in + Statement.DeclareClass fn) + env + + and declare_function ?(leading = []) env = + let leading = leading @ Peek.comments env in + Expect.token env T_FUNCTION; + let id = id_remove_trailing env (Parse.identifier env) in + let annot = + with_loc + (fun env -> + let tparams = type_params_remove_trailing env (Type.type_params env) in + let params = Type.function_param_list env in + Expect.token env T_COLON; + let return = + let return = Type._type env in + let has_predicate = + Eat.push_lex_mode env Lex_mode.TYPE; + let type_token = Peek.token env in + Eat.pop_lex_mode env; + type_token = T_CHECKS + in + if has_predicate then + type_remove_trailing env return + else + return + in + Ast.Type.(Function { Function.params; return; tparams; comments = None })) + env + in + let predicate = Type.predicate_opt env in + let (trailing, annot, predicate) = + match (semicolon env, predicate) with + | (Explicit comments, _) -> (comments, annot, predicate) + | (Implicit { remove_trailing; _ }, None) -> + ([], remove_trailing annot (fun remover annot -> remover#type_ annot), None) + | (Implicit { remove_trailing; _ }, Some pred) -> + ([], annot, Some (remove_trailing pred (fun remover pred -> remover#predicate pred))) + in + let annot = (fst annot, annot) in + + { + Statement.DeclareFunction.id; + annot; + predicate; + comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing (); + } + + and declare_function_statement env = + with_loc + (fun env -> + let leading = Peek.comments env in + Expect.token env T_DECLARE; + begin + match Peek.token env with + | T_ASYNC -> + error env Parse_error.DeclareAsync; + Expect.token env T_ASYNC + | _ -> () + end; + let fn = declare_function ~leading env in + Statement.DeclareFunction fn) + env + + and declare_var env leading = + let leading = leading @ Peek.comments env in + Expect.token env T_VAR; + let name = Parse.identifier ~restricted_error:Parse_error.StrictVarName env in + let annot = Type.annotation env in + let (trailing, name, annot) = + match semicolon env with + (* declare var x; *) + | Explicit trailing -> (trailing, name, annot) + (* declare var x *) + | Implicit { remove_trailing; _ } -> + ([], name, remove_trailing annot (fun remover annot -> remover#type_annotation annot)) + in + + { + Statement.DeclareVariable.id = name; + annot; + comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing (); + } + + and declare_var_statement env = + with_loc + (fun env -> + let leading = Peek.comments env in + Expect.token env T_DECLARE; + let var = declare_var env leading in + Statement.DeclareVariable var) + env + + and declare_module = + let rec module_items env ~module_kind acc = + match Peek.token env with + | T_EOF + | T_RCURLY -> + (module_kind, List.rev acc) + | _ -> + let stmt = declare ~in_module:true env in + (* TODO: This is a semantic analysis and shouldn't be in the parser *) + let module_kind = + let open Statement in + let (_loc, stmt) = stmt in + match (module_kind, stmt) with + (* + * The first time we see either a `declare export` or a + * `declare module.exports`, we lock in the kind of the module. + * + * `declare export type` and `declare export interface` are the two + * exceptions to this rule because they are valid in both CommonJS + * and ES modules (and thus do not indicate an intent for either). + *) + | (None, DeclareModuleExports _) -> Some DeclareModule.CommonJS + | (None, DeclareExportDeclaration { DeclareExportDeclaration.declaration; _ }) -> + (match declaration with + | Some (DeclareExportDeclaration.NamedType _) + | Some (DeclareExportDeclaration.Interface _) -> + module_kind + | _ -> Some DeclareModule.ES) + (* + * There should never be more than one `declare module.exports` + * statement *) + | (Some DeclareModule.CommonJS, DeclareModuleExports _) -> + error env Parse_error.DuplicateDeclareModuleExports; + module_kind + (* + * It's never ok to mix and match `declare export` and + * `declare module.exports` in the same module because it leaves the + * kind of the module (CommonJS vs ES) ambiguous. + * + * The 1 exception to this rule is that `export type/interface` are + * both ok in CommonJS modules. + *) + | (Some DeclareModule.ES, DeclareModuleExports _) -> + error env Parse_error.AmbiguousDeclareModuleKind; + module_kind + | ( Some DeclareModule.CommonJS, + DeclareExportDeclaration { DeclareExportDeclaration.declaration; _ } + ) -> + (match declaration with + | Some (DeclareExportDeclaration.NamedType _) + | Some (DeclareExportDeclaration.Interface _) -> + () + | _ -> error env Parse_error.AmbiguousDeclareModuleKind); + module_kind + | _ -> module_kind + in + module_items env ~module_kind (stmt :: acc) + in + let declare_module_ ~leading env = + let id = + match Peek.token env with + | T_STRING str -> + Statement.DeclareModule.Literal + (string_literal_remove_trailing env (string_literal env str)) + | _ -> Statement.DeclareModule.Identifier (id_remove_trailing env (Parse.identifier env)) + in + let (body, module_kind) = + with_loc_extra + (fun env -> + let leading = Peek.comments env in + Expect.token env T_LCURLY; + let (module_kind, body) = module_items env ~module_kind:None [] in + let internal = + if body = [] then + Peek.comments env + else + [] + in + Expect.token env T_RCURLY; + let { trailing; _ } = statement_end_trailing_comments env in + let comments = + Flow_ast_utils.mk_comments_with_internal_opt ~leading ~trailing ~internal () + in + let body = { Statement.Block.body; comments } in + (body, module_kind)) + env + in + let kind = + match module_kind with + | Some k -> k + | None -> Statement.DeclareModule.CommonJS + in + let comments = Flow_ast_utils.mk_comments_opt ~leading () in + Statement.(DeclareModule DeclareModule.{ id; body; kind; comments }) + in + fun ~in_module env -> + let start_loc = Peek.loc env in + let leading = Peek.comments env in + Expect.token env T_DECLARE; + let leading = leading @ Peek.comments env in + Expect.identifier env "module"; + if in_module || Peek.token env = T_PERIOD then + with_loc ~start_loc (declare_module_exports ~leading) env + else + with_loc ~start_loc (declare_module_ ~leading) env + + and declare_module_exports ~leading env = + let leading_period = Peek.comments env in + Expect.token env T_PERIOD; + let leading_exports = Peek.comments env in + Expect.identifier env "exports"; + let leading_annot = Peek.comments env in + let leading = List.concat [leading; leading_period; leading_exports; leading_annot] in + let annot = Type.annotation env in + let (annot, trailing) = + match semicolon env with + | Explicit trailing -> (annot, trailing) + | Implicit { remove_trailing; _ } -> + (remove_trailing annot (fun remover annot -> remover#type_annotation annot), []) + in + let comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing () in + Statement.DeclareModuleExports { Statement.DeclareModuleExports.annot; comments } + + and declare ?(in_module = false) env = + if not (should_parse_types env) then error env Parse_error.UnexpectedTypeDeclaration; + + (* eventually, just emit a wrapper AST node *) + match Peek.ith_token ~i:1 env with + | T_CLASS -> declare_class_statement env + | T_INTERFACE -> declare_interface env + | T_TYPE -> + (match Peek.token env with + | T_IMPORT when in_module -> import_declaration env + | _ -> declare_type_alias env) + | T_OPAQUE -> declare_opaque_type env + | T_TYPEOF when Peek.token env = T_IMPORT -> import_declaration env + | T_FUNCTION + | T_ASYNC -> + declare_function_statement env + | T_VAR -> declare_var_statement env + | T_EXPORT when in_module -> declare_export_declaration ~allow_export_type:in_module env + | T_IDENTIFIER { raw = "module"; _ } -> declare_module ~in_module env + | _ when in_module -> + (match Peek.token env with + | T_IMPORT -> + error env Parse_error.InvalidNonTypeImportInDeclareModule; + Parse.statement env + | _ -> + (* Oh boy, found some bad stuff in a declare module. Let's just + * pretend it's a declare var (arbitrary choice) *) + declare_var_statement env) + | _ -> Parse.statement env + + and export_source env = + Expect.identifier env "from"; + match Peek.token env with + | T_STRING str -> string_literal env str + | _ -> + (* Just make up a string for the error case *) + let ret = (Peek.loc env, { StringLiteral.value = ""; raw = ""; comments = None }) in + error_unexpected ~expected:"a string" env; + ret + + and export_source_and_semicolon env = + let (source_loc, source) = export_source env in + match semicolon env with + | Explicit trailing -> ((source_loc, source), trailing) + | Implicit { remove_trailing; _ } -> + ( ( source_loc, + remove_trailing source (fun remover source -> + remover#string_literal_type source_loc source + ) + ), + [] + ) + + and export_specifiers ?(preceding_comma = true) env specifiers = + match Peek.token env with + | T_EOF + | T_RCURLY -> + List.rev specifiers + | _ -> + if not preceding_comma then error env Parse_error.ExportSpecifierMissingComma; + let specifier = + with_loc + (fun env -> + let local = identifier_name env in + let exported = + match Peek.token env with + | T_IDENTIFIER { raw = "as"; _ } -> + Eat.token env; + Some (identifier_name env) + | _ -> None + in + { Statement.ExportNamedDeclaration.ExportSpecifier.local; exported }) + env + in + let preceding_comma = Eat.maybe env T_COMMA in + export_specifiers ~preceding_comma env (specifier :: specifiers) + + and assert_export_specifier_identifiers env specifiers = + Statement.ExportNamedDeclaration.ExportSpecifier.( + List.iter + (function + | (_, { local = id; exported = None }) -> + assert_identifier_name_is_identifier ~restricted_error:Parse_error.StrictVarName env id + | _ -> ()) + specifiers + ) + + and export_declaration ~decorators env = + let env = env |> with_strict true |> with_in_export true in + let leading = Peek.comments env in + let start_loc = Peek.loc env in + Expect.token env T_EXPORT; + match Peek.token env with + | T_DEFAULT -> + (* export default ... *) + with_loc + ~start_loc + (fun env -> + let open Statement.ExportDefaultDeclaration in + let leading = leading @ Peek.comments env in + let (default, ()) = with_loc (fun env -> Expect.token env T_DEFAULT) env in + let env = with_in_export_default true env in + let (declaration, trailing) = + if Peek.is_function env then + (* export default [async] function [foo] (...) { ... } *) + let fn = Declaration._function env in + (Declaration fn, []) + else if Peek.is_class env then + (* export default class foo { ... } *) + let _class = Object.class_declaration env decorators in + (Declaration _class, []) + else if Peek.token env = T_ENUM then + (* export default enum foo { ... } *) + (Declaration (Declaration.enum_declaration env), []) + else + (* export default [assignment expression]; *) + let expr = Parse.assignment env in + let (expr, trailing) = + match semicolon env with + | Explicit trailing -> (expr, trailing) + | Implicit { remove_trailing; _ } -> + (remove_trailing expr (fun remover expr -> remover#expression expr), []) + in + (Expression expr, trailing) + in + Statement.ExportDefaultDeclaration + { + default; + declaration; + comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing (); + }) + env + | T_TYPE when Peek.ith_token ~i:1 env <> T_LCURLY -> + (* export type ... *) + with_loc + ~start_loc + (fun env -> + let open Statement.ExportNamedDeclaration in + if not (should_parse_types env) then error env Parse_error.UnexpectedTypeExport; + match Peek.ith_token ~i:1 env with + | T_MULT -> + Expect.token env T_TYPE; + let specifier_loc = Peek.loc env in + Expect.token env T_MULT; + let (source, trailing) = export_source_and_semicolon env in + Statement.ExportNamedDeclaration + { + declaration = None; + specifiers = Some (ExportBatchSpecifier (specifier_loc, None)); + source = Some source; + export_kind = Statement.ExportType; + comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing (); + } + | T_ENUM -> + error env Parse_error.EnumInvalidExport; + Expect.token env T_TYPE; + Statement.ExportNamedDeclaration + { + declaration = None; + specifiers = None; + source = None; + export_kind = Statement.ExportType; + comments = Flow_ast_utils.mk_comments_opt ~leading (); + } + | _ -> + let (loc, type_alias) = with_loc (type_alias_helper ~leading:[]) env in + let type_alias = (loc, Statement.TypeAlias type_alias) in + Statement.ExportNamedDeclaration + { + declaration = Some type_alias; + specifiers = None; + source = None; + export_kind = Statement.ExportType; + comments = Flow_ast_utils.mk_comments_opt ~leading (); + }) + env + | T_OPAQUE -> + (* export opaque type ... *) + with_loc + ~start_loc + (fun env -> + let open Statement.ExportNamedDeclaration in + let (loc, opaque_t) = with_loc (opaque_type_helper ~leading:[]) env in + let opaque_t = (loc, Statement.OpaqueType opaque_t) in + Statement.ExportNamedDeclaration + { + declaration = Some opaque_t; + specifiers = None; + source = None; + export_kind = Statement.ExportType; + comments = Flow_ast_utils.mk_comments_opt ~leading (); + }) + env + | T_INTERFACE -> + (* export interface I { ... } *) + with_loc + ~start_loc + (fun env -> + let open Statement.ExportNamedDeclaration in + if not (should_parse_types env) then error env Parse_error.UnexpectedTypeExport; + let interface = + let (loc, iface) = with_loc (interface_helper ~leading:[]) env in + (loc, Statement.InterfaceDeclaration iface) + in + Statement.ExportNamedDeclaration + { + declaration = Some interface; + specifiers = None; + source = None; + export_kind = Statement.ExportType; + comments = Flow_ast_utils.mk_comments_opt ~leading (); + }) + env + | _ when Peek.is_class env -> + with_loc + ~start_loc + (fun env -> + let stmt = Object.class_declaration env decorators in + Statement.ExportNamedDeclaration + { + Statement.ExportNamedDeclaration.declaration = Some stmt; + specifiers = None; + source = None; + export_kind = Statement.ExportValue; + comments = Flow_ast_utils.mk_comments_opt ~leading (); + }) + env + | _ when Peek.is_function env -> + with_loc + ~start_loc + (fun env -> + error_on_decorators env decorators; + let stmt = Declaration._function env in + Statement.ExportNamedDeclaration + { + Statement.ExportNamedDeclaration.declaration = Some stmt; + specifiers = None; + source = None; + export_kind = Statement.ExportValue; + comments = Flow_ast_utils.mk_comments_opt ~leading (); + }) + env + | T_LET + | T_CONST + | T_VAR -> + with_loc + ~start_loc + (fun env -> + let stmt = Parse.statement_list_item env ~decorators in + Statement.ExportNamedDeclaration + { + Statement.ExportNamedDeclaration.declaration = Some stmt; + specifiers = None; + source = None; + export_kind = Statement.ExportValue; + comments = Flow_ast_utils.mk_comments_opt ~leading (); + }) + env + | T_ENUM when (parse_options env).enums -> + with_loc + ~start_loc + (fun env -> + let stmt = Parse.statement_list_item env ~decorators in + Statement.ExportNamedDeclaration + { + Statement.ExportNamedDeclaration.declaration = Some stmt; + specifiers = None; + source = None; + export_kind = Statement.ExportValue; + comments = Flow_ast_utils.mk_comments_opt ~leading (); + }) + env + | T_MULT -> + with_loc + ~start_loc + (fun env -> + let open Statement.ExportNamedDeclaration in + let loc = Peek.loc env in + Expect.token env T_MULT; + let local_name = + match Peek.token env with + | T_IDENTIFIER { raw = "as"; _ } -> + Eat.token env; + Some (Parse.identifier env) + | _ -> None + in + let specifiers = Some (ExportBatchSpecifier (loc, local_name)) in + let (source, trailing) = export_source_and_semicolon env in + Statement.ExportNamedDeclaration + { + declaration = None; + specifiers; + source = Some source; + export_kind = Statement.ExportValue; + comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing (); + }) + env + | _ -> + let open Statement.ExportNamedDeclaration in + let export_kind = + if Eat.maybe env T_TYPE then + Statement.ExportType + else + Statement.ExportValue + in + if Eat.maybe env T_LCURLY then + with_loc + ~start_loc + (fun env -> + let specifiers = export_specifiers env [] in + Expect.token env T_RCURLY; + let (source, trailing) = + match Peek.token env with + | T_IDENTIFIER { raw = "from"; _ } -> + let (source, trailing) = export_source_and_semicolon env in + (Some source, trailing) + | _ -> + assert_export_specifier_identifiers env specifiers; + let trailing = + match semicolon env with + | Explicit trailing -> trailing + | Implicit { trailing; _ } -> trailing + in + (None, trailing) + in + Statement.ExportNamedDeclaration + { + declaration = None; + specifiers = Some (ExportSpecifiers specifiers); + source; + export_kind; + comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing (); + }) + env + else ( + (* error. recover by ignoring the `export` *) + error_unexpected ~expected:"a declaration, statement or export specifiers" env; + Parse.statement_list_item env ~decorators + ) + + and declare_export_declaration ?(allow_export_type = false) = + with_loc (fun env -> + if not (should_parse_types env) then error env Parse_error.UnexpectedTypeDeclaration; + let leading = Peek.comments env in + Expect.token env T_DECLARE; + let env = env |> with_strict true |> with_in_export true in + let leading = leading @ Peek.comments env in + Expect.token env T_EXPORT; + Statement.DeclareExportDeclaration.( + match Peek.token env with + | T_DEFAULT -> + (* declare export default ... *) + let leading = leading @ Peek.comments env in + let (default, ()) = with_loc (fun env -> Expect.token env T_DEFAULT) env in + let env = with_in_export_default true env in + let (declaration, trailing) = + match Peek.token env with + | T_FUNCTION -> + (* declare export default function foo (...): ... *) + let fn = with_loc declare_function env in + (Some (Function fn), []) + | T_CLASS -> + (* declare export default class foo { ... } *) + let class_ = with_loc (declare_class ~leading:[]) env in + (Some (Class class_), []) + | _ -> + (* declare export default [type]; *) + let type_ = Type._type env in + let (type_, trailing) = + match semicolon env with + | Explicit trailing -> (type_, trailing) + | Implicit { remove_trailing; _ } -> + (remove_trailing type_ (fun remover type_ -> remover#type_ type_), []) + in + (Some (DefaultType type_), trailing) + in + let comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing () in + Statement.DeclareExportDeclaration + { default = Some default; declaration; specifiers = None; source = None; comments } + | T_LET + | T_CONST + | T_VAR + | T_CLASS + | T_FUNCTION -> + let declaration = + match Peek.token env with + | T_FUNCTION -> + (* declare export function foo (...): ... *) + let fn = with_loc declare_function env in + Some (Function fn) + | T_CLASS -> + (* declare export class foo { ... } *) + let class_ = with_loc (declare_class ~leading:[]) env in + Some (Class class_) + | (T_LET | T_CONST | T_VAR) as token -> + (match token with + | T_LET -> error env Parse_error.DeclareExportLet + | T_CONST -> error env Parse_error.DeclareExportConst + | _ -> ()); + + (* declare export var foo: ... *) + let var = with_loc (fun env -> declare_var env []) env in + Some (Variable var) + | _ -> assert false + in + let comments = Flow_ast_utils.mk_comments_opt ~leading () in + Statement.DeclareExportDeclaration + { default = None; declaration; specifiers = None; source = None; comments } + | T_MULT -> + (* declare export * from 'foo' *) + let loc = Peek.loc env in + Expect.token env T_MULT; + let local_name = + match Peek.token env with + | T_IDENTIFIER { raw = "as"; _ } -> + Eat.token env; + Some (Parse.identifier env) + | _ -> None + in + let specifiers = + Statement.ExportNamedDeclaration.(Some (ExportBatchSpecifier (loc, local_name))) + in + let (source, trailing) = export_source_and_semicolon env in + let comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing () in + Statement.DeclareExportDeclaration + { default = None; declaration = None; specifiers; source = Some source; comments } + | T_TYPE when allow_export_type -> + (* declare export type = ... *) + let alias = with_loc (type_alias_helper ~leading:[]) env in + let comments = Flow_ast_utils.mk_comments_opt ~leading () in + Statement.DeclareExportDeclaration + { + default = None; + declaration = Some (NamedType alias); + specifiers = None; + source = None; + comments; + } + | T_OPAQUE -> + (* declare export opaque type = ... *) + let opaque = with_loc (opaque_type_helper ~declare:true ~leading:[]) env in + let comments = Flow_ast_utils.mk_comments_opt ~leading () in + Statement.DeclareExportDeclaration + { + default = None; + declaration = Some (NamedOpaqueType opaque); + specifiers = None; + source = None; + comments; + } + | T_INTERFACE when allow_export_type -> + (* declare export interface ... *) + let iface = with_loc (interface_helper ~leading:[]) env in + let comments = Flow_ast_utils.mk_comments_opt ~leading () in + Statement.DeclareExportDeclaration + { + default = None; + declaration = Some (Interface iface); + specifiers = None; + source = None; + comments; + } + | _ -> + (match Peek.token env with + | T_TYPE -> error env Parse_error.DeclareExportType + | T_INTERFACE -> error env Parse_error.DeclareExportInterface + | _ -> ()); + Expect.token env T_LCURLY; + let specifiers = export_specifiers env [] in + Expect.token env T_RCURLY; + let (source, trailing) = + match Peek.token env with + | T_IDENTIFIER { raw = "from"; _ } -> + let (source, trailing) = export_source_and_semicolon env in + (Some source, trailing) + | _ -> + assert_export_specifier_identifiers env specifiers; + let trailing = + match semicolon env with + | Explicit trailing -> trailing + | Implicit { trailing; _ } -> trailing + in + (None, trailing) + in + let comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing () in + Statement.DeclareExportDeclaration + { + default = None; + declaration = None; + specifiers = Some (Statement.ExportNamedDeclaration.ExportSpecifiers specifiers); + source; + comments; + } + ) + ) + + and import_declaration = + Statement.ImportDeclaration.( + let missing_source env = + (* Just make up a string for the error case *) + let loc = Peek.loc_skip_lookahead env in + (loc, { StringLiteral.value = ""; raw = ""; comments = None }) + in + let source env = + match Peek.token env with + | T_IDENTIFIER { raw = "from"; _ } -> + Eat.token env; + (match Peek.token env with + | T_STRING str -> string_literal env str + | _ -> + error_unexpected ~expected:"a string" env; + missing_source env) + | _ -> + error_unexpected ~expected:"the keyword `from`" env; + missing_source env + in + let is_type_import = function + | T_TYPE + | T_TYPEOF -> + true + | _ -> false + (* `x` or `x as y` in a specifier *) + in + let with_maybe_as ~for_type ?error_if_type env = + let identifier env = + if for_type then + Type.type_identifier env + else + Parse.identifier env + in + match Peek.ith_token ~i:1 env with + | T_IDENTIFIER { raw = "as"; _ } -> + let remote = identifier_name env in + Eat.token env; + + (* as *) + let local = Some (identifier env) in + (remote, local) + | T_EOF + | T_COMMA + | T_RCURLY -> + (identifier env, None) + | _ -> + begin + match (error_if_type, Peek.token env) with + | (Some error_if_type, T_TYPE) + | (Some error_if_type, T_TYPEOF) -> + error env error_if_type; + Eat.token env; + + (* consume `type` or `typeof` *) + (Type.type_identifier env, None) + | _ -> (identifier env, None) + end + (* + ImportSpecifier[Type]: + [~Type] ImportedBinding + [~Type] IdentifierName ImportedTypeBinding + [~Type] IdentifierName IdentifierName ImportedBinding + [~Type] IdentifierName IdentifierName IdentifierName ImportedTypeBinding + [+Type] ImportedTypeBinding + [+Type] IdentifierName IdentifierName ImportedTypeBinding + + Static Semantics: + + `IdentifierName ImportedTypeBinding`: + - It is a Syntax Error if IdentifierName's StringValue is not "type" or "typeof" + + `IdentifierName IdentifierName ImportedBinding`: + - It is a Syntax Error if the second IdentifierName's StringValue is not "as" + + `IdentifierName IdentifierName IdentifierName ImportedTypeBinding`: + - It is a Syntax Error if the first IdentifierName's StringValue is not "type" + or "typeof", and the third IdentifierName's StringValue is not "as" + *) + in + + let specifier env = + let kind = + match Peek.token env with + | T_TYPE -> Some ImportType + | T_TYPEOF -> Some ImportTypeof + | _ -> None + in + if is_type_import (Peek.token env) then + (* consume `type`, but we don't know yet whether this is `type foo` or + `type as foo`. *) + let type_keyword_or_remote = identifier_name env in + match Peek.token env with + (* `type` (a value) *) + | T_EOF + | T_RCURLY + | T_COMMA -> + let remote = type_keyword_or_remote in + (* `type` becomes a value *) + assert_identifier_name_is_identifier env remote; + { remote; local = None; kind = None } + (* `type as foo` (value named `type`) or `type as,` (type named `as`) *) + | T_IDENTIFIER { raw = "as"; _ } -> + begin + match Peek.ith_token ~i:1 env with + | T_EOF + | T_RCURLY + | T_COMMA -> + (* `type as` *) + { remote = Type.type_identifier env; local = None; kind } + | T_IDENTIFIER { raw = "as"; _ } -> + (* `type as as foo` *) + let remote = identifier_name env in + (* first `as` *) + Eat.token env; + + (* second `as` *) + let local = Some (Type.type_identifier env) in + (* `foo` *) + { remote; local; kind } + | _ -> + (* `type as foo` *) + let remote = type_keyword_or_remote in + (* `type` becomes a value *) + assert_identifier_name_is_identifier env remote; + Eat.token env; + + (* `as` *) + let local = Some (Parse.identifier env) in + { remote; local; kind = None } + end + (* `type x`, or `type x as y` *) + | _ -> + let (remote, local) = with_maybe_as ~for_type:true env in + { remote; local; kind } + else + (* standard `x` or `x as y` *) + let (remote, local) = with_maybe_as ~for_type:false env in + { remote; local; kind = None } + (* specifier in an `import type { ... }` *) + in + let type_specifier env = + let (remote, local) = + with_maybe_as + env + ~for_type:true + ~error_if_type:Parse_error.ImportTypeShorthandOnlyInPureImport + in + { remote; local; kind = None } + (* specifier in an `import typeof { ... }` *) + in + let typeof_specifier env = + let (remote, local) = + with_maybe_as + env + ~for_type:true + ~error_if_type:Parse_error.ImportTypeShorthandOnlyInPureImport + in + { remote; local; kind = None } + in + let rec specifier_list ?(preceding_comma = true) env statement_kind acc = + match Peek.token env with + | T_EOF + | T_RCURLY -> + List.rev acc + | _ -> + if not preceding_comma then error env Parse_error.ImportSpecifierMissingComma; + let specifier = + match statement_kind with + | ImportType -> type_specifier env + | ImportTypeof -> typeof_specifier env + | ImportValue -> specifier env + in + let preceding_comma = Eat.maybe env T_COMMA in + specifier_list ~preceding_comma env statement_kind (specifier :: acc) + in + let named_or_namespace_specifier env import_kind = + match Peek.token env with + | T_MULT -> + let id = + with_loc_opt + (fun env -> + (* consume T_MULT *) + Eat.token env; + match Peek.token env with + | T_IDENTIFIER { raw = "as"; _ } -> + (* consume "as" *) + Eat.token env; + (match import_kind with + | ImportType + | ImportTypeof -> + Some (Type.type_identifier env) + | ImportValue -> Some (Parse.identifier env)) + | _ -> + error_unexpected ~expected:"the keyword `as`" env; + None) + env + in + (match id with + | Some id -> Some (ImportNamespaceSpecifier id) + | None -> None) + | _ -> + Expect.token env T_LCURLY; + let specifiers = specifier_list env import_kind [] in + Expect.token env T_RCURLY; + Some (ImportNamedSpecifiers specifiers) + in + let semicolon_and_trailing env source = + match semicolon env with + | Explicit trailing -> (trailing, source) + | Implicit { remove_trailing; _ } -> + ( [], + remove_trailing source (fun remover (loc, source) -> + (loc, remover#string_literal_type loc source) + ) + ) + in + let with_specifiers import_kind env leading = + let specifiers = named_or_namespace_specifier env import_kind in + let source = source env in + let (trailing, source) = semicolon_and_trailing env source in + Statement.ImportDeclaration + { + import_kind; + source; + specifiers; + default = None; + comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing (); + } + in + let with_default import_kind env leading = + let default_specifier = + match import_kind with + | ImportType + | ImportTypeof -> + Type.type_identifier env + | ImportValue -> Parse.identifier env + in + let additional_specifiers = + match Peek.token env with + | T_COMMA -> + (* `import Foo, ...` *) + Expect.token env T_COMMA; + named_or_namespace_specifier env import_kind + | _ -> None + in + let source = source env in + let (trailing, source) = semicolon_and_trailing env source in + Statement.ImportDeclaration + { + import_kind; + source; + specifiers = additional_specifiers; + default = Some default_specifier; + comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing (); + } + in + with_loc (fun env -> + let env = env |> with_strict true in + let leading = Peek.comments env in + Expect.token env T_IMPORT; + + match Peek.token env with + (* `import * as ns from "ModuleName";` *) + | T_MULT -> with_specifiers ImportValue env leading + (* `import { ... } from "ModuleName";` *) + | T_LCURLY -> with_specifiers ImportValue env leading + (* `import "ModuleName";` *) + | T_STRING str -> + let source = string_literal env str in + let (trailing, source) = semicolon_and_trailing env source in + Statement.ImportDeclaration + { + import_kind = ImportValue; + source; + specifiers = None; + default = None; + comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing (); + } + (* `import type [...] from "ModuleName";` + note that if [...] is missing, we're importing a value named `type`! *) + | T_TYPE when should_parse_types env -> + begin + match Peek.ith_token ~i:1 env with + (* `import type, { other, names } from "ModuleName";` *) + | T_COMMA + (* `import type from "ModuleName";` *) + | T_IDENTIFIER { raw = "from"; _ } -> + (* Importing the exported value named "type". This is not a type-import.*) + with_default ImportValue env leading + (* `import type *` is invalid, since the namespace can't be a type *) + | T_MULT -> + (* consume `type` *) + Eat.token env; + + (* unexpected `*` *) + error_unexpected env; + + with_specifiers ImportType env leading + | T_LCURLY -> + (* consume `type` *) + Eat.token env; + + with_specifiers ImportType env leading + | _ -> + (* consume `type` *) + Eat.token env; + + with_default ImportType env leading + end + (* `import typeof ... from "ModuleName";` *) + | T_TYPEOF when should_parse_types env -> + Expect.token env T_TYPEOF; + begin + match Peek.token env with + | T_MULT + | T_LCURLY -> + with_specifiers ImportTypeof env leading + | _ -> with_default ImportTypeof env leading + end + (* import Foo from "ModuleName"; *) + | _ -> with_default ImportValue env leading + ) + ) +end diff --git a/analysis/vendor/js_parser/token.ml b/analysis/vendor/js_parser/token.ml new file mode 100644 index 000000000..fe5c667d3 --- /dev/null +++ b/analysis/vendor/js_parser/token.ml @@ -0,0 +1,996 @@ +(* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) +open Primitive_deriving + +type t = + | T_NUMBER of { + kind: number_type; + raw: string; + } + | T_BIGINT of { + kind: bigint_type; + raw: string; + } + | T_STRING of (Loc.t * string * string * bool) (* loc, value, raw, octal *) + | T_TEMPLATE_PART of (Loc.t * template_part * bool) (* loc, value, is_tail *) + | T_IDENTIFIER of { + loc: Loc.t; + value: string; + raw: string; + } + | T_REGEXP of Loc.t * string * string (* /pattern/flags *) + (* Syntax *) + | T_LCURLY + | T_RCURLY + | T_LCURLYBAR + | T_RCURLYBAR + | T_LPAREN + | T_RPAREN + | T_LBRACKET + | T_RBRACKET + | T_SEMICOLON + | T_COMMA + | T_PERIOD + | T_ARROW + | T_ELLIPSIS + | T_AT + | T_POUND + (* Keywords *) + | T_FUNCTION + | T_IF + | T_IN + | T_INSTANCEOF + | T_RETURN + | T_SWITCH + | T_THIS + | T_THROW + | T_TRY + | T_VAR + | T_WHILE + | T_WITH + | T_CONST + | T_LET + | T_NULL + | T_FALSE + | T_TRUE + | T_BREAK + | T_CASE + | T_CATCH + | T_CONTINUE + | T_DEFAULT + | T_DO + | T_FINALLY + | T_FOR + | T_CLASS + | T_EXTENDS + | T_STATIC + | T_ELSE + | T_NEW + | T_DELETE + | T_TYPEOF + | T_VOID + | T_ENUM + | T_EXPORT + | T_IMPORT + | T_SUPER + | T_IMPLEMENTS + | T_INTERFACE + | T_PACKAGE + | T_PRIVATE + | T_PROTECTED + | T_PUBLIC + | T_YIELD + | T_DEBUGGER + | T_DECLARE + | T_TYPE + | T_OPAQUE + | T_OF + | T_ASYNC + | T_AWAIT + | T_CHECKS + (* Operators *) + | T_RSHIFT3_ASSIGN + | T_RSHIFT_ASSIGN + | T_LSHIFT_ASSIGN + | T_BIT_XOR_ASSIGN + | T_BIT_OR_ASSIGN + | T_BIT_AND_ASSIGN + | T_MOD_ASSIGN + | T_DIV_ASSIGN + | T_MULT_ASSIGN + | T_EXP_ASSIGN + | T_MINUS_ASSIGN + | T_PLUS_ASSIGN + | T_NULLISH_ASSIGN + | T_AND_ASSIGN + | T_OR_ASSIGN + | T_ASSIGN + | T_PLING_PERIOD + | T_PLING_PLING + | T_PLING + | T_COLON + | T_OR + | T_AND + | T_BIT_OR + | T_BIT_XOR + | T_BIT_AND + | T_EQUAL + | T_NOT_EQUAL + | T_STRICT_EQUAL + | T_STRICT_NOT_EQUAL + | T_LESS_THAN_EQUAL + | T_GREATER_THAN_EQUAL + | T_LESS_THAN + | T_GREATER_THAN + | T_LSHIFT + | T_RSHIFT + | T_RSHIFT3 + | T_PLUS + | T_MINUS + | T_DIV + | T_MULT + | T_EXP + | T_MOD + | T_NOT + | T_BIT_NOT + | T_INCR + | T_DECR + (* Extra tokens *) + | T_ERROR of string + | T_EOF + (* JSX *) + | T_JSX_IDENTIFIER of { + raw: string; + loc: Loc.t; + } + | T_JSX_TEXT of Loc.t * string * string (* loc, value, raw *) + (* Type primitives *) + | T_ANY_TYPE + | T_MIXED_TYPE + | T_EMPTY_TYPE + | T_BOOLEAN_TYPE of bool_or_boolean + | T_NUMBER_TYPE + | T_BIGINT_TYPE + | T_NUMBER_SINGLETON_TYPE of { + kind: number_type; + value: float; + raw: string; + } + | T_BIGINT_SINGLETON_TYPE of { + kind: bigint_type; + value: int64 option; + raw: string; + } + | T_STRING_TYPE + | T_VOID_TYPE + | T_SYMBOL_TYPE + +(* `bool` and `boolean` are equivalent annotations, but we need to track + which one was used for when it might be an identifier, as in + `(bool: boolean) => void`. It's lexed as two T_BOOLEAN_TYPEs, then the + first one is converted into an identifier. *) +and bool_or_boolean = + | BOOL + | BOOLEAN + +and number_type = + | BINARY + | LEGACY_OCTAL + | LEGACY_NON_OCTAL (* NonOctalDecimalIntegerLiteral in Annex B *) + | OCTAL + | NORMAL + +and bigint_type = + | BIG_BINARY + | BIG_OCTAL + | BIG_NORMAL + +and template_part = { + cooked: string; + (* string after processing special chars *) + raw: string; + (* string as specified in source *) + literal: string; (* same as raw, plus characters like ` and ${ *) +} +[@@deriving_inline equal] +let _ = fun (_ : t) -> () +let _ = fun (_ : bool_or_boolean) -> () +let _ = fun (_ : number_type) -> () +let _ = fun (_ : bigint_type) -> () +let _ = fun (_ : template_part) -> () +let rec equal = + (fun a__001_ -> + fun b__002_ -> + if Ppx_compare_lib.phys_equal a__001_ b__002_ + then true + else + (match (a__001_, b__002_) with + | (T_NUMBER _a__003_, T_NUMBER _b__004_) -> + Ppx_compare_lib.(&&) + (equal_number_type _a__003_.kind _b__004_.kind) + (equal_string _a__003_.raw _b__004_.raw) + | (T_NUMBER _, _) -> false + | (_, T_NUMBER _) -> false + | (T_BIGINT _a__005_, T_BIGINT _b__006_) -> + Ppx_compare_lib.(&&) + (equal_bigint_type _a__005_.kind _b__006_.kind) + (equal_string _a__005_.raw _b__006_.raw) + | (T_BIGINT _, _) -> false + | (_, T_BIGINT _) -> false + | (T_STRING _a__007_, T_STRING _b__008_) -> + let (t__009_, t__010_, t__011_, t__012_) = _a__007_ in + let (t__013_, t__014_, t__015_, t__016_) = _b__008_ in + Ppx_compare_lib.(&&) (Loc.equal t__009_ t__013_) + (Ppx_compare_lib.(&&) (equal_string t__010_ t__014_) + (Ppx_compare_lib.(&&) (equal_string t__011_ t__015_) + (equal_bool t__012_ t__016_))) + | (T_STRING _, _) -> false + | (_, T_STRING _) -> false + | (T_TEMPLATE_PART _a__017_, T_TEMPLATE_PART _b__018_) -> + let (t__019_, t__020_, t__021_) = _a__017_ in + let (t__022_, t__023_, t__024_) = _b__018_ in + Ppx_compare_lib.(&&) (Loc.equal t__019_ t__022_) + (Ppx_compare_lib.(&&) (equal_template_part t__020_ t__023_) + (equal_bool t__021_ t__024_)) + | (T_TEMPLATE_PART _, _) -> false + | (_, T_TEMPLATE_PART _) -> false + | (T_IDENTIFIER _a__025_, T_IDENTIFIER _b__026_) -> + Ppx_compare_lib.(&&) (Loc.equal _a__025_.loc _b__026_.loc) + (Ppx_compare_lib.(&&) + (equal_string _a__025_.value _b__026_.value) + (equal_string _a__025_.raw _b__026_.raw)) + | (T_IDENTIFIER _, _) -> false + | (_, T_IDENTIFIER _) -> false + | (T_REGEXP (_a__027_, _a__029_, _a__031_), T_REGEXP + (_b__028_, _b__030_, _b__032_)) -> + Ppx_compare_lib.(&&) (Loc.equal _a__027_ _b__028_) + (Ppx_compare_lib.(&&) (equal_string _a__029_ _b__030_) + (equal_string _a__031_ _b__032_)) + | (T_REGEXP _, _) -> false + | (_, T_REGEXP _) -> false + | (T_LCURLY, T_LCURLY) -> true + | (T_LCURLY, _) -> false + | (_, T_LCURLY) -> false + | (T_RCURLY, T_RCURLY) -> true + | (T_RCURLY, _) -> false + | (_, T_RCURLY) -> false + | (T_LCURLYBAR, T_LCURLYBAR) -> true + | (T_LCURLYBAR, _) -> false + | (_, T_LCURLYBAR) -> false + | (T_RCURLYBAR, T_RCURLYBAR) -> true + | (T_RCURLYBAR, _) -> false + | (_, T_RCURLYBAR) -> false + | (T_LPAREN, T_LPAREN) -> true + | (T_LPAREN, _) -> false + | (_, T_LPAREN) -> false + | (T_RPAREN, T_RPAREN) -> true + | (T_RPAREN, _) -> false + | (_, T_RPAREN) -> false + | (T_LBRACKET, T_LBRACKET) -> true + | (T_LBRACKET, _) -> false + | (_, T_LBRACKET) -> false + | (T_RBRACKET, T_RBRACKET) -> true + | (T_RBRACKET, _) -> false + | (_, T_RBRACKET) -> false + | (T_SEMICOLON, T_SEMICOLON) -> true + | (T_SEMICOLON, _) -> false + | (_, T_SEMICOLON) -> false + | (T_COMMA, T_COMMA) -> true + | (T_COMMA, _) -> false + | (_, T_COMMA) -> false + | (T_PERIOD, T_PERIOD) -> true + | (T_PERIOD, _) -> false + | (_, T_PERIOD) -> false + | (T_ARROW, T_ARROW) -> true + | (T_ARROW, _) -> false + | (_, T_ARROW) -> false + | (T_ELLIPSIS, T_ELLIPSIS) -> true + | (T_ELLIPSIS, _) -> false + | (_, T_ELLIPSIS) -> false + | (T_AT, T_AT) -> true + | (T_AT, _) -> false + | (_, T_AT) -> false + | (T_POUND, T_POUND) -> true + | (T_POUND, _) -> false + | (_, T_POUND) -> false + | (T_FUNCTION, T_FUNCTION) -> true + | (T_FUNCTION, _) -> false + | (_, T_FUNCTION) -> false + | (T_IF, T_IF) -> true + | (T_IF, _) -> false + | (_, T_IF) -> false + | (T_IN, T_IN) -> true + | (T_IN, _) -> false + | (_, T_IN) -> false + | (T_INSTANCEOF, T_INSTANCEOF) -> true + | (T_INSTANCEOF, _) -> false + | (_, T_INSTANCEOF) -> false + | (T_RETURN, T_RETURN) -> true + | (T_RETURN, _) -> false + | (_, T_RETURN) -> false + | (T_SWITCH, T_SWITCH) -> true + | (T_SWITCH, _) -> false + | (_, T_SWITCH) -> false + | (T_THIS, T_THIS) -> true + | (T_THIS, _) -> false + | (_, T_THIS) -> false + | (T_THROW, T_THROW) -> true + | (T_THROW, _) -> false + | (_, T_THROW) -> false + | (T_TRY, T_TRY) -> true + | (T_TRY, _) -> false + | (_, T_TRY) -> false + | (T_VAR, T_VAR) -> true + | (T_VAR, _) -> false + | (_, T_VAR) -> false + | (T_WHILE, T_WHILE) -> true + | (T_WHILE, _) -> false + | (_, T_WHILE) -> false + | (T_WITH, T_WITH) -> true + | (T_WITH, _) -> false + | (_, T_WITH) -> false + | (T_CONST, T_CONST) -> true + | (T_CONST, _) -> false + | (_, T_CONST) -> false + | (T_LET, T_LET) -> true + | (T_LET, _) -> false + | (_, T_LET) -> false + | (T_NULL, T_NULL) -> true + | (T_NULL, _) -> false + | (_, T_NULL) -> false + | (T_FALSE, T_FALSE) -> true + | (T_FALSE, _) -> false + | (_, T_FALSE) -> false + | (T_TRUE, T_TRUE) -> true + | (T_TRUE, _) -> false + | (_, T_TRUE) -> false + | (T_BREAK, T_BREAK) -> true + | (T_BREAK, _) -> false + | (_, T_BREAK) -> false + | (T_CASE, T_CASE) -> true + | (T_CASE, _) -> false + | (_, T_CASE) -> false + | (T_CATCH, T_CATCH) -> true + | (T_CATCH, _) -> false + | (_, T_CATCH) -> false + | (T_CONTINUE, T_CONTINUE) -> true + | (T_CONTINUE, _) -> false + | (_, T_CONTINUE) -> false + | (T_DEFAULT, T_DEFAULT) -> true + | (T_DEFAULT, _) -> false + | (_, T_DEFAULT) -> false + | (T_DO, T_DO) -> true + | (T_DO, _) -> false + | (_, T_DO) -> false + | (T_FINALLY, T_FINALLY) -> true + | (T_FINALLY, _) -> false + | (_, T_FINALLY) -> false + | (T_FOR, T_FOR) -> true + | (T_FOR, _) -> false + | (_, T_FOR) -> false + | (T_CLASS, T_CLASS) -> true + | (T_CLASS, _) -> false + | (_, T_CLASS) -> false + | (T_EXTENDS, T_EXTENDS) -> true + | (T_EXTENDS, _) -> false + | (_, T_EXTENDS) -> false + | (T_STATIC, T_STATIC) -> true + | (T_STATIC, _) -> false + | (_, T_STATIC) -> false + | (T_ELSE, T_ELSE) -> true + | (T_ELSE, _) -> false + | (_, T_ELSE) -> false + | (T_NEW, T_NEW) -> true + | (T_NEW, _) -> false + | (_, T_NEW) -> false + | (T_DELETE, T_DELETE) -> true + | (T_DELETE, _) -> false + | (_, T_DELETE) -> false + | (T_TYPEOF, T_TYPEOF) -> true + | (T_TYPEOF, _) -> false + | (_, T_TYPEOF) -> false + | (T_VOID, T_VOID) -> true + | (T_VOID, _) -> false + | (_, T_VOID) -> false + | (T_ENUM, T_ENUM) -> true + | (T_ENUM, _) -> false + | (_, T_ENUM) -> false + | (T_EXPORT, T_EXPORT) -> true + | (T_EXPORT, _) -> false + | (_, T_EXPORT) -> false + | (T_IMPORT, T_IMPORT) -> true + | (T_IMPORT, _) -> false + | (_, T_IMPORT) -> false + | (T_SUPER, T_SUPER) -> true + | (T_SUPER, _) -> false + | (_, T_SUPER) -> false + | (T_IMPLEMENTS, T_IMPLEMENTS) -> true + | (T_IMPLEMENTS, _) -> false + | (_, T_IMPLEMENTS) -> false + | (T_INTERFACE, T_INTERFACE) -> true + | (T_INTERFACE, _) -> false + | (_, T_INTERFACE) -> false + | (T_PACKAGE, T_PACKAGE) -> true + | (T_PACKAGE, _) -> false + | (_, T_PACKAGE) -> false + | (T_PRIVATE, T_PRIVATE) -> true + | (T_PRIVATE, _) -> false + | (_, T_PRIVATE) -> false + | (T_PROTECTED, T_PROTECTED) -> true + | (T_PROTECTED, _) -> false + | (_, T_PROTECTED) -> false + | (T_PUBLIC, T_PUBLIC) -> true + | (T_PUBLIC, _) -> false + | (_, T_PUBLIC) -> false + | (T_YIELD, T_YIELD) -> true + | (T_YIELD, _) -> false + | (_, T_YIELD) -> false + | (T_DEBUGGER, T_DEBUGGER) -> true + | (T_DEBUGGER, _) -> false + | (_, T_DEBUGGER) -> false + | (T_DECLARE, T_DECLARE) -> true + | (T_DECLARE, _) -> false + | (_, T_DECLARE) -> false + | (T_TYPE, T_TYPE) -> true + | (T_TYPE, _) -> false + | (_, T_TYPE) -> false + | (T_OPAQUE, T_OPAQUE) -> true + | (T_OPAQUE, _) -> false + | (_, T_OPAQUE) -> false + | (T_OF, T_OF) -> true + | (T_OF, _) -> false + | (_, T_OF) -> false + | (T_ASYNC, T_ASYNC) -> true + | (T_ASYNC, _) -> false + | (_, T_ASYNC) -> false + | (T_AWAIT, T_AWAIT) -> true + | (T_AWAIT, _) -> false + | (_, T_AWAIT) -> false + | (T_CHECKS, T_CHECKS) -> true + | (T_CHECKS, _) -> false + | (_, T_CHECKS) -> false + | (T_RSHIFT3_ASSIGN, T_RSHIFT3_ASSIGN) -> true + | (T_RSHIFT3_ASSIGN, _) -> false + | (_, T_RSHIFT3_ASSIGN) -> false + | (T_RSHIFT_ASSIGN, T_RSHIFT_ASSIGN) -> true + | (T_RSHIFT_ASSIGN, _) -> false + | (_, T_RSHIFT_ASSIGN) -> false + | (T_LSHIFT_ASSIGN, T_LSHIFT_ASSIGN) -> true + | (T_LSHIFT_ASSIGN, _) -> false + | (_, T_LSHIFT_ASSIGN) -> false + | (T_BIT_XOR_ASSIGN, T_BIT_XOR_ASSIGN) -> true + | (T_BIT_XOR_ASSIGN, _) -> false + | (_, T_BIT_XOR_ASSIGN) -> false + | (T_BIT_OR_ASSIGN, T_BIT_OR_ASSIGN) -> true + | (T_BIT_OR_ASSIGN, _) -> false + | (_, T_BIT_OR_ASSIGN) -> false + | (T_BIT_AND_ASSIGN, T_BIT_AND_ASSIGN) -> true + | (T_BIT_AND_ASSIGN, _) -> false + | (_, T_BIT_AND_ASSIGN) -> false + | (T_MOD_ASSIGN, T_MOD_ASSIGN) -> true + | (T_MOD_ASSIGN, _) -> false + | (_, T_MOD_ASSIGN) -> false + | (T_DIV_ASSIGN, T_DIV_ASSIGN) -> true + | (T_DIV_ASSIGN, _) -> false + | (_, T_DIV_ASSIGN) -> false + | (T_MULT_ASSIGN, T_MULT_ASSIGN) -> true + | (T_MULT_ASSIGN, _) -> false + | (_, T_MULT_ASSIGN) -> false + | (T_EXP_ASSIGN, T_EXP_ASSIGN) -> true + | (T_EXP_ASSIGN, _) -> false + | (_, T_EXP_ASSIGN) -> false + | (T_MINUS_ASSIGN, T_MINUS_ASSIGN) -> true + | (T_MINUS_ASSIGN, _) -> false + | (_, T_MINUS_ASSIGN) -> false + | (T_PLUS_ASSIGN, T_PLUS_ASSIGN) -> true + | (T_PLUS_ASSIGN, _) -> false + | (_, T_PLUS_ASSIGN) -> false + | (T_NULLISH_ASSIGN, T_NULLISH_ASSIGN) -> true + | (T_NULLISH_ASSIGN, _) -> false + | (_, T_NULLISH_ASSIGN) -> false + | (T_AND_ASSIGN, T_AND_ASSIGN) -> true + | (T_AND_ASSIGN, _) -> false + | (_, T_AND_ASSIGN) -> false + | (T_OR_ASSIGN, T_OR_ASSIGN) -> true + | (T_OR_ASSIGN, _) -> false + | (_, T_OR_ASSIGN) -> false + | (T_ASSIGN, T_ASSIGN) -> true + | (T_ASSIGN, _) -> false + | (_, T_ASSIGN) -> false + | (T_PLING_PERIOD, T_PLING_PERIOD) -> true + | (T_PLING_PERIOD, _) -> false + | (_, T_PLING_PERIOD) -> false + | (T_PLING_PLING, T_PLING_PLING) -> true + | (T_PLING_PLING, _) -> false + | (_, T_PLING_PLING) -> false + | (T_PLING, T_PLING) -> true + | (T_PLING, _) -> false + | (_, T_PLING) -> false + | (T_COLON, T_COLON) -> true + | (T_COLON, _) -> false + | (_, T_COLON) -> false + | (T_OR, T_OR) -> true + | (T_OR, _) -> false + | (_, T_OR) -> false + | (T_AND, T_AND) -> true + | (T_AND, _) -> false + | (_, T_AND) -> false + | (T_BIT_OR, T_BIT_OR) -> true + | (T_BIT_OR, _) -> false + | (_, T_BIT_OR) -> false + | (T_BIT_XOR, T_BIT_XOR) -> true + | (T_BIT_XOR, _) -> false + | (_, T_BIT_XOR) -> false + | (T_BIT_AND, T_BIT_AND) -> true + | (T_BIT_AND, _) -> false + | (_, T_BIT_AND) -> false + | (T_EQUAL, T_EQUAL) -> true + | (T_EQUAL, _) -> false + | (_, T_EQUAL) -> false + | (T_NOT_EQUAL, T_NOT_EQUAL) -> true + | (T_NOT_EQUAL, _) -> false + | (_, T_NOT_EQUAL) -> false + | (T_STRICT_EQUAL, T_STRICT_EQUAL) -> true + | (T_STRICT_EQUAL, _) -> false + | (_, T_STRICT_EQUAL) -> false + | (T_STRICT_NOT_EQUAL, T_STRICT_NOT_EQUAL) -> true + | (T_STRICT_NOT_EQUAL, _) -> false + | (_, T_STRICT_NOT_EQUAL) -> false + | (T_LESS_THAN_EQUAL, T_LESS_THAN_EQUAL) -> true + | (T_LESS_THAN_EQUAL, _) -> false + | (_, T_LESS_THAN_EQUAL) -> false + | (T_GREATER_THAN_EQUAL, T_GREATER_THAN_EQUAL) -> true + | (T_GREATER_THAN_EQUAL, _) -> false + | (_, T_GREATER_THAN_EQUAL) -> false + | (T_LESS_THAN, T_LESS_THAN) -> true + | (T_LESS_THAN, _) -> false + | (_, T_LESS_THAN) -> false + | (T_GREATER_THAN, T_GREATER_THAN) -> true + | (T_GREATER_THAN, _) -> false + | (_, T_GREATER_THAN) -> false + | (T_LSHIFT, T_LSHIFT) -> true + | (T_LSHIFT, _) -> false + | (_, T_LSHIFT) -> false + | (T_RSHIFT, T_RSHIFT) -> true + | (T_RSHIFT, _) -> false + | (_, T_RSHIFT) -> false + | (T_RSHIFT3, T_RSHIFT3) -> true + | (T_RSHIFT3, _) -> false + | (_, T_RSHIFT3) -> false + | (T_PLUS, T_PLUS) -> true + | (T_PLUS, _) -> false + | (_, T_PLUS) -> false + | (T_MINUS, T_MINUS) -> true + | (T_MINUS, _) -> false + | (_, T_MINUS) -> false + | (T_DIV, T_DIV) -> true + | (T_DIV, _) -> false + | (_, T_DIV) -> false + | (T_MULT, T_MULT) -> true + | (T_MULT, _) -> false + | (_, T_MULT) -> false + | (T_EXP, T_EXP) -> true + | (T_EXP, _) -> false + | (_, T_EXP) -> false + | (T_MOD, T_MOD) -> true + | (T_MOD, _) -> false + | (_, T_MOD) -> false + | (T_NOT, T_NOT) -> true + | (T_NOT, _) -> false + | (_, T_NOT) -> false + | (T_BIT_NOT, T_BIT_NOT) -> true + | (T_BIT_NOT, _) -> false + | (_, T_BIT_NOT) -> false + | (T_INCR, T_INCR) -> true + | (T_INCR, _) -> false + | (_, T_INCR) -> false + | (T_DECR, T_DECR) -> true + | (T_DECR, _) -> false + | (_, T_DECR) -> false + | (T_ERROR _a__033_, T_ERROR _b__034_) -> + equal_string _a__033_ _b__034_ + | (T_ERROR _, _) -> false + | (_, T_ERROR _) -> false + | (T_EOF, T_EOF) -> true + | (T_EOF, _) -> false + | (_, T_EOF) -> false + | (T_JSX_IDENTIFIER _a__035_, T_JSX_IDENTIFIER _b__036_) -> + Ppx_compare_lib.(&&) (equal_string _a__035_.raw _b__036_.raw) + (Loc.equal _a__035_.loc _b__036_.loc) + | (T_JSX_IDENTIFIER _, _) -> false + | (_, T_JSX_IDENTIFIER _) -> false + | (T_JSX_TEXT (_a__037_, _a__039_, _a__041_), T_JSX_TEXT + (_b__038_, _b__040_, _b__042_)) -> + Ppx_compare_lib.(&&) (Loc.equal _a__037_ _b__038_) + (Ppx_compare_lib.(&&) (equal_string _a__039_ _b__040_) + (equal_string _a__041_ _b__042_)) + | (T_JSX_TEXT _, _) -> false + | (_, T_JSX_TEXT _) -> false + | (T_ANY_TYPE, T_ANY_TYPE) -> true + | (T_ANY_TYPE, _) -> false + | (_, T_ANY_TYPE) -> false + | (T_MIXED_TYPE, T_MIXED_TYPE) -> true + | (T_MIXED_TYPE, _) -> false + | (_, T_MIXED_TYPE) -> false + | (T_EMPTY_TYPE, T_EMPTY_TYPE) -> true + | (T_EMPTY_TYPE, _) -> false + | (_, T_EMPTY_TYPE) -> false + | (T_BOOLEAN_TYPE _a__043_, T_BOOLEAN_TYPE _b__044_) -> + equal_bool_or_boolean _a__043_ _b__044_ + | (T_BOOLEAN_TYPE _, _) -> false + | (_, T_BOOLEAN_TYPE _) -> false + | (T_NUMBER_TYPE, T_NUMBER_TYPE) -> true + | (T_NUMBER_TYPE, _) -> false + | (_, T_NUMBER_TYPE) -> false + | (T_BIGINT_TYPE, T_BIGINT_TYPE) -> true + | (T_BIGINT_TYPE, _) -> false + | (_, T_BIGINT_TYPE) -> false + | (T_NUMBER_SINGLETON_TYPE _a__045_, T_NUMBER_SINGLETON_TYPE + _b__046_) -> + Ppx_compare_lib.(&&) + (equal_number_type _a__045_.kind _b__046_.kind) + (Ppx_compare_lib.(&&) + (equal_float _a__045_.value _b__046_.value) + (equal_string _a__045_.raw _b__046_.raw)) + | (T_NUMBER_SINGLETON_TYPE _, _) -> false + | (_, T_NUMBER_SINGLETON_TYPE _) -> false + | (T_BIGINT_SINGLETON_TYPE _a__047_, T_BIGINT_SINGLETON_TYPE + _b__048_) -> + Ppx_compare_lib.(&&) + (equal_bigint_type _a__047_.kind _b__048_.kind) + (Ppx_compare_lib.(&&) + (equal_option equal_int64 _a__047_.value _b__048_.value) + (equal_string _a__047_.raw _b__048_.raw)) + | (T_BIGINT_SINGLETON_TYPE _, _) -> false + | (_, T_BIGINT_SINGLETON_TYPE _) -> false + | (T_STRING_TYPE, T_STRING_TYPE) -> true + | (T_STRING_TYPE, _) -> false + | (_, T_STRING_TYPE) -> false + | (T_VOID_TYPE, T_VOID_TYPE) -> true + | (T_VOID_TYPE, _) -> false + | (_, T_VOID_TYPE) -> false + | (T_SYMBOL_TYPE, T_SYMBOL_TYPE) -> true) : t -> t -> bool) +and equal_bool_or_boolean = + (fun a__051_ -> + fun b__052_ -> Ppx_compare_lib.polymorphic_equal a__051_ b__052_ : + bool_or_boolean -> bool_or_boolean -> bool) +and equal_number_type = + (fun a__053_ -> + fun b__054_ -> Ppx_compare_lib.polymorphic_equal a__053_ b__054_ : + number_type -> number_type -> bool) +and equal_bigint_type = + (fun a__055_ -> + fun b__056_ -> Ppx_compare_lib.polymorphic_equal a__055_ b__056_ : + bigint_type -> bigint_type -> bool) +and equal_template_part = + (fun a__057_ -> + fun b__058_ -> + if Ppx_compare_lib.phys_equal a__057_ b__058_ + then true + else + Ppx_compare_lib.(&&) (equal_string a__057_.cooked b__058_.cooked) + (Ppx_compare_lib.(&&) (equal_string a__057_.raw b__058_.raw) + (equal_string a__057_.literal b__058_.literal)) : template_part + -> + template_part + -> + bool) +let _ = equal +and _ = equal_bool_or_boolean +and _ = equal_number_type +and _ = equal_bigint_type +and _ = equal_template_part +[@@@end] +(*****************************************************************************) +(* Pretty printer (pretty?) *) +(*****************************************************************************) +let token_to_string = function + | T_NUMBER _ -> "T_NUMBER" + | T_BIGINT _ -> "T_BIGINT" + | T_STRING _ -> "T_STRING" + | T_TEMPLATE_PART _ -> "T_TEMPLATE_PART" + | T_IDENTIFIER _ -> "T_IDENTIFIER" + | T_REGEXP _ -> "T_REGEXP" + | T_FUNCTION -> "T_FUNCTION" + | T_IF -> "T_IF" + | T_IN -> "T_IN" + | T_INSTANCEOF -> "T_INSTANCEOF" + | T_RETURN -> "T_RETURN" + | T_SWITCH -> "T_SWITCH" + | T_THIS -> "T_THIS" + | T_THROW -> "T_THROW" + | T_TRY -> "T_TRY" + | T_VAR -> "T_VAR" + | T_WHILE -> "T_WHILE" + | T_WITH -> "T_WITH" + | T_CONST -> "T_CONST" + | T_LET -> "T_LET" + | T_NULL -> "T_NULL" + | T_FALSE -> "T_FALSE" + | T_TRUE -> "T_TRUE" + | T_BREAK -> "T_BREAK" + | T_CASE -> "T_CASE" + | T_CATCH -> "T_CATCH" + | T_CONTINUE -> "T_CONTINUE" + | T_DEFAULT -> "T_DEFAULT" + | T_DO -> "T_DO" + | T_FINALLY -> "T_FINALLY" + | T_FOR -> "T_FOR" + | T_CLASS -> "T_CLASS" + | T_EXTENDS -> "T_EXTENDS" + | T_STATIC -> "T_STATIC" + | T_ELSE -> "T_ELSE" + | T_NEW -> "T_NEW" + | T_DELETE -> "T_DELETE" + | T_TYPEOF -> "T_TYPEOF" + | T_VOID -> "T_VOID" + | T_ENUM -> "T_ENUM" + | T_EXPORT -> "T_EXPORT" + | T_IMPORT -> "T_IMPORT" + | T_SUPER -> "T_SUPER" + | T_IMPLEMENTS -> "T_IMPLEMENTS" + | T_INTERFACE -> "T_INTERFACE" + | T_PACKAGE -> "T_PACKAGE" + | T_PRIVATE -> "T_PRIVATE" + | T_PROTECTED -> "T_PROTECTED" + | T_PUBLIC -> "T_PUBLIC" + | T_YIELD -> "T_YIELD" + | T_DEBUGGER -> "T_DEBUGGER" + | T_DECLARE -> "T_DECLARE" + | T_TYPE -> "T_TYPE" + | T_OPAQUE -> "T_OPAQUE" + | T_OF -> "T_OF" + | T_ASYNC -> "T_ASYNC" + | T_AWAIT -> "T_AWAIT" + | T_CHECKS -> "T_CHECKS" + | T_LCURLY -> "T_LCURLY" + | T_RCURLY -> "T_RCURLY" + | T_LCURLYBAR -> "T_LCURLYBAR" + | T_RCURLYBAR -> "T_RCURLYBAR" + | T_LPAREN -> "T_LPAREN" + | T_RPAREN -> "T_RPAREN" + | T_LBRACKET -> "T_LBRACKET" + | T_RBRACKET -> "T_RBRACKET" + | T_SEMICOLON -> "T_SEMICOLON" + | T_COMMA -> "T_COMMA" + | T_PERIOD -> "T_PERIOD" + | T_ARROW -> "T_ARROW" + | T_ELLIPSIS -> "T_ELLIPSIS" + | T_AT -> "T_AT" + | T_POUND -> "T_POUND" + | T_RSHIFT3_ASSIGN -> "T_RSHIFT3_ASSIGN" + | T_RSHIFT_ASSIGN -> "T_RSHIFT_ASSIGN" + | T_LSHIFT_ASSIGN -> "T_LSHIFT_ASSIGN" + | T_BIT_XOR_ASSIGN -> "T_BIT_XOR_ASSIGN" + | T_BIT_OR_ASSIGN -> "T_BIT_OR_ASSIGN" + | T_BIT_AND_ASSIGN -> "T_BIT_AND_ASSIGN" + | T_MOD_ASSIGN -> "T_MOD_ASSIGN" + | T_DIV_ASSIGN -> "T_DIV_ASSIGN" + | T_MULT_ASSIGN -> "T_MULT_ASSIGN" + | T_EXP_ASSIGN -> "T_EXP_ASSIGN" + | T_MINUS_ASSIGN -> "T_MINUS_ASSIGN" + | T_PLUS_ASSIGN -> "T_PLUS_ASSIGN" + | T_NULLISH_ASSIGN -> "T_NULLISH_ASSIGN" + | T_AND_ASSIGN -> "T_AND_ASSIGN" + | T_OR_ASSIGN -> "T_OR_ASSIGN" + | T_ASSIGN -> "T_ASSIGN" + | T_PLING_PERIOD -> "T_PLING_PERIOD" + | T_PLING_PLING -> "T_PLING_PLING" + | T_PLING -> "T_PLING" + | T_COLON -> "T_COLON" + | T_OR -> "T_OR" + | T_AND -> "T_AND" + | T_BIT_OR -> "T_BIT_OR" + | T_BIT_XOR -> "T_BIT_XOR" + | T_BIT_AND -> "T_BIT_AND" + | T_EQUAL -> "T_EQUAL" + | T_NOT_EQUAL -> "T_NOT_EQUAL" + | T_STRICT_EQUAL -> "T_STRICT_EQUAL" + | T_STRICT_NOT_EQUAL -> "T_STRICT_NOT_EQUAL" + | T_LESS_THAN_EQUAL -> "T_LESS_THAN_EQUAL" + | T_GREATER_THAN_EQUAL -> "T_GREATER_THAN_EQUAL" + | T_LESS_THAN -> "T_LESS_THAN" + | T_GREATER_THAN -> "T_GREATER_THAN" + | T_LSHIFT -> "T_LSHIFT" + | T_RSHIFT -> "T_RSHIFT" + | T_RSHIFT3 -> "T_RSHIFT3" + | T_PLUS -> "T_PLUS" + | T_MINUS -> "T_MINUS" + | T_DIV -> "T_DIV" + | T_MULT -> "T_MULT" + | T_EXP -> "T_EXP" + | T_MOD -> "T_MOD" + | T_NOT -> "T_NOT" + | T_BIT_NOT -> "T_BIT_NOT" + | T_INCR -> "T_INCR" + | T_DECR -> "T_DECR" + (* Extra tokens *) + | T_ERROR _ -> "T_ERROR" + | T_EOF -> "T_EOF" + | T_JSX_IDENTIFIER _ -> "T_JSX_IDENTIFIER" + | T_JSX_TEXT _ -> "T_JSX_TEXT" + (* Type primitives *) + | T_ANY_TYPE -> "T_ANY_TYPE" + | T_MIXED_TYPE -> "T_MIXED_TYPE" + | T_EMPTY_TYPE -> "T_EMPTY_TYPE" + | T_BOOLEAN_TYPE _ -> "T_BOOLEAN_TYPE" + | T_NUMBER_TYPE -> "T_NUMBER_TYPE" + | T_BIGINT_TYPE -> "T_BIGINT_TYPE" + | T_NUMBER_SINGLETON_TYPE _ -> "T_NUMBER_SINGLETON_TYPE" + | T_BIGINT_SINGLETON_TYPE _ -> "T_BIGINT_SINGLETON_TYPE" + | T_STRING_TYPE -> "T_STRING_TYPE" + | T_VOID_TYPE -> "T_VOID_TYPE" + | T_SYMBOL_TYPE -> "T_SYMBOL_TYPE" + +let value_of_token = function + | T_NUMBER { raw; _ } -> raw + | T_BIGINT { raw; _ } -> raw + | T_STRING (_, _, raw, _) -> raw + | T_TEMPLATE_PART (_, { literal; _ }, _) -> literal + | T_IDENTIFIER { raw; _ } -> raw + | T_REGEXP (_, pattern, flags) -> "/" ^ pattern ^ "/" ^ flags + | T_LCURLY -> "{" + | T_RCURLY -> "}" + | T_LCURLYBAR -> "{|" + | T_RCURLYBAR -> "|}" + | T_LPAREN -> "(" + | T_RPAREN -> ")" + | T_LBRACKET -> "[" + | T_RBRACKET -> "]" + | T_SEMICOLON -> ";" + | T_COMMA -> "," + | T_PERIOD -> "." + | T_ARROW -> "=>" + | T_ELLIPSIS -> "..." + | T_AT -> "@" + | T_POUND -> "#" + | T_FUNCTION -> "function" + | T_IF -> "if" + | T_IN -> "in" + | T_INSTANCEOF -> "instanceof" + | T_RETURN -> "return" + | T_SWITCH -> "switch" + | T_THIS -> "this" + | T_THROW -> "throw" + | T_TRY -> "try" + | T_VAR -> "var" + | T_WHILE -> "while" + | T_WITH -> "with" + | T_CONST -> "const" + | T_LET -> "let" + | T_NULL -> "null" + | T_FALSE -> "false" + | T_TRUE -> "true" + | T_BREAK -> "break" + | T_CASE -> "case" + | T_CATCH -> "catch" + | T_CONTINUE -> "continue" + | T_DEFAULT -> "default" + | T_DO -> "do" + | T_FINALLY -> "finally" + | T_FOR -> "for" + | T_CLASS -> "class" + | T_EXTENDS -> "extends" + | T_STATIC -> "static" + | T_ELSE -> "else" + | T_NEW -> "new" + | T_DELETE -> "delete" + | T_TYPEOF -> "typeof" + | T_VOID -> "void" + | T_ENUM -> "enum" + | T_EXPORT -> "export" + | T_IMPORT -> "import" + | T_SUPER -> "super" + | T_IMPLEMENTS -> "implements" + | T_INTERFACE -> "interface" + | T_PACKAGE -> "package" + | T_PRIVATE -> "private" + | T_PROTECTED -> "protected" + | T_PUBLIC -> "public" + | T_YIELD -> "yield" + | T_DEBUGGER -> "debugger" + | T_DECLARE -> "declare" + | T_TYPE -> "type" + | T_OPAQUE -> "opaque" + | T_OF -> "of" + | T_ASYNC -> "async" + | T_AWAIT -> "await" + | T_CHECKS -> "%checks" + | T_RSHIFT3_ASSIGN -> ">>>=" + | T_RSHIFT_ASSIGN -> ">>=" + | T_LSHIFT_ASSIGN -> "<<=" + | T_BIT_XOR_ASSIGN -> "^=" + | T_BIT_OR_ASSIGN -> "|=" + | T_BIT_AND_ASSIGN -> "&=" + | T_MOD_ASSIGN -> "%=" + | T_DIV_ASSIGN -> "/=" + | T_MULT_ASSIGN -> "*=" + | T_EXP_ASSIGN -> "**=" + | T_MINUS_ASSIGN -> "-=" + | T_PLUS_ASSIGN -> "+=" + | T_NULLISH_ASSIGN -> "??=" + | T_AND_ASSIGN -> "&&=" + | T_OR_ASSIGN -> "||=" + | T_ASSIGN -> "=" + | T_PLING_PERIOD -> "?." + | T_PLING_PLING -> "??" + | T_PLING -> "?" + | T_COLON -> ":" + | T_OR -> "||" + | T_AND -> "&&" + | T_BIT_OR -> "|" + | T_BIT_XOR -> "^" + | T_BIT_AND -> "&" + | T_EQUAL -> "==" + | T_NOT_EQUAL -> "!=" + | T_STRICT_EQUAL -> "===" + | T_STRICT_NOT_EQUAL -> "!==" + | T_LESS_THAN_EQUAL -> "<=" + | T_GREATER_THAN_EQUAL -> ">=" + | T_LESS_THAN -> "<" + | T_GREATER_THAN -> ">" + | T_LSHIFT -> "<<" + | T_RSHIFT -> ">>" + | T_RSHIFT3 -> ">>>" + | T_PLUS -> "+" + | T_MINUS -> "-" + | T_DIV -> "/" + | T_MULT -> "*" + | T_EXP -> "**" + | T_MOD -> "%" + | T_NOT -> "!" + | T_BIT_NOT -> "~" + | T_INCR -> "++" + | T_DECR -> "--" + (* Extra tokens *) + | T_ERROR raw -> raw + | T_EOF -> "" + | T_JSX_IDENTIFIER { raw; _ } -> raw + | T_JSX_TEXT (_, _, raw) -> raw + (* Type primitives *) + | T_ANY_TYPE -> "any" + | T_MIXED_TYPE -> "mixed" + | T_EMPTY_TYPE -> "empty" + | T_BOOLEAN_TYPE kind -> begin + match kind with + | BOOL -> "bool" + | BOOLEAN -> "boolean" + end + | T_NUMBER_TYPE -> "number" + | T_BIGINT_TYPE -> "bigint" + | T_NUMBER_SINGLETON_TYPE { raw; _ } -> raw + | T_BIGINT_SINGLETON_TYPE { raw; _ } -> raw + | T_STRING_TYPE -> "string" + | T_VOID_TYPE -> "void" + | T_SYMBOL_TYPE -> "symbol" + +let quote_token_value value = Printf.sprintf "token `%s`" value + +let explanation_of_token ?(use_article = false) token = + let (value, article) = + match token with + | T_NUMBER_SINGLETON_TYPE _ + | T_NUMBER _ -> + ("number", "a") + | T_BIGINT_SINGLETON_TYPE _ + | T_BIGINT _ -> + ("bigint", "a") + | T_JSX_TEXT _ + | T_STRING _ -> + ("string", "a") + | T_TEMPLATE_PART _ -> ("template literal part", "a") + | T_JSX_IDENTIFIER _ + | T_IDENTIFIER _ -> + ("identifier", "an") + | T_REGEXP _ -> ("regexp", "a") + | T_EOF -> ("end of input", "the") + | _ -> (quote_token_value (value_of_token token), "the") + in + if use_article then + article ^ " " ^ value + else + value diff --git a/analysis/vendor/js_parser/type_parser.ml b/analysis/vendor/js_parser/type_parser.ml new file mode 100644 index 000000000..ba898a1bf --- /dev/null +++ b/analysis/vendor/js_parser/type_parser.ml @@ -0,0 +1,1487 @@ +(* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) + +module Ast = Flow_ast +open Token +open Parser_env +open Flow_ast +open Parser_common +open Comment_attachment + +module type TYPE = sig + val _type : env -> (Loc.t, Loc.t) Ast.Type.t + + val type_identifier : env -> (Loc.t, Loc.t) Ast.Identifier.t + + val type_params : env -> (Loc.t, Loc.t) Ast.Type.TypeParams.t option + + val type_args : env -> (Loc.t, Loc.t) Ast.Type.TypeArgs.t option + + val generic : env -> Loc.t * (Loc.t, Loc.t) Ast.Type.Generic.t + + val _object : is_class:bool -> env -> Loc.t * (Loc.t, Loc.t) Type.Object.t + + val interface_helper : + env -> + (Loc.t * (Loc.t, Loc.t) Ast.Type.Generic.t) list * (Loc.t * (Loc.t, Loc.t) Ast.Type.Object.t) + + val function_param_list : env -> (Loc.t, Loc.t) Type.Function.Params.t + + val annotation : env -> (Loc.t, Loc.t) Ast.Type.annotation + + val annotation_opt : env -> (Loc.t, Loc.t) Ast.Type.annotation_or_hint + + val predicate_opt : env -> (Loc.t, Loc.t) Ast.Type.Predicate.t option + + val annotation_and_predicate_opt : + env -> (Loc.t, Loc.t) Ast.Type.annotation_or_hint * (Loc.t, Loc.t) Ast.Type.Predicate.t option +end + +module Type (Parse : Parser_common.PARSER) : TYPE = struct + type param_list_or_type = + | ParamList of (Loc.t, Loc.t) Type.Function.Params.t' + | Type of (Loc.t, Loc.t) Type.t + + let maybe_variance env = + let loc = Peek.loc env in + match Peek.token env with + | T_PLUS -> + let leading = Peek.comments env in + Eat.token env; + Some + ( loc, + { Variance.kind = Variance.Plus; comments = Flow_ast_utils.mk_comments_opt ~leading () } + ) + | T_MINUS -> + let leading = Peek.comments env in + Eat.token env; + Some + ( loc, + { Variance.kind = Variance.Minus; comments = Flow_ast_utils.mk_comments_opt ~leading () } + ) + | _ -> None + + let rec _type env = union env + + and annotation env = + if not (should_parse_types env) then error env Parse_error.UnexpectedTypeAnnotation; + with_loc + (fun env -> + Expect.token env T_COLON; + _type env) + env + + and union env = + let leading = + if Peek.token env = T_BIT_OR then ( + let leading = Peek.comments env in + Eat.token env; + leading + ) else + [] + in + let left = intersection env in + union_with env ~leading left + + and union_with = + let rec unions leading acc env = + match Peek.token env with + | T_BIT_OR -> + Expect.token env T_BIT_OR; + unions leading (intersection env :: acc) env + | _ -> + (match List.rev acc with + | t0 :: t1 :: ts -> + Type.Union + { + Type.Union.types = (t0, t1, ts); + comments = Flow_ast_utils.mk_comments_opt ~leading (); + } + | _ -> assert false) + in + fun env ?(leading = []) left -> + if Peek.token env = T_BIT_OR then + with_loc ~start_loc:(fst left) (unions leading [left]) env + else + left + + and intersection env = + let leading = + if Peek.token env = T_BIT_AND then ( + let leading = Peek.comments env in + Eat.token env; + leading + ) else + [] + in + let left = anon_function_without_parens env in + intersection_with env ~leading left + + and intersection_with = + let rec intersections leading acc env = + match Peek.token env with + | T_BIT_AND -> + Expect.token env T_BIT_AND; + intersections leading (anon_function_without_parens env :: acc) env + | _ -> + (match List.rev acc with + | t0 :: t1 :: ts -> + Type.Intersection + { + Type.Intersection.types = (t0, t1, ts); + comments = Flow_ast_utils.mk_comments_opt ~leading (); + } + | _ -> assert false) + in + fun env ?(leading = []) left -> + if Peek.token env = T_BIT_AND then + with_loc ~start_loc:(fst left) (intersections leading [left]) env + else + left + + and anon_function_without_parens env = + let param = prefix env in + anon_function_without_parens_with env param + + and anon_function_without_parens_with env param = + match Peek.token env with + | T_ARROW when not (no_anon_function_type env) -> + let (start_loc, tparams, params) = + let param = anonymous_function_param env param in + ( fst param, + None, + ( fst param, + { + Ast.Type.Function.Params.params = [param]; + this_ = None; + rest = None; + comments = None; + } + ) + ) + in + function_with_params env start_loc tparams params + | _ -> param + + and prefix env = + match Peek.token env with + | T_PLING -> + with_loc + (fun env -> + let leading = Peek.comments env in + Expect.token env T_PLING; + Type.Nullable + { + Type.Nullable.argument = prefix env; + comments = Flow_ast_utils.mk_comments_opt ~leading (); + }) + env + | _ -> postfix env + + and postfix env = + let t = primary env in + postfix_with env t + + and postfix_with ?(in_optional_indexed_access = false) env t = + if Peek.is_line_terminator env then + t + else + match Peek.token env with + | T_PLING_PERIOD -> + Eat.token env; + if Peek.token env <> T_LBRACKET then error env Parse_error.InvalidOptionalIndexedAccess; + Expect.token env T_LBRACKET; + postfix_brackets ~in_optional_indexed_access:true ~optional_indexed_access:true env t + | T_LBRACKET -> + Eat.token env; + postfix_brackets ~in_optional_indexed_access ~optional_indexed_access:false env t + | T_PERIOD -> + (match Peek.ith_token ~i:1 env with + | T_LBRACKET -> + error env (Parse_error.InvalidIndexedAccess { has_bracket = true }); + Expect.token env T_PERIOD; + Expect.token env T_LBRACKET; + postfix_brackets ~in_optional_indexed_access ~optional_indexed_access:false env t + | _ -> + error env (Parse_error.InvalidIndexedAccess { has_bracket = false }); + t) + | _ -> t + + and postfix_brackets ~in_optional_indexed_access ~optional_indexed_access env t = + let t = + with_loc + ~start_loc:(fst t) + (fun env -> + (* Legacy Array syntax `Foo[]` *) + if (not optional_indexed_access) && Eat.maybe env T_RBRACKET then + let trailing = Eat.trailing_comments env in + Type.Array + { Type.Array.argument = t; comments = Flow_ast_utils.mk_comments_opt ~trailing () } + else + let index = _type env in + Expect.token env T_RBRACKET; + let trailing = Eat.trailing_comments env in + let indexed_access = + { + Type.IndexedAccess._object = t; + index; + comments = Flow_ast_utils.mk_comments_opt ~trailing (); + } + in + if in_optional_indexed_access then + Type.OptionalIndexedAccess + { Type.OptionalIndexedAccess.indexed_access; optional = optional_indexed_access } + else + Type.IndexedAccess indexed_access) + env + in + postfix_with env ~in_optional_indexed_access t + + and typeof_expr env = raw_typeof_expr_with_identifier env (Parse.identifier env) + + and raw_typeof_expr_with_identifier = + let rec identifier env (q_loc, qualification) = + if Peek.token env = T_PERIOD && Peek.ith_is_identifier ~i:1 env then + let (loc, q) = + with_loc + ~start_loc:q_loc + (fun env -> + Expect.token env T_PERIOD; + let id = identifier_name env in + { Type.Typeof.Target.qualification; id }) + env + in + let qualification = Type.Typeof.Target.Qualified (loc, q) in + identifier env (loc, qualification) + else + qualification + in + fun env ((loc, _) as id) -> + let id = Type.Typeof.Target.Unqualified id in + identifier env (loc, id) + + and typeof_arg env = + match Peek.token env with + | T_LPAREN -> + Eat.token env; + let typeof = typeof_arg env in + Expect.token env T_RPAREN; + typeof + | T_IDENTIFIER _ (* `static` is reserved in strict mode, but still an identifier *) -> + Some (typeof_expr env) + | _ -> + error env Parse_error.InvalidTypeof; + None + + and typeof env = + with_loc + (fun env -> + let leading = Peek.comments env in + Expect.token env T_TYPEOF; + match typeof_arg env with + | None -> Type.Any None + | Some argument -> + Type.Typeof + { Type.Typeof.argument; comments = Flow_ast_utils.mk_comments_opt ~leading () }) + env + + and primary env = + let loc = Peek.loc env in + match Peek.token env with + | T_MULT -> + let leading = Peek.comments env in + Expect.token env T_MULT; + let trailing = Eat.trailing_comments env in + (loc, Type.Exists (Flow_ast_utils.mk_comments_opt ~leading ~trailing ())) + | T_LESS_THAN -> _function env + | T_LPAREN -> function_or_group env + | T_LCURLY + | T_LCURLYBAR -> + let (loc, o) = _object env ~is_class:false ~allow_exact:true ~allow_spread:true in + (loc, Type.Object o) + | T_INTERFACE -> + with_loc + (fun env -> + let leading = Peek.comments env in + Expect.token env T_INTERFACE; + let (extends, body) = interface_helper env in + Type.Interface + { Type.Interface.extends; body; comments = Flow_ast_utils.mk_comments_opt ~leading () }) + env + | T_TYPEOF -> typeof env + | T_LBRACKET -> tuple env + | T_IDENTIFIER _ + | T_STATIC (* `static` is reserved in strict mode, but still an identifier *) -> + let (loc, g) = generic env in + (loc, Type.Generic g) + | T_STRING (loc, value, raw, octal) -> + if octal then strict_error env Parse_error.StrictOctalLiteral; + let leading = Peek.comments env in + Expect.token env (T_STRING (loc, value, raw, octal)); + let trailing = Eat.trailing_comments env in + ( loc, + Type.StringLiteral + { + Ast.StringLiteral.value; + raw; + comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing (); + } + ) + | T_NUMBER_SINGLETON_TYPE { kind; value; raw } -> + if kind = LEGACY_OCTAL then strict_error env Parse_error.StrictOctalLiteral; + let leading = Peek.comments env in + Expect.token env (T_NUMBER_SINGLETON_TYPE { kind; value; raw }); + let trailing = Eat.trailing_comments env in + ( loc, + Type.NumberLiteral + { + Ast.NumberLiteral.value; + raw; + comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing (); + } + ) + | T_BIGINT_SINGLETON_TYPE { kind; value; raw } -> + let leading = Peek.comments env in + Expect.token env (T_BIGINT_SINGLETON_TYPE { kind; value; raw }); + let trailing = Eat.trailing_comments env in + ( loc, + Type.BigIntLiteral + { + Ast.BigIntLiteral.value; + raw; + comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing (); + } + ) + | (T_TRUE | T_FALSE) as token -> + let leading = Peek.comments env in + Expect.token env token; + let trailing = Eat.trailing_comments env in + let value = token = T_TRUE in + ( loc, + Type.BooleanLiteral + { BooleanLiteral.value; comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing () } + ) + | _ -> + (match primitive env with + | Some t -> (loc, t) + | None -> + error_unexpected ~expected:"a type" env; + (loc, Type.Any None)) + + and is_primitive = function + | T_ANY_TYPE + | T_MIXED_TYPE + | T_EMPTY_TYPE + | T_BOOLEAN_TYPE _ + | T_NUMBER_TYPE + | T_BIGINT_TYPE + | T_STRING_TYPE + | T_SYMBOL_TYPE + | T_VOID_TYPE + | T_NULL -> + true + | _ -> false + + and primitive env = + let leading = Peek.comments env in + let token = Peek.token env in + match token with + | T_ANY_TYPE -> + Eat.token env; + let trailing = Eat.trailing_comments env in + Some (Type.Any (Flow_ast_utils.mk_comments_opt ~leading ~trailing ())) + | T_MIXED_TYPE -> + Eat.token env; + let trailing = Eat.trailing_comments env in + Some (Type.Mixed (Flow_ast_utils.mk_comments_opt ~leading ~trailing ())) + | T_EMPTY_TYPE -> + Eat.token env; + let trailing = Eat.trailing_comments env in + Some (Type.Empty (Flow_ast_utils.mk_comments_opt ~leading ~trailing ())) + | T_BOOLEAN_TYPE _ -> + Eat.token env; + let trailing = Eat.trailing_comments env in + Some (Type.Boolean (Flow_ast_utils.mk_comments_opt ~leading ~trailing ())) + | T_NUMBER_TYPE -> + Eat.token env; + let trailing = Eat.trailing_comments env in + Some (Type.Number (Flow_ast_utils.mk_comments_opt ~leading ~trailing ())) + | T_BIGINT_TYPE -> + Eat.token env; + let trailing = Eat.trailing_comments env in + Some (Type.BigInt (Flow_ast_utils.mk_comments_opt ~leading ~trailing ())) + | T_STRING_TYPE -> + Eat.token env; + let trailing = Eat.trailing_comments env in + Some (Type.String (Flow_ast_utils.mk_comments_opt ~leading ~trailing ())) + | T_SYMBOL_TYPE -> + Eat.token env; + let trailing = Eat.trailing_comments env in + Some (Type.Symbol (Flow_ast_utils.mk_comments_opt ~leading ~trailing ())) + | T_VOID_TYPE -> + Eat.token env; + let trailing = Eat.trailing_comments env in + Some (Type.Void (Flow_ast_utils.mk_comments_opt ~leading ~trailing ())) + | T_NULL -> + Eat.token env; + let trailing = Eat.trailing_comments env in + Some (Type.Null (Flow_ast_utils.mk_comments_opt ~leading ~trailing ())) + | _ -> None + + and tuple = + let rec types env acc = + match Peek.token env with + | T_EOF + | T_RBRACKET -> + List.rev acc + | _ -> + let acc = _type env :: acc in + (* Trailing comma support (like [number, string,]) *) + if Peek.token env <> T_RBRACKET then Expect.token env T_COMMA; + types env acc + in + fun env -> + with_loc + (fun env -> + let leading = Peek.comments env in + Expect.token env T_LBRACKET; + let tl = types (with_no_anon_function_type false env) [] in + Expect.token env T_RBRACKET; + let trailing = Eat.trailing_comments env in + Type.Tuple + { + Type.Tuple.types = tl; + comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing (); + }) + env + + and anonymous_function_param _env annot = + (fst annot, Type.Function.Param.{ name = None; annot; optional = false }) + + and function_param_with_id env = + with_loc + (fun env -> + Eat.push_lex_mode env Lex_mode.NORMAL; + let name = Parse.identifier env in + Eat.pop_lex_mode env; + if not (should_parse_types env) then error env Parse_error.UnexpectedTypeAnnotation; + let optional = Eat.maybe env T_PLING in + Expect.token env T_COLON; + let annot = _type env in + { Type.Function.Param.name = Some name; annot; optional }) + env + + and function_param_list_without_parens = + let param env = + match Peek.ith_token ~i:1 env with + | T_COLON + | T_PLING -> + function_param_with_id env + | _ -> + let annot = _type env in + anonymous_function_param env annot + in + let rec param_list env this_ acc = + match Peek.token env with + | (T_EOF | T_ELLIPSIS | T_RPAREN) as t -> + let rest = + if t = T_ELLIPSIS then + let rest = + with_loc + (fun env -> + let leading = Peek.comments env in + Expect.token env T_ELLIPSIS; + { + Type.Function.RestParam.argument = param env; + comments = Flow_ast_utils.mk_comments_opt ~leading (); + }) + env + in + Some rest + else + None + in + { Ast.Type.Function.Params.params = List.rev acc; rest; this_; comments = None } + | T_IDENTIFIER { raw = "this"; _ } + when Peek.ith_token ~i:1 env == T_COLON || Peek.ith_token ~i:1 env == T_PLING -> + if this_ <> None || acc <> [] then error env Parse_error.ThisParamMustBeFirst; + let this_ = + with_loc + (fun env -> + let leading = Peek.comments env in + Eat.token env; + if Peek.token env == T_PLING then error env Parse_error.ThisParamMayNotBeOptional; + { + Type.Function.ThisParam.annot = annotation env; + comments = Flow_ast_utils.mk_comments_opt ~leading (); + }) + env + in + if Peek.token env <> T_RPAREN then Expect.token env T_COMMA; + param_list env (Some this_) acc + | _ -> + let acc = param env :: acc in + if Peek.token env <> T_RPAREN then Expect.token env T_COMMA; + param_list env this_ acc + in + (fun env -> param_list env None) + + and function_param_list env = + with_loc + (fun env -> + let leading = Peek.comments env in + Expect.token env T_LPAREN; + let params = function_param_list_without_parens env [] in + let internal = Peek.comments env in + Expect.token env T_RPAREN; + let trailing = Eat.trailing_comments env in + { + params with + Ast.Type.Function.Params.comments = + Flow_ast_utils.mk_comments_with_internal_opt ~leading ~trailing ~internal (); + }) + env + + and param_list_or_type env = + let leading = Peek.comments env in + Expect.token env T_LPAREN; + let ret = + let env = with_no_anon_function_type false env in + match Peek.token env with + | T_EOF + | T_ELLIPSIS -> + (* (... is definitely the beginning of a param list *) + ParamList (function_param_list_without_parens env []) + | T_RPAREN -> + (* () or is definitely a param list *) + ParamList + { Ast.Type.Function.Params.this_ = None; params = []; rest = None; comments = None } + | T_IDENTIFIER _ + | T_STATIC (* `static` is reserved in strict mode, but still an identifier *) -> + (* This could be a function parameter or a generic type *) + function_param_or_generic_type env + | token when is_primitive token -> + (* Don't know if this is (number) or (number: number). The first + * is a type, the second is a param. *) + (match Peek.ith_token ~i:1 env with + | T_PLING + | T_COLON -> + (* Ok this is definitely a parameter *) + ParamList (function_param_list_without_parens env []) + | _ -> Type (_type env)) + | _ -> + (* All params start with an identifier or `...` *) + Type (_type env) + in + (* Now that we allow anonymous parameters in function types, we need to + * disambiguate a little bit more *) + let ret = + match ret with + | ParamList _ -> ret + | Type _ when no_anon_function_type env -> ret + | Type t -> + (match Peek.token env with + | T_RPAREN -> + (* Reinterpret `(type) =>` as a ParamList *) + if Peek.ith_token ~i:1 env = T_ARROW then + let param = anonymous_function_param env t in + ParamList (function_param_list_without_parens env [param]) + else + Type t + | T_COMMA -> + (* Reinterpret `(type,` as a ParamList *) + Expect.token env T_COMMA; + let param = anonymous_function_param env t in + ParamList (function_param_list_without_parens env [param]) + | _ -> ret) + in + let internal = Peek.comments env in + Expect.token env T_RPAREN; + let trailing = Eat.trailing_comments env in + let ret = + match ret with + | ParamList params -> + ParamList + { + params with + Ast.Type.Function.Params.comments = + Flow_ast_utils.mk_comments_with_internal_opt ~leading ~trailing ~internal (); + } + | Type t -> Type (add_comments t leading trailing) + in + ret + + and function_param_or_generic_type env = + match Peek.ith_token ~i:1 env with + | T_PLING + (* optional param *) + | T_COLON -> + ParamList (function_param_list_without_parens env []) + | _ -> + let id = type_identifier env in + Type + (generic_type_with_identifier env id + |> postfix_with env + |> anon_function_without_parens_with env + |> intersection_with env + |> union_with env + ) + + and function_or_group env = + let start_loc = Peek.loc env in + match with_loc param_list_or_type env with + | (loc, ParamList params) -> function_with_params env start_loc None (loc, params) + | (_, Type _type) -> _type + + and _function env = + let start_loc = Peek.loc env in + let tparams = type_params_remove_trailing env (type_params env) in + let params = function_param_list env in + function_with_params env start_loc tparams params + + and function_with_params env start_loc tparams (params : (Loc.t, Loc.t) Ast.Type.Function.Params.t) + = + with_loc + ~start_loc + (fun env -> + Expect.token env T_ARROW; + let return = _type env in + Type.(Function { Function.params; return; tparams; comments = None })) + env + + and _object = + let methodish env start_loc tparams = + with_loc + ~start_loc + (fun env -> + let params = function_param_list env in + Expect.token env T_COLON; + let return = _type env in + { Type.Function.params; return; tparams; comments = None }) + env + in + let method_property env start_loc static key ~leading = + let key = object_key_remove_trailing env key in + let tparams = type_params_remove_trailing env (type_params env) in + let value = methodish env start_loc tparams in + let value = (fst value, Type.Function (snd value)) in + Type.Object.( + Property + ( fst value, + { + Property.key; + value = Property.Init value; + optional = false; + static = static <> None; + proto = false; + _method = true; + variance = None; + comments = Flow_ast_utils.mk_comments_opt ~leading (); + } + ) + ) + in + let call_property env start_loc static ~leading = + let prop = + with_loc + ~start_loc + (fun env -> + let start_loc = Peek.loc env in + let tparams = type_params_remove_trailing env (type_params env) in + let value = methodish env start_loc tparams in + Type.Object.CallProperty. + { + value; + static = static <> None; + comments = Flow_ast_utils.mk_comments_opt ~leading (); + } + ) + env + in + Type.Object.CallProperty prop + in + let init_property env start_loc ~variance ~static ~proto ~leading (key_loc, key) = + ignore proto; + if not (should_parse_types env) then error env Parse_error.UnexpectedTypeAnnotation; + let prop = + with_loc + ~start_loc + (fun env -> + let optional = Eat.maybe env T_PLING in + let value = + if Expect.token_maybe env T_COLON then + _type env + else + (key_loc, Type.Any None) + in + Type.Object.Property. + { + key; + value = Init value; + optional; + static = static <> None; + proto = proto <> None; + _method = false; + variance; + comments = Flow_ast_utils.mk_comments_opt ~leading (); + } + ) + env + in + Type.Object.Property prop + in + let getter_or_setter ~is_getter ~leading env start_loc static key = + let prop = + with_loc + ~start_loc + (fun env -> + let (key_loc, key) = key in + let key = object_key_remove_trailing env key in + let value = methodish env start_loc None in + let (_, { Type.Function.params; _ }) = value in + begin + match (is_getter, params) with + | (true, (_, { Type.Function.Params.this_ = Some _; _ })) -> + error_at env (key_loc, Parse_error.GetterMayNotHaveThisParam) + | (false, (_, { Type.Function.Params.this_ = Some _; _ })) -> + error_at env (key_loc, Parse_error.SetterMayNotHaveThisParam) + | ( true, + (_, { Type.Function.Params.params = []; rest = None; this_ = None; comments = _ }) + ) -> + () + | (false, (_, { Type.Function.Params.rest = Some _; _ })) -> + (* rest params don't make sense on a setter *) + error_at env (key_loc, Parse_error.SetterArity) + | (false, (_, { Type.Function.Params.params = [_]; _ })) -> () + | (true, _) -> error_at env (key_loc, Parse_error.GetterArity) + | (false, _) -> error_at env (key_loc, Parse_error.SetterArity) + end; + Type.Object.Property. + { + key; + value = + ( if is_getter then + Get value + else + Set value + ); + optional = false; + static = static <> None; + proto = false; + _method = false; + variance = None; + comments = Flow_ast_utils.mk_comments_opt ~leading (); + } + ) + env + in + Type.Object.Property prop + in + let indexer_property env start_loc static variance ~leading = + let indexer = + with_loc + ~start_loc + (fun env -> + let leading = leading @ Peek.comments env in + Expect.token env T_LBRACKET; + let id = + if Peek.ith_token ~i:1 env = T_COLON then ( + let id = identifier_name env in + Expect.token env T_COLON; + Some id + ) else + None + in + let key = _type env in + Expect.token env T_RBRACKET; + let trailing = Eat.trailing_comments env in + Expect.token env T_COLON; + let value = _type env in + { + Type.Object.Indexer.id; + key; + value; + static = static <> None; + variance; + comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing (); + }) + env + in + Type.Object.Indexer indexer + in + let internal_slot env start_loc static ~leading = + let islot = + with_loc + ~start_loc + (fun env -> + let leading = leading @ Peek.comments env in + Expect.token env T_LBRACKET; + Expect.token env T_LBRACKET; + let id = identifier_name env in + Expect.token env T_RBRACKET; + Expect.token env T_RBRACKET; + let (optional, _method, value, trailing) = + match Peek.token env with + | T_LESS_THAN + | T_LPAREN -> + let tparams = type_params_remove_trailing env (type_params env) in + let value = + let (fn_loc, fn) = methodish env start_loc tparams in + (fn_loc, Type.Function fn) + in + (false, true, value, []) + | _ -> + let optional = Eat.maybe env T_PLING in + let trailing = Eat.trailing_comments env in + Expect.token env T_COLON; + let value = _type env in + (optional, false, value, trailing) + in + { + Type.Object.InternalSlot.id; + value; + optional; + static = static <> None; + _method; + comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing (); + }) + env + in + Type.Object.InternalSlot islot + (* Expects the T_ELLIPSIS has already been eaten *) + in + let spread_property env start_loc ~leading = + let spread = + with_loc + ~start_loc + (fun env -> + { + Type.Object.SpreadProperty.argument = _type env; + comments = Flow_ast_utils.mk_comments_opt ~leading (); + }) + env + in + Type.Object.SpreadProperty spread + in + let semicolon exact env = + match Peek.token env with + | T_COMMA + | T_SEMICOLON -> + Eat.token env + | T_RCURLYBAR when exact -> () + | T_RCURLY when not exact -> () + | _ -> Expect.error env T_COMMA + in + let error_unexpected_variance env = function + | Some (loc, _) -> error_at env (loc, Parse_error.UnexpectedVariance) + | None -> () + in + let error_unexpected_proto env = function + | Some loc -> error_at env (loc, Parse_error.UnexpectedProto) + | None -> () + in + let error_invalid_property_name env is_class static key = + let is_static = static <> None in + let is_constructor = String.equal "constructor" in + let is_prototype = String.equal "prototype" in + match key with + | Expression.Object.Property.Identifier (loc, { Identifier.name; comments = _ }) + when is_class && (is_constructor name || (is_static && is_prototype name)) -> + error_at + env + ( loc, + Parse_error.InvalidClassMemberName + { name; static = is_static; method_ = false; private_ = false } + ) + | _ -> () + in + let rec properties + ~is_class ~allow_inexact ~allow_spread ~exact env ((props, inexact, internal) as acc) = + (* no `static ...A` *) + assert (not (is_class && allow_spread)); + + (* allow_inexact implies allow_spread *) + assert ((not allow_inexact) || allow_spread); + + let start_loc = Peek.loc env in + match Peek.token env with + | T_EOF -> (List.rev props, inexact, internal) + | T_RCURLYBAR when exact -> (List.rev props, inexact, internal) + | T_RCURLY when not exact -> (List.rev props, inexact, internal) + | T_ELLIPSIS when allow_spread -> + let leading = Peek.comments env in + Eat.token env; + begin + match Peek.token env with + | T_COMMA + | T_SEMICOLON + | T_RCURLY + | T_RCURLYBAR -> + semicolon exact env; + begin + match Peek.token env with + | T_RCURLY when allow_inexact -> (List.rev props, true, leading) + | T_RCURLYBAR -> + error_at env (start_loc, Parse_error.InexactInsideExact); + (List.rev props, inexact, internal) + | _ -> + error_at env (start_loc, Parse_error.UnexpectedExplicitInexactInObject); + properties ~is_class ~allow_inexact ~allow_spread ~exact env acc + end + | _ -> + let prop = spread_property env start_loc ~leading in + semicolon exact env; + properties + ~is_class + ~allow_inexact + ~allow_spread + ~exact + env + (prop :: props, inexact, internal) + end + (* In this case, allow_spread is false, so we may assume allow_inexact is false based on our + * assertion at the top of this function. Thus, any T_ELLIPSIS here is not allowed. + *) + | T_ELLIPSIS -> + Eat.token env; + begin + match Peek.token env with + | T_COMMA + | T_SEMICOLON + | T_RCURLY + | T_RCURLYBAR -> + error_at env (start_loc, Parse_error.InexactInsideNonObject); + semicolon exact env; + properties ~is_class ~allow_inexact ~allow_spread ~exact env acc + | _ -> + error_list env (Peek.errors env); + error_at env (start_loc, Parse_error.UnexpectedSpreadType); + + (* It's likely the user is trying to spread something here, so we can + * eat what they try to spread to try to continue parsing the remaining + * properties. + *) + Eat.token env; + semicolon exact env; + properties ~is_class ~allow_inexact ~allow_spread ~exact env acc + end + | _ -> + let prop = + property + env + start_loc + ~is_class + ~allow_static:is_class + ~allow_proto:is_class + ~variance:None + ~static:None + ~proto:None + ~leading:[] + in + semicolon exact env; + properties + ~is_class + ~allow_inexact + ~allow_spread + ~exact + env + (prop :: props, inexact, internal) + and property + env ~is_class ~allow_static ~allow_proto ~variance ~static ~proto ~leading start_loc = + match Peek.token env with + | T_PLUS + | T_MINUS + when variance = None -> + let variance = maybe_variance env in + property + env + ~is_class + ~allow_static:false + ~allow_proto:false + ~variance + ~static + ~proto + ~leading + start_loc + | T_STATIC when allow_static -> + assert (variance = None); + + (* if we parsed variance, allow_static = false *) + let static = Some (Peek.loc env) in + let leading = leading @ Peek.comments env in + Eat.token env; + property + env + ~is_class + ~allow_static:false + ~allow_proto:false + ~variance + ~static + ~proto + ~leading + start_loc + | T_IDENTIFIER { raw = "proto"; _ } when allow_proto -> + assert (variance = None); + + (* if we parsed variance, allow_proto = false *) + let proto = Some (Peek.loc env) in + let leading = leading @ Peek.comments env in + Eat.token env; + property + env + ~is_class + ~allow_static:false + ~allow_proto:false + ~variance + ~static + ~proto + ~leading + start_loc + | T_LBRACKET -> + error_unexpected_proto env proto; + (match Peek.ith_token ~i:1 env with + | T_LBRACKET -> + error_unexpected_variance env variance; + internal_slot env start_loc static ~leading + | _ -> indexer_property env start_loc static variance ~leading) + | T_LESS_THAN + | T_LPAREN -> + (* Note that `static(): void` is a static callable property if we + successfully parsed the static modifier above. *) + error_unexpected_proto env proto; + error_unexpected_variance env variance; + call_property env start_loc static ~leading + | token -> + (match (static, proto, token) with + | (Some _, Some _, _) -> failwith "Can not have both `static` and `proto`" + | (Some static_loc, None, (T_PLING | T_COLON)) -> + (* We speculatively parsed `static` as a static modifier, but now + that we've parsed the next token, we changed our minds and want + to parse `static` as the key of a named property. *) + let key = + Expression.Object.Property.Identifier + (Flow_ast_utils.ident_of_source + (static_loc, "static") + ?comments:(Flow_ast_utils.mk_comments_opt ~leading ()) + ) + in + let static = None in + init_property env start_loc ~variance ~static ~proto ~leading:[] (static_loc, key) + | (None, Some proto_loc, (T_PLING | T_COLON)) -> + (* We speculatively parsed `proto` as a proto modifier, but now + that we've parsed the next token, we changed our minds and want + to parse `proto` as the key of a named property. *) + let key = + Expression.Object.Property.Identifier + (Flow_ast_utils.ident_of_source + (proto_loc, "proto") + ?comments:(Flow_ast_utils.mk_comments_opt ~leading ()) + ) + in + let proto = None in + init_property env start_loc ~variance ~static ~proto ~leading:[] (proto_loc, key) + | _ -> + let object_key env = + Eat.push_lex_mode env Lex_mode.NORMAL; + let result = Parse.object_key env in + Eat.pop_lex_mode env; + result + in + let leading_key = Peek.comments env in + (match object_key env with + | ( key_loc, + ( Expression.Object.Property.Identifier + (_, { Identifier.name = ("get" | "set") as name; comments = _ }) as key + ) + ) -> + begin + match Peek.token env with + | T_LESS_THAN + | T_LPAREN -> + error_unexpected_proto env proto; + error_unexpected_variance env variance; + method_property env start_loc static key ~leading + | T_COLON + | T_PLING -> + init_property env start_loc ~variance ~static ~proto ~leading (key_loc, key) + | _ -> + ignore (object_key_remove_trailing env key); + let key = object_key env in + let is_getter = name = "get" in + let leading = leading @ leading_key in + error_unexpected_proto env proto; + error_unexpected_variance env variance; + getter_or_setter ~is_getter ~leading env start_loc static key + end + | (key_loc, key) -> + begin + match Peek.token env with + | T_LESS_THAN + | T_LPAREN -> + error_unexpected_proto env proto; + error_unexpected_variance env variance; + method_property env start_loc static key ~leading + | _ -> + error_invalid_property_name env is_class static key; + init_property env start_loc ~variance ~static ~proto ~leading (key_loc, key) + end)) + in + fun ~is_class ~allow_exact ~allow_spread env -> + let exact = allow_exact && Peek.token env = T_LCURLYBAR in + let allow_inexact = allow_exact && not exact in + with_loc + (fun env -> + let leading = Peek.comments env in + Expect.token + env + ( if exact then + T_LCURLYBAR + else + T_LCURLY + ); + let (properties, inexact, internal) = + let env = with_no_anon_function_type false env in + properties ~is_class ~allow_inexact ~exact ~allow_spread env ([], false, []) + in + let internal = internal @ Peek.comments env in + Expect.token + env + ( if exact then + T_RCURLYBAR + else + T_RCURLY + ); + let trailing = Eat.trailing_comments env in + + (* inexact = true iff `...` was used to indicate inexactnes *) + { + Type.Object.exact; + properties; + inexact; + comments = Flow_ast_utils.mk_comments_with_internal_opt ~leading ~trailing ~internal (); + }) + env + + and interface_helper = + let rec supers env acc = + let super = generic env in + let acc = super :: acc in + match Peek.token env with + | T_COMMA -> + Expect.token env T_COMMA; + supers env acc + | _ -> List.rev acc + in + fun env -> + let extends = + if Peek.token env = T_EXTENDS then ( + Expect.token env T_EXTENDS; + let extends = supers env [] in + generic_type_list_remove_trailing env extends + ) else + [] + in + let body = _object env ~allow_exact:false ~allow_spread:false ~is_class:false in + (extends, body) + + and type_identifier env = + let (loc, { Identifier.name; comments }) = identifier_name env in + if is_reserved_type name then error_at env (loc, Parse_error.UnexpectedReservedType); + (loc, { Identifier.name; comments }) + + and bounded_type env = + with_loc + (fun env -> + let name = type_identifier env in + let bound = + if Peek.token env = T_COLON then + Ast.Type.Available (annotation env) + else + Ast.Type.Missing (Peek.loc_skip_lookahead env) + in + (name, bound)) + env + + and type_params = + let rec params env ~require_default acc = + Type.TypeParam.( + let (loc, (variance, name, bound, default, require_default)) = + with_loc + (fun env -> + let variance = maybe_variance env in + let (loc, (name, bound)) = bounded_type env in + let (default, require_default) = + match Peek.token env with + | T_ASSIGN -> + Eat.token env; + (Some (_type env), true) + | _ -> + if require_default then error_at env (loc, Parse_error.MissingTypeParamDefault); + (None, require_default) + in + (variance, name, bound, default, require_default)) + env + in + let param = (loc, { name; bound; variance; default }) in + let acc = param :: acc in + match Peek.token env with + | T_EOF + | T_GREATER_THAN -> + List.rev acc + | _ -> + Expect.token env T_COMMA; + if Peek.token env = T_GREATER_THAN then + List.rev acc + else + params env ~require_default acc + ) + in + fun env -> + if Peek.token env = T_LESS_THAN then ( + if not (should_parse_types env) then error env Parse_error.UnexpectedTypeAnnotation; + Some + (with_loc + (fun env -> + let leading = Peek.comments env in + Expect.token env T_LESS_THAN; + let params = params env ~require_default:false [] in + let internal = Peek.comments env in + Expect.token env T_GREATER_THAN; + let trailing = Eat.trailing_comments env in + { + Type.TypeParams.params; + comments = + Flow_ast_utils.mk_comments_with_internal_opt ~leading ~trailing ~internal (); + }) + env + ) + ) else + None + + and type_args = + let rec args env acc = + match Peek.token env with + | T_EOF + | T_GREATER_THAN -> + List.rev acc + | _ -> + let acc = _type env :: acc in + if Peek.token env <> T_GREATER_THAN then Expect.token env T_COMMA; + args env acc + in + fun env -> + if Peek.token env = T_LESS_THAN then + Some + (with_loc + (fun env -> + let leading = Peek.comments env in + Expect.token env T_LESS_THAN; + let env = with_no_anon_function_type false env in + let arguments = args env [] in + let internal = Peek.comments env in + Expect.token env T_GREATER_THAN; + let trailing = Eat.trailing_comments env in + { + Type.TypeArgs.arguments; + comments = + Flow_ast_utils.mk_comments_with_internal_opt ~leading ~trailing ~internal (); + }) + env + ) + else + None + + and generic env = raw_generic_with_identifier env (type_identifier env) + + and raw_generic_with_identifier = + let rec identifier env (q_loc, qualification) = + if Peek.token env = T_PERIOD && Peek.ith_is_type_identifier ~i:1 env then + let (loc, q) = + with_loc + ~start_loc:q_loc + (fun env -> + Expect.token env T_PERIOD; + let id = type_identifier env in + { Type.Generic.Identifier.qualification; id }) + env + in + let qualification = Type.Generic.Identifier.Qualified (loc, q) in + identifier env (loc, qualification) + else + (q_loc, qualification) + in + fun env id -> + with_loc + ~start_loc:(fst id) + (fun env -> + let id = (fst id, Type.Generic.Identifier.Unqualified id) in + let id = + let (_id_loc, id) = identifier env id in + if Peek.token env <> T_LESS_THAN then + id + else + let { remove_trailing; _ } = trailing_and_remover env in + remove_trailing id (fun remover id -> remover#generic_identifier_type id) + in + let targs = type_args env in + { Type.Generic.id; targs; comments = None }) + env + + and generic_type_with_identifier env id = + let (loc, generic) = raw_generic_with_identifier env id in + (loc, Type.Generic generic) + + and annotation_opt env = + match Peek.token env with + | T_COLON -> Type.Available (annotation env) + | _ -> Type.Missing (Peek.loc_skip_lookahead env) + + and add_comments (loc, t) leading trailing = + let merge_comments inner = + Flow_ast_utils.merge_comments + ~inner + ~outer:(Flow_ast_utils.mk_comments_opt ~leading ~trailing ()) + in + let merge_comments_with_internal inner = + Flow_ast_utils.merge_comments_with_internal + ~inner + ~outer:(Flow_ast_utils.mk_comments_opt ~leading ~trailing ()) + in + let open Ast.Type in + ( loc, + match t with + | Any comments -> Any (merge_comments comments) + | Mixed comments -> Mixed (merge_comments comments) + | Empty comments -> Empty (merge_comments comments) + | Void comments -> Void (merge_comments comments) + | Null comments -> Null (merge_comments comments) + | Number comments -> Number (merge_comments comments) + | BigInt comments -> BigInt (merge_comments comments) + | String comments -> String (merge_comments comments) + | Boolean comments -> Boolean (merge_comments comments) + | Symbol comments -> Symbol (merge_comments comments) + | Exists comments -> Exists (merge_comments comments) + | Nullable ({ Nullable.comments; _ } as t) -> + Nullable { t with Nullable.comments = merge_comments comments } + | Function ({ Function.comments; _ } as t) -> + Function { t with Function.comments = merge_comments comments } + | Object ({ Object.comments; _ } as t) -> + Object { t with Object.comments = merge_comments_with_internal comments } + | Interface ({ Interface.comments; _ } as t) -> + Interface { t with Interface.comments = merge_comments comments } + | Array ({ Array.comments; _ } as t) -> + Array { t with Array.comments = merge_comments comments } + | Generic ({ Generic.comments; _ } as t) -> + Generic { t with Generic.comments = merge_comments comments } + | IndexedAccess ({ IndexedAccess.comments; _ } as t) -> + IndexedAccess { t with IndexedAccess.comments = merge_comments comments } + | OptionalIndexedAccess + { + OptionalIndexedAccess.indexed_access = { IndexedAccess.comments; _ } as indexed_access; + optional; + } -> + OptionalIndexedAccess + { + OptionalIndexedAccess.indexed_access = + { indexed_access with IndexedAccess.comments = merge_comments comments }; + optional; + } + | Union ({ Union.comments; _ } as t) -> + Union { t with Union.comments = merge_comments comments } + | Intersection ({ Intersection.comments; _ } as t) -> + Intersection { t with Intersection.comments = merge_comments comments } + | Typeof ({ Typeof.comments; _ } as t) -> + Typeof { t with Typeof.comments = merge_comments comments } + | Tuple ({ Tuple.comments; _ } as t) -> + Tuple { t with Tuple.comments = merge_comments comments } + | StringLiteral ({ StringLiteral.comments; _ } as t) -> + StringLiteral { t with StringLiteral.comments = merge_comments comments } + | NumberLiteral ({ NumberLiteral.comments; _ } as t) -> + NumberLiteral { t with NumberLiteral.comments = merge_comments comments } + | BigIntLiteral ({ BigIntLiteral.comments; _ } as t) -> + BigIntLiteral { t with BigIntLiteral.comments = merge_comments comments } + | BooleanLiteral ({ BooleanLiteral.comments; _ } as t) -> + BooleanLiteral { t with BooleanLiteral.comments = merge_comments comments } + ) + + let predicate = + with_loc (fun env -> + let open Ast.Type.Predicate in + let leading = Peek.comments env in + Expect.token env T_CHECKS; + if Peek.token env = T_LPAREN then ( + let leading = leading @ Peek.comments env in + Expect.token env T_LPAREN; + Eat.push_lex_mode env Lex_mode.NORMAL; + let exp = Parse.conditional env in + Eat.pop_lex_mode env; + Expect.token env T_RPAREN; + let trailing = Eat.trailing_comments env in + { kind = Declared exp; comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing () } + ) else + let trailing = Eat.trailing_comments env in + { + kind = Ast.Type.Predicate.Inferred; + comments = Flow_ast_utils.mk_comments_opt ~leading ~trailing (); + } + ) + + let predicate_opt env = + let env = with_no_anon_function_type false env in + match Peek.token env with + | T_CHECKS -> Some (predicate env) + | _ -> None + + let annotation_and_predicate_opt env = + let open Ast.Type in + match (Peek.token env, Peek.ith_token ~i:1 env) with + | (T_COLON, T_CHECKS) -> + Expect.token env T_COLON; + (Missing (Peek.loc_skip_lookahead env), predicate_opt env) + | (T_COLON, _) -> + let annotation = + let annotation = annotation_opt env in + if Peek.token env = T_CHECKS then + type_annotation_hint_remove_trailing env annotation + else + annotation + in + let predicate = predicate_opt env in + (annotation, predicate) + | _ -> (Missing (Peek.loc_skip_lookahead env), None) + + let wrap f env = + let env = env |> with_strict true in + Eat.push_lex_mode env Lex_mode.TYPE; + let ret = f env in + Eat.pop_lex_mode env; + ret + + let _type = wrap _type + + let type_identifier = wrap type_identifier + + let type_params = wrap type_params + + let type_args = wrap type_args + + let _object ~is_class env = wrap (_object ~is_class ~allow_exact:false ~allow_spread:false) env + + let interface_helper = wrap interface_helper + + let function_param_list = wrap function_param_list + + let annotation = wrap annotation + + let annotation_opt = wrap annotation_opt + + let predicate_opt = wrap predicate_opt + + let annotation_and_predicate_opt = wrap annotation_and_predicate_opt + + let generic = wrap generic +end diff --git a/analysis/vendor/js_parser/wtf8.ml b/analysis/vendor/js_parser/wtf8.ml new file mode 100644 index 000000000..be7d3718f --- /dev/null +++ b/analysis/vendor/js_parser/wtf8.ml @@ -0,0 +1,103 @@ +(** + * Copyright (c) 2017-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) + +(* + * WTF-8 is a superset of UTF-8 that allows unpaired surrogates. + * + * From ES6 6.1.4, "The String Type": + * + * Where ECMAScript operations interpret String values, each element is + * interpreted as a single UTF-16 code unit. However, ECMAScript does not + * place any restrictions or requirements on the sequence of code units in + * a String value, so they may be ill-formed when interpreted as UTF-16 code + * unit sequences. Operations that do not interpret String contents treat + * them as sequences of undifferentiated 16-bit unsigned integers. + * + * If we try to encode these ill-formed code units into UTF-8, we similarly + * get ill-formed UTF-8. WTF-8 is a fun name for that encoding. + * + * https://simonsapin.github.io/wtf-8/ + *) + +type codepoint = + | Point of int + | Malformed + +type 'a folder = 'a -> int -> codepoint -> 'a + +(* WTF-8 is a variable length encoding. The first byte in each codepoint + determines how many other bytes follow. *) +let needed_bytes c = + if 0x00 <= c && c <= 0x7F then 1 else + if 0xC2 <= c && c <= 0xDF then 2 else + if 0xE0 <= c && c <= 0xEF then 3 else + if 0xF0 <= c && c <= 0xF4 then 4 else + 0 + +let unsafe_char s i = Char.code (Bytes.unsafe_get s i) + +let codepoint s i = function + | 1 -> unsafe_char s i + | 2 -> + let b0 = unsafe_char s i in + let b1 = unsafe_char s (i + 1) in + ((b0 land 0x1F) lsl 6) lor (b1 land 0x3F) + | 3 -> + let b0 = unsafe_char s (i) in + let b1 = unsafe_char s (i + 1) in + let b2 = unsafe_char s (i + 2) in + ((b0 land 0x0F) lsl 12) lor + ((b1 land 0x3F) lsl 6) lor + (b2 land 0x3F) + | 4 -> + let b0 = unsafe_char s (i) in + let b1 = unsafe_char s (i + 1) in + let b2 = unsafe_char s (i + 2) in + let b3 = unsafe_char s (i + 3) in + ((b0 land 0x07) lsl 18) lor + ((b1 land 0x3F) lsl 12) lor + ((b2 land 0x3F) lsl 6) lor + (b3 land 0x3F) + | _ -> assert false + +(* Fold over the WTF-8 code units in a string *) +let fold_wtf_8 ?(pos = 0) ?len f acc s = + let rec loop acc f s i l = + if i = l then acc else + let need = needed_bytes (unsafe_char s i) in + if need = 0 then (loop [@tailcall]) (f acc i Malformed) f s (i + 1) l else + let rem = l - i in + if rem < need then f acc i Malformed else + (loop [@tailcall]) (f acc i (Point (codepoint s i need))) f s (i + need) l + in + let len = match len with + | None -> String.length s - pos + | Some l -> l + in + loop acc f (Bytes.unsafe_of_string s) pos len + +(* Add a UTF-16 code unit to a buffer, encoded in WTF-8. *) +let add_wtf_8 buf code = + let[@inline] w byte = Buffer.add_char buf (Char.unsafe_chr byte) in + if code >= 0x10000 then begin + (* 4 bytes *) + w (0xf0 lor (code lsr 18)); + w (0x80 lor ((code lsr 12) land 0x3F)); + w (0x80 lor ((code lsr 6) land 0x3F)); + w (0x80 lor (code land 0x3F)) + end else if code >= 0x800 then begin + (* 3 bytes *) + w (0xe0 lor (code lsr 12)); + w (0x80 lor ((code lsr 6) land 0x3F)); + w (0x80 lor (code land 0x3F)) + end else if code >= 0x80 then begin + (* 2 bytes *) + w (0xc0 lor (code lsr 6)); + w (0x80 lor (code land 0x3F)) + end else + (* 1 byte *) + w code diff --git a/analysis/vendor/js_parser/wtf8.mli b/analysis/vendor/js_parser/wtf8.mli new file mode 100644 index 000000000..8aac2e983 --- /dev/null +++ b/analysis/vendor/js_parser/wtf8.mli @@ -0,0 +1,19 @@ +(* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) + +[@@@ocaml.text +"\n * Copyright (c) 2017-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n "] + +type codepoint = + | Point of int + | Malformed + +type 'a folder = 'a -> int -> codepoint -> 'a + +val fold_wtf_8 : ?pos:int -> ?len:int -> 'a folder -> 'a -> string -> 'a + +val add_wtf_8 : Buffer.t -> int -> unit diff --git a/analysis/vendor/ml/ast_async.ml b/analysis/vendor/ml/ast_async.ml new file mode 100644 index 000000000..d16b193a4 --- /dev/null +++ b/analysis/vendor/ml/ast_async.ml @@ -0,0 +1,36 @@ +let is_async : Parsetree.attribute -> bool = + fun ({txt}, _) -> txt = "async" || txt = "res.async" + +let add_promise_type ?(loc = Location.none) ~async + (result : Parsetree.expression) = + if async then + let unsafe_async = + Ast_helper.Exp.ident ~loc + {txt = Ldot (Ldot (Lident "Js", "Promise"), "unsafe_async"); loc} + in + Ast_helper.Exp.apply ~loc unsafe_async [(Nolabel, result)] + else result + +let add_async_attribute ~async (body : Parsetree.expression) = + if async then + { + body with + pexp_attributes = + ({txt = "res.async"; loc = Location.none}, PStr []) + :: body.pexp_attributes; + } + else body + +let rec add_promise_to_result ~loc (e : Parsetree.expression) = + match e.pexp_desc with + | Pexp_fun (label, eo, pat, body) -> + let body = add_promise_to_result ~loc body in + {e with pexp_desc = Pexp_fun (label, eo, pat, body)} + | _ -> add_promise_type ~loc ~async:true e + +let make_function_async ~async (e : Parsetree.expression) = + if async then + match e.pexp_desc with + | Pexp_fun (_, _, {ppat_loc}, _) -> add_promise_to_result ~loc:ppat_loc e + | _ -> assert false + else e diff --git a/analysis/vendor/ml/ast_await.ml b/analysis/vendor/ml/ast_await.ml new file mode 100644 index 000000000..410f3b9c7 --- /dev/null +++ b/analysis/vendor/ml/ast_await.ml @@ -0,0 +1,41 @@ +let is_await : Parsetree.attribute -> bool = + fun ({txt}, _) -> txt = "await" || txt = "res.await" + +let create_await_expression (e : Parsetree.expression) = + let loc = e.pexp_loc in + let unsafe_await = + Ast_helper.Exp.ident ~loc + {txt = Ldot (Ldot (Lident "Js", "Promise"), "unsafe_await"); loc} + in + Ast_helper.Exp.apply ~loc unsafe_await [(Nolabel, e)] + +(* Transform `@res.await M` to unpack(@res.await Js.import(module(M: __M0__))) *) +let create_await_module_expression ~module_type_lid (e : Parsetree.module_expr) + = + let open Ast_helper in + let remove_await_attribute = + List.filter (fun ((loc, _) : Parsetree.attribute) -> loc.txt != "res.await") + in + { + e with + pmod_desc = + Pmod_unpack + (create_await_expression + (Exp.apply ~loc:e.pmod_loc + (Exp.ident ~loc:e.pmod_loc + { + txt = Longident.Ldot (Lident "Js", "import"); + loc = e.pmod_loc; + }) + [ + ( Nolabel, + Exp.constraint_ ~loc:e.pmod_loc + (Exp.pack ~loc:e.pmod_loc + { + e with + pmod_attributes = + remove_await_attribute e.pmod_attributes; + }) + (Typ.package ~loc:e.pmod_loc module_type_lid []) ); + ])); + } diff --git a/analysis/vendor/ml/ast_payload.ml b/analysis/vendor/ml/ast_payload.ml new file mode 100644 index 000000000..0f973b9e1 --- /dev/null +++ b/analysis/vendor/ml/ast_payload.ml @@ -0,0 +1,262 @@ +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) + +type t = Parsetree.payload + +let is_single_string (x : t) = + match x with + (* TODO also need detect empty phrase case *) + | PStr + [ + { + pstr_desc = + Pstr_eval + ({pexp_desc = Pexp_constant (Pconst_string (name, dec)); _}, _); + _; + }; + ] -> + Some (name, dec) + | _ -> None + +let is_single_string_as_ast (x : t) : Parsetree.expression option = + match x with + (*TODO also need detect empty phrase case *) + | PStr + [ + { + pstr_desc = + Pstr_eval + (({pexp_desc = Pexp_constant (Pconst_string (_, _)); _} as e), _); + _; + }; + ] -> + Some e + | _ -> None + +let is_single_int (x : t) : int option = + match x with + | PStr + [ + { + pstr_desc = + Pstr_eval + ({pexp_desc = Pexp_constant (Pconst_integer (name, _)); _}, _); + _; + }; + ] -> + Some (int_of_string name) + | _ -> None + +let is_single_float (x : t) : string option = + match x with + | PStr + [ + { + pstr_desc = + Pstr_eval + ({pexp_desc = Pexp_constant (Pconst_float (name, _)); _}, _); + _; + }; + ] -> + Some name + | _ -> None + +let is_single_bool (x : t) : bool option = + match x with + | PStr + [ + { + pstr_desc = + Pstr_eval + ( { + pexp_desc = + Pexp_construct ({txt = Lident (("true" | "false") as b)}, _); + _; + }, + _ ); + _; + }; + ] -> + Some (b = "true") + | _ -> None + +let is_single_ident (x : t) = + match x with + | PStr [{pstr_desc = Pstr_eval ({pexp_desc = Pexp_ident lid}, _); _}] -> + Some lid.txt + | _ -> None + +let raw_as_string_exp_exn ~(kind : Js_raw_info.raw_kind) ?is_function (x : t) : + Parsetree.expression option = + match x with + (* TODO also need detect empty phrase case *) + | PStr + [ + { + pstr_desc = + Pstr_eval + ( ({ + pexp_desc = Pexp_constant (Pconst_string (str, deli)); + pexp_loc = loc; + } as e), + _ ); + _; + }; + ] -> + Bs_flow_ast_utils.check_flow_errors ~loc + ~offset:(Bs_flow_ast_utils.flow_deli_offset deli) + (match kind with + | Raw_re | Raw_exp -> + let ((_loc, e) as prog), errors = + Parser_flow.parse_expression (Parser_env.init_env None str) false + in + (if kind = Raw_re then + match e with + | Literal {value = RegExp _} -> () + | _ -> + Location.raise_errorf ~loc + "Syntax error: a valid JS regex literal expected"); + (match is_function with + | Some is_function -> ( + match Classify_function.classify_exp prog with + | Js_function {arity; _} -> is_function := Some arity + | _ -> ()) + | None -> ()); + errors + | Raw_program -> snd (Parser_flow.parse_program false None str)); + Some {e with pexp_desc = Pexp_constant (Pconst_string (str, None))} + | _ -> None + +let as_core_type loc (x : t) = + match x with + | PTyp x -> x + | _ -> Location.raise_errorf ~loc "except a core type" + +let as_ident (x : t) = + match x with + | PStr [{pstr_desc = Pstr_eval ({pexp_desc = Pexp_ident ident}, _)}] -> + Some ident + | _ -> None + +type lid = string Asttypes.loc + +type label_expr = lid * Parsetree.expression + +type action = lid * Parsetree.expression option +(** None means punning is hit + {[ { x } ]} + otherwise it comes with a payload + {[ { x = exp }]} +*) + +let unrecognizedConfigRecord loc text = + Location.prerr_warning loc (Warnings.Bs_derive_warning text) + +let ident_or_record_as_config loc (x : t) : + (string Location.loc * Parsetree.expression option) list = + match x with + | PStr + [ + { + pstr_desc = + Pstr_eval + ( {pexp_desc = Pexp_record (label_exprs, with_obj); pexp_loc = loc}, + _ ); + _; + }; + ] -> ( + match with_obj with + | None -> + Ext_list.map label_exprs (fun u -> + match u with + | ( {txt = Lident name; loc}, + {Parsetree.pexp_desc = Pexp_ident {txt = Lident name2}} ) + when name2 = name -> + ({Asttypes.txt = name; loc}, None) + | {txt = Lident name; loc}, y -> ({Asttypes.txt = name; loc}, Some y) + | _ -> Location.raise_errorf ~loc "Qualified label is not allowed") + | Some _ -> + unrecognizedConfigRecord loc "`with` is not supported, discarding"; + []) + | PStr + [ + { + pstr_desc = + Pstr_eval + ({pexp_desc = Pexp_ident {loc = lloc; txt = Lident txt}}, _); + }; + ] -> + [({Asttypes.txt; loc = lloc}, None)] + | PStr [] -> [] + | _ -> + unrecognizedConfigRecord loc "invalid attribute config-record, ignoring"; + [] + +let assert_strings loc (x : t) : string list = + let exception Not_str in + match x with + | PStr + [ + { + pstr_desc = Pstr_eval ({pexp_desc = Pexp_tuple strs; _}, _); + pstr_loc = loc; + _; + }; + ] -> ( + try + Ext_list.map strs (fun e -> + match (e : Parsetree.expression) with + | {pexp_desc = Pexp_constant (Pconst_string (name, _)); _} -> name + | _ -> raise Not_str) + with Not_str -> Location.raise_errorf ~loc "expect string tuple list") + | PStr + [ + { + pstr_desc = + Pstr_eval + ({pexp_desc = Pexp_constant (Pconst_string (name, _)); _}, _); + _; + }; + ] -> + [name] + | PStr [] -> [] + | PSig _ | PStr _ | PTyp _ | PPat _ -> + Location.raise_errorf ~loc "expect string tuple list" + +let assert_bool_lit (e : Parsetree.expression) = + match e.pexp_desc with + | Pexp_construct ({txt = Lident "true"}, None) -> true + | Pexp_construct ({txt = Lident "false"}, None) -> false + | _ -> + Location.raise_errorf ~loc:e.pexp_loc + "expect `true` or `false` in this field" + +let empty : t = Parsetree.PStr [] + +let table_dispatch table (action : action) = + match action with + | {txt = name; loc}, y -> ( + match Map_string.find_exn table name with + | fn -> fn y + | exception _ -> Location.raise_errorf ~loc "%s is not supported" name) diff --git a/analysis/vendor/ml/ast_payload.mli b/analysis/vendor/ml/ast_payload.mli new file mode 100644 index 000000000..addd8f911 --- /dev/null +++ b/analysis/vendor/ml/ast_payload.mli @@ -0,0 +1,92 @@ +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) + +(** A utility module used when destructuring parsetree attributes, used for + compiling FFI attributes and built-in ppx *) + +type t = Parsetree.payload + +type lid = string Asttypes.loc + +type label_expr = lid * Parsetree.expression + +type action = lid * Parsetree.expression option + +val is_single_string : t -> (string * string option) option + +val is_single_string_as_ast : t -> Parsetree.expression option + +val is_single_int : t -> int option + +val is_single_float : t -> string option + +val is_single_bool : t -> bool option + +val is_single_ident : t -> Longident.t option + +val raw_as_string_exp_exn : + kind:Js_raw_info.raw_kind -> + ?is_function:int option ref -> + t -> + Parsetree.expression option +(** Convert %raw into expression *) + +val as_core_type : Location.t -> t -> Parsetree.core_type + +(* val as_empty_structure : t -> bool *) +val as_ident : t -> Longident.t Asttypes.loc option + +(* val raw_string_payload : Location.t -> string -> t *) +val assert_strings : Location.t -> t -> string list + +(** as a record or empty + it will accept + + {[ [@@@bs.config ]]} + or + {[ [@@@bs.config no_export ] ]} + or + {[ [@@@bs.config { property .. } ]]} + Note that we only + {[ + { flat_property} + ]} + below is not allowed + {[ + {M.flat_property} + ]} +*) + +val ident_or_record_as_config : Location.t -> t -> action list + +val assert_bool_lit : Parsetree.expression -> bool + +val empty : t + +val table_dispatch : + (Parsetree.expression option -> 'a) Map_string.t -> action -> 'a + +val unrecognizedConfigRecord : Location.t -> string -> unit +(** Report to the user, as a warning, that the bs-attribute parser is bailing out. (This is to allow + external ppx, like ppx_deriving, to pick up where the builtin ppx leave off.) *) diff --git a/analysis/vendor/ml/ast_uncurried.ml b/analysis/vendor/ml/ast_uncurried.ml index 8b418ef28..1a49b2743 100644 --- a/analysis/vendor/ml/ast_uncurried.ml +++ b/analysis/vendor/ml/ast_uncurried.ml @@ -69,12 +69,7 @@ let coreTypeIsUncurriedFun (typ : Parsetree.core_type) = true | _ -> false -let typeIsUncurriedFun (typ : Types.type_expr) = - match typ.desc with - | Tconstr (Pident {name = "function$"}, [{desc = Tarrow _}; _], _) -> - true - | _ -> false - +let typeIsUncurriedFun = Ast_uncurried_utils.typeIsUncurriedFun let typeExtractUncurriedFun (typ : Parsetree.core_type) = match typ.ptyp_desc with diff --git a/analysis/vendor/ml/ast_uncurried_utils.ml b/analysis/vendor/ml/ast_uncurried_utils.ml new file mode 100644 index 000000000..ad18b01a6 --- /dev/null +++ b/analysis/vendor/ml/ast_uncurried_utils.ml @@ -0,0 +1,5 @@ +let typeIsUncurriedFun (typ : Types.type_expr) = + match typ.desc with + | Tconstr (Pident {name = "function$"}, [{desc = Tarrow _}; _], _) -> + true + | _ -> false \ No newline at end of file diff --git a/analysis/vendor/ml/ast_untagged_variants.ml b/analysis/vendor/ml/ast_untagged_variants.ml new file mode 100644 index 000000000..7f4e85532 --- /dev/null +++ b/analysis/vendor/ml/ast_untagged_variants.ml @@ -0,0 +1,463 @@ +module Instance = struct + type t = + | Array + | Blob + | Date + | File + | Promise + | RegExp + let to_string = function + Array -> "Array" + | Blob -> "Blob" + | Date -> "Date" + | File -> "File" + | Promise -> "Promise" + | RegExp -> "RegExp" +end + +type untaggedError = + | OnlyOneUnknown of string + | AtMostOneObject + | AtMostOneInstance of Instance.t + | AtMostOneFunction + | AtMostOneString + | AtMostOneNumber + | AtMostOneBoolean + | DuplicateLiteral of string + | ConstructorMoreThanOneArg of string +type error = + | InvalidVariantAsAnnotation + | Duplicated_bs_as + | InvalidVariantTagAnnotation + | InvalidUntaggedVariantDefinition of untaggedError +exception Error of Location.t * error + +let report_error ppf = + let open Format in + function + | InvalidVariantAsAnnotation -> + fprintf ppf + "A variant case annotation @as(...) must be a string or integer, \ + boolean, null, undefined" + | Duplicated_bs_as -> fprintf ppf "duplicate @as " + | InvalidVariantTagAnnotation -> + fprintf ppf "A variant tag annotation @tag(...) must be a string" + | InvalidUntaggedVariantDefinition untaggedVariant -> + fprintf ppf "This untagged variant definition is invalid: %s" + (match untaggedVariant with + | OnlyOneUnknown name -> "Case " ^ name ^ " has a payload that is not of one of the recognized shapes (object, array, etc). Then it must be the only case with payloads." + | AtMostOneObject -> "At most one case can be an object type." + | AtMostOneInstance i -> "At most one case can be a " ^ (Instance.to_string i) ^ " type." + | AtMostOneFunction -> "At most one case can be a function type." + | AtMostOneString -> "At most one case can be a string type." + | AtMostOneBoolean -> "At most one case can be a boolean type." + | AtMostOneNumber -> + "At most one case can be a number type (int or float)." + | DuplicateLiteral s -> "Duplicate literal " ^ s ^ "." + | ConstructorMoreThanOneArg (name) -> "Constructor " ^ name ^ " has more than one argument.") + +(* Type of the runtime representation of an untagged block (case with payoad) *) +type block_type = + | IntType + | StringType + | FloatType + | BooleanType + | InstanceType of Instance.t + | FunctionType + | ObjectType + | UnknownType + +(* + Type of the runtime representation of a tag. + Can be a literal (case with no payload), or a block (case with payload). + In the case of block it can be tagged or untagged. +*) +type tag_type = + | String of string + | Int of int + | Float of string + | Bool of bool + | Null + | Undefined (* literal or tagged block *) + | Untagged of block_type (* untagged block *) +type tag = {name: string; tag_type: tag_type option} +type block = {tag: tag; tag_name: string option; block_type: block_type option} +type switch_names = {consts: tag array; blocks: block array} + +let untagged = "unboxed" + +let has_untagged (attrs : Parsetree.attributes) = + Ext_list.exists attrs (function {txt}, _ -> txt = untagged) + +let process_untagged (attrs : Parsetree.attributes) = + let st = ref false in + Ext_list.iter attrs (fun ({txt}, _) -> + match txt with + | "unboxed" -> st := true + | _ -> ()); + !st + +let extract_concrete_typedecl: (Env.t -> + Types.type_expr -> + Path.t * Path.t * Types.type_declaration) ref = ref (Obj.magic ()) + +let expand_head: (Env.t -> Types.type_expr -> Types.type_expr) ref = ref (Obj.magic ()) + +let process_tag_type (attrs : Parsetree.attributes) = + let st : tag_type option ref = ref None in + Ext_list.iter attrs (fun ({txt; loc}, payload) -> + match txt with + | "bs.as" | "as" -> + if !st = None then ( + (match Ast_payload.is_single_string payload with + | None -> () + | Some (s, _dec) -> st := Some (String s)); + (match Ast_payload.is_single_int payload with + | None -> () + | Some i -> st := Some (Int i)); + (match Ast_payload.is_single_float payload with + | None -> () + | Some f -> st := Some (Float f)); + (match Ast_payload.is_single_bool payload with + | None -> () + | Some b -> st := Some (Bool b)); + (match Ast_payload.is_single_ident payload with + | None -> () + | Some (Lident "null") -> st := Some Null + | Some (Lident "undefined") -> st := Some Undefined + | Some _ -> raise (Error (loc, InvalidVariantAsAnnotation))); + if !st = None then raise (Error (loc, InvalidVariantAsAnnotation))) + else raise (Error (loc, Duplicated_bs_as)) + | _ -> ()); + !st + +let () = + Location.register_error_of_exn (function + | Error (loc, err) -> Some (Location.error_of_printer loc report_error err) + | _ -> None) + +let reportConstructorMoreThanOneArg ~loc ~name = + raise (Error (loc, InvalidUntaggedVariantDefinition (ConstructorMoreThanOneArg name))) + +let type_is_builtin_object (t : Types.type_expr) = + match t.desc with + | Tconstr (path, _, _) -> + let name = Path.name path in + name = "Js.Dict.t" || name = "Js_dict.t" + | _ -> false + +let type_to_instanceof_backed_obj (t : Types.type_expr) = + match t.desc with + | Tconstr (path, _, _) when Path.same path Predef.path_promise -> + Some Instance.Promise + | Tconstr (path, _, _) when Path.same path Predef.path_array -> + Some Array + | Tconstr (path, _, _) -> ( + match Path.name path with + | "Js_date.t" -> Some(Date) + | "Js_re.t" -> Some(RegExp) + | "Js_file.t" -> Some(File) + | "Js_blob.t" -> Some(Blob) + | _ -> None) + | _ -> None + +let get_block_type_from_typ ~env (t: Types.type_expr) : block_type option = + let t = !expand_head env t in + match t with + | {desc = Tconstr (path, _, _)} when Path.same path Predef.path_string -> + Some StringType + | {desc = Tconstr (path, _, _)} when Path.same path Predef.path_int -> + Some IntType + | {desc = Tconstr (path, _, _)} when Path.same path Predef.path_float -> + Some FloatType + | {desc = Tconstr (path, _, _)} when Path.same path Predef.path_bool -> + Some BooleanType + | ({desc = Tconstr _} as t) when Ast_uncurried_utils.typeIsUncurriedFun t -> + Some FunctionType + | {desc = Tarrow _} -> Some FunctionType + | {desc = Tconstr (path, _, _)} when Path.same path Predef.path_string -> + Some StringType + | ({desc = Tconstr _} as t) when type_is_builtin_object t -> + Some ObjectType + | ({desc = Tconstr _} as t) when type_to_instanceof_backed_obj t |> Option.is_some -> + (match type_to_instanceof_backed_obj t with + | None -> None + | Some instanceType -> Some (InstanceType instanceType)) + | _ -> None + +let get_block_type ~env (cstr : Types.constructor_declaration) : + block_type option = + match (process_untagged cstr.cd_attributes, cstr.cd_args) with + | false, _ -> None + | true, Cstr_tuple [{desc = Tconstr _} as t] when get_block_type_from_typ ~env t |> Option.is_some -> get_block_type_from_typ ~env t + | true, Cstr_tuple [ty] -> ( + let default = Some UnknownType in + match !extract_concrete_typedecl env ty with + | _, _, {type_kind = Type_record (_, Record_unboxed _)} -> default + | _, _, {type_kind = Type_record (_, _)} -> Some ObjectType + | _ -> default + | exception _ -> default) + | true, Cstr_tuple (_ :: _ :: _) -> + (* C(_, _) with at least 2 args is an object *) + Some ObjectType + | true, Cstr_record _ -> + (* inline record is an object *) + Some ObjectType + | true, _ -> None (* TODO: add restrictions here *) + +let process_tag_name (attrs : Parsetree.attributes) = + let st = ref None in + Ext_list.iter attrs (fun ({txt; loc}, payload) -> + match txt with + | "tag" -> + if !st = None then ( + (match Ast_payload.is_single_string payload with + | None -> () + | Some (s, _dec) -> st := Some s); + if !st = None then raise (Error (loc, InvalidVariantTagAnnotation))) + else raise (Error (loc, Duplicated_bs_as)) + | _ -> ()); + !st + +let get_tag_name (cstr : Types.constructor_declaration) = + process_tag_name cstr.cd_attributes + +let is_nullary_variant (x : Types.constructor_arguments) = + match x with + | Types.Cstr_tuple [] -> true + | _ -> false + +let checkInvariant ~isUntaggedDef ~(consts : (Location.t * tag) list) + ~(blocks : (Location.t * block) list) = + let module StringSet = Set.Make (String) in + let string_literals = ref StringSet.empty in + let nonstring_literals = ref StringSet.empty in + let instanceTypes = Hashtbl.create 1 in + let functionTypes = ref 0 in + let objectTypes = ref 0 in + let stringTypes = ref 0 in + let numberTypes = ref 0 in + let booleanTypes = ref 0 in + let unknownTypes = ref 0 in + let addStringLiteral ~loc s = + if StringSet.mem s !string_literals then + raise (Error (loc, InvalidUntaggedVariantDefinition (DuplicateLiteral s))); + string_literals := StringSet.add s !string_literals + in + let addNonstringLiteral ~loc s = + if StringSet.mem s !nonstring_literals then + raise (Error (loc, InvalidUntaggedVariantDefinition (DuplicateLiteral s))); + nonstring_literals := StringSet.add s !nonstring_literals + in + let invariant loc name = + if !unknownTypes <> 0 && List.length blocks <> 1 then + raise (Error (loc, InvalidUntaggedVariantDefinition (OnlyOneUnknown name))); + if !objectTypes > 1 then + raise (Error (loc, InvalidUntaggedVariantDefinition AtMostOneObject)); + Hashtbl.iter (fun i count -> + if count > 1 then + raise (Error (loc, InvalidUntaggedVariantDefinition (AtMostOneInstance i)))) + instanceTypes; + if !functionTypes > 1 then + raise (Error (loc, InvalidUntaggedVariantDefinition AtMostOneFunction)); + if !stringTypes > 1 then + raise (Error (loc, InvalidUntaggedVariantDefinition AtMostOneString)); + if !numberTypes > 1 then + raise (Error (loc, InvalidUntaggedVariantDefinition AtMostOneNumber)); + if !booleanTypes > 1 then + raise (Error (loc, InvalidUntaggedVariantDefinition AtMostOneBoolean)); + if !booleanTypes > 0 && (StringSet.mem "true" !nonstring_literals || StringSet.mem "false" !nonstring_literals) then + raise (Error (loc, InvalidUntaggedVariantDefinition AtMostOneBoolean)); + () + in + Ext_list.rev_iter consts (fun (loc, literal) -> + match literal.tag_type with + | Some (String s) -> addStringLiteral ~loc s + | Some (Int i) -> addNonstringLiteral ~loc (string_of_int i) + | Some (Float f) -> addNonstringLiteral ~loc f + | Some Null -> addNonstringLiteral ~loc "null" + | Some Undefined -> addNonstringLiteral ~loc "undefined" + | Some (Bool b) -> addNonstringLiteral ~loc (if b then "true" else "false") + | Some (Untagged _) -> () + | None -> addStringLiteral ~loc literal.name); + if isUntaggedDef then + Ext_list.rev_iter blocks (fun (loc, block) -> + match block.block_type with + | Some block_type -> + (match block_type with + | UnknownType -> incr unknownTypes; + | ObjectType -> incr objectTypes; + | (InstanceType i) -> + let count = Hashtbl.find_opt instanceTypes i |> Option.value ~default:0 in + Hashtbl.replace instanceTypes i (count + 1); + | FunctionType -> incr functionTypes; + | (IntType | FloatType) -> incr numberTypes; + | BooleanType -> incr booleanTypes; + | StringType -> incr stringTypes; + ); + invariant loc block.tag.name + | None -> () + ) + +let names_from_type_variant ?(isUntaggedDef = false) ~env + (cstrs : Types.constructor_declaration list) = + let get_cstr_name (cstr : Types.constructor_declaration) = + ( cstr.cd_loc, + { + name = Ident.name cstr.cd_id; + tag_type = process_tag_type cstr.cd_attributes; + } ) + in + let get_block (cstr : Types.constructor_declaration) : block = + let tag = snd (get_cstr_name cstr) in + {tag; tag_name = get_tag_name cstr; block_type = get_block_type ~env cstr} + in + let consts, blocks = + Ext_list.fold_left cstrs ([], []) (fun (consts, blocks) cstr -> + if is_nullary_variant cstr.cd_args then + (get_cstr_name cstr :: consts, blocks) + else (consts, (cstr.cd_loc, get_block cstr) :: blocks)) + in + checkInvariant ~isUntaggedDef ~consts ~blocks; + let blocks = blocks |> List.map snd in + let consts = consts |> List.map snd in + let consts = Ext_array.reverse_of_list consts in + let blocks = Ext_array.reverse_of_list blocks in + Some {consts; blocks} + +let check_well_formed ~env ~isUntaggedDef + (cstrs : Types.constructor_declaration list) = + ignore (names_from_type_variant ~env ~isUntaggedDef cstrs) + +let has_undefined_literal attrs = process_tag_type attrs = Some Undefined + +let block_is_object ~env attrs = get_block_type ~env attrs = Some ObjectType + +module DynamicChecks = struct + type op = EqEqEq | NotEqEq | Or | And + type 'a t = + | BinOp of op * 'a t * 'a t + | TagType of tag_type + | TypeOf of 'a t + | IsInstanceOf of Instance.t * 'a t + | Not of 'a t + | Expr of 'a + + let bin op x y = BinOp (op, x, y) + let tag_type t = TagType t + let typeof x = TypeOf x + let str s = String s |> tag_type + let is_instance i x = IsInstanceOf (i, x) + let not x = Not x + let nil = Null |> tag_type + let undefined = Undefined |> tag_type + let object_ = Untagged ObjectType |> tag_type + + let function_ = Untagged FunctionType |> tag_type + let string = Untagged StringType |> tag_type + let number = Untagged IntType |> tag_type + let boolean = Untagged BooleanType |> tag_type + + let ( == ) x y = bin EqEqEq x y + let ( != ) x y = bin NotEqEq x y + let ( ||| ) x y = bin Or x y + let ( &&& ) x y = bin And x y + + let rec is_a_literal_case ~(literal_cases : tag_type list) ~block_cases + (e : _ t) = + let literals_overlaps_with_string () = + Ext_list.exists literal_cases (function + | String _ -> true + | _ -> false) + in + let literals_overlaps_with_number () = + Ext_list.exists literal_cases (function + | Int _ | Float _ -> true + | _ -> false) + in + let literals_overlaps_with_boolean () = + Ext_list.exists literal_cases (function + | Bool _ -> true + | _ -> false) + in + let literals_overlaps_with_object () = + Ext_list.exists literal_cases (function + | Null -> true + | _ -> false) + in + let is_literal_case (t : tag_type) : _ t = e == tag_type t in + let is_not_block_case (c : block_type) : _ t = + match c with + | StringType + when literals_overlaps_with_string () = false (* No overlap *) -> + typeof e != string + | IntType when literals_overlaps_with_number () = false -> + typeof e != number + | FloatType when literals_overlaps_with_number () = false -> + typeof e != number + | BooleanType when literals_overlaps_with_boolean () = false -> + typeof e != boolean + | InstanceType i -> not (is_instance i e) + | FunctionType -> typeof e != function_ + | ObjectType when literals_overlaps_with_object () = false -> + typeof e != object_ + | ObjectType (* overlap *) -> e == nil ||| (typeof e != object_) + | StringType (* overlap *) + | IntType (* overlap *) + | FloatType (* overlap *) + | BooleanType (* overlap *) + | UnknownType -> ( + (* We don't know the type of unknown, so we need to express: + this is not one of the literals *) + match literal_cases with + | [] -> + (* this should not happen *) + assert false + | l1 :: others -> + let is_literal_1 = is_literal_case l1 in + Ext_list.fold_right others is_literal_1 (fun literal_n acc -> + is_literal_case literal_n ||| acc)) + in + match block_cases with + | [c] -> is_not_block_case c + | c1 :: (_ :: _ as rest) -> + is_not_block_case c1 + &&& is_a_literal_case ~literal_cases ~block_cases:rest e + | [] -> assert false + + let is_int_tag ?(has_null_undefined_other = (false, false, false)) (e : _ t) : + _ t = + let has_null, has_undefined, has_other = has_null_undefined_other in + if has_null && has_undefined = false && has_other = false then + (* null *) + bin EqEqEq e nil + else if has_null && has_undefined && has_other = false then + (* null + undefined *) + e == nil ||| e == undefined + else if has_null = false && has_undefined && has_other = false then + (* undefined *) + e == undefined + else if has_null then + (* (null + undefined + other) || (null + other) *) + e == nil ||| typeof e != object_ + else (* (undefiled + other) || other *) + typeof e != object_ + + let add_runtime_type_check ~tag_type ~(block_cases : block_type list) x y = + let instances = Ext_list.filter_map block_cases (function InstanceType i -> Some i | _ -> None) in + match tag_type with + | Untagged (IntType | StringType | FloatType | BooleanType | FunctionType) -> + typeof y == x + | Untagged ObjectType -> + if instances <> [] then + let not_one_of_the_instances = + Ext_list.fold_right instances (typeof y == x) (fun i x -> x &&& not (is_instance i y)) in + not_one_of_the_instances + else + typeof y == x + | Untagged (InstanceType i) -> is_instance i y + | Untagged UnknownType -> + (* This should not happen because unknown must be the only non-literal case *) + assert false + | Bool _ | Float _ | Int _ | String _ | Null | Undefined -> x +end diff --git a/analysis/vendor/ml/bs_flow_ast_utils.ml b/analysis/vendor/ml/bs_flow_ast_utils.ml new file mode 100644 index 000000000..d151ebe91 --- /dev/null +++ b/analysis/vendor/ml/bs_flow_ast_utils.ml @@ -0,0 +1,49 @@ +(* Copyright (C) 2020 - Hongbo Zhang, Authors of ReScript + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) + +let offset_pos ({pos_lnum; pos_bol; pos_cnum} as loc : Lexing.position) + ({line; column} : Loc.position) first_line_offset : Lexing.position = + if line = 1 then {loc with pos_cnum = pos_cnum + column + first_line_offset} + else {loc with pos_lnum = pos_lnum + line - 1; pos_cnum = pos_bol + column} + +let flow_deli_offset deli = + match deli with + | None -> 1 (* length of '"'*) + | Some deli -> String.length deli + 2 +(* length of "{|"*) + +(* Here the loc is the payload loc *) +let check_flow_errors ~(loc : Location.t) ~offset + (errors : (Loc.t * Parse_error.t) list) : unit = + match errors with + | [] -> () + | ({start; _end}, first_error) :: _ -> + let loc_start = loc.loc_start in + Location.prerr_warning + { + loc with + loc_start = offset_pos loc_start start offset; + loc_end = offset_pos loc_start _end offset; + } + (Bs_ffi_warning (Parse_error.PP.error first_error)) diff --git a/analysis/vendor/ml/bs_flow_ast_utils.mli b/analysis/vendor/ml/bs_flow_ast_utils.mli new file mode 100644 index 000000000..8f1dc009b --- /dev/null +++ b/analysis/vendor/ml/bs_flow_ast_utils.mli @@ -0,0 +1,28 @@ +(* Copyright (C) 2020 - Authors of ReScript + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) + +val flow_deli_offset : string option -> int + +val check_flow_errors : + loc:Location.t -> offset:int -> (Loc.t * Parse_error.t) list -> unit diff --git a/analysis/vendor/ml/builtin_attributes.ml b/analysis/vendor/ml/builtin_attributes.ml index 391aa890b..f53edbf90 100755 --- a/analysis/vendor/ml/builtin_attributes.ml +++ b/analysis/vendor/ml/builtin_attributes.ml @@ -61,9 +61,8 @@ let rec error_of_extension ext = let cat s1 s2 = if s2 = "" then s1 else - if Clflags.bs_vscode then s1 ^ " " ^ s2 (* 2 spaces indentation for the next line *) - else s1 ^ "\n " ^ s2 + s1 ^ "\n " ^ s2 let rec deprecated_of_attrs = function | [] -> None diff --git a/analysis/vendor/ml/classify_function.ml b/analysis/vendor/ml/classify_function.ml new file mode 100644 index 000000000..5565b230b --- /dev/null +++ b/analysis/vendor/ml/classify_function.ml @@ -0,0 +1,103 @@ +(* Copyright (C) 2020- Hongbo Zhang, Authors of ReScript + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) + +let rec is_obj_literal (x : _ Flow_ast.Expression.t) : bool = + match snd x with + | Identifier (_, {name = "undefined"}) | Literal _ -> true + | Unary {operator = Minus; argument} -> is_obj_literal argument + | Object {properties} -> Ext_list.for_all properties is_literal_kv + | Array {elements} -> + Ext_list.for_all elements (fun x -> + match x with + | Expression x -> is_obj_literal x + | _ -> false) + | _ -> false + +and is_literal_kv (x : _ Flow_ast.Expression.Object.property) = + match x with + | Property (_, Init {value}) -> is_obj_literal value + | _ -> false + +let classify_exp (prog : _ Flow_ast.Expression.t) : Js_raw_info.exp = + match prog with + | ( _, + Function + { + id = _; + params = _, {params}; + async = false; + generator = false; + predicate = None; + } ) -> + Js_function {arity = List.length params; arrow = false} + | ( _, + ArrowFunction + { + id = None; + params = _, {params}; + async = false; + generator = false; + predicate = None; + } ) -> + Js_function {arity = List.length params; arrow = true} + | _, Literal {comments} -> + let comment = + match comments with + | None -> None + | Some {leading = [(_, {kind = Block; text = comment})]} -> + Some ("/*" ^ comment ^ "*/") + | Some {leading = [(_, {kind = Line; text = comment})]} -> + Some ("//" ^ comment) + | Some _ -> None + in + Js_literal {comment} + | _, Identifier (_, {name = "undefined"}) -> Js_literal {comment = None} + | _, _ -> + if is_obj_literal prog then Js_literal {comment = None} else Js_exp_unknown + | exception _ -> Js_exp_unknown + +(** It seems we do the parse twice + - in parsing + - in code generation +*) +let classify ?(check : (Location.t * int) option) (prog : string) : + Js_raw_info.exp = + let prog, errors = + Parser_flow.parse_expression (Parser_env.init_env None prog) false + in + match (check, errors) with + | Some (loc, offset), _ :: _ -> + Bs_flow_ast_utils.check_flow_errors ~loc ~offset errors; + Js_exp_unknown + | Some _, [] | None, [] -> classify_exp prog + | None, _ :: _ -> Js_exp_unknown + +let classify_stmt (prog : string) : Js_raw_info.stmt = + let result = Parser_flow.parse_program false None prog in + match fst result with + | _loc, {statements = []} -> Js_stmt_comment + | _ -> Js_stmt_unknown +(* we can also analayze throw + x.x pure access +*) diff --git a/analysis/vendor/ml/classify_function.mli b/analysis/vendor/ml/classify_function.mli new file mode 100644 index 000000000..38b154851 --- /dev/null +++ b/analysis/vendor/ml/classify_function.mli @@ -0,0 +1,29 @@ +(* Copyright (C) 2020- Authors of ReScript + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) + +val classify : ?check:Location.t * int -> string -> Js_raw_info.exp + +val classify_exp : (Loc.t, Loc.t) Flow_ast.Expression.t -> Js_raw_info.exp + +val classify_stmt : string -> Js_raw_info.stmt diff --git a/analysis/vendor/ml/clflags.ml b/analysis/vendor/ml/clflags.ml index e4bcd4d23..b2b2a78db 100644 --- a/analysis/vendor/ml/clflags.ml +++ b/analysis/vendor/ml/clflags.ml @@ -25,7 +25,8 @@ let dump_parsetree = ref false (* -dparsetree *) and dump_typedtree = ref false (* -dtypedtree *) and dump_rawlambda = ref false (* -drawlambda *) and dump_lambda = ref false (* -dlambda *) -and only_parse = ref false (* -only-parse *) +and only_parse = ref false (* -only-parse *) +and ignore_parse_errors = ref false (* -ignore-parse-errors *) let dont_write_files = ref false (* set to true under ocamldoc *) @@ -60,11 +61,6 @@ let unboxed_types = ref false type mli_status = Mli_exists | Mli_non_exists let assume_no_mli = ref Mli_non_exists -let bs_vscode = - try ignore @@ Sys.getenv "BS_VSCODE" ; true with _ -> false - (* We get it from environment variable mostly due to - we don't want to rebuild when flip on or off - *) let dont_record_crc_unit : string option ref = ref None let bs_gentype = ref false let no_assert_false = ref false diff --git a/analysis/vendor/ml/clflags.mli b/analysis/vendor/ml/clflags.mli index 9cee27d4e..80b170422 100644 --- a/analysis/vendor/ml/clflags.mli +++ b/analysis/vendor/ml/clflags.mli @@ -25,6 +25,7 @@ val dont_write_files : bool ref val keep_docs : bool ref val keep_locs : bool ref val only_parse : bool ref +val ignore_parse_errors: bool ref val parse_color_setting : string -> Misc.Color.setting option @@ -37,7 +38,6 @@ val reset_dump_state: unit -> unit type mli_status = Mli_exists | Mli_non_exists val assume_no_mli : mli_status ref -val bs_vscode : bool val dont_record_crc_unit : string option ref val bs_gentype : bool ref val no_assert_false : bool ref diff --git a/analysis/vendor/ml/cmt_format.ml b/analysis/vendor/ml/cmt_format.ml index 815c693ed..b3a6b6683 100644 --- a/analysis/vendor/ml/cmt_format.ml +++ b/analysis/vendor/ml/cmt_format.ml @@ -13,7 +13,10 @@ (* *) (**************************************************************************) -open Cmi_format +#ifdef BROWSER +[@@@warning "-32"] +#endif + open Typedtree (* Note that in Typerex, there is an awful hack to save a cmt file @@ -164,10 +167,12 @@ let record_value_dependency vd1 vd2 = if vd1.Types.val_loc <> vd2.Types.val_loc then value_deps := (vd1, vd2) :: !value_deps -let save_cmt filename modname binary_annots sourcefile initial_env cmi = #ifdef BROWSER - () -#else +let save_cmt _filename _modname _binary_annots _sourcefile _initial_env _cmi = () +#else +open Cmi_format + +let save_cmt filename modname binary_annots sourcefile initial_env cmi = if !Clflags.binary_annotations then begin (if !Config.bs_only then Misc.output_to_bin_file_directly else Misc.output_to_file_via_temporary diff --git a/analysis/vendor/ml/ctype.ml b/analysis/vendor/ml/ctype.ml index 62745e025..89143f44b 100644 --- a/analysis/vendor/ml/ctype.ml +++ b/analysis/vendor/ml/ctype.ml @@ -65,7 +65,7 @@ let () = Some Location. (errorf ~loc:(in_file !input_name) - "In this program,@ variant constructors@ `%s and `%s@ \ + "In this program,@ variant constructors@ #%s and #%s@ \ have the same hash value.@ Change one of them." l l' ) | _ -> None @@ -3951,29 +3951,72 @@ let rec subtype_rec env trace t1 t2 cstrs = end | (Tconstr(p1, _, _), _) when generic_private_abbrev env p1 -> subtype_rec env trace (expand_abbrev_opt env t1) t2 cstrs - | (Tconstr(_, [], _), Tconstr(_, [], _)) -> (* type coercion for records *) + | (Tconstr(_, [], _), Tconstr(path, [], _)) when Variant_coercion.can_coerce_path path && + extract_concrete_typedecl env t1 |> Variant_coercion.can_try_coerce_variant_to_primitive |> Option.is_some + -> + (* type coercion for variants to primitives *) + (match Variant_coercion.can_try_coerce_variant_to_primitive (extract_concrete_typedecl env t1) with + | Some constructors -> + if constructors |> Variant_coercion.can_coerce_variant ~path then + cstrs + else + (trace, t1, t2, !univar_pairs)::cstrs + | None -> (trace, t1, t2, !univar_pairs)::cstrs) + | (Tconstr(_, [], _), Tconstr(_, [], _)) -> (* type coercion for variants and records *) (match extract_concrete_typedecl env t1, extract_concrete_typedecl env t2 with + | (_, _, {type_kind=Type_variant (c1); type_attributes=t1attrs}), (_, _, {type_kind=Type_variant (c2); type_attributes=t2attrs}) -> + if + Variant_coercion.variant_configuration_can_be_coerced t1attrs t2attrs = false + then + (trace, t1, t2, !univar_pairs)::cstrs + else + let c1_len = List.length c1 in + if c1_len > List.length c2 then (trace, t1, t2, !univar_pairs)::cstrs + else + let constructor_map = Hashtbl.create c1_len in + c2 + |> List.iter (fun (c : Types.constructor_declaration) -> + Hashtbl.add constructor_map (Ident.name c.cd_id) c); + if c1 |> List.for_all (fun (c : Types.constructor_declaration) -> + match (c, Hashtbl.find_opt constructor_map (Ident.name c.cd_id)) with + | ( {Types.cd_args = Cstr_record fields1; cd_attributes=c1_attributes}, + Some {Types.cd_args = Cstr_record fields2; cd_attributes=c2_attributes} ) -> + if Variant_coercion.variant_representation_matches c1_attributes c2_attributes then + let violation, tl1, tl2 = Record_coercion.check_record_fields fields1 fields2 in + if violation then false + else + begin try + let lst = subtype_list env trace tl1 tl2 cstrs in + List.length lst = List.length cstrs + with | _ -> false end + else false + | ( {Types.cd_args = Cstr_tuple tl1; cd_attributes=c1_attributes}, + Some {Types.cd_args = Cstr_tuple tl2; cd_attributes=c2_attributes} ) -> + if Variant_coercion.variant_representation_matches c1_attributes c2_attributes then + begin try + let lst = subtype_list env trace tl1 tl2 cstrs in + List.length lst = List.length cstrs + with | _ -> false end + else false + | _ -> false) + then cstrs + else (trace, t1, t2, !univar_pairs)::cstrs | (_, _, {type_kind=Type_record (fields1, repr1)}), (_, _, {type_kind=Type_record (fields2, repr2)}) -> - let field_is_optional id repr = match repr with - | Record_optional_labels lbls -> List.mem (Ident.name id) lbls + let same_repr = match repr1, repr2 with + | (Record_regular | Record_optional_labels _), (Record_regular | Record_optional_labels _) -> + true (* handled in the fields checks *) + | Record_unboxed b1, Record_unboxed b2 -> b1 = b2 + | Record_inlined _, Record_inlined _ -> repr1 = repr2 + | Record_extension, Record_extension -> true | _ -> false in - let violation = ref false in - let label_decl_sub (acc1, acc2) ld2 = - match fields1 |> List.find_opt (fun ld1 -> Ident.name ld1.ld_id = Ident.name ld2.ld_id) with - | Some ld1 -> - if field_is_optional ld1.ld_id repr1 && not (field_is_optional ld2.ld_id repr2) then - (* optional field can't be cast to non-optional one *) - violation := true; - ld1.ld_type :: acc1, ld2.ld_type :: acc2 - | None -> - (* field must be present *) - violation := true; - (acc1, acc2) in - let tl1, tl2 = List.fold_left label_decl_sub ([], []) fields2 in - if !violation - then (trace, t1, t2, !univar_pairs)::cstrs + if same_repr then + let violation, tl1, tl2 = Record_coercion.check_record_fields ~repr1 ~repr2 fields1 fields2 in + if violation + then (trace, t1, t2, !univar_pairs)::cstrs + else + subtype_list env trace tl1 tl2 cstrs else - subtype_list env trace tl1 tl2 cstrs + (trace, t1, t2, !univar_pairs)::cstrs | _ -> (trace, t1, t2, !univar_pairs)::cstrs | exception Not_found -> (trace, t1, t2, !univar_pairs)::cstrs ) diff --git a/analysis/vendor/ml/datarepr.ml b/analysis/vendor/ml/datarepr.ml index 105462df0..8412621f5 100644 --- a/analysis/vendor/ml/datarepr.ml +++ b/analysis/vendor/ml/datarepr.ml @@ -142,7 +142,7 @@ let constructor_descrs ty_path decl cstrs = let representation = if decl.type_unboxed.unboxed then Record_unboxed true - else Record_inlined {tag = idx_nonconst; name = cstr_name; num_nonconsts = !num_nonconsts; optional_labels} + else Record_inlined {tag = idx_nonconst; name = cstr_name; num_nonconsts = !num_nonconsts; optional_labels; attrs = cd_attributes} in constructor_args decl.type_private cd_args cd_res (Path.Pdot (ty_path, cstr_name, Path.nopos)) representation diff --git a/analysis/vendor/ml/dune b/analysis/vendor/ml/dune index 2d5cb2106..c7b015ae7 100644 --- a/analysis/vendor/ml/dune +++ b/analysis/vendor/ml/dune @@ -6,6 +6,6 @@ (run %{bin:cppo} %{env:CPPO_FLAGS=} %{input-file}))) (flags (:standard -w +a-4-42-40-41-44-45-9-48-67-70)) - (libraries ext)) + (libraries ext js_parser)) (ocamllex lexer) diff --git a/analysis/vendor/ml/env.ml b/analysis/vendor/ml/env.ml index 99119bc1a..8a914c825 100644 --- a/analysis/vendor/ml/env.ml +++ b/analysis/vendor/ml/env.ml @@ -2276,32 +2276,42 @@ let env_of_only_summary env_from_summary env = open Format +(* taken from https://github.com/rescript-lang/ocaml/blob/d4144647d1bf9bc7dc3aadc24c25a7efa3a67915/typing/env.ml#L1842 *) +(* modified branches are commented *) let report_error ppf = function - | Illegal_renaming(modname, ps_name, filename) -> fprintf ppf - "Wrong file naming: %a@ contains the compiled interface for @ \ - %s when %s was expected" - Location.print_filename filename ps_name modname - | Inconsistent_import(name, source1, source2) -> fprintf ppf + | Illegal_renaming(name, modname, _filename) -> + (* modified *) + fprintf ppf + "@[You referred to the module %s, but we've found one called %s instead.@ \ + Is the name's casing right?@]" + name modname + | Inconsistent_import(name, source1, source2) -> + (* modified *) + fprintf ppf "@[\ + @[@{It's possible that your build is stale.@}@ Try to clean the artifacts and build again?@]@,@,\ + @[@{Here's the original error message@}@]@,\ + @]"; + fprintf ppf "@[The files %a@ and %a@ \ - make inconsistent assumptions@ over interface %s@]" + make inconsistent assumptions@ over interface %s@]" Location.print_filename source1 Location.print_filename source2 name | Need_recursive_types(import, export) -> - fprintf ppf - "@[Unit %s imports from %s, which uses recursive types.@ %s@]" - export import "The compilation flag -rectypes is required" + fprintf ppf + "@[Unit %s imports from %s, which uses recursive types.@ %s@]" + export import "The compilation flag -rectypes is required" | Missing_module(_, path1, path2) -> - fprintf ppf "@[@["; - if Path.same path1 path2 then - fprintf ppf "Internal path@ %s@ is dangling." (Path.name path1) - else - fprintf ppf "Internal path@ %s@ expands to@ %s@ which is dangling." - (Path.name path1) (Path.name path2); - fprintf ppf "@]@ @[%s@ %s@ %s.@]@]" - "The compiled interface for module" (Ident.name (Path.head path2)) - "was not found" + fprintf ppf "@[@["; + if Path.same path1 path2 then + fprintf ppf "Internal path@ %s@ is dangling." (Path.name path1) + else + fprintf ppf "Internal path@ %s@ expands to@ %s@ which is dangling." + (Path.name path1) (Path.name path2); + fprintf ppf "@]@ @[%s@ %s@ %s.@]@]" + "The compiled interface for module" (Ident.name (Path.head path2)) + "was not found" | Illegal_value_name(_loc, name) -> - fprintf ppf "'%s' is not a valid value identifier." - name + fprintf ppf "'%s' is not a valid value identifier." + name let () = Location.register_error_of_exn diff --git a/analysis/vendor/ml/error_message_utils.ml b/analysis/vendor/ml/error_message_utils.ml new file mode 100644 index 000000000..f0b47ecd5 --- /dev/null +++ b/analysis/vendor/ml/error_message_utils.ml @@ -0,0 +1,214 @@ +type typeClashStatement = FunctionCall +type typeClashContext = + | SetRecordField + | ArrayValue + | FunctionReturn + | MaybeUnwrapOption + | IfCondition + | IfReturn + | Switch + | StringConcat + | ComparisonOperator + | MathOperator of { + forFloat: bool; + operator: string; + isConstant: string option; + } + | FunctionArgument + | Statement of typeClashStatement + +let fprintf = Format.fprintf + +let errorTypeText ppf typeClashContext = + let text = + match typeClashContext with + | Some (Statement FunctionCall) -> "This function call returns:" + | Some (MathOperator {isConstant = Some _}) -> "This value has type:" + | Some ArrayValue -> "This array item has type:" + | Some SetRecordField -> + "You're assigning something to this field that has type:" + | _ -> "This has type:" + in + fprintf ppf "%s" text + +let errorExpectedTypeText ppf typeClashContext = + match typeClashContext with + | Some FunctionArgument -> + fprintf ppf "But this function argument is expecting:" + | Some ComparisonOperator -> + fprintf ppf "But it's being compared to something of type:" + | Some Switch -> fprintf ppf "But this switch is expected to return:" + | Some IfCondition -> + fprintf ppf "But @{if@} conditions must always be of type:" + | Some IfReturn -> + fprintf ppf "But this @{if@} statement is expected to return:" + | Some ArrayValue -> + fprintf ppf "But this array is expected to have items of type:" + | Some SetRecordField -> fprintf ppf "But this record field is of type:" + | Some (Statement FunctionCall) -> fprintf ppf "But it's expected to return:" + | Some (MathOperator {operator}) -> + fprintf ppf + "But it's being used with the @{%s@} operator, which works on:" + operator + | Some FunctionReturn -> + fprintf ppf "But this function is expecting you to return:" + | _ -> fprintf ppf "But it's expected to have type:" + +let printExtraTypeClashHelp ppf trace typeClashContext = + match (typeClashContext, trace) with + | Some (MathOperator {forFloat; operator; isConstant}), _ -> ( + let operatorForOtherType = + match operator with + | "+" -> "+." + | "+." -> "+" + | "/" -> "/." + | "/." -> "/" + | "-" -> "-." + | "*" -> "*." + | "*." -> "*" + | v -> v + in + let operatorText = + match operator.[0] with + | '+' -> "add" + | '-' -> "subtract" + | '/' -> "divide" + | '*' -> "multiply" + | _ -> "compute" + in + (* TODO check int vs float explicitly before showing this *) + (match (operator, trace) with + | ( "+", + [ + ({Types.desc = Tconstr (p1, _, _)}, _); + ({desc = Tconstr (p2, _, _)}, _); + ] ) + when Path.same Predef.path_string p1 || Path.same Predef.path_string p2 -> + fprintf ppf + "\n\n\ + \ Are you looking to concatenate strings? Use the operator \ + @{++@}, which concatenates strings.\n\n\ + \ Possible solutions:\n\ + \ - Change the @{+@} operator to @{++@} to concatenate \ + strings instead." + | _ -> + fprintf ppf + "\n\n\ + \ Floats and ints have their own mathematical operators. This means \ + you cannot %s a float and an int without converting between the two.\n\n\ + \ Possible solutions:\n\ + \ - Ensure all values in this calculation has the type @{%s@}. \ + You can convert between floats and ints via \ + @{Belt.Float.toInt@} and @{Belt.Int.fromFloat@}." + operatorText + (if forFloat then "float" else "int")); + match (isConstant, trace) with + | Some constant, _ -> + if forFloat then + fprintf ppf + "\n\ + \ - Make @{%s@} a @{float@} by adding a trailing dot: \ + @{%s.@}" + constant constant + else + fprintf ppf + "\n\ + \ - Make @{%s@} an @{int@} by removing the dot or \ + explicitly converting to int" + constant + | ( _, + [ + ({Types.desc = Tconstr (p1, _, _)}, _); + ({desc = Tconstr (p2, _, _)}, _); + ] ) -> ( + match (Path.name p1, Path.name p2) with + | "float", "int" | "int", "float" -> + fprintf ppf + "\n\ + \ - Change the operator to @{%s@}, which works on @{%s@}" + operatorForOtherType + (if forFloat then "int" else "float") + | _ -> ()) + | _ -> ()) + | Some Switch, _ -> + fprintf ppf + "\n\n\ + \ All branches in a @{switch@} must return the same type. To fix \ + this, change your branch to return the expected type." + | Some IfCondition, _ -> + fprintf ppf + "\n\n\ + \ To fix this, change the highlighted code so it evaluates to a \ + @{bool@}." + | Some IfReturn, _ -> + fprintf ppf + "\n\n\ + \ @{if@} expressions must return the same type in all branches \ + (@{if@}, @{else if@}, @{else@})." + | Some MaybeUnwrapOption, _ -> + fprintf ppf + "\n\n\ + \ Possible solutions:\n\ + \ - Unwrap the option to its underlying value using \ + `yourValue->Belt.Option.getWithDefault(someDefaultValue)`" + | Some ComparisonOperator, _ -> + fprintf ppf "\n\n You can only compare things of the same type." + | Some ArrayValue, _ -> + fprintf ppf + "\n\n\ + \ Arrays can only contain items of the same type.\n\n\ + \ Possible solutions:\n\ + \ - Convert all values in the array to the same type.\n\ + \ - Use a tuple, if your array is of fixed length. Tuples can mix types \ + freely, and compiles to a JavaScript array. Example of a tuple: `let \ + myTuple = (10, \"hello\", 15.5, true)" + | _ -> () + +let typeClashContextFromFunction sexp sfunct = + let isConstant = + match sexp.Parsetree.pexp_desc with + | Pexp_constant (Pconst_integer (txt, _) | Pconst_float (txt, _)) -> + Some txt + | _ -> None + in + match sfunct.Parsetree.pexp_desc with + | Pexp_ident + {txt = Lident ("=" | "==" | "<>" | "!=" | ">" | ">=" | "<" | "<=")} -> + Some ComparisonOperator + | Pexp_ident {txt = Lident "++"} -> Some StringConcat + | Pexp_ident {txt = Lident (("/." | "*." | "+." | "-.") as operator)} -> + Some (MathOperator {forFloat = true; operator; isConstant}) + | Pexp_ident {txt = Lident (("/" | "*" | "+" | "-") as operator)} -> + Some (MathOperator {forFloat = false; operator; isConstant}) + | _ -> Some FunctionArgument + +let typeClashContextForFunctionArgument typeClashContext sarg0 = + match typeClashContext with + | Some (MathOperator {forFloat; operator}) -> + Some + (MathOperator + { + forFloat; + operator; + isConstant = + (match sarg0.Parsetree.pexp_desc with + | Pexp_constant (Pconst_integer (txt, _) | Pconst_float (txt, _)) + -> + Some txt + | _ -> None); + }) + | typeClashContext -> typeClashContext + +let typeClashContextMaybeOption ty_expected ty_res = + match (ty_expected, ty_res) with + | ( {Types.desc = Tconstr (expectedPath, _, _)}, + {Types.desc = Tconstr (typePath, _, _)} ) + when Path.same Predef.path_option typePath + && Path.same expectedPath Predef.path_option = false -> + Some MaybeUnwrapOption + | _ -> None + +let typeClashContextInStatement sexp = + match sexp.Parsetree.pexp_desc with + | Pexp_apply _ -> Some (Statement FunctionCall) + | _ -> None diff --git a/analysis/vendor/ml/includecore.ml b/analysis/vendor/ml/includecore.ml index 8bf9770c9..2b8039f46 100644 --- a/analysis/vendor/ml/includecore.ml +++ b/analysis/vendor/ml/includecore.ml @@ -236,39 +236,53 @@ and compare_variants ~loc env params1 params2 n else compare_variants ~loc env params1 params2 (n+1) rem1 rem2 end - -and compare_records ~loc env params1 params2 n - (labels1 : Types.label_declaration list) - (labels2 : Types.label_declaration list) = - match labels1, labels2 with - [], [] -> [] - | [], l::_ -> [Field_missing (true, l.Types.ld_id)] - | l::_, [] -> [Field_missing (false, l.Types.ld_id)] - | ld1::rem1, ld2::rem2 -> - if Ident.name ld1.ld_id <> Ident.name ld2.ld_id - then [Field_names (n, ld1.ld_id.name, ld2.ld_id.name)] - else if ld1.ld_mutable <> ld2.ld_mutable then [Field_mutable ld1.ld_id] else begin - Builtin_attributes.check_deprecated_mutable_inclusion - ~def:ld1.ld_loc - ~use:ld2.ld_loc - loc - ld1.ld_attributes ld2.ld_attributes - (Ident.name ld1.ld_id); - let field_mismatch = !Builtin_attributes.check_bs_attributes_inclusion - ld1.ld_attributes ld2.ld_attributes - (Ident.name ld1.ld_id) in - match field_mismatch with - | Some (a,b) -> [Field_names (n,a,b)] - | None -> - if Ctype.equal env true (ld1.ld_type::params1)(ld2.ld_type::params2) - then (* add arguments to the parameters, cf. PR#7378 *) - compare_records ~loc env - (ld1.ld_type::params1) (ld2.ld_type::params2) - (n+1) - rem1 rem2 +and compare_records ~loc env params1_ params2_ n_ + (labels1_ : Types.label_declaration list) + (labels2_ : Types.label_declaration list) = + (* First try a fast path that checks if all the fields at once are consistent. + When that fails, try a slow path that blames the first inconsistent field *) + let rec aux ~fast params1 params2 n labels1 labels2 = + match labels1, labels2 with + [], [] -> + if fast then + if Ctype.equal env true params1 params2 then + [] + else + aux ~fast:false params1_ params2_ n_ labels1_ labels2_ else - [Field_type ld1.ld_id] - end + [] + | [], l::_ -> [Field_missing (true, l.Types.ld_id)] + | l::_, [] -> [Field_missing (false, l.Types.ld_id)] + | ld1::rem1, ld2::rem2 -> + if Ident.name ld1.ld_id <> Ident.name ld2.ld_id + then [Field_names (n, ld1.ld_id.name, ld2.ld_id.name)] + else if ld1.ld_mutable <> ld2.ld_mutable then [Field_mutable ld1.ld_id] else begin + Builtin_attributes.check_deprecated_mutable_inclusion + ~def:ld1.ld_loc + ~use:ld2.ld_loc + loc + ld1.ld_attributes ld2.ld_attributes + (Ident.name ld1.ld_id); + let field_mismatch = !Builtin_attributes.check_bs_attributes_inclusion + ld1.ld_attributes ld2.ld_attributes + (Ident.name ld1.ld_id) in + match field_mismatch with + | Some (a,b) -> [Field_names (n,a,b)] + | None -> + let current_field_consistent = + if fast then true + else Ctype.equal env true (ld1.ld_type::params1)(ld2.ld_type::params2) in + if current_field_consistent + then (* add arguments to the parameters, cf. PR#7378 *) + aux ~fast + (ld1.ld_type::params1) (ld2.ld_type::params2) + (n+1) + rem1 rem2 + else + [Field_type ld1.ld_id] + end in + aux ~fast:true params1_ params2_ n_ labels1_ labels2_ + let type_declarations ?(equality = false) ~loc env name decl1 id decl2 = Builtin_attributes.check_deprecated_inclusion @@ -324,8 +338,7 @@ let type_declarations ?(equality = false) ~loc env name decl1 id decl2 = if equality then mark cstrs2 Env.Positive (Ident.name id) decl2; compare_variants ~loc env decl1.type_params decl2.type_params 1 cstrs1 cstrs2 | (Type_record(labels1,rep1), Type_record(labels2,rep2)) -> - let err = compare_records ~loc env decl1.type_params decl2.type_params - 1 labels1 labels2 in + let err = compare_records ~loc env decl1.type_params decl2.type_params 1 labels1 labels2 in if err <> [] || rep1 = rep2 then err else [Record_representation (rep1, rep2)] | (Type_open, Type_open) -> [] diff --git a/analysis/vendor/ml/js_raw_info.ml b/analysis/vendor/ml/js_raw_info.ml new file mode 100644 index 000000000..a900a9663 --- /dev/null +++ b/analysis/vendor/ml/js_raw_info.ml @@ -0,0 +1,50 @@ +(* Copyright (C) 2020 Hongbo Zhang, Authors of ReScript + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) + +type exp = + | Js_function of {arity: int; arrow: bool} + | Js_literal of {comment: string option} + (* A special handling of + [%raw "/*lint*/ 0"] + *) + (* Flow ast module + {[ + and value = + | String of string + | Boolean of bool + | Null + | Number of float + | BigInt of float + | RegExp of RegExp.t + ]} + *) + | Js_exp_unknown + +type raw_kind = Raw_re | Raw_exp | Raw_program + +type stmt = Js_stmt_comment | Js_stmt_unknown + +type code_info = Exp of exp | Stmt of stmt + +type t = {code: string; code_info: code_info} diff --git a/analysis/vendor/ml/lambda.ml b/analysis/vendor/ml/lambda.ml index 9437253a6..037502950 100644 --- a/analysis/vendor/ml/lambda.ml +++ b/analysis/vendor/ml/lambda.ml @@ -38,9 +38,10 @@ type record_repr = | Record_regular | Record_optional + type tag_info = - | Blk_constructor of {name : string ; num_nonconst : int ; tag : int } - | Blk_record_inlined of { name : string ; num_nonconst : int; tag : int; optional_labels: string list; fields : string array; mutable_flag : Asttypes.mutable_flag } + | Blk_constructor of {name : string ; num_nonconst : int ; tag : int; attrs : Parsetree.attributes } + | Blk_record_inlined of { name : string ; num_nonconst : int; tag : int; optional_labels: string list; fields : string array; mutable_flag : Asttypes.mutable_flag; attrs : Parsetree.attributes } | Blk_tuple | Blk_poly_var of string | Blk_record of {fields : string array; mutable_flag : Asttypes.mutable_flag; record_repr : record_repr} @@ -96,9 +97,9 @@ let blk_record_ext = ref (fun fields mutable_flag -> Blk_record_ext {fields = all_labels_info; mutable_flag } ) -let blk_record_inlined = ref (fun fields name num_nonconst optional_labels ~tag mutable_flag -> +let blk_record_inlined = ref (fun fields name num_nonconst optional_labels ~tag ~attrs mutable_flag -> let fields = fields |> Array.map (fun (x,_) -> x.Types.lbl_name) in - Blk_record_inlined {fields; name; num_nonconst; tag; mutable_flag; optional_labels} + Blk_record_inlined {fields; name; num_nonconst; tag; mutable_flag; optional_labels; attrs } ) let ref_tag_info : tag_info = @@ -233,12 +234,11 @@ and raise_kind = | Raise_reraise | Raise_notrace -type pointer_info = - | Pt_constructor of {name : string; const : int ; non_const : int } - | Pt_variant of {name : string} - | Pt_module_alias - - | Pt_shape_none +type pointer_info = + | Pt_constructor of {name: string; const: int; non_const: int; attrs: Parsetree.attributes} + | Pt_variant of {name: string} + | Pt_module_alias + | Pt_shape_none | Pt_assertfalse @@ -270,8 +270,8 @@ type function_attribute = { stub: bool; return_unit : bool; async : bool; + oneUnitArg : bool; } -type switch_names = {consts: string array; blocks: string array} type lambda = Lvar of Ident.t @@ -299,7 +299,8 @@ and lfunction = params: Ident.t list; body: lambda; attr: function_attribute; (* specified with [@inline] attribute *) - loc: Location.t; } + loc: Location.t; + } and lambda_apply = { ap_func : lambda; @@ -314,7 +315,7 @@ and lambda_switch = sw_numblocks: int; sw_blocks: (int * lambda) list; sw_failaction : lambda option; - sw_names: switch_names option } + sw_names: Ast_untagged_variants.switch_names option } @@ -323,7 +324,9 @@ and lambda_switch = not necessary "()", it can be used as a place holder for module alias etc. *) -let const_unit = Const_pointer(0, Pt_constructor{name = "()"; const = 1; non_const = 0}) +let const_unit = + Const_pointer + (0, Pt_constructor {name = "()"; const = 1; non_const = 0; attrs = []}) let lambda_assert_false = Lconst (Const_pointer(0, Pt_assertfalse)) @@ -337,6 +340,7 @@ let default_function_attribute = { stub = false; return_unit = false; async = false; + oneUnitArg = false; } let default_stub_attribute = diff --git a/analysis/vendor/ml/lambda.mli b/analysis/vendor/ml/lambda.mli index 2be51ec90..af7b81e80 100644 --- a/analysis/vendor/ml/lambda.mli +++ b/analysis/vendor/ml/lambda.mli @@ -39,8 +39,8 @@ type record_repr = | Record_optional type tag_info = - | Blk_constructor of {name : string ; num_nonconst : int; tag : int} - | Blk_record_inlined of { name : string ; num_nonconst : int ; tag : int; optional_labels: string list; fields : string array; mutable_flag : mutable_flag } + | Blk_constructor of { name : string ; num_nonconst : int; tag : int; attrs : Parsetree.attributes } + | Blk_record_inlined of { name : string ; num_nonconst : int ; tag : int; optional_labels: string list; fields : string array; mutable_flag : mutable_flag; attrs : Parsetree.attributes } | Blk_tuple | Blk_poly_var of string | Blk_record of {fields : string array; mutable_flag : mutable_flag; record_repr : record_repr } @@ -86,7 +86,8 @@ val blk_record_inlined : string -> int -> string list -> - tag:int -> + tag:int -> + attrs:Parsetree.attributes -> mutable_flag -> tag_info ) ref @@ -134,15 +135,13 @@ type is_safe = | Safe | Unsafe -type pointer_info = - | Pt_constructor of {name : string; const : int ; non_const : int} - | Pt_variant of {name : string} - | Pt_module_alias - | Pt_shape_none +type pointer_info = + | Pt_constructor of {name: string; const: int; non_const: int; attrs: Parsetree.attributes} + | Pt_variant of {name: string} + | Pt_module_alias + | Pt_shape_none | Pt_assertfalse - - type primitive = | Pidentity | Pbytes_to_string @@ -272,10 +271,9 @@ type function_attribute = { stub: bool; return_unit : bool; async : bool; + oneUnitArg : bool; } -type switch_names = {consts: string array; blocks: string array} - type lambda = Lvar of Ident.t | Lconst of structured_constant @@ -319,7 +317,7 @@ and lambda_switch = sw_numblocks: int; (* Number of tag block cases *) sw_blocks: (int * lambda) list; (* Tag block cases *) sw_failaction : lambda option; (* Action to take if failure *) - sw_names: switch_names option } + sw_names: Ast_untagged_variants.switch_names option } diff --git a/analysis/vendor/ml/matching.ml b/analysis/vendor/ml/matching.ml index 4802a3dbf..575e11891 100644 --- a/analysis/vendor/ml/matching.ml +++ b/analysis/vendor/ml/matching.ml @@ -1329,8 +1329,9 @@ let make_constr_matching p def ctx = function [] -> fatal_error "Matching.make_constr_matching" | ((arg, _mut) :: argl) -> let cstr = pat_as_constr p in + let untagged = Ast_untagged_variants.has_untagged cstr.cstr_attributes in let newargs = - if cstr.cstr_inlined <> None then + if cstr.cstr_inlined <> None || (untagged && cstr.cstr_args <> []) then (arg, Alias) :: argl else match cstr.cstr_tag with | Cstr_block _ when @@ -1344,7 +1345,7 @@ let make_constr_matching p def ctx = function [ { pat_type ; pat_env } ]) - when Typeopt.cannot_inhabit_none_like_value pat_type pat_env + when Typeopt.type_cannot_contain_undefined pat_type pat_env -> val_from_unnest_option_bs_primitive | _ -> val_from_option_bs_primitive in (Lprim (from_option, [arg], p.pat_loc), Alias) :: argl @@ -2348,19 +2349,21 @@ let combine_constructor sw_names loc arg ex_pat cstr partial ctx def match (cstr.cstr_consts, cstr.cstr_nonconsts, consts, nonconsts) with - | (1, 1, [0, act1], [0, act2]) -> - (* Typically, match on lists, will avoid isint primitive in that - case *) + | (1, 1, [0, act1], [0, act2]) + when cstr.cstr_name = "::" || cstr.cstr_name = "[]" || Datarepr.constructor_has_optional_shape cstr + -> + (* Typically, match on lists, will avoid isint primitive in that + case *) let arg = if !Config.bs_only && Datarepr.constructor_has_optional_shape cstr then Lprim(is_not_none_bs_primitve , [arg], loc) else arg in Lifthenelse(arg, act2, act1) - | (2,0, [(i1,act1); (_,act2)],[]) -> - if i1 = 0 then Lifthenelse(arg, act2, act1) - else Lifthenelse (arg,act1,act2) - | (n,0,_,[]) -> (* The type defines constant constructors only *) + | (2,0, [(i1,act1); (_,act2)],[]) when cstr.cstr_name = "true" || cstr.cstr_name = "false" -> + if i1 = 0 then Lifthenelse(arg, act2, act1) + else Lifthenelse (arg, act1, act2) + | (n,0,_,[]) when false (* relies on tag being an int *) -> (* The type defines constant constructors only *) call_switcher loc fail_opt arg 0 (n-1) consts sw_names | (n, _, _, _) -> let act0 = @@ -2373,7 +2376,7 @@ let combine_constructor sw_names loc arg ex_pat cstr partial ctx def else None | None,_ -> same_actions nonconsts in match act0 with - | Some act -> + | Some act when false (* relies on tag being an int *) -> Lifthenelse (Lprim (Pisint, [arg], loc), call_switcher loc @@ -2381,7 +2384,7 @@ let combine_constructor sw_names loc arg ex_pat cstr partial ctx def 0 (n-1) consts sw_names, act) (* Emit a switch, as bytecode implements this sophisticated instruction *) - | None -> + | _ -> let sw = {sw_numconsts = cstr.cstr_consts; sw_consts = consts; sw_numblocks = cstr.cstr_nonconsts; sw_blocks = nonconsts; @@ -2413,7 +2416,7 @@ let call_switcher_variant_constant : Lambda.lambda option -> Lambda.lambda -> (int * (string * Lambda.lambda)) list -> - Lambda.switch_names option -> + Ast_untagged_variants.switch_names option -> Lambda.lambda) ref= ref call_switcher_variant_constant @@ -2422,7 +2425,7 @@ let call_switcher_variant_constr : Lambda.lambda option -> Lambda.lambda -> (int * (string * Lambda.lambda)) list -> - Lambda.switch_names option -> + Ast_untagged_variants.switch_names option -> Lambda.lambda) ref = ref call_switcher_variant_constr @@ -2691,7 +2694,7 @@ let arg_to_var arg cls = match arg with v,Lvar v (* To be set by Lam_compile *) -let names_from_construct_pattern : (pattern -> switch_names option) ref = +let names_from_construct_pattern : (pattern -> Ast_untagged_variants.switch_names option) ref = ref (fun _ -> None) (* diff --git a/analysis/vendor/ml/matching.mli b/analysis/vendor/ml/matching.mli index 136a4b565..16fda89bf 100644 --- a/analysis/vendor/ml/matching.mli +++ b/analysis/vendor/ml/matching.mli @@ -23,7 +23,7 @@ val call_switcher_variant_constant : Lambda.lambda option -> Lambda.lambda -> (int * (string * Lambda.lambda)) list -> - Lambda.switch_names option -> + Ast_untagged_variants.switch_names option -> Lambda.lambda) ref @@ -32,7 +32,7 @@ val call_switcher_variant_constr : Lambda.lambda option -> Lambda.lambda -> (int * (string * Lambda.lambda)) list -> - Lambda.switch_names option -> + Ast_untagged_variants.switch_names option -> Lambda.lambda) ref @@ -70,4 +70,4 @@ val expand_stringswitch: val inline_lazy_force : lambda -> Location.t -> lambda (* To be set by Lam_compile *) -val names_from_construct_pattern : (pattern -> switch_names option) ref +val names_from_construct_pattern : (pattern -> Ast_untagged_variants.switch_names option) ref diff --git a/analysis/vendor/ml/printtyp.ml b/analysis/vendor/ml/printtyp.ml index 74a5c694a..38fe28a7e 100644 --- a/analysis/vendor/ml/printtyp.ml +++ b/analysis/vendor/ml/printtyp.ml @@ -25,6 +25,8 @@ open Types open Btype open Outcometree +let print_res_poly_identifier: (string -> string) ref = ref (fun _ -> assert false) + (* Print a long identifier *) let rec longident ppf = function @@ -1413,8 +1415,8 @@ let may_prepare_expansion compact (t, t') = let print_tags ppf fields = match fields with [] -> () | (t, _) :: fields -> - fprintf ppf "`%s" t; - List.iter (fun (t, _) -> fprintf ppf ",@ `%s" t) fields + fprintf ppf "%s" (!print_res_poly_identifier t); + List.iter (fun (t, _) -> fprintf ppf ",@ %s" (!print_res_poly_identifier t)) fields let has_explanation t3 t4 = match t3.desc, t4.desc with @@ -1494,7 +1496,7 @@ let explanation unif t3 t4 ppf = "@,@[The second variant type does not allow tag(s)@ @[%a@]@]" print_tags fields | [l1,_], true, [l2,_], true when l1 = l2 -> - fprintf ppf "@,Types for tag `%s are incompatible" l1 + fprintf ppf "@,Types for tag %s are incompatible" (!print_res_poly_identifier l1) | _ -> () end | _ -> () diff --git a/analysis/vendor/ml/printtyp.mli b/analysis/vendor/ml/printtyp.mli index 6a3be2eb2..af92ffa01 100644 --- a/analysis/vendor/ml/printtyp.mli +++ b/analysis/vendor/ml/printtyp.mli @@ -19,6 +19,7 @@ open Format open Types open Outcometree +val print_res_poly_identifier: (string -> string) ref val longident: formatter -> Longident.t -> unit val ident: formatter -> Ident.t -> unit val tree_of_path: Path.t -> out_ident diff --git a/analysis/vendor/ml/record_coercion.ml b/analysis/vendor/ml/record_coercion.ml new file mode 100644 index 000000000..338749e52 --- /dev/null +++ b/analysis/vendor/ml/record_coercion.ml @@ -0,0 +1,33 @@ +let check_record_fields ?repr1 ?repr2 (fields1 : Types.label_declaration list) + (fields2 : Types.label_declaration list) = + let field_is_optional id repr = + match repr with + | Some (Types.Record_optional_labels lbls) -> List.mem (Ident.name id) lbls + | _ -> false + in + let violation = ref false in + let label_decl_sub (acc1, acc2) (ld2 : Types.label_declaration) = + match + Ext_list.find_first fields1 (fun ld1 -> ld1.ld_id.name = ld2.ld_id.name) + with + | Some ld1 -> + if field_is_optional ld1.ld_id repr1 <> field_is_optional ld2.ld_id repr2 + then (* optional field can't be modified *) + violation := true; + let get_as (({txt}, payload) : Parsetree.attribute) = + if txt = "as" then Ast_payload.is_single_string payload else None + in + let get_as_name (ld : Types.label_declaration) = + match Ext_list.filter_map ld.ld_attributes get_as with + | [] -> ld.ld_id.name + | (s, _) :: _ -> s + in + if get_as_name ld1 <> get_as_name ld2 then violation := true; + (ld1.ld_type :: acc1, ld2.ld_type :: acc2) + | None -> + (* field must be present *) + violation := true; + (acc1, acc2) + in + let tl1, tl2 = List.fold_left label_decl_sub ([], []) fields2 in + (!violation, tl1, tl2) \ No newline at end of file diff --git a/analysis/vendor/ml/record_type_spread.ml b/analysis/vendor/ml/record_type_spread.ml new file mode 100644 index 000000000..76cc710f6 --- /dev/null +++ b/analysis/vendor/ml/record_type_spread.ml @@ -0,0 +1,88 @@ +module StringMap = Map.Make (String) + +let t_equals t1 t2 = t1.Types.level = t2.Types.level && t1.id = t2.id + +let substitute_types ~type_map (t : Types.type_expr) = + if StringMap.is_empty type_map then t + else + let apply_substitution type_variable_name t = + match StringMap.find_opt type_variable_name type_map with + | None -> t + | Some substituted_type -> substituted_type + in + let rec loop (t : Types.type_expr) = + match t.desc with + | Tlink t -> {t with desc = Tlink (loop t)} + | Tvar (Some type_variable_name) -> + apply_substitution type_variable_name t + | Tvar None -> t + | Tunivar _ -> t + | Tconstr (path, args, _memo) -> + {t with desc = Tconstr (path, args |> List.map loop, ref Types.Mnil)} + | Tsubst t -> {t with desc = Tsubst (loop t)} + | Tvariant rd -> {t with desc = Tvariant (row_desc rd)} + | Tnil -> t + | Tarrow (lbl, t1, t2, c) -> + {t with desc = Tarrow (lbl, loop t1, loop t2, c)} + | Ttuple tl -> {t with desc = Ttuple (tl |> List.map loop)} + | Tobject (t, r) -> {t with desc = Tobject (loop t, r)} + | Tfield (n, k, t1, t2) -> {t with desc = Tfield (n, k, loop t1, loop t2)} + | Tpoly (t, []) -> loop t + | Tpoly (t, tl) -> {t with desc = Tpoly (loop t, tl |> List.map loop)} + | Tpackage (p, l, tl) -> + {t with desc = Tpackage (p, l, tl |> List.map loop)} + and row_desc (rd : Types.row_desc) = + let row_fields = + rd.row_fields |> List.map (fun (l, rf) -> (l, row_field rf)) + in + let row_more = loop rd.row_more in + let row_name = + match rd.row_name with + | None -> None + | Some (p, tl) -> Some (p, tl |> List.map loop) + in + {rd with row_fields; row_more; row_name} + and row_field (rf : Types.row_field) = + match rf with + | Rpresent None -> rf + | Rpresent (Some t) -> Rpresent (Some (loop t)) + | Reither (b1, tl, b2, r) -> Reither (b1, tl |> List.map loop, b2, r) + | Rabsent -> Rabsent + in + loop t + +let substitute_type_vars (type_vars : (string * Types.type_expr) list) + (typ : Types.type_expr) = + let type_map = + type_vars + |> List.fold_left + (fun acc (tvar_name, tvar_typ) -> StringMap.add tvar_name tvar_typ acc) + StringMap.empty + in + substitute_types ~type_map typ + +let has_type_spread (lbls : Typedtree.label_declaration list) = + lbls + |> List.exists (fun (l : Typedtree.label_declaration) -> + match l with + | {ld_name = {txt = "..."}} -> true + | _ -> false) + +let extract_type_vars (type_params : Types.type_expr list) + (typ : Types.type_expr) = + (* The type variables applied to the record spread itself. *) + let applied_type_vars = + match Ctype.repr typ with + | {desc = Tpoly ({desc = Tconstr (_, tvars, _)}, _)} -> tvars + | _ -> [] + in + if List.length type_params = List.length applied_type_vars then + (* Track which type param in the record we're spreading + belongs to which type variable applied to the spread itself. *) + let paired_type_vars = List.combine type_params applied_type_vars in + paired_type_vars + |> List.filter_map (fun (t, applied_tvar) -> + match t.Types.desc with + | Tvar (Some tname) -> Some (tname, applied_tvar) + | _ -> None) + else [] \ No newline at end of file diff --git a/analysis/vendor/ml/switch.ml b/analysis/vendor/ml/switch.ml index 9caa94e80..a4bab631e 100644 --- a/analysis/vendor/ml/switch.ml +++ b/analysis/vendor/ml/switch.ml @@ -106,7 +106,7 @@ module type S = val make_isout : act -> act -> act val make_isin : act -> act -> act val make_if : act -> act -> act -> act - val make_switch : Location.t -> act -> int array -> act array -> offset:int -> Lambda.switch_names option -> act + val make_switch : Location.t -> act -> int array -> act array -> offset:int -> Ast_untagged_variants.switch_names option -> act val make_catch : act -> int * (act -> act) val make_exit : int -> act end diff --git a/analysis/vendor/ml/switch.mli b/analysis/vendor/ml/switch.mli index 2dc3e2c56..a12a1be0b 100644 --- a/analysis/vendor/ml/switch.mli +++ b/analysis/vendor/ml/switch.mli @@ -79,7 +79,7 @@ module type S = make_switch arg cases acts NB: cases is in the value form *) val make_switch : - Location.t -> act -> int array -> act array -> offset:int -> Lambda.switch_names option -> act + Location.t -> act -> int array -> act array -> offset:int -> Ast_untagged_variants.switch_names option -> act (* Build last minute sharing of action stuff *) val make_catch : act -> int * (act -> act) val make_exit : int -> act @@ -107,7 +107,7 @@ module Make : Arg.act -> (int * int * int) array -> Arg.act t_store -> - Lambda.switch_names option -> + Ast_untagged_variants.switch_names option -> Arg.act (* Output test sequence, sharing tracked *) diff --git a/analysis/vendor/ml/transl_recmodule.ml b/analysis/vendor/ml/transl_recmodule.ml index 99425fbff..3e709b6dc 100644 --- a/analysis/vendor/ml/transl_recmodule.ml +++ b/analysis/vendor/ml/transl_recmodule.ml @@ -31,10 +31,10 @@ let init_shape modl = (Blk_tuple, [ x; Const_base (Const_string (Ident.name id, None)) ]) in let module_tag_info : Lambda.tag_info = - Blk_constructor { name = "Module"; num_nonconst = 2; tag = 0 } + Blk_constructor { name="Module"; num_nonconst = 2; tag = 0; attrs = [] } in let value_tag_info : Lambda.tag_info = - Blk_constructor { name = "value"; num_nonconst = 2; tag = 1 } + Blk_constructor { name = "value"; num_nonconst = 2; tag = 1; attrs = [] } in let rec init_shape_mod env mty = match Mtype.scrape env mty with @@ -61,6 +61,7 @@ let init_shape modl = name = "Function"; const = cstr_const; non_const = cstr_non_const; + attrs = []; } ) | { desc = Tconstr (p, _, _) } when Path.same p Predef.path_lazy_t -> Const_pointer @@ -70,6 +71,7 @@ let init_shape modl = name = "Lazy"; const = cstr_const; non_const = cstr_non_const; + attrs = []; } ) | _ -> raise Not_found in diff --git a/analysis/vendor/ml/translattribute.ml b/analysis/vendor/ml/translattribute.ml index ac282fdf6..4f7eca2b3 100644 --- a/analysis/vendor/ml/translattribute.ml +++ b/analysis/vendor/ml/translattribute.ml @@ -62,7 +62,7 @@ let get_inline_attribute l = let attr, _ = find_attribute is_inline_attribute l in parse_inline_attribute attr -let add_inline_attribute (expr : Lambda.lambda) loc attributes = +let rec add_inline_attribute (expr : Lambda.lambda) loc attributes = match (expr, get_inline_attribute attributes) with | expr, Default_inline -> expr | Lfunction ({ attr = { stub = false } as attr } as funct), inline -> @@ -72,8 +72,13 @@ let add_inline_attribute (expr : Lambda.lambda) loc attributes = Location.prerr_warning loc (Warnings.Duplicated_attribute "inline")); let attr = { attr with inline } in Lfunction { funct with attr } - | expr, (Always_inline | Never_inline) -> - Location.prerr_warning loc (Warnings.Misplaced_attribute "inline"); + | Lprim (Pccall {prim_name = "#fn_mk" | "#fn_mk_unit"} as p, [e], l), _ -> + Lambda.Lprim (p, [add_inline_attribute e loc attributes], l) + | expr, (Always_inline) -> + Location.prerr_warning loc (Warnings.Misplaced_attribute "inline1"); + expr + | expr, (Never_inline) -> + Location.prerr_warning loc (Warnings.Misplaced_attribute "inline2"); expr (* Get the [@inlined] attribute payload (or default if not present). diff --git a/analysis/vendor/ml/translcore.ml b/analysis/vendor/ml/translcore.ml index 0854908dd..b4e4d1d92 100644 --- a/analysis/vendor/ml/translcore.ml +++ b/analysis/vendor/ml/translcore.ml @@ -762,7 +762,14 @@ and transl_exp0 (e : Typedtree.expression) : Lambda.lambda = let inlined, funct = Translattribute.get_and_remove_inlined_attribute funct in - transl_apply ~inlined (transl_exp funct) oargs e.exp_loc + let uncurried_partial_application = + let uncurried_partial_app = Ext_list.exists e.exp_attributes (fun ({txt },_) -> txt = "res.partial") in + if uncurried_partial_app then + let arity_opt = Ast_uncurried.uncurried_type_get_arity_opt ~env:funct.exp_env funct.exp_type in + arity_opt + else + None in + transl_apply ~inlined ~uncurried_partial_application (transl_exp funct) oargs e.exp_loc | Texp_match (arg, pat_expr_list, exn_pat_expr_list, partial) -> transl_match e arg pat_expr_list exn_pat_expr_list partial | Texp_try (body, pat_expr_list) -> @@ -781,9 +788,17 @@ and transl_exp0 (e : Typedtree.expression) : Lambda.lambda = (* ReScript uncurried encoding *) let loc = expr.exp_loc in let lambda = transl_exp expr in - let arity_s = Ast_uncurried.uncurried_type_get_arity ~env:e.exp_env e.exp_type |> string_of_int in + let arity = Ast_uncurried.uncurried_type_get_arity ~env:e.exp_env e.exp_type in + let arity_s = arity |> string_of_int in + let name = match (Ctype.expand_head expr.exp_env expr.exp_type).desc with + | Tarrow (Nolabel, t, _, _) -> ( + match (Ctype.expand_head expr.exp_env t).desc with + | Tconstr (Pident {name= "unit"}, [], _) -> "#fn_mk_unit" + | _ -> "#fn_mk" + ) + | _ -> "#fn_mk" in let prim = - Primitive.make ~name:"#fn_mk" ~alloc:true ~native_name:arity_s + Primitive.make ~name ~alloc:true ~native_name:arity_s ~native_repr_args:[ Same_as_ocaml_repr ] ~native_repr_res:Same_as_ocaml_repr in @@ -816,6 +831,7 @@ and transl_exp0 (e : Typedtree.expression) : Lambda.lambda = name = cstr.cstr_name; const = cstr.cstr_consts; non_const = cstr.cstr_nonconsts; + attrs = cstr.cstr_attributes; } )) | Cstr_unboxed -> ( match ll with [ v ] -> v | _ -> assert false) | Cstr_block n -> ( @@ -823,7 +839,7 @@ and transl_exp0 (e : Typedtree.expression) : Lambda.lambda = if Datarepr.constructor_has_optional_shape cstr then match args with | [ arg ] - when Typeopt.cannot_inhabit_none_like_value arg.exp_type + when Typeopt.type_cannot_contain_undefined arg.exp_type arg.exp_env -> (* Format.fprintf Format.err_formatter "@[special boxingl@]@."; *) Blk_some_not_nested @@ -834,6 +850,7 @@ and transl_exp0 (e : Typedtree.expression) : Lambda.lambda = name = cstr.cstr_name; num_nonconst = cstr.cstr_nonconsts; tag = n; + attrs = cstr.cstr_attributes; } in try Lconst (Const_block (tag_info, List.map extract_constant ll)) @@ -968,7 +985,7 @@ and transl_cases_try cases = in List.map transl_case_try cases -and transl_apply ?(inlined = Default_inline) lam sargs loc = +and transl_apply ?(inlined = Default_inline) ?(uncurried_partial_application=None) lam sargs loc = let lapply funct args = match funct with (* Attention: This may not be what we need to change the application arity*) @@ -1018,11 +1035,36 @@ and transl_apply ?(inlined = Default_inline) lam sargs loc = | (Some arg, optional) :: l -> build_apply lam ((arg, optional) :: args) l | [] -> lapply lam (List.rev_map fst args) in - (build_apply lam [] - (List.map - (fun (l, x) -> (may_map transl_exp x, Btype.is_optional l)) - sargs) - : Lambda.lambda) + match uncurried_partial_application with + | Some arity when arity > List.length sargs -> + let extra_arity = arity - List.length sargs in + let none_ids = ref [] in + let args = Ext_list.filter_map sargs (function + | _, Some e -> + Some (transl_exp e) + | _, None -> + let id_arg = Ident.create "none" in + none_ids := id_arg :: !none_ids; + Some (Lvar id_arg)) in + let extra_ids = ref [] in + extra_ids := Ident.create "extra" :: !extra_ids; + let extra_ids = Array.init extra_arity (fun _ -> Ident.create "extra") |> Array.to_list in + let extra_args = Ext_list.map extra_ids (fun id -> Lvar id) in + let ap_args = args @ extra_args in + let l0 = Lapply { ap_func = lam; ap_args; ap_inlined = inlined; ap_loc = loc } in + Lfunction + { + params = List.rev_append !none_ids extra_ids ; + body = l0; + attr = default_function_attribute; + loc; + } + | _ -> + (build_apply lam [] + (List.map + (fun (l, x) -> (may_map transl_exp x, Btype.is_optional l)) + sargs) + : Lambda.lambda) and transl_function loc partial param cases = match cases with @@ -1155,10 +1197,10 @@ and transl_record loc env fields repres opt_init_expr = | Record_optional_labels _ -> Lconst (Const_block (!Lambda.blk_record fields mut Record_optional, cl)) - | Record_inlined { tag; name; num_nonconsts; optional_labels } -> + | Record_inlined { tag; name; num_nonconsts; optional_labels; attrs } -> Lconst (Const_block - ( !Lambda.blk_record_inlined fields name num_nonconsts optional_labels ~tag + ( !Lambda.blk_record_inlined fields name num_nonconsts optional_labels ~tag ~attrs mut, cl )) | Record_unboxed _ -> @@ -1177,10 +1219,10 @@ and transl_record loc env fields repres opt_init_expr = ll, loc ) | Record_float_unused -> assert false - | Record_inlined { tag; name; num_nonconsts; optional_labels } -> + | Record_inlined { tag; name; num_nonconsts; optional_labels; attrs } -> Lprim ( Pmakeblock - (!Lambda.blk_record_inlined fields name num_nonconsts optional_labels ~tag + (!Lambda.blk_record_inlined fields name num_nonconsts optional_labels ~tag ~attrs mut), ll, loc ) diff --git a/analysis/vendor/ml/translmod.ml b/analysis/vendor/ml/translmod.ml index 533e281ab..881520977 100644 --- a/analysis/vendor/ml/translmod.ml +++ b/analysis/vendor/ml/translmod.ml @@ -277,6 +277,7 @@ let rec compile_functor mexp coercion root_path loc = stub = false; return_unit = false; async = false; + oneUnitArg = false; }; loc; body; diff --git a/analysis/vendor/ml/typecore.ml b/analysis/vendor/ml/typecore.ml index e9aea7c5f..111ac9fe9 100644 --- a/analysis/vendor/ml/typecore.ml +++ b/analysis/vendor/ml/typecore.ml @@ -22,6 +22,7 @@ open Types open Typedtree open Btype open Ctype +open Error_message_utils type error = Polymorphic_label of Longident.t @@ -31,11 +32,11 @@ type error = | Or_pattern_type_clash of Ident.t * (type_expr * type_expr) list | Multiply_bound_variable of string | Orpat_vars of Ident.t * Ident.t list - | Expr_type_clash of (type_expr * type_expr) list + | Expr_type_clash of (type_expr * type_expr) list * (typeClashContext option) | Apply_non_function of type_expr | Apply_wrong_label of arg_label * type_expr | Label_multiply_defined of string - | Labels_missing of string list + | Labels_missing of string list * bool | Label_not_mutable of Longident.t | Wrong_name of string * type_expr * string * Path.t * string * string list | Name_type_mismatch of @@ -335,14 +336,14 @@ let unify_pat_types loc env ty ty' = raise(Typetexp.Error(loc, env, Typetexp.Variant_tags (l1, l2))) (* unification inside type_exp and type_expect *) -let unify_exp_types loc env ty expected_ty = +let unify_exp_types ?typeClashContext loc env ty expected_ty = (* Format.eprintf "@[%a@ %a@]@." Printtyp.raw_type_expr exp.exp_type Printtyp.raw_type_expr expected_ty; *) try unify env ty expected_ty with Unify trace -> - raise(Error(loc, env, Expr_type_clash(trace))) + raise(Error(loc, env, Expr_type_clash(trace, typeClashContext))) | Tags(l1,l2) -> raise(Typetexp.Error(loc, env, Typetexp.Variant_tags (l1, l2))) @@ -610,6 +611,120 @@ let rec expand_path env p = let compare_type_path env tpath1 tpath2 = Path.same (expand_path env tpath1) (expand_path env tpath2) +let fprintf = Format.fprintf + +let rec bottom_aliases = function + | (_, one) :: (_, two) :: rest -> begin match bottom_aliases rest with + | Some types -> Some types + | None -> Some (one, two) + end + | _ -> None + +let simple_conversions = [ + (("float", "int"), "Belt.Float.toInt"); + (("float", "string"), "Belt.Float.toString"); + (("int", "float"), "Belt.Int.toFloat"); + (("int", "string"), "Belt.Int.toString"); + (("string", "float"), "Belt.Float.fromString"); + (("string", "int"), "Belt.Int.fromString"); +] + +let print_simple_conversion ppf (actual, expected) = + try ( + let converter = List.assoc (actual, expected) simple_conversions in + fprintf ppf "@,@,@[You can convert @{%s@} to @{%s@} with @{%s@}.@]" actual expected converter + ) with | Not_found -> () + +let print_simple_message ppf = function + | ("float", "int") -> fprintf ppf "@ If this is a literal, try a number without a trailing dot (e.g. @{20@})." + | ("int", "float") -> fprintf ppf "@ If this is a literal, try a number with a trailing dot (e.g. @{20.@})." + | _ -> () + +let show_extra_help ppf _env trace = begin + match bottom_aliases trace with + | Some ({Types.desc = Tconstr (actualPath, actualArgs, _)}, {desc = Tconstr (expectedPath, expextedArgs, _)}) -> begin + match (actualPath, actualArgs, expectedPath, expextedArgs) with + | (Pident {name = actualName}, [], Pident {name = expectedName}, []) -> begin + print_simple_conversion ppf (actualName, expectedName); + print_simple_message ppf (actualName, expectedName); + end + | _ -> () + end; + | _ -> (); +end + +let rec collect_missing_arguments env type1 type2 = match type1 with + (* why do we use Ctype.matches here? Please see https://github.com/rescript-lang/rescript-compiler/pull/2554 *) + | {Types.desc=Tarrow (label, argtype, typ, _)} when Ctype.matches env typ type2 -> + Some [(label, argtype)] + | {desc=Tarrow (label, argtype, typ, _)} -> begin + match collect_missing_arguments env typ type2 with + | Some res -> Some ((label, argtype) :: res) + | None -> None + end + | _ -> None + +let print_expr_type_clash ?typeClashContext env trace ppf = begin + (* this is the most frequent error. We should do whatever we can to provide + specific guidance to this generic error before giving up *) + let bottom_aliases_result = bottom_aliases trace in + let missing_arguments = match bottom_aliases_result with + | Some (actual, expected) -> collect_missing_arguments env actual expected + | None -> assert false + in + let print_arguments = + Format.pp_print_list + ~pp_sep:(fun ppf _ -> fprintf ppf ",@ ") + (fun ppf (label, argtype) -> + match label with + | Asttypes.Nolabel -> fprintf ppf "@[%a@]" Printtyp.type_expr argtype + | Labelled label -> + fprintf ppf "@[(~%s: %a)@]" label Printtyp.type_expr argtype + | Optional label -> + fprintf ppf "@[(?%s: %a)@]" label Printtyp.type_expr argtype + ) + in + match missing_arguments with + | Some [singleArgument] -> + (* btw, you can't say "final arguments". Intermediate labeled + arguments might be the ones missing *) + fprintf ppf "@[@{This call is missing an argument@} of type@ %a@]" + print_arguments [singleArgument] + | Some arguments -> + fprintf ppf "@[@{This call is missing arguments@} of type:@ %a@]" + print_arguments arguments + | None -> + let missing_parameters = match bottom_aliases_result with + | Some (actual, expected) -> collect_missing_arguments env expected actual + | None -> assert false + in + begin match missing_parameters with + | Some [singleParameter] -> + fprintf ppf "@[This value might need to be @{wrapped in a function@ that@ takes@ an@ extra@ parameter@}@ of@ type@ %a@]@,@," + print_arguments [singleParameter]; + fprintf ppf "@[@{Here's the original error message@}@]@," + | Some arguments -> + fprintf ppf "@[This value seems to @{need to be wrapped in a function that takes extra@ arguments@}@ of@ type:@ @[%a@]@]@,@," + print_arguments arguments; + fprintf ppf "@[@{Here's the original error message@}@]@," + | None -> () + end; + + Printtyp.super_report_unification_error ppf env trace + (function ppf -> + errorTypeText ppf typeClashContext) + (function ppf -> + errorExpectedTypeText ppf typeClashContext); + printExtraTypeClashHelp ppf trace typeClashContext; + show_extra_help ppf env trace; +end + +let reportArityMismatch ~arityA ~arityB ppf = + fprintf ppf "This function expected @{%s@} %s, but got @{%s@}" + arityB + (if arityB = "1" then "argument" else "arguments") + arityA + (* Records *) let label_of_kind kind = if kind = "record" then "field" else "constructor" @@ -1577,7 +1692,7 @@ let rec type_approx env sexp = let ty = type_approx env e in let ty1 = approx_type env sty in begin try unify env ty ty1 with Unify trace -> - raise(Error(sexp.pexp_loc, env, Expr_type_clash trace)) + raise(Error(sexp.pexp_loc, env, Expr_type_clash (trace, None))) end; ty1 | Pexp_coerce (e, sty1, sty2) -> @@ -1589,7 +1704,7 @@ let rec type_approx env sexp = and ty1 = approx_ty_opt sty1 and ty2 = approx_type env sty2 in begin try unify env ty ty1 with Unify trace -> - raise(Error(sexp.pexp_loc, env, Expr_type_clash trace)) + raise(Error(sexp.pexp_loc, env, Expr_type_clash (trace, None))) end; ty2 | _ -> newvar () @@ -1819,9 +1934,9 @@ let rec name_pattern default = function (* Typing of expressions *) -let unify_exp env exp expected_ty = +let unify_exp ?typeClashContext env exp expected_ty = let loc = proper_exp_loc exp in - unify_exp_types loc env exp.exp_type expected_ty + unify_exp_types ?typeClashContext loc env exp.exp_type expected_ty let is_ignore funct env = @@ -1850,6 +1965,11 @@ let rec lower_args env seen ty_fun = let not_function env ty = let ls, tvar = list_labels env ty in ls = [] && not tvar + +let check_might_be_component env ty_record = + match (expand_head env ty_record).desc with + | Tconstr (path, _, _) when path |> Path.last = "props" -> true + | _ -> false type lazy_args = (Asttypes.arg_label * (unit -> Typedtree.expression) option) list @@ -1866,23 +1986,23 @@ let rec type_exp ?recarg env sexp = In the principal case, [type_expected'] may be at generic_level. *) -and type_expect ?in_function ?recarg env sexp ty_expected = +and type_expect ?typeClashContext ?in_function ?recarg env sexp ty_expected = let previous_saved_types = Cmt_format.get_saved_types () in let exp = Builtin_attributes.warning_scope sexp.pexp_attributes (fun () -> - type_expect_ ?in_function ?recarg env sexp ty_expected + type_expect_ ?typeClashContext ?in_function ?recarg env sexp ty_expected ) in Cmt_format.set_saved_types (Cmt_format.Partial_expression exp :: previous_saved_types); exp -and type_expect_ ?in_function ?(recarg=Rejected) env sexp ty_expected = +and type_expect_ ?typeClashContext ?in_function ?(recarg=Rejected) env sexp ty_expected = let loc = sexp.pexp_loc in (* Record the expression type before unifying it with the expected type *) let rue exp = - unify_exp env (re exp) (instance env ty_expected); + unify_exp ?typeClashContext env (re exp) (instance env ty_expected); exp in let process_optional_label (id, ld, e) = @@ -2020,7 +2140,8 @@ and type_expect_ ?in_function ?(recarg=Rejected) env sexp ty_expected = Ext_list.exists sexp.pexp_attributes (fun ({txt },_) -> txt = "res.uapp") && not @@ Ext_list.exists sexp.pexp_attributes (fun ({txt },_) -> txt = "res.partial") && not @@ is_automatic_curried_application env funct in - let (args, ty_res, fully_applied) = type_application uncurried env funct sargs in + let typeClashContext = typeClashContextFromFunction sexp sfunct in + let (args, ty_res, fully_applied) = type_application ?typeClashContext uncurried env funct sargs in end_def (); unify_var env (newvar()) funct.exp_type; @@ -2072,9 +2193,9 @@ and type_expect_ ?in_function ?(recarg=Rejected) env sexp ty_expected = empty pattern matching can be generated by Camlp4 with its revised syntax. Let's accept it for backward compatibility. *) let val_cases, partial = - type_cases env arg.exp_type ty_expected true loc val_caselist in + type_cases ~rootTypeClashContext:Switch env arg.exp_type ty_expected true loc val_caselist in let exn_cases, _ = - type_cases env Predef.type_exn ty_expected false loc exn_caselist in + type_cases ~rootTypeClashContext:Switch env Predef.type_exn ty_expected false loc exn_caselist in re { exp_desc = Texp_match(arg, val_cases, exn_cases, partial); exp_loc = loc; exp_extra = []; @@ -2186,8 +2307,9 @@ and type_expect_ ?in_function ?(recarg=Rejected) env sexp ty_expected = else Some name in let labels_missing = fields |> List.filter_map filter_missing in - if labels_missing <> [] then - raise(Error(loc, env, Labels_missing labels_missing)); + if labels_missing <> [] then ( + let might_be_component = check_might_be_component env ty_record in + raise(Error(loc, env, Labels_missing (labels_missing, might_be_component)))); [||], representation | [], _ -> if fields = [] && repr_opt <> None then @@ -2211,8 +2333,9 @@ and type_expect_ ?in_function ?(recarg=Rejected) env sexp ty_expected = Overridden ({loc ; txt = Lident lbl.lbl_name}, option_none lbl.lbl_arg loc)) label_descriptions in - if !labels_missing <> [] then - raise(Error(loc, env, Labels_missing (List.rev !labels_missing))); + if !labels_missing <> [] then ( + let might_be_component = check_might_be_component env ty_record in + raise(Error(loc, env, Labels_missing ((List.rev !labels_missing), might_be_component)))); let fields = Array.map2 (fun descr def -> descr, def) label_descriptions label_definitions @@ -2327,7 +2450,7 @@ and type_expect_ ?in_function ?(recarg=Rejected) env sexp ty_expected = let (record, label, opath) = type_label_access env srecord lid in let ty_record = if opath = None then newvar () else record.exp_type in let (label_loc, label, newval) = - type_label_exp false env loc ty_record (lid, label, snewval) in + type_label_exp ~typeClashContext:SetRecordField false env loc ty_record (lid, label, snewval) in unify_exp env record ty_record; if label.lbl_mut = Immutable then raise(Error(loc, env, Label_not_mutable lid.txt)); @@ -2343,7 +2466,7 @@ and type_expect_ ?in_function ?(recarg=Rejected) env sexp ty_expected = let ty = newgenvar() in let to_unify = Predef.type_array ty in unify_exp_types loc env to_unify ty_expected; - let argl = List.map (fun sarg -> type_expect env sarg ty) sargl in + let argl = List.map (fun sarg -> type_expect ~typeClashContext:ArrayValue env sarg ty) sargl in re { exp_desc = Texp_array argl; exp_loc = loc; exp_extra = []; @@ -2351,10 +2474,10 @@ and type_expect_ ?in_function ?(recarg=Rejected) env sexp ty_expected = exp_attributes = sexp.pexp_attributes; exp_env = env } | Pexp_ifthenelse(scond, sifso, sifnot) -> - let cond = type_expect env scond Predef.type_bool in + let cond = type_expect ~typeClashContext:IfCondition env scond Predef.type_bool in begin match sifnot with None -> - let ifso = type_expect env sifso Predef.type_unit in + let ifso = type_expect ~typeClashContext:IfReturn env sifso Predef.type_unit in rue { exp_desc = Texp_ifthenelse(cond, ifso, None); exp_loc = loc; exp_extra = []; @@ -2362,10 +2485,10 @@ and type_expect_ ?in_function ?(recarg=Rejected) env sexp ty_expected = exp_attributes = sexp.pexp_attributes; exp_env = env } | Some sifnot -> - let ifso = type_expect env sifso ty_expected in - let ifnot = type_expect env sifnot ty_expected in + let ifso = type_expect ~typeClashContext:IfReturn env sifso ty_expected in + let ifnot = type_expect ~typeClashContext:IfReturn env sifnot ty_expected in (* Keep sharing *) - unify_exp env ifnot ifso.exp_type; + unify_exp ~typeClashContext:IfReturn env ifnot ifso.exp_type; re { exp_desc = Texp_ifthenelse(cond, ifso, Some ifnot); exp_loc = loc; exp_extra = []; @@ -2453,7 +2576,7 @@ and type_expect_ ?in_function ?(recarg=Rejected) env sexp ty_expected = let tv = newvar () in let gen = generalizable tv.level arg.exp_type in (try unify_var env tv arg.exp_type with Unify trace -> - raise(Error(arg.exp_loc, env, Expr_type_clash trace))); + raise(Error(arg.exp_loc, env, Expr_type_clash (trace, typeClashContext)))); gen end else true in @@ -2843,7 +2966,7 @@ and type_label_access env srecord lid = (* Typing format strings for printing or reading. These formats are used by functions in modules Printf, Format, and Scanf. (Handling of * modifiers contributed by Thorsten Ohl.) *) -and type_label_exp create env loc ty_expected +and type_label_exp ?typeClashContext create env loc ty_expected (lid, label, sarg) = (* Here also ty_expected may be at generic_level *) begin_def (); @@ -2875,7 +2998,7 @@ and type_label_exp create env loc ty_expected raise (Error(lid.loc, env, Private_label(lid.txt, ty_expected))); let arg = let snap = if vars = [] then None else Some (Btype.snapshot ()) in - let arg = type_argument env sarg ty_arg (instance env ty_arg) in + let arg = type_argument ?typeClashContext env sarg ty_arg (instance env ty_arg) in end_def (); try check_univars env (vars <> []) "field value" arg label.lbl_arg vars; @@ -2895,7 +3018,7 @@ and type_label_exp create env loc ty_expected in (lid, label, {arg with exp_type = instance env arg.exp_type}) -and type_argument ?recarg env sarg ty_expected' ty_expected = +and type_argument ?typeClashContext ?recarg env sarg ty_expected' ty_expected = (* ty_expected' may be generic *) let no_labels ty = let ls, tvar = list_labels env ty in @@ -2975,8 +3098,8 @@ and type_argument ?recarg env sarg ty_expected' ty_expected = func let_var) } end | _ -> - let texp = type_expect ?recarg env sarg ty_expected' in - unify_exp env texp ty_expected; + let texp = type_expect ?typeClashContext ?recarg env sarg ty_expected' in + unify_exp ?typeClashContext env texp ty_expected; texp and is_automatic_curried_application env funct = (* When a curried function is used with uncurried application, treat it as a curried application *) @@ -2984,7 +3107,7 @@ and is_automatic_curried_application env funct = match (expand_head env funct.exp_type).desc with | Tarrow _ -> true | _ -> false -and type_application uncurried env funct (sargs : sargs) : targs * Types.type_expr * bool = +and type_application ?typeClashContext uncurried env funct (sargs : sargs) : targs * Types.type_expr * bool = (* funct.exp_type may be generic *) let result_type omitted ty_fun = List.fold_left @@ -3035,7 +3158,7 @@ and type_application uncurried env funct (sargs : sargs) : targs * Types.type_ex (fully_applied, newT) | _ -> (false, newT) in - let rec type_unknown_args max_arity (args : lazy_args) omitted ty_fun (syntax_args : sargs) + let rec type_unknown_args max_arity ~(args : lazy_args) omitted ty_fun (syntax_args : sargs) : targs * _ = match syntax_args with | [] -> @@ -3050,14 +3173,14 @@ and type_application uncurried env funct (sargs : sargs) : targs * Types.type_ex | Tarrow (Optional l,t1,t2,_) -> ignored := (Optional l,t1,ty_fun.level) :: !ignored; let arg = Optional l, Some (fun () -> option_none (instance env t1) Location.none) in - type_unknown_args max_arity (arg::args) omitted t2 [] + type_unknown_args max_arity ~args:(arg::args) omitted t2 [] | _ -> collect_args ()) else collect_args () | [(Nolabel, {pexp_desc = Pexp_construct ({txt = Lident "()"}, None)})] when uncurried && omitted = [] && args <> [] && List.length args = List.length !ignored -> (* foo(. ) treated as empty application if all args are optional (hence ignored) *) - type_unknown_args max_arity args omitted ty_fun [] + type_unknown_args max_arity ~args omitted ty_fun [] | (l1, sarg1) :: sargl -> let (ty1, ty2) = let ty_fun = expand_head env ty_fun in @@ -3097,9 +3220,9 @@ and type_application uncurried env funct (sargs : sargs) : targs * Types.type_ex unify_exp env arg1 (type_option(newvar())); arg1 in - type_unknown_args max_arity ((l1, Some arg1) :: args) omitted ty2 sargl + type_unknown_args max_arity ~args:((l1, Some arg1) :: args) omitted ty2 sargl in - let rec type_args max_arity args omitted ~ty_fun ty_fun0 ~(sargs : sargs) = + let rec type_args ?typeClashContext max_arity args omitted ~ty_fun ty_fun0 ~(sargs : sargs) = match expand_head env ty_fun, expand_head env ty_fun0 with {desc=Tarrow (l, ty, ty_fun, com); level=lv} , {desc=Tarrow (_, ty0, ty_fun0, _)} @@ -3122,15 +3245,15 @@ and type_application uncurried env funct (sargs : sargs) : targs * Types.type_ex sargs, omitted , Some ( if not optional || is_optional l' then - (fun () -> type_argument env sarg0 ty ty0) + (fun () -> type_argument ?typeClashContext:(typeClashContextForFunctionArgument typeClashContext sarg0) env sarg0 ty ty0) else - (fun () -> option_some (type_argument env sarg0 + (fun () -> option_some (type_argument ?typeClashContext env sarg0 (extract_option_type env ty) (extract_option_type env ty0)))) in - type_args max_arity ((l,arg)::args) omitted ~ty_fun ty_fun0 ~sargs + type_args ?typeClashContext max_arity ((l,arg)::args) omitted ~ty_fun ty_fun0 ~sargs | _ -> - type_unknown_args max_arity args omitted ty_fun0 sargs (* This is the hot path for non-labeled function*) + type_unknown_args max_arity ~args omitted ty_fun0 sargs (* This is the hot path for non-labeled function*) in let () = let ls, tvar = list_labels env funct.exp_type in @@ -3164,7 +3287,7 @@ and type_application uncurried env funct (sargs : sargs) : targs * Types.type_ex | _ -> if uncurried then force_uncurried_type funct; let ty, max_arity = extract_uncurried_type funct.exp_type in - let targs, ret_t = type_args max_arity [] [] ~ty_fun:ty (instance env ty) ~sargs in + let targs, ret_t = type_args ?typeClashContext max_arity [] [] ~ty_fun:ty (instance env ty) ~sargs in let fully_applied, ret_t = update_uncurried_arity funct.exp_type ~nargs:(List.length !ignored + List.length sargs) ret_t in targs, ret_t, fully_applied @@ -3203,10 +3326,11 @@ and type_construct env loc lid sarg ty_expected attrs = exp_type = ty_res; exp_attributes = attrs; exp_env = env } in + let typeClashContext = typeClashContextMaybeOption ty_expected ty_res in if separate then begin end_def (); generalize_structure ty_res; - unify_exp env {texp with exp_type = instance_def ty_res} + unify_exp ?typeClashContext env {texp with exp_type = instance_def ty_res} (instance env ty_expected); end_def (); List.iter generalize_structure ty_args; @@ -3218,7 +3342,7 @@ and type_construct env loc lid sarg ty_expected attrs = | _ -> assert false in let texp = {texp with exp_type = ty_res} in - if not separate then unify_exp env texp (instance env ty_expected); + if not separate then unify_exp ?typeClashContext env texp (instance env ty_expected); let recarg = match constr.cstr_inlined with | None -> Rejected @@ -3252,12 +3376,13 @@ and type_statement env sexp = if is_Tvar ty && ty.level > tv.level then Location.prerr_warning loc Warnings.Nonreturning_statement; let expected_ty = instance_def Predef.type_unit in - unify_exp env exp expected_ty; + let typeClashContext = typeClashContextInStatement sexp in + unify_exp ?typeClashContext env exp expected_ty; exp (* Typing of match cases *) -and type_cases ?in_function env ty_arg ty_res partial_flag loc caselist : _ * Typedtree.partial = +and type_cases ?rootTypeClashContext ?in_function env ty_arg ty_res partial_flag loc caselist : _ * Typedtree.partial = (* ty_arg is _fully_ generalized *) let patterns = List.map (fun {pc_lhs=p} -> p) caselist in let contains_polyvars = List.exists contains_polymorphic_variant patterns in @@ -3364,10 +3489,10 @@ and type_cases ?in_function env ty_arg ty_res partial_flag loc caselist : _ * Ty | None -> None | Some scond -> Some - (type_expect ext_env (wrap_unpacks scond unpacks) + (type_expect ?typeClashContext:(if Option.is_some rootTypeClashContext then Some IfCondition else None) ext_env (wrap_unpacks scond unpacks) Predef.type_bool) in - let exp = type_expect ?in_function ext_env sexp ty_res' in + let exp = type_expect ?typeClashContext:rootTypeClashContext ?in_function ext_env sexp ty_res' in { c_lhs = pat; c_guard = guard; @@ -3623,11 +3748,21 @@ let type_expression env sexp = Typetexp.reset_type_variables(); begin_def(); let exp = type_exp env sexp in - if Warnings.is_active Bs_toplevel_expression_unit then + if Warnings.is_active (Bs_toplevel_expression_unit None) then (try unify env exp.exp_type (instance_def Predef.type_unit) with - | Unify _ - | Tags _ -> Location.prerr_warning sexp.pexp_loc Bs_toplevel_expression_unit); + | Unify _ -> + let buffer = Buffer.create 10 in + let formatter = Format.formatter_of_buffer buffer in + Printtyp.type_expr formatter exp.exp_type; + Format.pp_print_flush formatter (); + let returnType = Buffer.contents buffer in + Location.prerr_warning sexp.pexp_loc (Bs_toplevel_expression_unit ( + match sexp.pexp_desc with + | Pexp_apply _ -> Some (returnType, FunctionCall) + | _ -> Some (returnType, Other) + )) + | Tags _ -> Location.prerr_warning sexp.pexp_loc (Bs_toplevel_expression_unit None)); end_def(); if not (is_nonexpansive exp) then generalize_expansive env exp.exp_type; generalize exp.exp_type; @@ -3656,61 +3791,86 @@ let report_error env ppf = function fprintf ppf "@[The record field %a is polymorphic.@ %s@]" longident lid "You cannot instantiate it in a pattern." | Constructor_arity_mismatch(lid, expected, provided) -> - fprintf ppf - "@[The constructor %a@ expects %i argument(s),@ \ - but is applied here to %i argument(s)@]" - longident lid expected provided + (* modified *) + fprintf ppf + "@[This variant constructor, %a, expects %i %s; here, we've %sfound %i.@]" + longident lid expected (if expected == 1 then "argument" else "arguments") (if provided < expected then "only " else "") provided | Label_mismatch(lid, trace) -> - report_unification_error ppf env trace - (function ppf -> - fprintf ppf "The record field %a@ belongs to the type" - longident lid) - (function ppf -> - fprintf ppf "but is mixed here with fields of type") + (* modified *) + super_report_unification_error ppf env trace + (function ppf -> + fprintf ppf "The record field %a@ belongs to the type" + longident lid) + (function ppf -> + fprintf ppf "but is mixed here with fields of type") | Pattern_type_clash trace -> - report_unification_error ppf env trace - (function ppf -> - fprintf ppf "This pattern matches values of type") - (function ppf -> - fprintf ppf "but a pattern was expected which matches values of type") + (* modified *) + super_report_unification_error ppf env trace + (function ppf -> + fprintf ppf "This pattern matches values of type") + (function ppf -> + fprintf ppf "but a pattern was expected which matches values of type") | Or_pattern_type_clash (id, trace) -> - report_unification_error ppf env trace - (function ppf -> - fprintf ppf "The variable %s on the left-hand side of this \ - or-pattern has type" (Ident.name id)) - (function ppf -> - fprintf ppf "but on the right-hand side it has type") + (* modified *) + super_report_unification_error ppf env trace + (function ppf -> + fprintf ppf "The variable %s on the left-hand side of this or-pattern has type" (Ident.name id)) + (function ppf -> + fprintf ppf "but on the right-hand side it has type") | Multiply_bound_variable name -> fprintf ppf "Variable %s is bound several times in this matching" name | Orpat_vars (id, valid_idents) -> fprintf ppf "Variable %s must occur on both sides of this | pattern" (Ident.name id); spellcheck_idents ppf id valid_idents - | Expr_type_clash ( + | Expr_type_clash (( + (_, {desc = Tarrow _}) :: + (_, {desc = Tconstr (Pident {name = "function$"},_,_)}) :: _ + ), _) -> + fprintf ppf "This function is a curried function where an uncurried function is expected" + | Expr_type_clash (( + (_, {desc = Tconstr (Pident {name = "function$"}, [{desc=Tvar _}; _],_)}) :: + (_, {desc = Tarrow _}) :: _ + ), _) -> + fprintf ppf "This function is an uncurried function where a curried function is expected" + | Expr_type_clash (( + (_, {desc = Tconstr (Pident {name = "function$"},[_; tA],_)}) :: + (_, {desc = Tconstr (Pident {name = "function$"},[_; tB],_)}) :: _ + ), _) when Ast_uncurried.type_to_arity tA <> Ast_uncurried.type_to_arity tB -> + let arityA = Ast_uncurried.type_to_arity tA |> string_of_int in + let arityB = Ast_uncurried.type_to_arity tB |> string_of_int in + reportArityMismatch ~arityA ~arityB ppf + | Expr_type_clash (( (_, {desc = Tconstr (Pdot (Pdot(Pident {name = "Js_OO"},"Meth",_),a,_),_,_)}) :: (_, {desc = Tconstr (Pdot (Pdot(Pident {name = "Js_OO"},"Meth",_),b,_),_,_)}) :: _ - ) when a <> b -> + ), _) when a <> b -> fprintf ppf "This method has %s but was expected %s" a b - | Expr_type_clash trace -> - report_unification_error ppf env trace - (function ppf -> - fprintf ppf "This expression has type") - (function ppf -> - fprintf ppf "but an expression was expected of type") + | Expr_type_clash (trace, typeClashContext) -> + (* modified *) + fprintf ppf "@["; + print_expr_type_clash ?typeClashContext env trace ppf; + fprintf ppf "@]" | Apply_non_function typ -> - reset_and_mark_loops typ; - begin match (repr typ).desc with - Tarrow _ -> - fprintf ppf "@[@[<2>This function has type@ %a@]" - type_expr typ; - fprintf ppf "@ @[It is applied to too many arguments;@ %s@]@]" - "maybe you forgot a `;'." + (* modified *) + reset_and_mark_loops typ; + begin match (repr typ).desc with + Tarrow (_, _inputType, returnType, _) -> + let rec countNumberOfArgs count {Types.desc} = match desc with + | Tarrow (_, _inputType, returnType, _) -> countNumberOfArgs (count + 1) returnType + | _ -> count + in + let countNumberOfArgs = countNumberOfArgs 1 in + let acceptsCount = countNumberOfArgs returnType in + fprintf ppf "@[@[<2>This function has type@ @{%a@}@]" + type_expr typ; + fprintf ppf "@ @[It only accepts %i %s; here, it's called with more.@]@]" + acceptsCount (if acceptsCount == 1 then "argument" else "arguments") | _ -> - fprintf ppf "@[@[<2>This expression has type@ %a@]@ %s@]" - type_expr typ - "This is not a function; it cannot be applied." - end + fprintf ppf "@[@[<2>This expression has type@ %a@]@ %s@]" + type_expr typ + "It is not a function." + end | Apply_wrong_label (l, ty) -> let print_label ppf = function | Nolabel -> fprintf ppf "without label" @@ -3724,28 +3884,35 @@ let report_error env ppf = function type_expr ty print_label l | Label_multiply_defined s -> fprintf ppf "The record field label %s is defined several times" s - | Labels_missing labels -> + | Labels_missing (labels, might_be_component) -> let print_labels ppf = List.iter (fun lbl -> fprintf ppf "@ %s" ( lbl)) in - fprintf ppf "@[Some required record fields are missing:%a. If this is a component, add the missing props.@]" - print_labels labels + let component_text = if might_be_component then " If this is a component, add the missing props." else "" in + fprintf ppf "@[Some required record fields are missing:%a.%s@]" + print_labels labels component_text | Label_not_mutable lid -> fprintf ppf "The record field %a is not mutable" longident lid | Wrong_name (eorp, ty, kind, p, name, valid_names) -> - reset_and_mark_loops ty; - if Path.is_constructor_typath p then begin - fprintf ppf "@[The field %s is not part of the record \ - argument for the %a constructor@]" - name - path p; - end else begin - fprintf ppf "@[@[<2>%s type@ %a@]@ " - eorp type_expr ty; - fprintf ppf "The %s %s does not belong to type %a@]" + (* modified *) + reset_and_mark_loops ty; + if Path.is_constructor_typath p then begin + fprintf ppf "@[The field %s is not part of the record \ + argument for the %a constructor@]" + name + Printtyp.path p; + end else begin + fprintf ppf "@["; + + fprintf ppf "@[<2>The %s @{%s@} does not belong to type @{%a@}@]@,@," (label_of_kind kind) - name (*kind*) path p; - end; - spellcheck ppf name valid_names; + name (*kind*) Printtyp.path p; + + fprintf ppf "@[<2>%s type@ @{%a@}@]" + eorp type_expr ty; + + fprintf ppf "@]"; + end; + spellcheck ppf name valid_names; | Name_type_mismatch (kind, lid, tp, tpl) -> let name = label_of_kind kind in report_ambiguous_type_error ppf env tp tpl @@ -3770,29 +3937,35 @@ let report_error env ppf = function | Not_subtype(tr1, tr2) -> report_subtyping_error ppf env tr1 "is not a subtype of" tr2 | Coercion_failure (ty, ty', trace, b) -> - report_unification_error ppf env trace - (function ppf -> - let ty, ty' = prepare_expansion (ty, ty') in - fprintf ppf - "This expression cannot be coerced to type@;<1 2>%a;@ it has type" - (type_expansion ty) ty') - (function ppf -> - fprintf ppf "but is here used with type"); - if b then - fprintf ppf ".@.@[%s@ %s@]" - "This simple coercion was not fully general." - "Consider using a double coercion." + (* modified *) + super_report_unification_error ppf env trace + (function ppf -> + let ty, ty' = Printtyp.prepare_expansion (ty, ty') in + fprintf ppf + "This expression cannot be coerced to type@;<1 2>%a;@ it has type" + (Printtyp.type_expansion ty) ty') + (function ppf -> + fprintf ppf "but is here used with type"); + if b then + fprintf ppf ".@.@[%s@ %s@]" + "This simple coercion was not fully general." + "Consider using a double coercion." | Too_many_arguments (in_function, ty) -> - reset_and_mark_loops ty; - if in_function then begin - fprintf ppf "This function expects too many arguments,@ "; - fprintf ppf "it should have type@ %a" - type_expr ty - end else begin - fprintf ppf "This expression should not be a function,@ "; - fprintf ppf "the expected type is@ %a" + (* modified *) + reset_and_mark_loops ty; + if in_function then begin + fprintf ppf "@[This function expects too many arguments,@ "; + fprintf ppf "it should have type@ %a@]" + type_expr ty + end else begin + match ty with + | {desc = Tconstr (Pident {name = "function$"},_,_)} -> + fprintf ppf "This expression is expected to have an uncurried function" + | _ -> + fprintf ppf "@[This expression should not be a function,@ "; + fprintf ppf "the expected type is@ %a@]" type_expr ty - end + end | Abstract_wrong_label (l, ty) -> let label_mark = function | Nolabel -> "but its first argument is not labelled" @@ -3819,9 +3992,10 @@ let report_error env ppf = function fprintf ppf "in an order different from other calls.@ "; fprintf ppf "This is only allowed when the real type is known." | Less_general (kind, trace) -> - report_unification_error ppf env trace - (fun ppf -> fprintf ppf "This %s has type" kind) - (fun ppf -> fprintf ppf "which is less general than") + (* modified *) + super_report_unification_error ppf env trace + (fun ppf -> fprintf ppf "This %s has type" kind) + (fun ppf -> fprintf ppf "which is less general than") | Modules_not_allowed -> fprintf ppf "Modules are not allowed in this pattern." | Cannot_infer_signature -> @@ -3832,11 +4006,12 @@ let report_error env ppf = function "This expression is packed module, but the expected type is@ %a" type_expr ty | Recursive_local_constraint trace -> - report_unification_error ppf env trace - (function ppf -> - fprintf ppf "Recursive local constraint when unifying") - (function ppf -> - fprintf ppf "with") + (* modified *) + super_report_unification_error ppf env trace + (function ppf -> + fprintf ppf "Recursive local constraint when unifying") + (function ppf -> + fprintf ppf "with") | Unexpected_existential -> fprintf ppf "Unexpected existential" diff --git a/analysis/vendor/ml/typecore.mli b/analysis/vendor/ml/typecore.mli index 502e4a689..650bae0d5 100644 --- a/analysis/vendor/ml/typecore.mli +++ b/analysis/vendor/ml/typecore.mli @@ -68,11 +68,11 @@ type error = | Or_pattern_type_clash of Ident.t * (type_expr * type_expr) list | Multiply_bound_variable of string | Orpat_vars of Ident.t * Ident.t list - | Expr_type_clash of (type_expr * type_expr) list + | Expr_type_clash of (type_expr * type_expr) list * (Error_message_utils.typeClashContext option) | Apply_non_function of type_expr | Apply_wrong_label of arg_label * type_expr | Label_multiply_defined of string - | Labels_missing of string list + | Labels_missing of string list * bool | Label_not_mutable of Longident.t | Wrong_name of string * type_expr * string * Path.t * string * string list | Name_type_mismatch of diff --git a/analysis/vendor/ml/typedecl.ml b/analysis/vendor/ml/typedecl.ml index 36097256f..344cdd246 100644 --- a/analysis/vendor/ml/typedecl.ml +++ b/analysis/vendor/ml/typedecl.ml @@ -27,7 +27,7 @@ type native_repr_kind = Unboxed | Untagged type error = Repeated_parameter | Duplicate_constructor of string - | Duplicate_label of string + | Duplicate_label of string * string option | Recursive_abbrev of string | Cycle_in_def of string * type_expr | Definition_mismatch of type_expr * Includecore.type_mismatch list @@ -53,6 +53,8 @@ type error = | Bad_unboxed_attribute of string | Boxed_and_unboxed | Nonrec_gadt + | Variant_runtime_representation_mismatch of Variant_coercion.variant_error + | Variant_spread_fail of Variant_type_spread.variant_type_spread_error open Typedtree @@ -205,17 +207,17 @@ let make_params env params = in List.map make_param params -let transl_labels env closed lbls = +let transl_labels ?recordName env closed lbls = if !Config.bs_only then match !Builtin_attributes.check_duplicated_labels lbls with | None -> () - | Some {loc;txt=name} -> raise (Error(loc,Duplicate_label name)) + | Some {loc;txt=name} -> raise (Error(loc,Duplicate_label (name, recordName))) else ( let all_labels = ref StringSet.empty in List.iter (fun {pld_name = {txt=name; loc}} -> if StringSet.mem name !all_labels then - raise(Error(loc, Duplicate_label name)); + raise(Error(loc, Duplicate_label (name, recordName))); all_labels := StringSet.add name !all_labels) lbls); let mk {pld_name=name;pld_mutable=mut;pld_type=arg;pld_loc=loc; @@ -290,7 +292,7 @@ let make_constructor env type_path type_params sargs sret_type = *) -let transl_declaration env sdecl id = +let transl_declaration ~typeRecordAsObject env sdecl id = (* Bind type parameters *) reset_type_variables(); Ctype.begin_def (); @@ -303,28 +305,25 @@ let transl_declaration env sdecl id = sdecl.ptype_cstrs in let raw_status = get_unboxed_from_attributes sdecl in - if raw_status.unboxed && not raw_status.default then begin + + let checkUntaggedVariant() = match sdecl.ptype_kind with + | Ptype_variant cds -> Ext_list.for_all cds (function + | {pcd_args = Pcstr_tuple ([] | [_])} -> + (* at most one payload allowed for untagged variants *) + true + | {pcd_args = Pcstr_tuple (_::_::_); pcd_name={txt=name}} -> + Ast_untagged_variants.reportConstructorMoreThanOneArg ~loc:sdecl.ptype_loc ~name + | {pcd_args = Pcstr_record _} -> true + ) + | _ -> false + in + + if raw_status.unboxed && not raw_status.default && not (checkUntaggedVariant()) then begin match sdecl.ptype_kind with | Ptype_abstract -> raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute "it is abstract")) - | Ptype_variant [{pcd_args = Pcstr_tuple []; _}] -> - raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute - "its constructor has no argument")) - | Ptype_variant [{pcd_args = Pcstr_tuple [_]; _}] -> () - | Ptype_variant [{pcd_args = Pcstr_tuple _; _}] -> - raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute - "its constructor has more than one argument")) - | Ptype_variant [{pcd_args = Pcstr_record - [{pld_mutable=Immutable; _}]; _}] -> () - | Ptype_variant [{pcd_args = Pcstr_record [{pld_mutable=Mutable; _}]; _}] -> - raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute "it is mutable")) - | Ptype_variant [{pcd_args = Pcstr_record _; _}] -> - raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute - "its constructor has more than one argument")) - | Ptype_variant _ -> - raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute - "it has more than one constructor")) + | Ptype_variant _ -> () | Ptype_record [{pld_mutable=Immutable; _}] -> () | Ptype_record [{pld_mutable=Mutable; _}] -> raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute @@ -338,7 +337,7 @@ let transl_declaration env sdecl id = end; let unboxed_status = match sdecl.ptype_kind with - | Ptype_variant [{pcd_args = Pcstr_tuple [_]; _}] + | Ptype_variant [{pcd_args = Pcstr_tuple _; _}] | Ptype_variant [{pcd_args = Pcstr_record [{pld_mutable = Immutable; _}]; _}] | Ptype_record [{pld_mutable = Immutable; _}] -> @@ -347,9 +346,9 @@ let transl_declaration env sdecl id = unboxed_false_default_false in let unbox = unboxed_status.unboxed in - let (tkind, kind) = + let (tkind, kind, sdecl) = match sdecl.ptype_kind with - | Ptype_abstract -> Ttype_abstract, Type_abstract + | Ptype_abstract -> Ttype_abstract, Type_abstract, sdecl | Ptype_variant scstrs -> assert (scstrs <> []); if List.exists (fun cstr -> cstr.pcd_res <> None) scstrs then begin @@ -379,59 +378,201 @@ let transl_declaration env sdecl id = raise(Error(sdecl.ptype_loc, Duplicate_constructor name)); all_constrs := StringSet.add name !all_constrs) scstrs; + let copy_tag_attr_from_decl attr = + let tag_attrs = Ext_list.filter sdecl.ptype_attributes (fun ({txt}, _) -> txt = "tag" || txt = Ast_untagged_variants.untagged) in + if tag_attrs = [] then attr else tag_attrs @ attr in + let constructors_from_variant_spreads = Hashtbl.create 10 in let make_cstr scstr = let name = Ident.create scstr.pcd_name.txt in let targs, tret_type, args, ret_type, _cstr_params = make_constructor env (Path.Pident id) params scstr.pcd_args scstr.pcd_res in - let tcstr = - { cd_id = name; - cd_name = scstr.pcd_name; - cd_args = targs; - cd_res = tret_type; - cd_loc = scstr.pcd_loc; - cd_attributes = scstr.pcd_attributes } - in - let cstr = - { Types.cd_id = name; - cd_args = args; - cd_res = ret_type; - cd_loc = scstr.pcd_loc; - cd_attributes = scstr.pcd_attributes } - in + if String.starts_with scstr.pcd_name.txt ~prefix:"..." then ( + (* Any constructor starting with "..." represents a variant type spread, and + will have the spread variant itself as a single argument. + + We pull that variant type out, and then track the type of each of its + constructors, so that we can replace our dummy constructors added before + type checking with the realtypes for each constructor. + *) + (match args with + | Cstr_tuple [spread_variant] -> ( + match Ctype.extract_concrete_typedecl env spread_variant with + | (_, _, {type_kind=Type_variant constructors}) -> ( + constructors |> List.iter(fun (c: Types.constructor_declaration) -> + Hashtbl.add constructors_from_variant_spreads c.cd_id.name c) + ) + | _ -> () + ) + | _ -> ()); + None) + else ( + (* Check if this constructor is from a variant spread. If so, we need to replace + its type with the right type we've pulled from the type checked spread variant + itself. *) + let tcstr, cstr = match Hashtbl.find_opt constructors_from_variant_spreads (Ident.name name) with + | Some cstr -> + let tcstr = + { + cd_id = name; + cd_name = scstr.pcd_name; + cd_args = + (match cstr.cd_args with + | Cstr_tuple args -> + Cstr_tuple + (args + |> List.map (fun texpr : Typedtree.core_type -> + { + ctyp_attributes = cstr.cd_attributes; + ctyp_loc = cstr.cd_loc; + ctyp_env = env; + ctyp_type = texpr; + ctyp_desc = Ttyp_any; + (* This is fine because the type checker seems to only look at `ctyp_type` for type checking. *) + })) + | Cstr_record lbls -> + Cstr_record + (lbls + |> List.map + (fun (l : Types.label_declaration) : Typedtree.label_declaration + -> + { + ld_id = l.ld_id; + ld_name = Location.mkloc (Ident.name l.ld_id) l.ld_loc; + ld_mutable = l.ld_mutable; + ld_type = + { + ctyp_desc = Ttyp_any; + ctyp_type = l.ld_type; + ctyp_env = env; + ctyp_loc = l.ld_loc; + ctyp_attributes = []; + }; + ld_loc = l.ld_loc; + ld_attributes = l.ld_attributes; + }))); + cd_res = tret_type; + (* This is also strictly wrong, but is fine because the type checker does not look at this field. *) + cd_loc = scstr.pcd_loc; + cd_attributes = scstr.pcd_attributes |> copy_tag_attr_from_decl; + } + in tcstr, cstr + | None -> + let tcstr = + { cd_id = name; + cd_name = scstr.pcd_name; + cd_args = targs; + cd_res = tret_type; + cd_loc = scstr.pcd_loc; + cd_attributes = scstr.pcd_attributes |> copy_tag_attr_from_decl } + in + let cstr = + { Types.cd_id = name; + cd_args = args; + cd_res = ret_type; + cd_loc = scstr.pcd_loc; + cd_attributes = scstr.pcd_attributes |> copy_tag_attr_from_decl } + in + tcstr, cstr + in Some (tcstr, cstr) + ) in let make_cstr scstr = Builtin_attributes.warning_scope scstr.pcd_attributes (fun () -> make_cstr scstr) in - let tcstrs, cstrs = List.split (List.map make_cstr scstrs) in - Ttype_variant tcstrs, Type_variant cstrs - | Ptype_record lbls -> + let tcstrs, cstrs = List.split (List.filter_map make_cstr scstrs) in + let isUntaggedDef = Ast_untagged_variants.has_untagged sdecl.ptype_attributes in + Ast_untagged_variants.check_well_formed ~env ~isUntaggedDef cstrs; + Ttype_variant tcstrs, Type_variant cstrs, sdecl + | Ptype_record lbls_ -> let has_optional attrs = Ext_list.exists attrs (fun ({txt },_) -> txt = "res.optional") in let optionalLabels = - Ext_list.filter_map lbls + Ext_list.filter_map lbls_ (fun lbl -> if has_optional lbl.pld_attributes then Some lbl.pld_name.txt else None) in let lbls = - if optionalLabels = [] then lbls - else Ext_list.map lbls (fun lbl -> + if optionalLabels = [] then lbls_ + else Ext_list.map lbls_ (fun lbl -> let typ = lbl.pld_type in let typ = if has_optional lbl.pld_attributes then {typ with ptyp_desc = Ptyp_constr ({txt = Lident "option"; loc=typ.ptyp_loc}, [typ])} else typ in {lbl with pld_type = typ }) in - let lbls, lbls' = transl_labels env true lbls in - let rep = - if unbox then Record_unboxed false - else - if optionalLabels <> [] - then Record_optional_labels optionalLabels - else Record_regular - in - Ttype_record lbls, Type_record(lbls', rep) - | Ptype_open -> Ttype_open, Type_open + let lbls, lbls' = transl_labels ~recordName:(sdecl.ptype_name.txt) env true lbls in + let lbls_opt = match Record_type_spread.has_type_spread lbls with + | true -> + let rec extract t = match t.desc with + | Tpoly(t, []) -> extract t + | _ -> Ctype.repr t in + let mkLbl (l: Types.label_declaration) (ld_type: Typedtree.core_type) (type_vars: (string * Types.type_expr) list) : Typedtree.label_declaration = + { + ld_id = l.ld_id; + ld_name = {txt = Ident.name l.ld_id; loc = l.ld_loc}; + ld_mutable = l.ld_mutable; + ld_type = {ld_type with ctyp_type = Record_type_spread.substitute_type_vars type_vars l.ld_type}; + ld_loc = l.ld_loc; + ld_attributes = l.ld_attributes; + } in + let rec process_lbls acc lbls lbls' = match lbls, lbls' with + | {ld_name = {txt = "..."}; ld_type} :: rest, _ :: rest' -> + (match Ctype.extract_concrete_typedecl env (extract ld_type.ctyp_type) with + (_p0, _p, {type_kind=Type_record (fields, _repr); type_params}) -> + let type_vars = Record_type_spread.extract_type_vars type_params ld_type.ctyp_type in + process_lbls + ( fst acc + @ (Ext_list.map fields (fun l -> + mkLbl l ld_type type_vars)) + , + snd acc + @ (Ext_list.map fields (fun l -> + { + l with + ld_type = + Record_type_spread.substitute_type_vars type_vars l.ld_type; + })) ) + rest rest' + | _ -> assert false + | exception _ -> None) + | lbl::rest, lbl'::rest' -> process_lbls (fst acc @ [lbl], snd acc @ [lbl']) rest rest' + | _ -> Some acc + in + process_lbls ([], []) lbls lbls' + | false -> Some (lbls, lbls') in + let rec check_duplicates loc (lbls : Typedtree.label_declaration list) seen = match lbls with + | [] -> () + | lbl::rest -> + let name = lbl.ld_id.name in + if StringSet.mem name seen then raise(Error(loc, Duplicate_label (name, Some sdecl.ptype_name.txt))); + check_duplicates loc rest (StringSet.add name seen) in + (match lbls_opt with + | Some (lbls, lbls') -> + check_duplicates sdecl.ptype_loc lbls StringSet.empty; + let optionalLabels = + Ext_list.filter_map lbls (fun lbl -> + if has_optional lbl.ld_attributes then Some lbl.ld_name.txt else None) + in + Ttype_record lbls, Type_record(lbls', if unbox then + Record_unboxed false + else if optionalLabels <> [] then + Record_optional_labels optionalLabels + else Record_regular), sdecl + | None -> + (* Could not find record type decl for ...t: assume t is an object type and this is syntax ambiguity *) + typeRecordAsObject := true; + let fields = Ext_list.map lbls_ (fun ld -> + match ld.pld_name.txt with + | "..." -> Parsetree.Oinherit ld.pld_type + | _ -> Otag (ld.pld_name, ld.pld_attributes, ld.pld_type)) in + let sdecl = + {sdecl with + ptype_kind = Ptype_abstract; + ptype_manifest = Some (Ast_helper.Typ.object_ ~loc:sdecl.ptype_loc fields Closed); + } in + (Ttype_abstract, Type_abstract, sdecl)) + | Ptype_open -> Ttype_open, Type_open, sdecl in let (tman, man) = match sdecl.ptype_manifest with None -> None, None @@ -530,7 +671,7 @@ module SMap = Map.Make(String) let check_constraints_labels env visited l pl = let rec get_loc name = function - [] -> assert false + [] -> Location.none | pld :: tl -> if name = pld.pld_name.txt then pld.pld_type.ptyp_loc else get_loc name tl @@ -540,7 +681,7 @@ let check_constraints_labels env visited l pl = check_constraints_rec env (get_loc (Ident.name name) pl) visited ty) l -let check_constraints env sdecl (_, decl) = +let check_constraints ~typeRecordAsObject env sdecl (_, decl) = let visited = ref TypeSet.empty in begin match decl.type_kind with | Type_abstract -> () @@ -589,10 +730,12 @@ let check_constraints env sdecl (_, decl) = begin match decl.type_manifest with | None -> () | Some ty -> + if not !typeRecordAsObject then let sty = match sdecl.ptype_manifest with Some sty -> sty | _ -> assert false in check_constraints_rec env sty.ptyp_loc visited ty + end (* @@ -1167,6 +1310,7 @@ let check_duplicates sdecl_list = (fun {pld_name=cname;pld_loc=loc} -> try let name' = Hashtbl.find labels cname.txt in + if cname.txt <> "..." then Location.prerr_warning loc (Warnings.Duplicate_definitions ("label", cname.txt, name', sdecl.ptype_name.txt)) @@ -1203,7 +1347,12 @@ let transl_type_decl env rec_flag sdecl_list = {sdecl with ptype_name; ptype_kind = Ptype_abstract; ptype_manifest = None}) fixed_types - @ sdecl_list + @ (try + sdecl_list |> Variant_type_spread.expand_variant_spreads env + with + | Variant_coercion.VariantConfigurationError ((VariantError {left_loc}) as err) -> raise(Error(left_loc, Variant_runtime_representation_mismatch err)) + | Variant_type_spread.VariantTypeSpreadError (loc, err) -> raise(Error(loc, Variant_spread_fail err)) + ) in (* Create identifiers. *) @@ -1246,16 +1395,18 @@ let transl_type_decl env rec_flag sdecl_list = | Asttypes.Recursive | Asttypes.Nonrecursive -> id, None in + let typeRecordAsObject = ref false in let transl_declaration name_sdecl (id, slot) = current_slot := slot; Builtin_attributes.warning_scope name_sdecl.ptype_attributes - (fun () -> transl_declaration temp_env name_sdecl id) + (fun () -> transl_declaration ~typeRecordAsObject temp_env name_sdecl id) in let tdecls = List.map2 transl_declaration sdecl_list (List.map id_slots id_list) in let decls = List.map (fun tdecl -> (tdecl.typ_id, tdecl.typ_type)) tdecls in + let sdecl_list = Variant_type_spread.expand_dummy_constructor_args sdecl_list decls in current_slot := None; (* Check for duplicates *) check_duplicates sdecl_list; @@ -1301,7 +1452,7 @@ let transl_type_decl env rec_flag sdecl_list = | None -> ()) sdecl_list tdecls; (* Check that constraints are enforced *) - List.iter2 (check_constraints newenv) sdecl_list decls; + List.iter2 (check_constraints ~typeRecordAsObject newenv) sdecl_list decls; (* Name recursion *) let decls = List.map2 (fun sdecl (id, decl) -> id, name_recursion sdecl id decl) @@ -1847,8 +1998,10 @@ let report_error ppf = function fprintf ppf "A type parameter occurs several times" | Duplicate_constructor s -> fprintf ppf "Two constructors are named %s" s - | Duplicate_label s -> - fprintf ppf "Two labels are named %s" s + | Duplicate_label (s, None) -> + fprintf ppf "The field @{%s@} is defined several times in this record. Fields can only be added once to a record." s + | Duplicate_label (s, Some recordName) -> + fprintf ppf "The field @{%s@} is defined several times in the record @{%s@}. Fields can only be added once to a record." s recordName | Recursive_abbrev s -> fprintf ppf "The type abbreviation %s is cyclic" s | Cycle_in_def (s, ty) -> @@ -2004,6 +2157,40 @@ let report_error ppf = function | Nonrec_gadt -> fprintf ppf "@[GADT case syntax cannot be used in a 'nonrec' block.@]" + | Variant_runtime_representation_mismatch + (Variant_coercion.VariantError + {is_spread_context; error = Variant_coercion.Untagged {left_is_unboxed}}) + -> + let other_variant_text = + if is_spread_context then "the variant where this is spread" + else "the other variant" + in + fprintf ppf "@[%s.@]" + ("This variant is " + ^ (if left_is_unboxed then "unboxed" else "not unboxed") + ^ ", but " ^ other_variant_text + ^ " is not. Both variants unboxed configuration must match") + | Variant_runtime_representation_mismatch + (Variant_coercion.VariantError + {is_spread_context; error = Variant_coercion.TagName _}) -> + let other_variant_text = + if is_spread_context then "the variant where this is spread" + else "the other variant" + in + fprintf ppf "@[%s.@]" + ("The @tag attribute does not match for this variant and " + ^ other_variant_text + ^ ". Both variants must have the same @tag attribute configuration, or no \ + @tag attribute at all") + | Variant_spread_fail Variant_type_spread.CouldNotFindType -> + fprintf ppf "@[This type could not be found. It's only possible to spread variants that are known as the spread happens. This means for example that you can't spread variants in recursive definitions.@]" + | Variant_spread_fail Variant_type_spread.HasTypeParams -> + fprintf ppf "@[Type parameters are not supported in variant type spreads.@]" + | Variant_spread_fail Variant_type_spread.DuplicateConstructor + {variant_with_overlapping_constructor; overlapping_constructor_name} -> + fprintf ppf "@[Variant %s has a constructor named %s, but a constructor named %s already exists in the variant it's spread into.@ You cannot spread variants with overlapping constructors.@]" + variant_with_overlapping_constructor overlapping_constructor_name overlapping_constructor_name + let () = Location.register_error_of_exn diff --git a/analysis/vendor/ml/typemod.ml b/analysis/vendor/ml/typemod.ml index 8972d987a..76b9cf1e5 100644 --- a/analysis/vendor/ml/typemod.ml +++ b/analysis/vendor/ml/typemod.ml @@ -33,7 +33,7 @@ type error = Longident.t * Path.t * Includemod.error list | With_changes_module_alias of Longident.t * Ident.t * Path.t | With_cannot_remove_constrained_type - | Repeated_name of string * string + | Repeated_name of string * string * Warnings.loc | Non_generalizable of type_expr | Non_generalizable_module of module_type | Interface_not_compiled of string @@ -623,25 +623,26 @@ let check_recmod_typedecls env sdecls decls = module StringSet = Set.Make(struct type t = string let compare (x:t) y = String.compare x y end) -let check cl loc set_ref name = - if StringSet.mem name !set_ref - then raise(Error(loc, Env.empty, Repeated_name(cl, name))) - else set_ref := StringSet.add name !set_ref +let check cl loc tbl name = + match Hashtbl.find_opt tbl name with + | Some repeated_loc -> + raise(Error(loc, Env.empty, Repeated_name(cl, name, repeated_loc))) + | None -> Hashtbl.add tbl name loc type names = { - types: StringSet.t ref; - modules: StringSet.t ref; - modtypes: StringSet.t ref; - typexts: StringSet.t ref; + types: (string, Warnings.loc) Hashtbl.t; + modules: (string, Warnings.loc) Hashtbl.t; + modtypes: (string, Warnings.loc) Hashtbl.t; + typexts: (string, Warnings.loc) Hashtbl.t; } let new_names () = { - types = ref StringSet.empty; - modules = ref StringSet.empty; - modtypes = ref StringSet.empty; - typexts = ref StringSet.empty; + types = (Hashtbl.create 10); + modules = (Hashtbl.create 10); + modtypes = (Hashtbl.create 10); + typexts = (Hashtbl.create 10); } @@ -1807,6 +1808,13 @@ let save_signature modname tsg outputprefix source_file initial_env cmi = open Printtyp +let non_generalizable_msg ppf print_fallback_msg = + fprintf ppf + "%a@,@,\ + @[This happens when the type system senses there's a mutation/side-effect,@ in combination with a polymorphic value.@,\ + @{Using or annotating that value usually solves it.@}@]" + print_fallback_msg () + let report_error ppf = function Cannot_apply mty -> fprintf ppf @@ -1853,18 +1861,31 @@ let report_error ppf = function "@[Destructive substitutions are not supported for constrained @ \ types (other than when replacing a type constructor with @ \ a type constructor with the same arguments).@]" - | Repeated_name(kind, name) -> + | Repeated_name(kind, name, repeated_loc) -> fprintf ppf - "@[Multiple definition of the %s name %s.@ \ - Names must be unique in a given structure or signature.@]" kind name + "@[Multiple definition of the %s name %s @ \ + at @{%a@}@ @ \ + Names must be unique in a given structure or signature.@]" kind name Location.print_loc repeated_loc | Non_generalizable typ -> - fprintf ppf - "@[The type of this expression,@ %a,@ \ - contains type variables that cannot be generalized@]" type_scheme typ + (* modified *) + fprintf ppf "@["; + non_generalizable_msg + ppf + (fun ppf () -> + fprintf ppf + "@[This expression's type contains type variables that cannot be generalized:@,@{%a@}@]" + type_scheme typ); + fprintf ppf "@]" | Non_generalizable_module mty -> - fprintf ppf - "@[The type of this module,@ %a,@ \ - contains type variables that cannot be generalized@]" modtype mty + (* modified *) + fprintf ppf "@["; + non_generalizable_msg + ppf + (fun ppf () -> + fprintf ppf + "@[The type of this module contains type variables that cannot be generalized:@,@{%a@}@]" + modtype mty); + fprintf ppf "@]" | Interface_not_compiled intf_name -> fprintf ppf "@[Could not find the .cmi file for interface@ %a.@]" diff --git a/analysis/vendor/ml/typemod.mli b/analysis/vendor/ml/typemod.mli index f8cd85f89..e7bcecec5 100644 --- a/analysis/vendor/ml/typemod.mli +++ b/analysis/vendor/ml/typemod.mli @@ -65,7 +65,7 @@ type error = Longident.t * Path.t * Includemod.error list | With_changes_module_alias of Longident.t * Ident.t * Path.t | With_cannot_remove_constrained_type - | Repeated_name of string * string + | Repeated_name of string * string * Warnings.loc | Non_generalizable of type_expr | Non_generalizable_module of module_type | Interface_not_compiled of string diff --git a/analysis/vendor/ml/typeopt.ml b/analysis/vendor/ml/typeopt.ml index 3a8ff7cf3..4513f4fbf 100644 --- a/analysis/vendor/ml/typeopt.ml +++ b/analysis/vendor/ml/typeopt.ml @@ -44,7 +44,7 @@ let scrape env ty = records the type at the definition type so for ['a option] it will always be [Tvar] *) -let cannot_inhabit_none_like_value (typ : Types.type_expr) (env : Env.t) = +let rec type_cannot_contain_undefined (typ : Types.type_expr) (env : Env.t) = match scrape env typ with | Tconstr(p, _,_) -> (* all built in types could not inhabit none-like values: @@ -52,26 +52,44 @@ let cannot_inhabit_none_like_value (typ : Types.type_expr) (env : Env.t) = int32, int64, lazy_t, bytes *) (match Predef.type_is_builtin_path_but_option p with - | For_sure_yes -> true + | For_sure_yes -> true | For_sure_no -> false - | NA -> - - begin match (Env.find_type p env).type_kind with + | NA -> + let untagged = ref false in + begin match + let decl = Env.find_type p env in + let () = + if Ast_untagged_variants.has_untagged decl.type_attributes + then untagged := true in + decl.type_kind with | exception _ -> false - | Types.Type_abstract | Types.Type_open -> false - | Types.Type_record _ -> true - | (Types.Type_variant + | Type_abstract | Type_open -> false + | Type_record _ -> true + | Type_variant ([{cd_id = {name="None"}; cd_args = Cstr_tuple [] }; {cd_id = {name = "Some"}; cd_args = Cstr_tuple [_]}] | [{cd_id = {name="Some"}; cd_args = Cstr_tuple [_] }; {cd_id = {name = "None"}; cd_args = Cstr_tuple []}] | [{cd_id= {name = "()"}; cd_args = Cstr_tuple []}] - )) - (* | Types.Type_variant *) + ) -> false (* conservative *) - | _ -> true + | Type_variant cdecls -> + Ext_list.for_all cdecls (fun cd -> + if Ast_untagged_variants.has_undefined_literal cd.cd_attributes + then false + else if !untagged then + match cd.cd_args with + | Cstr_tuple [t] -> + Ast_untagged_variants.type_is_builtin_object t || type_cannot_contain_undefined t env + | Cstr_tuple [] -> true + | Cstr_tuple (_::_::_) -> true (* Not actually possible for untagged *) + | Cstr_record [{ld_type=t}] -> + Ast_untagged_variants.type_is_builtin_object t || type_cannot_contain_undefined t env + | Cstr_record ([] | _::_::_) -> true + else + true) end) | Ttuple _ | Tvariant _ diff --git a/analysis/vendor/ml/typeopt.mli b/analysis/vendor/ml/typeopt.mli index ffb740c97..d0d5dffcc 100644 --- a/analysis/vendor/ml/typeopt.mli +++ b/analysis/vendor/ml/typeopt.mli @@ -34,7 +34,7 @@ val classify_lazy_argument : Typedtree.expression -> | `Identifier of [`Forward_value | `Other] | `Other] -val cannot_inhabit_none_like_value: +val type_cannot_contain_undefined: Types.type_expr -> Env.t -> bool diff --git a/analysis/vendor/ml/types.ml b/analysis/vendor/ml/types.ml index 1dea0bec6..0c94b4bc6 100644 --- a/analysis/vendor/ml/types.ml +++ b/analysis/vendor/ml/types.ml @@ -154,7 +154,7 @@ and record_representation = | Record_float_unused (* Was: all fields are floats. Now: unused *) | Record_unboxed of bool (* Unboxed single-field record, inlined or not *) | Record_inlined of (* Inlined record *) - { tag : int ; name : string; num_nonconsts : int; optional_labels : string list} + { tag : int ; name : string; num_nonconsts : int; optional_labels : string list; attrs: Parsetree.attributes} | Record_extension (* Inlined record under extension *) | Record_optional_labels of string list (* List of optional labels *) diff --git a/analysis/vendor/ml/types.mli b/analysis/vendor/ml/types.mli index e87361929..eacf0b7d2 100644 --- a/analysis/vendor/ml/types.mli +++ b/analysis/vendor/ml/types.mli @@ -301,7 +301,7 @@ and record_representation = | Record_float_unused (* Was: all fields are floats. Now: unused *) | Record_unboxed of bool (* Unboxed single-field record, inlined or not *) | Record_inlined of (* Inlined record *) - { tag : int ; name : string; num_nonconsts : int; optional_labels : string list} + { tag : int ; name : string; num_nonconsts : int; optional_labels : string list; attrs: Parsetree.attributes } | Record_extension (* Inlined record under extension *) | Record_optional_labels of string list (* List of optional labels *) diff --git a/analysis/vendor/ml/typetexp.ml b/analysis/vendor/ml/typetexp.ml index b288e6016..5e632574e 100644 --- a/analysis/vendor/ml/typetexp.ml +++ b/analysis/vendor/ml/typetexp.ml @@ -827,6 +827,32 @@ let transl_type_scheme env styp = open Format open Printtyp +let did_you_mean ppf choices : bool = + (* flush now to get the error report early, in the (unheard of) case + where the linear search would take a bit of time; in the worst + case, the user has seen the error, she can interrupt the process + before the spell-checking terminates. *) + Format.fprintf ppf "@?"; + match choices () with + | [] -> false + | last :: rev_rest -> + Format.fprintf ppf "@[@,@,@{Hint: Did you mean %s%s%s?@}@]" + (String.concat ", " (List.rev rev_rest)) + (if rev_rest = [] then "" else " or ") + last; + true + +let super_spellcheck ppf fold env lid = + let choices path name : string list = + let env : string list = fold (fun x _ _ xs -> x ::xs ) path env [] in + Misc.spellcheck env name in + match lid with + | Longident.Lapply _ -> false + | Longident.Lident s -> + did_you_mean ppf (fun _ -> choices None s) + | Longident.Ldot (r, s) -> + did_you_mean ppf (fun _ -> choices (Some r) s) + let spellcheck ppf fold env lid = let choices ~path name = let env = fold (fun x xs -> x::xs) path env [] in @@ -834,16 +860,13 @@ let spellcheck ppf fold env lid = match lid with | Longident.Lapply _ -> () | Longident.Lident s -> - Misc.did_you_mean ppf (fun () -> choices ~path:None s) + Misc.did_you_mean ppf (fun () -> choices ~path:None s) | Longident.Ldot (r, s) -> - Misc.did_you_mean ppf (fun () -> choices ~path:(Some r) s) + Misc.did_you_mean ppf (fun () -> choices ~path:(Some r) s) let fold_descr fold get_name f = fold (fun descr acc -> f (get_name descr) acc) let fold_simple fold4 f = fold4 (fun name _path _descr acc -> f name acc) -let fold_values = fold_simple Env.fold_values -let fold_types = fold_simple Env.fold_types -let fold_modules = fold_simple Env.fold_modules let fold_constructors = fold_descr Env.fold_constructors (fun d -> d.cstr_name) let fold_labels = fold_descr Env.fold_labels (fun d -> d.lbl_name) let fold_classs = fold_simple Env.fold_classs @@ -857,8 +880,11 @@ let report_error env ppf = function should be handled *) fprintf ppf "Unbound type parameter %s@." name | Unbound_type_constructor lid -> - fprintf ppf "Unbound type constructor %a" longident lid; - spellcheck ppf fold_types env lid; + (* modified *) + Format.fprintf ppf "@[This type constructor, `%a`, can't be found.@ " Printtyp.longident lid; + let has_candidate = super_spellcheck ppf Env.fold_types env lid in + if !Config.syntax_kind = `rescript && not has_candidate then + Format.fprintf ppf "If you wanted to write a recursive type, don't forget the `rec` in `type rec`@]" | Unbound_type_constructor_2 p -> fprintf ppf "The type constructor@ %a@ is not yet completely defined" path p @@ -920,8 +946,8 @@ let report_error env ppf = function end | Variant_tags (lab1, lab2) -> fprintf ppf - "@[Variant tags `%s@ and `%s have the same hash value.@ %s@]" - lab1 lab2 "Change one of them." + "@[Variant tags %s@ and %s have the same hash value.@ %s@]" + (!Printtyp.print_res_poly_identifier lab1) (!Printtyp.print_res_poly_identifier lab2) "Change one of them." | Invalid_variable_name name -> fprintf ppf "The type variable name %s is not allowed in programs" name | Cannot_quantify (name, v) -> @@ -939,17 +965,67 @@ let report_error env ppf = function fprintf ppf "@[Method '%s' has type %a,@ which should be %a@]" l Printtyp.type_expr ty Printtyp.type_expr ty') | Unbound_value lid -> - fprintf ppf "Unbound value %a" longident lid; - spellcheck ppf fold_values env lid; + (* modified *) + begin + match lid with + | Ldot (outer, inner) -> + Format.fprintf ppf "The value %s can't be found in %a" + inner + Printtyp.longident outer; + | other_ident -> Format.fprintf ppf "The value %a can't be found" Printtyp.longident other_ident + end; + super_spellcheck ppf Env.fold_values env lid |> ignore | Unbound_module lid -> - fprintf ppf "Unbound module %a" longident lid; - spellcheck ppf fold_modules env lid; + (* modified *) + begin match lid with + | Lident "Str" -> + begin + Format.fprintf ppf "@[\ + @{The module or file %a can't be found.@}@,@,\ + Are you trying to use the standard library's Str?@ \ + If you're compiling to JavaScript,@ use @{Js.Re@} instead.@ \ + Otherwise, add str.cma to your ocamlc/ocamlopt command.\ + @]" + Printtyp.longident lid + end + | lid -> + begin + Format.fprintf ppf "@[\ + @{The module or file %a can't be found.@}@,\ + @[- If it's a third-party dependency:@,\ + - Did you add it to the \"bs-dependencies\" or \"bs-dev-dependencies\" in bsconfig.json?@]@,\ + - Did you include the file's directory to the \"sources\" in bsconfig.json?@,\ + " + Printtyp.longident lid + end + end; + super_spellcheck ppf Env.fold_modules env lid |> ignore | Unbound_constructor lid -> - fprintf ppf "Unbound constructor %a" longident lid; - spellcheck ppf fold_constructors env lid; + (* modified *) + Format.fprintf ppf "@[\ + @{The variant constructor %a can't be found.@}@,@,\ + @[- If it's defined in another module or file, bring it into scope by:@,\ + @[- Prefixing it with said module name:@ @{TheModule.%a@}@]@,\ + @[- Or specifying its type:@ @{let theValue: TheModule.theType = %a@}@]\ + @]@,\ + - @[Constructors and modules are both capitalized.@ Did you want the latter?@ Then instead of @{let foo = Bar@}, try @{module Foo = Bar@}.@]\ + @]" + Printtyp.longident lid + Printtyp.longident lid + Printtyp.longident lid; + spellcheck ppf fold_constructors env lid | Unbound_label lid -> - fprintf ppf "Unbound record field %a" longident lid; - spellcheck ppf fold_labels env lid; + (* modified *) + Format.fprintf ppf "@[\ + @{The record field %a can't be found.@}@,@,\ + If it's defined in another module or file, bring it into scope by:@,\ + @[- Prefixing it with said module name:@ @{TheModule.%a@}@]@,\ + @[- Or specifying its type:@ @{let theValue: TheModule.theType = {%a: VALUE}@}@]\ + @]" + Printtyp.longident lid + Printtyp.longident lid + Printtyp.longident lid; + spellcheck ppf fold_labels env lid; | Unbound_class lid -> fprintf ppf "Unbound class %a" longident lid; spellcheck ppf fold_classs env lid; diff --git a/analysis/vendor/ml/variant_coercion.ml b/analysis/vendor/ml/variant_coercion.ml new file mode 100644 index 000000000..f174313ad --- /dev/null +++ b/analysis/vendor/ml/variant_coercion.ml @@ -0,0 +1,114 @@ +(* TODO: Improve error messages? Say why we can't coerce. *) + +(* Right now we only allow coercing to primitives string/int/float *) +let can_coerce_path (path : Path.t) = + Path.same path Predef.path_string + || Path.same path Predef.path_int + || Path.same path Predef.path_float + +let can_coerce_variant ~(path : Path.t) + (constructors : Types.constructor_declaration list) = + constructors + |> List.for_all (fun (c : Types.constructor_declaration) -> + let args = c.cd_args in + let payload = Ast_untagged_variants.process_tag_type c.cd_attributes in + match args with + | Cstr_tuple [] -> ( + match payload with + | None | Some (String _) -> Path.same path Predef.path_string + | Some (Int _) -> Path.same path Predef.path_int + | Some (Float _) -> Path.same path Predef.path_float + | Some (Null | Undefined | Bool _ | Untagged _) -> false) + | _ -> false) + +let can_try_coerce_variant_to_primitive + ((_, p, typedecl) : Path.t * Path.t * Types.type_declaration) = + match typedecl with + | {type_kind = Type_variant constructors; type_params = []} + when Path.name p <> "bool" -> + (* bool is represented as a variant internally, so we need to account for that *) + Some constructors + | _ -> None + +let variant_representation_matches (c1_attrs : Parsetree.attributes) + (c2_attrs : Parsetree.attributes) = + match + ( Ast_untagged_variants.process_tag_type c1_attrs, + Ast_untagged_variants.process_tag_type c2_attrs ) + with + | None, None -> true + | Some s1, Some s2 when s1 = s2 -> true + | _ -> false + +type variant_configuration_error = + | Untagged of {left_is_unboxed: bool} + | TagName of {left_tag: string option; right_tag: string option} + +type variant_error = + | VariantError of { + left_loc: Location.t; + right_loc: Location.t; + error: variant_configuration_error; + is_spread_context: bool; + } + +exception VariantConfigurationError of variant_error + +let variant_configuration_can_be_coerced (a1 : Parsetree.attributes) + (a2 : Parsetree.attributes) = + let unboxed = + match + ( Ast_untagged_variants.process_untagged a1, + Ast_untagged_variants.process_untagged a2 ) + with + | true, true | false, false -> true + | _ -> false + in + if not unboxed then false + else + let tag = + match + ( Ast_untagged_variants.process_tag_name a1, + Ast_untagged_variants.process_tag_name a2 ) + with + | Some tag1, Some tag2 when tag1 = tag2 -> true + | None, None -> true + | _ -> false + in + if not tag then false else true + +let variant_configuration_can_be_coerced_raises ~is_spread_context ~left_loc + ~right_loc ~(left_attributes : Parsetree.attributes) + ~(right_attributes : Parsetree.attributes) = + (match + ( Ast_untagged_variants.process_untagged left_attributes, + Ast_untagged_variants.process_untagged right_attributes ) + with + | true, true | false, false -> () + | left, _right -> + raise + (VariantConfigurationError + (VariantError + { + is_spread_context; + left_loc; + right_loc; + error = Untagged {left_is_unboxed = left}; + }))); + + match + ( Ast_untagged_variants.process_tag_name left_attributes, + Ast_untagged_variants.process_tag_name right_attributes ) + with + | Some host_tag, Some spread_tag when host_tag = spread_tag -> () + | None, None -> () + | left_tag, right_tag -> + raise + (VariantConfigurationError + (VariantError + { + is_spread_context; + left_loc; + right_loc; + error = TagName {left_tag; right_tag}; + })) diff --git a/analysis/vendor/ml/variant_type_spread.ml b/analysis/vendor/ml/variant_type_spread.ml new file mode 100644 index 000000000..94caebe58 --- /dev/null +++ b/analysis/vendor/ml/variant_type_spread.ml @@ -0,0 +1,195 @@ +let mk_constructor_comes_from_spread_attr () : Parsetree.attribute = + (Location.mknoloc "res.constructor_from_spread", PStr []) + +type variant_type_spread_error = + | CouldNotFindType + | HasTypeParams + | DuplicateConstructor of { + variant_with_overlapping_constructor: string; + overlapping_constructor_name: string; + } + +exception VariantTypeSpreadError of Location.t * variant_type_spread_error + +(* Spreads in variants are parsed as constructors named "...", with a single payload that's an identifier + pointing to the type that's spread. We need to expand those constructors as soon as we can, before type + checking. So, here we look for constructors named "...", look up their type, and add the constructors that + type itself has. +*) + +let map_constructors ~(sdecl : Parsetree.type_declaration) ~all_constructors env + (c : Parsetree.constructor_declaration) = + match c with + | { + pcd_name = {txt = "..."}; + pcd_args = Pcstr_tuple [{ptyp_loc; ptyp_desc = Ptyp_constr (loc, _)}]; + } -> ( + (* This is a variant type spread constructor. Look up its type *) + let _, type_decl = + try Typetexp.find_type env ptyp_loc loc.txt + with _ -> raise (VariantTypeSpreadError (loc.loc, CouldNotFindType)) + in + + match type_decl with + | {type_kind = Type_variant cstrs; type_attributes; type_params} -> + if List.length type_params > 0 then + raise (VariantTypeSpreadError (loc.loc, HasTypeParams)); + + Variant_coercion.variant_configuration_can_be_coerced_raises + ~is_spread_context:true ~left_loc:loc.loc + ~left_attributes:type_attributes + ~right_attributes:sdecl.ptype_attributes ~right_loc:sdecl.ptype_loc; + (* We add back the spread constructor here so the type checker + helps us resolve its type (we'll obviously filter this out + at a later stage). We also append the type identifier so we + can have multiple spreads, since each constructor name needs + to be unique. *) + let variant_name = Longident.flatten loc.txt |> String.concat "." in + let spread_constructor_name = "..." ^ variant_name in + {c with pcd_name = {c.pcd_name with txt = spread_constructor_name}} + :: (cstrs + |> List.map + (fun + (cstr : Types.constructor_declaration) + : + Parsetree.constructor_declaration + -> + match Hashtbl.find_opt all_constructors cstr.cd_id.name with + | Some _ -> + raise + (VariantTypeSpreadError + ( loc.loc, + DuplicateConstructor + { + overlapping_constructor_name = cstr.cd_id.name; + variant_with_overlapping_constructor = variant_name; + } )) + | None -> + Hashtbl.add all_constructors cstr.cd_id.name (); + { + (* This will mark this constructor as originating from a variant type spread. + We use that hint to fill in the real, typed constructor arguments (if any) + at a later stage when that information is available. *) + pcd_attributes = + mk_constructor_comes_from_spread_attr () + :: cstr.cd_attributes; + pcd_loc = cstr.cd_loc; + pcd_res = None; + (* It's important that we _don't_ fill in pcd_args here, since we have no way to produce + a valid set of args for the parsetree at this stage. Inserting dummies here instead + of later means that our dummies would end up being typechecked, and we don't want that. + + We'll fill in the correct arg types in the type checked version of this constructor later. *) + pcd_args = Pcstr_tuple []; + pcd_name = Location.mkloc cstr.cd_id.name cstr.cd_loc; + })) + | _ -> [c]) + | _ -> + Hashtbl.add all_constructors c.pcd_name.txt (); + [c] + +let expand_variant_spreads (env : Env.t) + (sdecl_list : Parsetree.type_declaration list) = + sdecl_list + |> List.map (fun (sdecl : Parsetree.type_declaration) -> + match sdecl with + | {ptype_kind = Ptype_variant constructors} -> + let has_spread = ref false in + let all_constructors = Hashtbl.create (List.length constructors) in + constructors + |> List.iter (fun (c : Parsetree.constructor_declaration) -> + if c.pcd_name.txt = "..." then has_spread := true + else Hashtbl.add all_constructors c.pcd_name.txt ()); + if !has_spread = false then sdecl + else + { + sdecl with + ptype_kind = + Ptype_variant + (constructors + |> List.map (map_constructors ~all_constructors ~sdecl env) + |> List.concat); + } + | _ -> sdecl) + +let constructor_is_from_spread (attrs : Parsetree.attributes) = + attrs + |> List.exists (fun (a : Parsetree.attribute) -> + match a with + | {txt = "res.constructor_from_spread"}, PStr [] -> true + | _ -> false) + +let remove_is_spread_attribute (attr : Parsetree.attribute) = + match attr with + | {txt = "res.constructor_from_spread"}, PStr [] -> false + | _ -> false + +(* Add dummy arguments of the right length to constructors that comes + from spreads, and that has arguments. *) +let expand_dummy_constructor_args (sdecl_list : Parsetree.type_declaration list) + (decls : (Ident.t * Types.type_declaration) list) = + List.map2 + (fun sdecl (_, decl) -> + match (sdecl, decl) with + | ( {Parsetree.ptype_kind = Ptype_variant c1}, + {Types.type_kind = Type_variant c2} ) -> + { + sdecl with + ptype_kind = + Ptype_variant + (c1 + |> List.map (fun (c : Parsetree.constructor_declaration) -> + if constructor_is_from_spread c.pcd_attributes then + match + c2 + |> List.find_opt + (fun (cc : Types.constructor_declaration) -> + Ident.name cc.cd_id = c.pcd_name.txt) + with + | None -> c + | Some constructor -> ( + match constructor with + | {cd_args = Cstr_record lbls} -> + { + c with + pcd_attributes = + c.pcd_attributes + |> List.filter remove_is_spread_attribute; + pcd_args = + Pcstr_record + (lbls + |> List.map + (fun (l : Types.label_declaration) -> + { + Parsetree.pld_name = c.pcd_name; + pld_mutable = l.ld_mutable; + pld_loc = l.ld_loc; + pld_attributes = []; + pld_type = + { + ptyp_desc = Ptyp_any; + ptyp_loc = l.ld_loc; + ptyp_attributes = []; + }; + })); + } + | {cd_args = Cstr_tuple args} -> + { + c with + pcd_attributes = + c.pcd_attributes + |> List.filter remove_is_spread_attribute; + pcd_args = + Pcstr_tuple + (args + |> List.map (fun _t -> + { + Parsetree.ptyp_loc = c.pcd_loc; + ptyp_attributes = []; + ptyp_desc = Ptyp_any; + })); + }) + else c)); + } + | _ -> sdecl) + sdecl_list decls diff --git a/analysis/vendor/res_syntax/react_jsx_common.ml b/analysis/vendor/res_syntax/react_jsx_common.ml index 0cfe798a7..51c471103 100644 --- a/analysis/vendor/res_syntax/react_jsx_common.ml +++ b/analysis/vendor/res_syntax/react_jsx_common.ml @@ -63,3 +63,15 @@ let removeArity binding = | _ -> expr in {binding with pvb_expr = removeArityRecord binding.pvb_expr} + +let async_component ~async expr = + if async then + let open Ast_helper in + Exp.apply + (Exp.ident + { + loc = Location.none; + txt = Ldot (Lident "JsxPPXReactSupport", "asyncComponent"); + }) + [(Nolabel, expr)] + else expr diff --git a/analysis/vendor/res_syntax/reactjs_jsx_ppx.mli b/analysis/vendor/res_syntax/reactjs_jsx_ppx.mli index 388202edb..36a846868 100644 --- a/analysis/vendor/res_syntax/reactjs_jsx_ppx.mli +++ b/analysis/vendor/res_syntax/reactjs_jsx_ppx.mli @@ -4,7 +4,7 @@ facilities; https://whitequark.org/blog/2014/04/16/a-guide-to-extension- points-in-ocaml/ You wouldn't use this file directly; it's used by ReScript's - bsconfig.json. Specifically, there's a field called `react-jsx` inside the + rescript.json. Specifically, there's a field called `react-jsx` inside the field `reason`, which enables this ppx through some internal call in bsb *) diff --git a/analysis/vendor/res_syntax/reactjs_jsx_v4.ml b/analysis/vendor/res_syntax/reactjs_jsx_v4.ml index da84d5595..1801edd01 100644 --- a/analysis/vendor/res_syntax/reactjs_jsx_v4.ml +++ b/analysis/vendor/res_syntax/reactjs_jsx_v4.ml @@ -634,7 +634,13 @@ let rec recursivelyTransformNamedArgsForMake expr args newtypes coreType = in let alias = match pattern with - | {ppat_desc = Ppat_alias (_, {txt}) | Ppat_var {txt}} -> txt + | { + ppat_desc = + ( Ppat_alias (_, {txt}) + | Ppat_var {txt} + | Ppat_constraint ({ppat_desc = Ppat_var {txt}}, _) ); + } -> + txt | {ppat_desc = Ppat_any} -> "_" | _ -> getLabel arg in @@ -852,7 +858,7 @@ let vbMatch ~expr (name, default, _, alias, loc, _) = Vb.mk (Pat.var (Location.mkloc alias loc)) (Exp.match_ - (Exp.ident {txt = Lident alias; loc = Location.none}) + (Exp.ident {txt = Lident ("__" ^ alias); loc = Location.none}) [ Exp.case (Pat.construct @@ -903,6 +909,10 @@ let mapBinding ~config ~emptyLoc ~pstr_loc ~fileName ~recFlag binding = let bindingWrapper, hasForwardRef, expression = modifiedBinding ~bindingLoc ~bindingPatLoc ~fnName binding in + let isAsync = + Ext_list.find_first binding.pvb_expr.pexp_attributes Ast_async.is_async + |> Option.is_some + in (* do stuff here! *) let namedArgList, newtypes, _typeConstraints = recursivelyTransformNamedArgsForMake @@ -936,6 +946,9 @@ let mapBinding ~config ~emptyLoc ~pstr_loc ~fileName ~recFlag binding = (Pat.var @@ Location.mknoloc "props") (Typ.constr (Location.mknoloc @@ Lident "props") [Typ.any ()]) in + let innerExpression = + React_jsx_common.async_component ~async:isAsync innerExpression + in let fullExpression = (* React component name should start with uppercase letter *) (* let make = { let \"App" = props => make(props); \"App" } *) @@ -978,6 +991,14 @@ let mapBinding ~config ~emptyLoc ~pstr_loc ~fileName ~recFlag binding = stripConstraintUnpack ~label pattern | _ -> pattern in + let safePatternLabel pattern = + match pattern with + | {ppat_desc = Ppat_var {txt; loc}} -> + {pattern with ppat_desc = Ppat_var {txt = "__" ^ txt; loc}} + | {ppat_desc = Ppat_alias (p, {txt; loc})} -> + {pattern with ppat_desc = Ppat_alias (p, {txt = "__" ^ txt; loc})} + | _ -> pattern + in let rec returnedExpression patternsWithLabel patternsWithNolabel ({pexp_desc} as expr) = match pexp_desc with @@ -991,16 +1012,26 @@ let mapBinding ~config ~emptyLoc ~pstr_loc ~fileName ~recFlag binding = {ppat_desc = Ppat_construct ({txt = Lident "()"}, _)}, expr ) -> (patternsWithLabel, patternsWithNolabel, expr) - | Pexp_fun (arg_label, _default, ({ppat_loc; ppat_desc} as pattern), expr) + | Pexp_fun (arg_label, default, ({ppat_loc; ppat_desc} as pattern), expr) -> ( let patternWithoutConstraint = stripConstraintUnpack ~label:(getLabel arg_label) pattern in + (* + If prop has the default value as Ident, it will get a build error + when the referenced Ident value and the prop have the same name. + So we add a "__" to label to resolve the build error. + *) + let patternWithSafeLabel = + match default with + | Some _ -> safePatternLabel patternWithoutConstraint + | _ -> patternWithoutConstraint + in if isLabelled arg_label || isOptional arg_label then returnedExpression (( {loc = ppat_loc; txt = Lident (getLabel arg_label)}, { - patternWithoutConstraint with + patternWithSafeLabel with ppat_attributes = (if isOptional arg_label then optionalAttrs else []) @ pattern.ppat_attributes; @@ -1059,6 +1090,7 @@ let mapBinding ~config ~emptyLoc ~pstr_loc ~fileName ~recFlag binding = | _ -> [Typ.any ()])))) expression in + let expression = Ast_async.add_async_attribute ~async:isAsync expression in let expression = (* Add new tupes (type a,b,c) to make's definition *) newtypes diff --git a/analysis/vendor/res_syntax/res_core.ml b/analysis/vendor/res_syntax/res_core.ml index d8e90407f..e15f1e66e 100644 --- a/analysis/vendor/res_syntax/res_core.ml +++ b/analysis/vendor/res_syntax/res_core.ml @@ -4730,6 +4730,12 @@ and parseTypeConstructorDeclaration ~startPos p = Parser.leaveBreadcrumb p Grammar.ConstructorDeclaration; let attrs = parseAttributes p in match p.Parser.token with + | DotDotDot -> + Parser.next p; + let name = Location.mkloc "..." (mkLoc startPos p.prevEndPos) in + let typ = parsePolyTypeExpr p in + let loc = mkLoc startPos typ.ptyp_loc.loc_end in + Ast_helper.Type.constructor ~loc ~attrs ~args:(Pcstr_tuple [typ]) name | Uident uident -> let uidentLoc = mkLoc p.startPos p.endPos in Parser.next p; diff --git a/analysis/vendor/res_syntax/res_multi_printer.ml b/analysis/vendor/res_syntax/res_multi_printer.ml index d419db1c8..81d14d844 100644 --- a/analysis/vendor/res_syntax/res_multi_printer.ml +++ b/analysis/vendor/res_syntax/res_multi_printer.ml @@ -1,21 +1,26 @@ let defaultPrintWidth = 100 -(* Determine if the file is in uncurried mode by looking for - the fist ancestor .bsconfig and see if it contains "uncurried": false *) -let getUncurriedFromBsconfig ~filename = - let rec findBsconfig ~dir = - let bsconfig = Filename.concat dir "bsconfig.json" in - if Sys.file_exists bsconfig then Some (Res_io.readFile ~filename:bsconfig) +(* Look at rescript.json (or bsconfig.json) to set Uncurried or Legacy mode if it contains "uncurried": false *) +let getUncurriedFromConfig ~filename = + let rec findConfig ~dir = + let config = Filename.concat dir "rescript.json" in + if Sys.file_exists config then Some (Res_io.readFile ~filename:config) else - let parent = Filename.dirname dir in - if parent = dir then None else findBsconfig ~dir:parent + let config = Filename.concat dir "bsconfig.json" in + if Sys.file_exists config then Some (Res_io.readFile ~filename:config) + else + let parent = Filename.dirname dir in + if parent = dir then None else findConfig ~dir:parent in let rec findFromNodeModules ~dir = let parent = Filename.dirname dir in if Filename.basename dir = "node_modules" then - let bsconfig = Filename.concat parent "bsconfig.json" in - if Sys.file_exists bsconfig then Some (Res_io.readFile ~filename:bsconfig) - else None + let config = Filename.concat parent "rescript.json" in + if Sys.file_exists config then Some (Res_io.readFile ~filename:config) + else + let config = Filename.concat parent "bsconfig.json" in + if Sys.file_exists config then Some (Res_io.readFile ~filename:config) + else None else if parent = dir then None else findFromNodeModules ~dir:parent in @@ -24,8 +29,8 @@ let getUncurriedFromBsconfig ~filename = Filename.dirname (Filename.concat (Sys.getcwd ()) filename) else Filename.dirname filename in - let bsconfig () = - match findBsconfig ~dir with + let config () = + match findConfig ~dir with | None -> (* The editor calls format on a temporary file. So bsconfig can't be found. This looks outside the node_modules containing the bsc binary *) @@ -33,34 +38,35 @@ let getUncurriedFromBsconfig ~filename = findFromNodeModules ~dir | x -> x in - match bsconfig () with + match config () with | exception _ -> () | None -> () - | Some bsconfig -> - let lines = bsconfig |> String.split_on_char '\n' in - let uncurried = + | Some config -> + let lines = config |> String.split_on_char '\n' in + let is_legacy_uncurried = lines |> List.exists (fun line -> - let uncurried = ref false in - let false_ = ref false in + let is_uncurried_option = ref false in + let is_option_falsy = ref false in let words = line |> String.split_on_char ' ' in words |> List.iter (fun word -> match word with - | "\"uncurried\"" | "\"uncurried\":" -> uncurried := true + | "\"uncurried\"" | "\"uncurried\":" -> + is_uncurried_option := true | "\"uncurried\":false" | "\"uncurried\":false," -> - uncurried := true; - false_ := true + is_uncurried_option := true; + is_option_falsy := true | "false" | ":false" | "false," | ":false," -> - false_ := true + is_option_falsy := true | _ -> ()); - not (!uncurried && !false_)) + !is_uncurried_option && !is_option_falsy) in - if uncurried then Config.uncurried := Uncurried + if not is_legacy_uncurried then Config.uncurried := Uncurried (* print res files to res syntax *) let printRes ~ignoreParseErrors ~isInterface ~filename = - getUncurriedFromBsconfig ~filename; + getUncurriedFromConfig ~filename; if isInterface then ( let parseResult = Res_driver.parsingEngine.parseInterface ~forPrinter:true ~filename diff --git a/analysis/vendor/res_syntax/res_outcome_printer.ml b/analysis/vendor/res_syntax/res_outcome_printer.ml index 7be5f6d1e..c9fda0c6d 100644 --- a/analysis/vendor/res_syntax/res_outcome_printer.ml +++ b/analysis/vendor/res_syntax/res_outcome_printer.ml @@ -352,7 +352,12 @@ and printOutArrowType ~uncurried typ = let needsParens = match typArgs with | _ when uncurried -> true - | [(_, (Otyp_tuple _ | Otyp_arrow _))] -> true + | [ + ( _, + ( Otyp_tuple _ | Otyp_arrow _ + | Otyp_constr (Oide_ident "function$", [Otyp_arrow _; _]) ) ); + ] -> + true (* single argument should not be wrapped *) | [("", _)] -> false | _ -> true diff --git a/analysis/vendor/res_syntax/res_printer.ml b/analysis/vendor/res_syntax/res_printer.ml index 0b456ffea..f85094a7c 100644 --- a/analysis/vendor/res_syntax/res_printer.ml +++ b/analysis/vendor/res_syntax/res_printer.ml @@ -480,6 +480,10 @@ let printPolyVarIdent txt = | "" -> Doc.concat [Doc.text "\""; Doc.text txt; Doc.text "\""] | _ -> Doc.text txt) +let polyVarIdentToString polyVarIdent = + Doc.concat [Doc.text "#"; printPolyVarIdent polyVarIdent] + |> Doc.toString ~width:80 + let printLident l = let flatLidOpt lid = let rec flat accu = function @@ -1442,8 +1446,9 @@ and printConstructorDeclarations ~state ~privateFlag and printConstructorDeclaration2 ~state i (cd : Parsetree.constructor_declaration) cmtTbl = let attrs = printAttributes ~state cd.pcd_attributes cmtTbl in + let isDotDotDot = cd.pcd_name.txt = "..." in let bar = - if i > 0 || cd.pcd_attributes <> [] then Doc.text "| " + if i > 0 || cd.pcd_attributes <> [] || isDotDotDot then Doc.text "| " else Doc.ifBreaks (Doc.text "| ") Doc.nil in let constrName = @@ -1451,7 +1456,8 @@ and printConstructorDeclaration2 ~state i printComments doc cmtTbl cd.pcd_name.loc in let constrArgs = - printConstructorArguments ~state ~indent:true cd.pcd_args cmtTbl + printConstructorArguments ~isDotDotDot ~state ~indent:true cd.pcd_args + cmtTbl in let gadt = match cd.pcd_res with @@ -1473,7 +1479,7 @@ and printConstructorDeclaration2 ~state i ]); ] -and printConstructorArguments ~state ~indent +and printConstructorArguments ?(isDotDotDot = false) ~state ~indent (cdArgs : Parsetree.constructor_arguments) cmtTbl = match cdArgs with | Pcstr_tuple [] -> Doc.nil @@ -1481,7 +1487,7 @@ and printConstructorArguments ~state ~indent let args = Doc.concat [ - Doc.lparen; + (if isDotDotDot then Doc.nil else Doc.lparen); Doc.indent (Doc.concat [ @@ -1494,7 +1500,7 @@ and printConstructorArguments ~state ~indent ]); Doc.trailingComma; Doc.softLine; - Doc.rparen; + (if isDotDotDot then Doc.nil else Doc.rparen); ] in Doc.group (if indent then Doc.indent args else args) @@ -3452,6 +3458,12 @@ and printTemplateLiteral ~state expr cmtTbl = printStringContents txt | _ -> let doc = printExpressionWithComments ~state expr cmtTbl in + let doc = + match Parens.expr expr with + | Parens.Parenthesized -> addParens doc + | Braced braces -> printBraces doc expr braces + | Nothing -> doc + in Doc.group (Doc.concat [Doc.text "${"; Doc.indent doc; Doc.rbrace]) in let content = walkExpr expr in @@ -3515,8 +3527,8 @@ and printBinaryExpression ~state (expr : Parsetree.expression) cmtTbl = Doc.concat [spacingBeforeOperator; Doc.text operatorTxt; spacingAfterOperator] in - let printOperand ~isLhs expr parentOperator = - let rec flatten ~isLhs expr parentOperator = + let printOperand ~isLhs ~isMultiline expr parentOperator = + let rec flatten ~isLhs ~isMultiline expr parentOperator = if ParsetreeViewer.isBinaryExpression expr then match expr with | { @@ -3529,7 +3541,7 @@ and printBinaryExpression ~state (expr : Parsetree.expression) cmtTbl = ParsetreeViewer.flattenableOperators parentOperator operator && not (ParsetreeViewer.hasAttributes expr.pexp_attributes) then - let leftPrinted = flatten ~isLhs:true left operator in + let leftPrinted = flatten ~isLhs:true ~isMultiline left operator in let rightPrinted = let rightPrinteableAttrs, rightInternalAttrs = ParsetreeViewer.partitionPrintableAttributes @@ -3573,12 +3585,26 @@ and printBinaryExpression ~state (expr : Parsetree.expression) cmtTbl = Doc.rparen; ] else - Doc.concat - [ - leftPrinted; - printBinaryOperator ~inlineRhs:false operator; - rightPrinted; - ] + match operator with + | ("|." | "|.u") when isMultiline -> + (* If the pipe-chain is written over multiple lines, break automatically + * `let x = a->b->c -> same line, break when line-width exceeded + * `let x = a-> + * b->c` -> pipe-chain is written on multiple lines, break the group *) + Doc.breakableGroup ~forceBreak:true + (Doc.concat + [ + leftPrinted; + printBinaryOperator ~inlineRhs:false operator; + rightPrinted; + ]) + | _ -> + Doc.concat + [ + leftPrinted; + printBinaryOperator ~inlineRhs:false operator; + rightPrinted; + ] in let doc = @@ -3653,7 +3679,7 @@ and printBinaryExpression ~state (expr : Parsetree.expression) cmtTbl = | Braced braces -> printBraces doc expr braces | Nothing -> doc) in - flatten ~isLhs expr parentOperator + flatten ~isLhs ~isMultiline expr parentOperator in match expr.pexp_desc with | Pexp_apply @@ -3667,8 +3693,8 @@ and printBinaryExpression ~state (expr : Parsetree.expression) cmtTbl = || ParsetreeViewer.isBinaryExpression rhs || printAttributes ~state expr.pexp_attributes cmtTbl <> Doc.nil) -> let lhsHasCommentBelow = hasCommentBelow cmtTbl lhs.pexp_loc in - let lhsDoc = printOperand ~isLhs:true lhs op in - let rhsDoc = printOperand ~isLhs:false rhs op in + let lhsDoc = printOperand ~isLhs:true ~isMultiline:false lhs op in + let rhsDoc = printOperand ~isLhs:false ~isMultiline:false rhs op in Doc.group (Doc.concat [ @@ -3685,12 +3711,16 @@ and printBinaryExpression ~state (expr : Parsetree.expression) cmtTbl = | Pexp_apply ( {pexp_desc = Pexp_ident {txt = Longident.Lident operator}}, [(Nolabel, lhs); (Nolabel, rhs)] ) -> + let isMultiline = + lhs.pexp_loc.loc_start.pos_lnum < rhs.pexp_loc.loc_start.pos_lnum + in + let right = let operatorWithRhs = let rhsDoc = printOperand ~isLhs:(ParsetreeViewer.isRhsBinaryOperator operator) - rhs operator + ~isMultiline rhs operator in Doc.concat [ @@ -3710,7 +3740,7 @@ and printBinaryExpression ~state (expr : Parsetree.expression) cmtTbl = [ printOperand ~isLhs:(not @@ ParsetreeViewer.isRhsBinaryOperator operator) - lhs operator; + ~isMultiline lhs operator; right; ]) in diff --git a/analysis/vendor/res_syntax/res_printer.mli b/analysis/vendor/res_syntax/res_printer.mli index 2f854ef6b..bca833da2 100644 --- a/analysis/vendor/res_syntax/res_printer.mli +++ b/analysis/vendor/res_syntax/res_printer.mli @@ -24,3 +24,5 @@ val printImplementation : width:int -> Parsetree.structure -> comments:Res_comment.t list -> string val printInterface : width:int -> Parsetree.signature -> comments:Res_comment.t list -> string + +val polyVarIdentToString : string -> string [@@live]