accordproject / ergo

Programming Language for Smart Legal Contracts
https://accordproject.org/projects/ergo
Apache License 2.0
157 stars 55 forks source link

Parsing dates in online REPL #553

Open jeromesimeon opened 5 years ago

jeromesimeon commented 5 years ago

Using some date operations in the JavaScript version of the Ergo REPL (e.g., at https://ergorepl.netlify.com) will fail. This is due to the calendar library which uses the OCaml Str library which isn't supported by js_of_ocaml.

We should switch to the (hopefully) upcoming version of Calendar from https://github.com/ocaml-community/calendar which relies on Re.Str as soon as it is available on opam.

jeromesimeon commented 5 years ago

The relevant js_of_ocaml warning during compilation:

ocamlfind ocamlc -linkpkg -package js_of_ocaml.ppx -package js_of_ocaml -package calendar -package re.str -package base64 -package unix -package atdgen -I src -I extracted src/DateTime.cmo src/Monitor_t.cmo src/Monitor_j.cmo src/Util.cmo extracted/ErgoComp.cmo src/Cto_t.cmo extracted/Resources.cmo src/ErgoStdlib.cmo src/ErgoUtil.cmo src/Cto_j.cmo src/CtoImport.cmo src/LexUtil.cmo src/ErgoParser.cmo src/ErgoLexer.cmo src/ParseUtil.cmo src/ErgoConfig.cmo src/PrettyCommon.cmo src/PrettyIL.cmo src/ErgoCompile.cmo ergoc.cmo ergocJS.cmo -o ergocJS.byte
js_of_ocaml _build_js/ergocJS.byte -o _build_js/ergocJS.js
There are some missing primitives
Dummy implementations (raising 'Failure' exception) will be used if they are not available at runtime.
You can prevent the generation of dummy implementations with the commandline option '--disable genprim'
Missing primitives:
  re_search_forward
jeromesimeon commented 5 years ago

There is hope of a new release. Most recent thread about that is at https://github.com/ocaml-community/calendar/pull/26