branec

Function compile_iter

Source
pub async fn compile_iter(
    state: &mut CompileState,
    source: &mut String,
    lang: Language,
    iname: impl AsRef<str>,
    input: &mut impl BufRead,
    oname: impl AsRef<str>,
    output: &mut impl Write,
    pretty: bool,
    compact: bool,
    packages_loc: &IndexLocation,
    data_loc: &IndexLocation,
    raw_assets: bool,
) -> Result<(), CompileError>
Expand description

Compiles a snippet of BraneScript statefully.

§Arguments

  • state: The CompileState that allows us to make repeated calls that are sensible.
  • lang: The language to compile.
  • iname: Some name useful for the reader to identify where is being read from.
  • input: The reader to read the snippet from.
  • source: The (automatically updated) total source, used for debugging.
  • oname: Some name useful for the user to identify where is being written to.
  • output: The Writer to write the output to.
  • pretty: If given, does not serialize to JSON but with brane_ast::traversals::print::ast.
  • compact: If given, serializes with as little whitespace as possible. Decreases the resulting size greatly, but also readability.
  • packages_loc: Where to get the package index from. Implemented as an IndexLocation so it may be both local or remote.
  • data_loc: Where to get the data index from. Implemented as an IndexLocation so it may be both local or remote.
  • raw_assets: If true, don’t read the package and data “canonically” but instead read them for testing purposes.

§Returns

Nothing directly, but does write the result to output and appends the input snippet to source.

§Errors

This function errors if the input is not valid BraneScript or an IO error occurred trying to read from / write to the input / output.