123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051(*
The MIT License
Copyright (c) 2021 Jason D. Nielsen <drjdnielsen@gmail.com>
*)openLexingletpposlexbuf=letp=lexbuf.lex_curr_pinPrintf.printf"File: %s, line: %d, col: %d, token: %s \n"p.pos_fnamep.pos_lnum(p.pos_cnum-p.pos_bol)(lexemelexbuf)letpsposlexbuf=letp=lexbuf.lex_curr_pinPrintf.sprintf"File: %s, line: %d, col: %d, token: %s"p.pos_fnamep.pos_lnum(p.pos_cnum-p.pos_bol)(lexemelexbuf)letlexemelexbuf=Lexing.lexemelexbufletnew_linelexbuf=Lexing.new_linelexbufletdp_strstr=string_of_float(float_of_stringstr)letp5_boolstr=matchstrwith|"true"->"True"|"false"->"False"|_->failwith"Not a boolean!"letextra_kwds=["define";"definerec";"lambda";"lambda_match";"let*";"range";"sum";"values"]letis_kwdskwdslst=List.memkwdslstletmap_identstr=matchis_kwdsstrextra_kwdswith|true->Tokens.KEYWORDstr|false->Tokens.IDENTstrletin_topl=reffalselettopl_errlexbuf=print_endline"Toplevel commands only allowed in repl!";psposlexbufletcheck_topllexbuf=ifnot!in_toplthenfailwith(topl_errlexbuf)