Skip to content

Possible to create AST at compile-time? #814

@Cerber-Ursi

Description

@Cerber-Ursi

I'm currently trying to use Rhai for one of my personal projects, and hit an interesting question.

This program will essentially do the following:

  • Build a statically-known module, with a bunch of native functions. One of these functions is essentially "run a source file with this module prepended".
  • Run this function on the source file provided by the user.
  • This source file can contain other calls to the same function, therefore executing other source files with the same context.
  • Continue until the whole files tree is walked.

So this statically-known module, if I understand correctly, can be compiled to AST once and then reused for every source file. But the question is, is it possible to make this AST at build-time, i.e. by calling into the rhai from the build script and emitting something to include_bytes! from? I understand that AST format can be unstable and change from version to version, but since buildscript and the program itself will use the same version, this should not be a problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions