Commit 9867c0d5 authored by Kim Nguyễn's avatar Kim Nguyễn
Browse files

Add a workaround for the parsing of long identifiers.

parent bcbb6528
(* Compatibilty for OCaml 4.11 & 4.12 *)
open Cduce_core
let () =Printexc.record_backtrace true
let longident_parse s =
let open Ocaml_common in
match String.index_opt s '.' with
| None -> Longident.Lident s
| _ -> Parse.longident (Lexing.from_string s)
let open Ocaml_common in
let rec loop first s =
match String.rindex_opt s '.' with
| None -> Longident.Lident s
| Some i ->
try
Parse.longident (Lexing.from_string s)
with
_ -> try
Parse.val_ident (Lexing.from_string s)
with
_ -> try Parse.constr_ident (Lexing.from_string s) with
| e -> (* last resort *)
if first then
let p, s = String.sub s 0 i, String.sub s (i+1) (String.length s - i - 1) in
let s = p ^".(" ^ s ^")" in
loop false s
else raise e
in loop true s
module Mlstub = struct
let noloc id = Some id
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment