#ifndef __JetAST_h__ #define __JetAST_h__ #include #include #include namespace jetc { enum class NodeKind { TEXT, VAR, SET, IF, FOR, WHILE, FALLBACK, TAGDEF, CONTAINER_SLOT }; enum class CondMode { VALUES, EXPR }; struct Node; using NodePtr = std::shared_ptr; struct Cond { CondMode mode = CondMode::EXPR; std::string value1, value2, type; // VALUES mode std::string expr; // EXPR mode }; struct Node { NodeKind kind; // TEXT std::string text; // VAR - raw source slice, e.g. "$[@greeting]" or "#[foo]" std::string varText; // SET std::string setName; bool setHasValue = false; std::string setValue; bool setHasExpr = false; std::string setExpr; std::string setScope; // "" = default/global // IF Cond cond; std::vector thenBody; std::vector elseBody; bool hasElse = false; // FOR bool forHasStart = false; std::string forStart; std::string forEnd; std::string forStep; bool forHasName = false; std::string forName; std::string forScope; std::vector body; // also used by WHILE // TAGDEF - a top-level ... custom-tag definition // (only recognized at the file's true top level - see Parser::topLevel; // one nested inside another tag's own definition body stays FALLBACK, // unchanged). tagDefName is already lowercased, matching __tag.cpp's // own registration key. tagDefBody is the compiled definition body // (may itself contain CONTAINER_SLOT nodes for markers, // and FALLBACK leaves for anything still unsupported). rawSpan // (shared with FALLBACK, below) still holds the exact original source // text - codegen still emits the same raw interpretSpan-based // registration into global.tags alongside the new compiled fast path, // so anything that reaches this tag some other way keeps working // exactly as it does today. std::string tagDefName; std::vector tagDefBody; // CONTAINER_SLOT - a marker (see Tag::renderContainer) - // a pure leaf, no extra fields. // FALLBACK - exact original source text of one unsupported tag std::string rawSpan; }; } #endif