stan-dev / stanc3

The Stan transpiler (from Stan to C++ and beyond).
BSD 3-Clause "New" or "Revised" License
138 stars 44 forks source link

Alt: `#include` for stancjs, simpler implementation #1433

Closed WardBrian closed 1 week ago

WardBrian commented 1 week ago

Alternative to #1432, also closes #1430

Rather than using functors, this just makes it so the include_paths variable in the Preprocessor now looks like

type include_provider_t =
  | FileSystemPaths of string list
  | InMemory of string String.Map.t

val include_provider : include_provider_t ref

And this is used in the preprocessor to switch between the two styles.

Submission Checklist

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.

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)

codecov[bot] commented 1 week ago

Codecov Report

Attention: Patch coverage is 92.59259% with 2 lines in your changes missing coverage. Please review.

Project coverage is 89.88%. Comparing base (b46cc7e) to head (e838a56).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1433 +/- ## ========================================== + Coverage 89.83% 89.88% +0.05% ========================================== Files 63 63 Lines 10484 10497 +13 ========================================== + Hits 9418 9435 +17 + Misses 1066 1062 -4 ``` | [Files](https://app.codecov.io/gh/stan-dev/stanc3/pull/1433?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=stan-dev) | Coverage Δ | | |---|---|---| | [src/frontend/Errors.ml](https://app.codecov.io/gh/stan-dev/stanc3/pull/1433?src=pr&el=tree&filepath=src%2Ffrontend%2FErrors.ml&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=stan-dev#diff-c3JjL2Zyb250ZW5kL0Vycm9ycy5tbA==) | `92.59% <100.00%> (+4.59%)` | :arrow_up: | | [src/middle/Location.ml](https://app.codecov.io/gh/stan-dev/stanc3/pull/1433?src=pr&el=tree&filepath=src%2Fmiddle%2FLocation.ml&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=stan-dev#diff-c3JjL21pZGRsZS9Mb2NhdGlvbi5tbA==) | `93.33% <ø> (ø)` | | | [src/stanc/stanc.ml](https://app.codecov.io/gh/stan-dev/stanc3/pull/1433?src=pr&el=tree&filepath=src%2Fstanc%2Fstanc.ml&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=stan-dev#diff-c3JjL3N0YW5jL3N0YW5jLm1s) | `80.71% <100.00%> (+0.13%)` | :arrow_up: | | [src/frontend/Preprocessor.ml](https://app.codecov.io/gh/stan-dev/stanc3/pull/1433?src=pr&el=tree&filepath=src%2Ffrontend%2FPreprocessor.ml&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=stan-dev#diff-c3JjL2Zyb250ZW5kL1ByZXByb2Nlc3Nvci5tbA==) | `97.33% <89.47%> (+0.41%)` | :arrow_up: | ... and [1 file with indirect coverage changes](https://app.codecov.io/gh/stan-dev/stanc3/pull/1433/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=stan-dev)