Expand description
Surface-level syntax translation between languages.
moss-surface-syntax provides a common IR for imperative code and
translates between language syntaxes (TypeScript, Lua, etc.) at the
surface level - it maps syntax, not deep semantics.
§Architecture
Source Languages IR Target Languages
──────────────── ───────────── ────────────────────
TypeScript ─┐ ┌─> TypeScript
Lua ─┼─> Program ─────┼─> Lua
(future) ─┘ (ir.rs) └─> (future)§Example
ⓘ
use normalize_surface_syntax::{input, output};
// Read TypeScript
let ir = input::read_typescript("const x = 1 + 2;")?;
// Write to Lua
let lua = output::LuaWriter::emit(&ir);
// => "local x = (1 + 2)"§S-Expression Format
The IR can be serialized to a compact S-expression format (JSON arrays):
["std.let", "x", 1]→ variable binding["math.add", left, right]→ binary operation["console.log", "hello"]→ function call
This format is used for storage (e.g., lotus verbs).
§Note on Translation Fidelity
This is surface-level translation, not semantic transpilation like Haxe or ReScript. The IR captures syntax structure; domain semantics are handled by the runtime (e.g., spore).
Re-exports§
pub use ir::BinaryOp;pub use ir::Expr;pub use ir::Function;pub use ir::Literal;pub use ir::Program;pub use ir::Stmt;pub use ir::StructureEq;pub use ir::UnaryOp;pub use traits::ReadError;pub use traits::Reader;pub use traits::Writer;pub use registry::reader_for_extension;pub use registry::reader_for_language;pub use registry::readers;pub use registry::register_reader;pub use registry::register_writer;pub use registry::writer_for_language;pub use registry::writers;pub use input::read_typescript;pub use input::typescript::TypeScriptReader;pub use output::LuaWriter;pub use output::lua::LuaWriterImpl;