let rec main buf lexbuf =
    __ocaml_lex_main_rec buf lexbuf 0
and __ocaml_lex_main_rec buf lexbuf __ocaml_lex_state =
  match Lexing.engine __ocaml_lex_tables __ocaml_lex_state lexbuf with
      | 0 ->
# 75 "lexer.mll"
            ( found_newline lexbuf 1; main buf lexbuf )
# 204 "lexer.ml"

  | 1 ->
# 76 "lexer.mll"
           ( main buf lexbuf )
# 209 "lexer.ml"

  | 2 ->
# 77 "lexer.mll"
                       ( main buf lexbuf )
# 214 "lexer.ml"

  | 3 ->
# 78 "lexer.mll"
        ( LPAREN )
# 219 "lexer.ml"

  | 4 ->
# 79 "lexer.mll"
        ( RPAREN )
# 224 "lexer.ml"

  | 5 ->
# 81 "lexer.mll"
      (
        scan_string buf lexbuf;
        let str = Buffer.contents buf in
        Buffer.clear buf;
        STRING str
      )
# 234 "lexer.ml"

  | 6 ->
let
# 87 "lexer.mll"
                                           str
# 240 "lexer.ml"
Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_start_pos lexbuf.Lexing.lex_curr_pos in
# 87 "lexer.mll"
                                               ( STRING str )
# 244 "lexer.ml"

  | 7 ->
# 88 "lexer.mll"
        ( EOF )
# 249 "lexer.ml"

  | __ocaml_lex_state -> lexbuf.Lexing.refill_buff lexbuf; __ocaml_lex_main_rec buf lexbuf __ocaml_lex_state

and scan_string buf lexbuf =
    __ocaml_lex_scan_string_rec buf lexbuf 11
and __ocaml_lex_scan_string_rec buf lexbuf __ocaml_lex_state =
  match Lexing.engine __ocaml_lex_tables __ocaml_lex_state lexbuf with
      | 0 ->
# 91 "lexer.mll"
        ( () )
# 260 "lexer.ml"

  | 1 ->
# 93 "lexer.mll"
      (
        let len = get_lexeme_len lexbuf in
        found_newline lexbuf (len - 2);
        scan_string buf lexbuf
      )
# 269 "lexer.ml"

  | 2 ->
# 99 "lexer.mll"
      (
        let len = get_lexeme_len lexbuf in
        found_newline lexbuf (len - 3);
        scan_string buf lexbuf
      )
# 278 "lexer.ml"

  | 3 ->
let
# 104 "lexer.mll"
                               c
# 284 "lexer.ml"
Lexing.sub_lexeme_char lexbuf (lexbuf.Lexing.lex_start_pos + 1) in
# 105 "lexer.mll"
      (
        Buffer.add_char buf (char_for_backslash c);
        scan_string buf lexbuf
      )
# 291 "lexer.ml"

  | 4 ->
let
# 109 "lexer.mll"
                       c1
# 297 "lexer.ml"
Lexing.sub_lexeme_char lexbuf (lexbuf.Lexing.lex_start_pos + 1)
and
# 109 "lexer.mll"
                                         c2
# 302 "lexer.ml"
Lexing.sub_lexeme_char lexbuf (lexbuf.Lexing.lex_start_pos + 2)
and
# 109 "lexer.mll"
                                                            c3
# 307 "lexer.ml"
Lexing.sub_lexeme_char lexbuf (lexbuf.Lexing.lex_start_pos + 3) in
# 110 "lexer.mll"
      (
        let v = dec_code c1 c2 c3 in
        if v > 255 then (
          let pos = lexbuf.lex_curr_p in
          let msg =
            sprintf
              "Sexplib.Lexer.scan_string: illegal escape at line %d char %d: `\\%c%c%c'"
              pos.pos_lnum (pos.pos_cnum - pos.pos_bol - 3)
              c1 c2 c3 in
          failwith msg);
        Buffer.add_char buf (Char.chr v);
        scan_string buf lexbuf
      )
# 324 "lexer.ml"

  | 5 ->
let
# 124 "lexer.mll"
                                           c1
# 330 "lexer.ml"
Lexing.sub_lexeme_char lexbuf (lexbuf.Lexing.lex_start_pos + 2)
and
# 124 "lexer.mll"
                                                                             c2
# 335 "lexer.ml"
Lexing.sub_lexeme_char lexbuf (lexbuf.Lexing.lex_start_pos + 3) in
# 125 "lexer.mll"
      (
        let v = hex_code c1 c2 in
        if v > 255 then (
          let pos = lexbuf.lex_curr_p in
          let msg =
            sprintf
              "Sexplib.Lexer.scan_string: illegal escape at line %d char %d: `\\x%c%c'"
              pos.pos_lnum (pos.pos_cnum - pos.pos_bol - 3)
              c1 c2 in
          failwith msg);
        Buffer.add_char buf (Char.chr v);
        scan_string buf lexbuf
      )
# 352 "lexer.ml"

  | 6 ->
let
# 139 "lexer.mll"
               c
# 358 "lexer.ml"
Lexing.sub_lexeme_char lexbuf (lexbuf.Lexing.lex_start_pos + 1) in
# 140 "lexer.mll"
      (
        Buffer.add_char buf '\\';
        Buffer.add_char buf c;
        scan_string buf lexbuf
      )
# 366 "lexer.ml"

  | 7 ->
let
# 145 "lexer.mll"
                       c
# 372 "lexer.ml"
Lexing.sub_lexeme_char lexbuf lexbuf.Lexing.lex_start_pos in
# 146 "lexer.mll"
      (
        found_newline lexbuf 1;
        Buffer.add_char buf c;
        scan_string buf lexbuf
      )
# 380 "lexer.ml"

  | 8 ->
# 152 "lexer.mll"
      (
        found_newline lexbuf 2;
        Buffer.add_string buf double_nl;
        scan_string buf lexbuf
      )
# 389 "lexer.ml"

  | 9 ->
# 158 "lexer.mll"
      (
        let ofs = lexbuf.lex_start_pos in
        let len = lexbuf.lex_curr_pos - ofs in
        Buffer.add_substring buf lexbuf.lex_buffer ofs len;
        scan_string buf lexbuf
      )
# 399 "lexer.ml"

  | 10 ->
# 164 "lexer.mll"
        ( failwith "Sexplib.Lexer.scan_string: unterminated string" )
# 404 "lexer.ml"

  | __ocaml_lex_state -> lexbuf.Lexing.refill_buff lexbuf; __ocaml_lex_scan_string_rec buf lexbuf __ocaml_lex_state