1234567891011121314151617181920212223242526272829303132333435(* Claude Code
*
* Copyright (C) 2026 Yoann Padioleau
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License
* (LGPL) as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*)openLisp(* See Lisp_read.mli *)exceptionErrorofstring(* the tree into Emacs's values: a character is its code, and a list is
conses ending with nil or with the dotted tail *)letrecof_sexpr(x:Sexpr.t):Lisp.t=matchx.datumwith|Intn|Charn->Intn|Strs->Strs|Syms->Syms|List(xs,tail)->List.fold_right(funxrest->Cons(of_sexprx,rest))xs(matchtailwithSomet->of_sexprt|None->nil)(* the Emacs dialect of the reader makes none of these *)|Float_|Bool_|Vector_->raise(Error"not Emacs Lisp")letread(s:string)(pos:int):Lisp.t*int=matchSexpr_read.readEmacssposwith|x,j->(of_sexprx,j)|exceptionSexpr_read.Error(msg,_)->raise(Errormsg)letread_all(s:string):Lisp.tlist=matchSexpr_read.read_allEmacsswithxs->List.mapof_sexprxs|exceptionSexpr_read.Error(msg,_)->raise(Errormsg)letonly_blank(s:string)(pos:int):bool=Sexpr_read.only_blankEmacsspos