|  | 
              
                
                  
                  
                  
                        
                    
 Generic function to impose lexing and exhaustion checking on a parser. 
 
                  
                
                  
                    pfn
                  
                  :
                  string list -> 'a * 'b list
                  
                    The input parser.
                  
                  
                    s
                  
                  :
                  string
                  
                    The input string to be parsed.
                   
                
                  
                    Returns: 
                  
                  'a
                  
                    
 The string parsed based on the input parser logic.
 
                   
                  // An oversimplified parser
 let rec parseIntList i = 
     match parseInt i with
     | e1, "," :: i1 ->
         let e2, i2 = parseIntList i1
         e1@e2, i2
     | x -> x
 and parseInt i = 
     match i with
     | [] -> failwith "eof"
     | tok :: i1 -> [int tok], i1
 
 make_parser parseIntList "11,12"
 val parseIntList: i: string list -> int list * string list val i: string list val parseInt: i: string list -> int list * string list val e1: int list val i1: string list val e2: int list val i2: string list val x: int list * string list val failwith: message: string -> 'T val tok: string Multiple itemsEvaluates toval int: value: 'T -> int (requires member op_Explicit)
 
 --------------------
 type int = int32
 
 --------------------
 type int<'Measure> =
  int
 [11; 12]. | 
        
          |  | 
              
                
                  
                  
                  
                        
                    
 Checks if the head of a list (typically the list of unparsed input) is some 
 particular item, but also ?rst checks that the list is nonempty before 
 looking at its head.
                  
                
                  
                    inp
                  
                  :
                  'a list
                  
                    tok
                  
                  :
                  'a 
                
                  
                    Returns: 
                  
                  bool | 
        
          |  | 
              
                
                  
                  
                  
                        
                    
 Applies a function to the first element of a pair, the idea being to 
 modify the returned abstract syntax tree while leaving the 'unparsed 
 input' alone.
 
                  
                
                  
                    f
                  
                  :
                  'a -> 'b
                  
                    ast
                  
                  :
                  'a
                  
                    rest
                  
                  :
                  'c 
                
                  
                    Returns: 
                  
                  'b * 'c | 
        
          |  | 
              
                
                  
                  
                  
                        
                    
 Deals with the common situation of syntactic items enclosed in brackets. It 
 simply calls the subparser and then checks and eliminates the closing 
 bracket. In principle, the terminating character can be anything, so this 
 function could equally be used for other purposes, but we will always use 
 ')' for the cbra ('closing bracket') argument.
                  
                
                  
                    subparser
                  
                  :
                  'a -> 'b * 'c list
                  
                    cbra
                  
                  :
                  'c
                  
                    inp
                  
                  :
                  'a 
                
                  
                    Returns: 
                  
                  'b * 'c list | 
        
          |  | 
              
                
                  
                  
                  
                        
                    
 General parsing of iterated infixes.
 
                  
                
                  
                    opsym
                  
                  :
                  'a
                  
                    opupdate
                  
                  :
                  ('b -> 'c) -> 'b -> 'b -> 'c
                  
                    Modifies the function appropriately when a new item is parsed.
                  
                  
                    sof
                  
                  :
                  'b -> 'c
                  
                    Takes the current input and combines it in some way with the items arrived at so far.
                  
                  
                    subparser
                  
                  :
                  'a list -> 'b * 'a list
                  
                    inp
                  
                  :
                  'a list 
                
                  
                    Returns: 
                  
                  'c * 'a list | 
        
          |  | 
              
                
                  
                  
                  
                        
                    
 Parses left infix.
                  
                
                  
                    opsym
                  
                  :
                  'a
                  
                    opcon
                  
                  :
                  'b * 'b -> 'b 
                
                  
                    Returns: 
                  
                  ('a list -> 'b * 'a list) -> 'a list -> 'b * 'a list | 
        
          |  | 
              
                
                  
                  
                  
                        
                    
 Parses a list: used to parse the list of arguments to a function.
                  
                
                  
                    opsym
                  
                  :
                  'a 
                
                  
                    Returns: 
                  
                  ('a list -> 'b * 'a list) -> 'a list -> 'b list * 'a list | 
        
          |  | 
              
                
                  
                  
                  
                        
                    
 Parses right infix.
                  
                
                  
                    opsym
                  
                  :
                  'a
                  
                    opcon
                  
                  :
                  'b * 'b -> 'b 
                
                  
                    Returns: 
                  
                  ('a list -> 'b * 'a list) -> 'a list -> 'b * 'a list |