diff --git a/AGENTS.md b/AGENTS.md index 50b6dc0..96fd565 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,6 +1,6 @@ -# Repository Guidelines +# Generato -Generato is a Wolfram Language code generator that produces C/C++ from symbolic tensor expressions using xAct. +Wolfram Language code generator that produces C/C++ from symbolic tensor expressions using xAct. ## Running @@ -13,14 +13,16 @@ Generato file1.wl file2.wl # Multiple files ## Architecture ### Core (src/) -- **Context.wl** - Global state via `$CurrentContext` +- **Generato.wl** - Package loader, imports modules in dependency order +- **Context.wl** - Global state via `$CurrentContext`, accessor generation - **Basic.wl** - Config, tensor utilities, SetEQN/SetEQNDelayed -- **ParseMode.wl** - Phase management, WithMode for scoped settings +- **ParseMode.wl** - Phase management, `WithMode[{...}, body]` for scoped settings - **Component.wl** - Tensor component to varlist mapping - **Varlist.wl** - Tensor definitions via ParseVarlist -- **Interface.wl** - Public API (DefTensors, GridTensors, TileTensors, TempTensors, SetComponents, PrintEquations, PrintInitializations) +- **Interface.wl** - Public API: DefTensors, GridTensors, TileTensors, TempTensors, SetComponents, PrintEquations, PrintInitializations - **BackendCommon.wl** - Shared backend utilities - **Writefile.wl** - Output buffering (SetMainPrint/GetMainPrint) +- **stencils/FiniteDifferenceStencils.wl** - Finite difference stencil generation ### Backends (codes/) Each implements `PrintComponentInitialization` and `PrintComponentEquation`: @@ -28,7 +30,8 @@ Each implements `PrintComponentInitialization` and `PrintComponentEquation`: ### Key Patterns - **State**: All in `$CurrentContext`; use `WithMode[{...}, body]` for scoped settings -- **Two phases**: SetComp (map components) then PrintComp (generate code) +- **Two phases**: SetComp (map components) → PrintComp (generate code) +- **Equations**: Use `SetEQN` normally; use `SetEQNDelayed` when RHS contains `If` statements ## Tests @@ -37,7 +40,7 @@ wolframscript -script test/AllTests.wl # All tests wolframscript -script test/AllTests.wl --unit-only # Unit tests only ``` -## Wolframscript Tips +## Tips Shell escaping with backticks causes errors. Use pipe instead: ```bash