#ifndef __JetAST_h__ #define __JetAST_h__ #include #include #include namespace jetc { enum class NodeKind { TEXT, VAR, SET, IF, FOR, WHILE, FALLBACK }; 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 // FALLBACK - exact original source text of one unsupported tag std::string rawSpan; }; } #endif