Skip to main content

Crate pasta_lua

Crate pasta_lua 

Source
Expand description

Pasta Lua - Lua integration for Pasta DSL

This crate provides a Lua transpiler for Pasta DSL, converting Pasta AST to Lua source code. It follows the same architecture as pasta_rune but targets Lua 5.3+ instead of Rune VM.

§Architecture

  • LuaTranspiler: Main transpiler interface
  • LuaCodeGenerator: Generates Lua code from AST nodes
  • StringLiteralizer: Converts strings to optimal Lua literal format
  • TranspileContext: Manages state during transpilation
  • TranspilerConfig: Configuration options
  • PastaLuaRuntime: Lua VM host with pasta module integration

§Example

use pasta_lua::{LuaTranspiler, TranspilerConfig, PastaLuaRuntime};

let transpiler = LuaTranspiler::default();
let mut output = Vec::new();

let context = transpiler.transpile(&actors, &scenes, &mut output)?;
let lua_code = String::from_utf8(output)?;

// Create runtime with the context
let runtime = PastaLuaRuntime::new(context)?;
runtime.exec(&lua_code)?;

Re-exports§

pub use code_gen::LuaCodeGenerator;
pub use config::LineEnding;
pub use config::TranspilerConfig;
pub use context::TranspileContext;
pub use debug::DebugConfig;
pub use debug::DebugError;
pub use debug::DebugHandle;
pub use debug::SourceMode;
pub use debug::enable as enable_debug;
pub use encoding::Encoder;
pub use encoding::Encoding;
pub use error::ConfigError;
pub use error::TranspileError;
pub use loader::CacheManager;
pub use loader::DebugFileConfig;
pub use loader::LoaderConfig;
pub use loader::LoaderContext;
pub use loader::LoaderError;
pub use loader::LoggingConfig;
pub use loader::LuaConfig;
pub use loader::PastaConfig;
pub use loader::PastaLoader;
pub use loader::TalkConfig;
pub use loader::TranspileFailure;
pub use loader::TranspileResult;
pub use loader::default_debug_port;
pub use loader::default_libs;
pub use logging::GlobalLoggerRegistry;
pub use logging::LoadDirGuard;
pub use logging::PastaLogger;
pub use logging::get_current_load_dir;
pub use logging::init_tracing_with_reload;
pub use logging::set_current_load_dir;
pub use logging::update_tracing_filter;
pub use runtime::PastaLuaRuntime;
pub use runtime::RuntimeConfig;
pub use search::SearchContext;
pub use search::SearchError;
pub use string_literalizer::StringLiteralizer;
pub use transpiler::LuaTranspiler;
pub use mlua;

Modules§

code_gen
Lua code generator for Pasta DSL.
config
Transpiler configuration for Lua code generation.
context
Transpile context for Lua code generation.
debug
Rust-hosted DAP debug backend for pasta_lua (SHIORI-independent).
encoding
Encoding conversion module for Windows ANSI code page support.
error
Error types for Pasta Lua transpiler.
loader
Pasta Loader - Startup sequence orchestration.
logging
Logging module for pasta_lua.
normalize
Output normalization for Pasta Lua transpiler.
runtime
Pasta Lua Runtime - Lua VM host for Pasta scripts.
sakura_script
Sakura Script Module - Wait insertion for talk text.
search
Pasta Search Module - Lua bindings for scene and word search.
string_literalizer
StringLiteralizer - Lua string literal conversion.
transpiler
Lua Transpiler for Pasta DSL.