text
stringlengths
0
601k
let escapeTemplateLiteral s = let len = String . length s in let b = Buffer . create len in let i = ref 0 in while ! i < len do let c = ( String . get [ @ doesNotRaise ] ) s ! i in if c = ' ` ' then ( Buffer . add_char b ' ' ; \\ Buffer . add_char b ' ` ' ; incr i ; ) else if c = ' ' $ then ( if ! i + 1 < len then ( le...
let escapeStringContents s = let len = String . length s in let b = Buffer . create len in let i = ref 0 in while ! i < len do let c = String . unsafe_get s ! i in if c = ' ' \\ then ( incr i ; Buffer . add_char b c ; let c = String . unsafe_get s ! i in if ! i < len then let ( ) = Buffer . add_char b c in incr i else ...
let looksLikeRecursiveTypeDeclaration typeDeclaration = let open Parsetree in let name = typeDeclaration . ptype_name . txt in let rec checkKind kind = match kind with | Ptype_abstract | Ptype_open -> false | Ptype_variant constructorDeclarations -> List . exists checkConstructorDeclaration constructorDeclarations | Pt...
let filterReasonRawLiteral attrs = List . filter ( fun attr -> match attr with | ( { Location . txt = ( " reason . raw_literal " ) } , _ ) -> false | _ -> true ) attrs
let stringLiteralMapper stringData = let isSameLocation l1 l2 = let open Location in l1 . loc_start . pos_cnum == l2 . loc_start . pos_cnum in let remainingStringData = stringData in let open Ast_mapper in { default_mapper with expr = ( fun mapper expr -> match expr . pexp_desc with | Pexp_constant ( Pconst_string ( _t...
let hasUncurriedAttribute attrs = List . exists ( fun attr -> match attr with | ( { Asttypes . txt = " bs " } , Parsetree . PStr [ ] ) -> true | _ -> false
let normalize = let open Ast_mapper in { default_mapper with extension = ( fun mapper ext -> match ext with | ( id , payload ) -> ( { id with txt = Res_printer . convertBsExtension id . txt } , default_mapper . payload mapper payload ) ) ; attribute = ( fun mapper attr -> match attr with | ( id , payload ) -> ( { id wi...
let normalizeReasonArityStructure ~ forPrinter s = let mapper = makeReasonArityMapper ~ forPrinter in mapper . Ast_mapper . structure mapper s
let normalizeReasonAritySignature ~ forPrinter s = let mapper = makeReasonArityMapper ~ forPrinter in mapper . Ast_mapper . signature mapper s
let structure s = normalize . Ast_mapper . structure normalize s
let signature s = normalize . Ast_mapper . signature normalize s
let replaceStringLiteralStructure stringData structure = let mapper = stringLiteralMapper stringData in mapper . Ast_mapper . structure mapper structure
let replaceStringLiteralSignature stringData signature = let mapper = stringLiteralMapper stringData in mapper . Ast_mapper . signature mapper signature
let printEngine = Res_driver . { printImplementation = begin fun ~ width : _ ~ filename : _ ~ comments : _ structure -> Printast . implementation Format . std_formatter structure end ; printInterface = begin fun ~ width : _ ~ filename : _ ~ comments : _ signature -> Printast . interface Format . std_formatter signature...
module Sexp : sig type t val atom : string -> t val list : t list -> t val toString : t -> string type t = | Atom of string | List of t list let atom s = Atom s let list l = List l let rec toDoc t = match t with | Atom s -> Doc . text s | List [ ] -> Doc . text " ( ) " | List [ sexpr ] -> Doc . concat [ Doc . lparen ; ...
module SexpAst = struct open Parsetree let mapEmpty ~ f items = match items with | [ ] -> [ Sexp . list [ ] ] | items -> List . map f items let string txt = Sexp . atom ( " " " \ ^ txt ^ " " " ) \ let char c = Sexp . atom ( " ' " ^ ( Char . escaped c ) ^ " ' " ) let optChar oc = match oc with | None -> Sexp . atom " No...
module Color = struct type color = | Black [ @ live ] | Red | Green [ @ live ] | Yellow | Blue [ @ live ] | Magenta | Cyan | White [ @ live ] ; ; type style = | FG of color | BG of color [ @ live ] | Bold | Reset | Dim let ansi_of_color = function | Black -> " 0 " | Red -> " 1 " | Green -> " 2 " | Yellow -> " 3 " | Blu...
module ResClflags : sig val recover : bool ref val print : string ref val width : int ref val origin : string ref val file : string ref val interface : bool ref val ppx : string ref val parse : unit -> unit let recover = ref false let width = ref 100 let print = ref " res " let origin = ref " " let interface = ref fals...
module CliArgProcessor = struct type backend = Parser : ( ' diagnostics ) Res_driver . parsingEngine -> backend [ @@ unboxed ] let processFile ~ isInterface ~ width ~ recover ~ origin ~ target ~ ppx filename = let len = String . length filename in let processInterface = isInterface || len > 0 && ( String . get [ @ does...
let [ @ raises Invalid_argument , Failure , exit ] ( ) = if not ! Sys . interactive then begin ResClflags . parse ( ) ; CliArgProcessor . processFile ~ isInterface :! ResClflags . interface ~ width :! ResClflags . width ~ recover :! ResClflags . recover ~ target :! ResClflags . print ~ origin :! ResClflags . origin ~ p...
type style = | SingleLine | MultiLine
let styleToString s = match s with | SingleLine -> " SingleLine " | MultiLine -> " MultiLine "
type t = { txt : string ; style : style ; loc : Location . t ; mutable prevTokEndPos : Lexing . position ; }
let loc t = t . loc
let txt t = t . txt
let prevTokEndPos t = t . prevTokEndPos
let setPrevTokEndPos t pos = t . prevTokEndPos <- pos
let isSingleLineComment t = match t . style with | SingleLine -> true | MultiLine -> false
let toString t = Format . sprintf " ( txt : % s \ nstyle : % s \ nlines : % d -% d ) " t . txt ( styleToString t . style ) t . loc . loc_start . pos_lnum t . loc . loc_end . pos_lnum
let makeSingleLineComment ~ loc txt = { txt ; loc ; style = SingleLine ; prevTokEndPos = Lexing . dummy_pos ; }
let makeMultiLineComment ~ loc txt = { txt ; loc ; style = MultiLine ; prevTokEndPos = Lexing . dummy_pos ; }
let fromOcamlComment ~ loc ~ txt ~ prevTokEndPos = { txt ; loc ; style = MultiLine ; prevTokEndPos = prevTokEndPos }
let trimSpaces s = let len = String . length s in if len = 0 then s else if String . unsafe_get s 0 = ' ' || String . unsafe_get s ( len - 1 ) = ' ' then ( let i = ref 0 in while ! i < len && ( String . unsafe_get s ! i ) = ' ' do incr i done ; let j = ref ( len - 1 ) in while ! j >= ! i && ( String . unsafe_get s ! j ...
type t = { leading : ( Location . t , Comment . t list ) Hashtbl . t ; inside : ( Location . t , Comment . t list ) Hashtbl . t ; trailing : ( Location . t , Comment . t list ) Hashtbl . t ; }
let make ( ) = { leading = Hashtbl . create 100 ; inside = Hashtbl . create 100 ; trailing = Hashtbl . create 100 ; }
let copy tbl = { leading = Hashtbl . copy tbl . leading ; inside = Hashtbl . copy tbl . inside ; trailing = Hashtbl . copy tbl . trailing ; }
let empty = make ( )
let log t = let open Location in let leadingStuff = Hashtbl . fold ( fun ( k : Location . t ) ( v : Comment . t list ) acc -> let loc = Doc . concat [ Doc . lbracket ; Doc . text ( string_of_int k . loc_start . pos_lnum ) ; Doc . text " " ; : Doc . text ( string_of_int ( k . loc_start . pos_cnum - k . loc_start . pos_b...
let attach tbl loc comments = match comments with | [ ] -> ( ) | comments -> Hashtbl . replace tbl loc comments
let partitionByLoc comments loc = let rec loop ( leading , inside , trailing ) comments = let open Location in match comments with | comment :: rest -> let cmtLoc = Comment . loc comment in if cmtLoc . loc_end . pos_cnum <= loc . loc_start . pos_cnum then loop ( comment :: leading , inside , trailing ) rest else if cmt...
let partitionLeadingTrailing comments loc = let rec loop ( leading , trailing ) comments = let open Location in match comments with | comment :: rest -> let cmtLoc = Comment . loc comment in if cmtLoc . loc_end . pos_cnum <= loc . loc_start . pos_cnum then loop ( comment :: leading , trailing ) rest else loop ( leading...
let partitionByOnSameLine loc comments = let rec loop ( onSameLine , onOtherLine ) comments = let open Location in match comments with | [ ] -> ( List . rev onSameLine , List . rev onOtherLine ) | comment :: rest -> let cmtLoc = Comment . loc comment in if cmtLoc . loc_start . pos_lnum == loc . loc_end . pos_lnum then ...
let partitionAdjacentTrailing loc1 comments = let open Location in let open Lexing in let rec loop ~ prevEndPos afterLoc1 comments = match comments with | [ ] -> ( List . rev afterLoc1 , [ ] ) | ( comment :: rest ) as comments -> let cmtPrevEndPos = Comment . prevTokEndPos comment in if prevEndPos . Lexing . pos_cnum =...
let rec collectListPatterns acc pattern = let open Parsetree in match pattern . ppat_desc with | Ppat_construct ( { txt = Longident . Lident " " } , :: Some { ppat_desc = Ppat_tuple ( pat :: rest [ ] ) } :: ) -> collectListPatterns ( pat :: acc ) rest | Ppat_construct ( { txt = Longident . Lident " [ ] " } , None ) -> ...
let rec collectListExprs acc expr = let open Parsetree in match expr . pexp_desc with | Pexp_construct ( { txt = Longident . Lident " " } , :: Some { pexp_desc = Pexp_tuple ( expr :: rest [ ] ) } :: ) -> collectListExprs ( expr :: acc ) rest | Pexp_construct ( { txt = Longident . Lident " [ ] " } , _ ) -> List . rev ac...
let arrowType ct = let open Parsetree in let rec process attrsBefore acc typ = match typ with | { ptyp_desc = Ptyp_arrow ( Nolabel as lbl , typ1 , typ2 ) ; ptyp_attributes = [ ] } -> let arg = ( [ ] , lbl , typ1 ) in process attrsBefore ( arg :: acc ) typ2 | { ptyp_desc = Ptyp_arrow ( Nolabel as lbl , typ1 , typ2 ) ; p...
let modExprApply modExpr = let rec loop acc modExpr = match modExpr with | { Parsetree . pmod_desc = Pmod_apply ( next , arg ) } -> loop ( arg :: acc ) next | _ -> ( modExpr :: acc ) in loop [ ] modExpr
let modExprFunctor modExpr = let rec loop acc modExpr = match modExpr with | { Parsetree . pmod_desc = Pmod_functor ( lbl , modType , returnModExpr ) ; pmod_attributes = attrs } -> let param = ( attrs , lbl , modType ) in loop ( param :: acc ) returnModExpr | returnModExpr -> ( List . rev acc , returnModExpr ) in loop ...
let functorType modtype = let rec process acc modtype = match modtype with | { Parsetree . pmty_desc = Pmty_functor ( lbl , argType , returnType ) ; pmty_attributes = attrs } -> let arg = ( attrs , lbl , argType ) in process ( arg :: acc ) returnType | modType -> ( List . rev acc , modType ) in process [ ] modtype
let funExpr expr = let open Parsetree in let rec collectNewTypes acc returnExpr = match returnExpr with | { pexp_desc = Pexp_newtype ( stringLoc , returnExpr ) ; pexp_attributes = [ ] } -> collectNewTypes ( stringLoc :: acc ) returnExpr | returnExpr -> let loc = match ( acc , List . rev acc ) with | ( _startLoc :: _ , ...
let rec isBlockExpr expr = let open Parsetree in match expr . pexp_desc with | Pexp_letmodule _ | Pexp_letexception _ | Pexp_let _ | Pexp_open _ | Pexp_sequence _ -> true | Pexp_apply ( callExpr , _ ) when isBlockExpr callExpr -> true | Pexp_constraint ( expr , _ ) when isBlockExpr expr -> true | Pexp_field ( expr , _ ...
let isIfThenElseExpr expr = let open Parsetree in match expr . pexp_desc with | Pexp_ifthenelse _ -> true | _ -> false
let rec walkStructure s t comments = match s with | _ when comments = [ ] -> ( ) | [ ] -> attach t . inside Location . none comments | s -> walkList ~ getLoc ( : fun n -> n . Parsetree . pstr_loc ) ~ walkNode : walkStructureItem s t comments and walkStructureItem si t comments = match si . Parsetree . pstr_desc with | ...
let init_path ( ) = let dirs = ! Clflags . include_dirs in let exp_dirs = List . map ( Misc . expand_directory Config . standard_library ) dirs in Load_path . reset ( ) ; List . iter Load_path . add_dir ( List . rev ( Lazy . force Js_config . stdlib_path :: exp_dirs ) ) ; Env . reset_cache ( ) let lid = { Asttypes . lo...
let initial_env ( ) = Ident . reinit ( ) ; let initial = Env . initial_safe_string in let env = if ! Clflags . nopervasives then initial else open_implicit_module " Stdlib " initial in List . fold_left ( fun env m -> open_implicit_module m env ) env ( List . rev ! Clflags . open_modules )
let mkLoc startLoc endLoc = Location . { loc_start = startLoc ; loc_end = endLoc ; loc_ghost = false ; }
module Recover = struct let defaultExpr ( ) = let id = Location . mknoloc " rescript . exprhole " in Ast_helper . Exp . mk ( Pexp_extension ( id , PStr [ ] ) ) let defaultType ( ) = let id = Location . mknoloc " rescript . typehole " in Ast_helper . Typ . extension ( id , PStr [ ] ) let defaultPattern ( ) = let id = Lo...
module ErrorMessages = struct let listPatternSpread = " List pattern matches only supports one ` . . . ` spread , at the end . \ n \ let recordPatternSpread = " Record ' s ` . . . ` spread is not supported in pattern matches . \ n \ [ @@ live ] let arrayPatternSpread = " Array ' s ` . . . ` spread is not supported in p...
let jsxAttr = ( Location . mknoloc " JSX " , Parsetree . PStr [ ] )
let uncurryAttr = ( Location . mknoloc " bs " , Parsetree . PStr [ ] )
let ternaryAttr = ( Location . mknoloc " ns . ternary " , Parsetree . PStr [ ] )
let ifLetAttr = ( Location . mknoloc " ns . iflet " , Parsetree . PStr [ ] )
let suppressFragileMatchWarningAttr = ( Location . mknoloc " warning " , Parsetree . PStr [ Ast_helper . Str . eval ( Ast_helper . Exp . constant ( Pconst_string ( " - 4 " , None ) ) ) ] )
let makeBracesAttr loc = ( Location . mkloc " ns . braces " loc , Parsetree . PStr [ ] )
type stringLiteralState = | Start | Backslash | HexEscape | DecimalEscape | OctalEscape | EscapedLineBreak
type typDefOrExt = | TypeDef of { recFlag : Asttypes . rec_flag ; types : Parsetree . type_declaration list } | TypeExt of Parsetree . type_extension
type labelledParameter = | TermParameter of { uncurried : bool ; attrs : Parsetree . attributes ; label : Asttypes . arg_label ; expr : Parsetree . expression option ; pat : Parsetree . pattern ; pos : Lexing . position } | TypeParameter of { uncurried : bool ; attrs : Parsetree . attributes ; locs : string Location . ...
type recordPatternItem = | PatUnderscore | PatField of ( Ast_helper . lid * Parsetree . pattern )
type context = | OrdinaryExpr | TernaryTrueBranchExpr | WhenExpr
let getClosingToken = function | Token . Lparen -> Token . Rparen | Lbrace -> Rbrace | Lbracket -> Rbracket | List -> Rbrace | LessThan -> GreaterThan | _ -> assert false
let rec goToClosing closingToken state = match ( state . Parser . token , closingToken ) with | ( Rparen , Token . Rparen ) | ( Rbrace , Rbrace ) | ( Rbracket , Rbracket ) | ( GreaterThan , GreaterThan ) -> Parser . next state ; ( ) | ( Token . Lbracket | Lparen | Lbrace | List | LessThan ) as t , _ -> Parser . next st...
let isEs6ArrowExpression ~ inTernary p = Parser . lookahead p ( fun state -> match state . Parser . token with | Lident _ | Underscore -> Parser . next state ; begin match state . Parser . token with | EqualGreater -> true | _ -> false end | Lparen -> let prevEndPos = state . prevEndPos in Parser . next state ; begin m...
let isEs6ArrowFunctor p = Parser . lookahead p ( fun state -> match state . Parser . token with | Lparen -> Parser . next state ; begin match state . token with | Rparen -> Parser . next state ; begin match state . token with | Colon | EqualGreater -> true | _ -> false end | _ -> goToClosing Rparen state ; begin match ...
let isEs6ArrowType p = Parser . lookahead p ( fun state -> match state . Parser . token with | Lparen -> Parser . next state ; begin match state . Parser . token with | Rparen -> Parser . next state ; begin match state . Parser . token with | EqualGreater -> true | _ -> false end | Tilde | Dot -> true | _ -> goToClosin...
let buildLongident words = match List . rev words with | [ ] -> assert false | hd :: tl -> List . fold_left ( fun p s -> Longident . Ldot ( p , s ) ) ( Lident hd ) tl
let makeInfixOperator p token startPos endPos = let stringifiedToken = if token = Token . MinusGreater then " . " | else if token = Token . PlusPlus then " " ^ else if token = Token . BangEqual then " " <> else if token = Token . BangEqualEqual then " " != else if token = Token . Equal then ( Parser . err ~ startPos ~ ...
let negateString s = if String . length s > 0 && ( s . [ 0 ] [ @ doesNotRaise ] ) = ' ' - then ( String . sub [ @ doesNotRaise ] ) s 1 ( String . length s - 1 ) else " " - ^ s
let makeUnaryExpr startPos tokenEnd token operand = match token , operand . Parsetree . pexp_desc with | ( Token . Plus | PlusDot ) , Pexp_constant ( ( Pconst_integer _ | Pconst_float _ ) ) -> operand | Minus , Pexp_constant ( Pconst_integer ( n , m ) ) -> { operand with pexp_desc = Pexp_constant ( Pconst_integer ( neg...
let makeListExpression loc seq extOpt = let rec handleSeq = function | [ ] -> begin match extOpt with | Some ext -> ext | None -> let loc = { loc with Location . loc_ghost = true } in let nil = Location . mkloc ( Longident . Lident " [ ] " ) loc in Ast_helper . Exp . construct ~ loc nil None end | e1 :: el -> let exp_e...
let makeListPattern loc seq ext_opt = let rec handle_seq = function [ ] -> let base_case = match ext_opt with | Some ext -> ext | None -> let loc = { loc with Location . loc_ghost = true } in let nil = { Location . txt = Longident . Lident " [ ] " ; loc } in Ast_helper . Pat . construct ~ loc nil None in base_case | p1...
let makeBsObjType ~ attrs ~ loc ~ closed rows = let obj = Ast_helper . Typ . object_ ~ loc rows closed in let jsDotTCtor = Location . mkloc ( Longident . Ldot ( Longident . Lident " Js " , " t " ) ) loc in Ast_helper . Typ . constr ~ loc ~ attrs jsDotTCtor [ obj ]
let lidentOfPath longident = match Longident . flatten longident |> List . rev with | [ ] -> " " | ident :: _ -> ident
let makeNewtypes ~ attrs ~ loc newtypes exp = let expr = List . fold_right ( fun newtype exp -> Ast_helper . Exp . mk ~ loc ( Pexp_newtype ( newtype , exp ) ) ) newtypes exp in { expr with pexp_attributes = attrs }
let wrapTypeAnnotation ~ loc newtypes core_type body = let exp = makeNewtypes ~ attrs [ ] : ~ loc newtypes ( Ast_helper . Exp . constraint_ ~ loc body core_type ) in let typ = Ast_helper . Typ . poly ~ loc newtypes ( Ast_helper . Typ . varify_constructors newtypes core_type ) in ( exp , typ )
let processUnderscoreApplication args = let open Parsetree in let exp_question = ref None in let hidden_var = " __x " in let check_arg ( ( lab , exp ) as arg ) = match exp . pexp_desc with | Pexp_ident ( { txt = Lident " _ " } as id ) -> let new_id = Location . mkloc ( Longident . Lident hidden_var ) id . loc in let ne...
let hexValue x = match x with | ' 0 ' . . ' 9 ' -> ( Char . code x ) - 48 | ' A ' . . ' Z ' -> ( Char . code x ) - 55 | ' a ' . . ' z ' -> ( Char . code x ) - 97 | _ -> 16
let parseStringLiteral s = let len = String . length s in let b = Buffer . create ( String . length s ) in let rec parse state i d = if i = len then ( match state with | HexEscape | DecimalEscape | OctalEscape -> false | _ -> true ) else let c = String . unsafe_get s i in match state with | Start -> ( match c with | ' ...
let rec parseLident p = let recoverLident p = if ( Token . isKeyword p . Parser . token && p . Parser . prevEndPos . pos_lnum == p . startPos . pos_lnum ) then ( Parser . err p ( Diagnostics . lident p . Parser . token ) ; Parser . next p ; None ) else ( let rec loop p = if not ( Recover . shouldAbortListParse p ) then...
let parseIdent ~ msg ~ startPos p = match p . Parser . token with | Lident ident | Uident ident -> Parser . next p ; let loc = mkLoc startPos p . prevEndPos in ( ident , loc ) | token when Token . isKeyword token && p . prevEndPos . pos_lnum == p . startPos . pos_lnum -> let tokenTxt = Token . toString token in let msg...
let parseHashIdent ~ startPos p = Parser . expect Hash p ; match p . token with | String text -> let text = if p . mode = ParseForTypeChecker then parseStringLiteral text else text in Parser . next p ; ( text , mkLoc startPos p . prevEndPos ) | Int { i ; suffix } -> let ( ) = match suffix with | Some _ -> Parser . err ...
let parseValuePath p = let startPos = p . Parser . startPos in let rec aux p path = match p . Parser . token with | Lident ident -> Longident . Ldot ( path , ident ) | Uident uident -> Parser . next p ; Parser . expect Dot p ; aux p ( Ldot ( path , uident ) ) | token -> Parser . err p ( Diagnostics . unexpected token p...
let parseValuePathTail p startPos ident = let rec loop p path = match p . Parser . token with | Lident ident -> Parser . next p ; Location . mkloc ( Longident . Ldot ( path , ident ) ) ( mkLoc startPos p . prevEndPos ) | Uident ident -> Parser . next p ; Parser . expect Dot p ; loop p ( Longident . Ldot ( path , ident ...
let parseModuleLongIdentTail ~ lowercase p startPos ident = let rec loop p acc = match p . Parser . token with | Lident ident when lowercase -> Parser . next p ; let lident = ( Longident . Ldot ( acc , ident ) ) in Location . mkloc lident ( mkLoc startPos p . prevEndPos ) | Uident ident -> Parser . next p ; let endPos ...
let parseModuleLongIdent ~ lowercase p = let startPos = p . Parser . startPos in let moduleIdent = match p . Parser . token with | Lident ident when lowercase -> let loc = mkLoc startPos p . endPos in let lident = Longident . Lident ident in Parser . next p ; Location . mkloc lident loc | Uident ident -> let lident = L...
let parseIdentPath p = let rec loop p acc = match p . Parser . token with | Uident ident | Lident ident -> Parser . next p ; let lident = ( Longident . Ldot ( acc , ident ) ) in begin match p . Parser . token with | Dot -> Parser . next p ; loop p lident | _ -> lident end | _t -> acc in match p . Parser . token with | ...
let verifyJsxOpeningClosingName p nameExpr = let closing = match p . Parser . token with | Lident lident -> Parser . next p ; Longident . Lident lident | Uident _ -> ( parseModuleLongIdent ~ lowercase : true p ) . txt | _ -> Longident . Lident " " in match nameExpr . Parsetree . pexp_desc with | Pexp_ident openingIdent...
let string_of_pexp_ident nameExpr = match nameExpr . Parsetree . pexp_desc with | Pexp_ident openingIdent -> Longident . flatten openingIdent . txt |> List . filter ( fun s -> s <> " createElement " ) |> String . concat " . " | _ -> " "
let parseOpenDescription ~ attrs p = Parser . leaveBreadcrumb p Grammar . OpenDescription ; let startPos = p . Parser . startPos in Parser . expect Open p ; let override = if Parser . optional p Token . Bang then Asttypes . Override else Asttypes . Fresh in let modident = parseModuleLongIdent ~ lowercase : false p in l...
let parseTemplateStringLiteral s = let len = String . length s in let b = Buffer . create len in let rec loop i = if i < len then let c = String . unsafe_get s i in match c with | ' ' \\ as c -> if i + 1 < len then let nextChar = String . unsafe_get s ( i + 1 ) in begin match nextChar with | ' ' \\ as c -> Buffer . add...
let parseConstant p = let isNegative = match p . Parser . token with | Token . Minus -> Parser . next p ; true | Plus -> Parser . next p ; false | _ -> false in let constant = match p . Parser . token with | Int { i ; suffix } -> let intTxt = if isNegative then " " - ^ i else i in Parsetree . Pconst_integer ( intTxt , ...