Some boilerplate-y code in stancjs.ml to read a { [s: string] : string } JS object into a ocaml string String.Map.t
Extracting the logic in the Preprocessor that looks up new included files into a module type that is passed in from the outside
Doing the same in the Lexer
An earlier version of this didn't use functors and just had Preprocessor store a function pointer that was set by stancjs.ml/stanc.ml, but I had both aesthetic and performance concerns with that approach. These functors are ultimately pretty lightweight
This is currently lightly tested in stanc.js but I intend to add more.
Submission Checklist
[x] Run unit tests
Documentation
[ ] If a user-facing facing change was made, the documentation PR is here:
[x] OR, no user-facing changes were made
Release notes
stanc.js can now accept models which contain #include statements. A fourth argument is available on the javascript stanc function which must be either undefined or a object mapping included file names to Stan source code as strings.
Closes #1430
This PR can be viewed as several parts:
{ [s: string] : string }
JS object into a ocamlstring String.Map.t
An earlier version of this didn't use functors and just had
Preprocessor
store a function pointer that was set by stancjs.ml/stanc.ml, but I had both aesthetic and performance concerns with that approach. These functors are ultimately pretty lightweightThis is currently lightly tested in stanc.js but I intend to add more.
Submission Checklist
Release notes
stanc.js
can now accept models which contain#include
statements. A fourth argument is available on the javascriptstanc
function which must be eitherundefined
or a object mapping included file names to Stan source code as strings.Copyright and Licensing
By submitting this pull request, the copyright holder is agreeing to license the submitted work under the BSD 3-clause license (https://opensource.org/licenses/BSD-3-Clause)