|
STAR
Cal STAR — firmware, DAQ server, and engine design
|
Namespaces | |
| namespace | anonymous_namespace{Lexer.cpp} |
| namespace | anonymous_namespace{Parser.cpp} |
| namespace | anonymous_namespace{ScriptConfig.cpp} |
| namespace | anonymous_namespace{Validate.cpp} |
Classes | |
| struct | BadSlug |
| A name that could not be turned into a usable slug, reported so config can refuse it loudly. More... | |
| struct | SlugCollision |
| Two config names in one namespace that slug to the same identifier — genuinely ambiguous. More... | |
| struct | TableBuild |
| struct | SlugRef |
| One slug reference, with its source span so a rename can rewrite exactly this token. More... | |
| struct | Stmt |
| struct | Expr |
| struct | ScriptProgram |
| A parsed script, as a flat arena. More... | |
| struct | Diagnostic |
| struct | ParseResult |
| struct | SlugTables |
| What a script's slugs are allowed to name, built from the loaded config. More... | |
| struct | Token |
| struct | LexResult |
Functions | |
| TableBuild | build_slug_tables (const fsw::config::Config &cfg) |
| Build the actuator / sensor / state slug tables from a loaded config. | |
| const char * | ns_name (Ns ns) |
| const char * | op_name (Op op) |
| const char * | diag_name (Diag d) |
| ParseResult | parse (const std::string &source) |
| Lex and parse, applying every check that does not need config. | |
| std::vector< Diagnostic > | validate (const ScriptProgram &program, const SlugTables &tables) |
| Config-dependent checks. | |
| std::string | slugify (const std::string &name) |
| Canonical name -> slug: trim, uppercase, collapse internal whitespace runs to a single '_'. | |
| bool | is_valid_slug (const std::string &slug) |
| True when a slug is usable as a bare identifier: ^[A-Z][A-Z0-9_]*$. | |
| std::string | print_canonical (const ScriptProgram &program) |
| A stable s-expression rendering of the parsed program. | |
| const char * | tok_name (Tok t) |
| LexResult | lex (const std::string &source) |
| Tokenize, emitting INDENT/DEDENT for block structure. | |
Variables | |
| constexpr size_t | kMaxSourceBytes = 4096 |
| constexpr uint32_t | kMaxLines = 200 |
| constexpr uint32_t | kMaxStatements = 500 |
| constexpr uint32_t | kMaxNestingDepth = 8 |
| constexpr uint32_t | kMaxVariables = 32 |
| constexpr uint32_t | kMaxExprDepth = 32 |
| constexpr uint32_t | kMaxIndentUnit = 8 |
| Widest indent unit accepted. | |
|
strong |
Diagnostic codes.
Tests and the shared corpus assert on the CODE and the LINE, never the message text, so wording can improve without churning them.
Definition at line 182 of file StateScript.hpp.
|
strong |
| Enumerator | |
|---|---|
| Number | |
| Var | |
| Pressure | |
| Elapsed | |
| Unary | |
| Binary | |
Definition at line 93 of file StateScript.hpp.
|
strong |
Which table a slug is resolved against.
Determined by argument position, never by spelling.
| Enumerator | |
|---|---|
| Actuator | |
| PtSensor | |
| State | |
Definition at line 66 of file StateScript.hpp.
|
strong |
| Enumerator | |
|---|---|
| Neg | |
| Not | |
| Add | |
| Sub | |
| Mul | |
| Div | |
| Lt | |
| Le | |
| Gt | |
| Ge | |
| Eq | |
| Ne | |
| And | |
| Or | |
Definition at line 102 of file StateScript.hpp.
|
strong |
| Enumerator | |
|---|---|
| Assign | |
| OpenValve | |
| CloseValve | |
| Delay | |
| TransitionTo | |
| If | |
| While | |
Definition at line 83 of file StateScript.hpp.
|
strong |
| TableBuild fsw::script::build_slug_tables | ( | const fsw::config::Config & | cfg | ) |
Build the actuator / sensor / state slug tables from a loaded config.
allowed_transitions is left empty — it depends on which state owns the script and on state_transitions.csv, neither of which this library reads. The caller fills it.
Collisions are reported per namespace only. Across namespaces they are expected and harmless: on the shipped server profile FUEL_VENT is both a valve and a state, and on digital-twin FUEL_UPSTREAM is both a valve and a sensor. Positional resolution is what makes that fine, and a blanket collision rule would refuse config that runs today.
Definition at line 36 of file ScriptConfig.cpp.
References fsw::config::pt_role_tables().
Referenced by sequencer::load_dynamic_states(), main(), and main().
| const char * fsw::script::diag_name | ( | Diag | d | ) |
Definition at line 56 of file Parser.cpp.
References AssignToCall, BadDedent, BadIndentUnit, BadNumber, CallNotAStatement, ChainedComparison, DelayNotPositive, DivideByZeroLiteral, ExpectedBlock, ExpectedColon, ExpectedExpr, ExpectedLParen, ExpectedName, ExpectedNewline, ExpectedRParen, ExprTooDeep, LoopWithoutDelay, ProgramTooLarge, TabIndent, TooDeep, TooManyLines, TooManyStatements, TooManyVariables, TransitionNotAllowed, UnexpectedChar, UnexpectedIndent, UnknownActuator, UnknownCall, UnknownSensor, UnknownState, VarShadowsSlug, and VarUsedBeforeAssign.
| bool fsw::script::is_valid_slug | ( | const std::string & | slug | ) |
True when a slug is usable as a bare identifier: ^[A-Z][A-Z0-9_]*$.
Definition at line 29 of file Slug.cpp.
References ok.
Referenced by fsw::script::anonymous_namespace{ScriptConfig.cpp}::addName(), and main().
| LexResult fsw::script::lex | ( | const std::string & | source | ) |
Tokenize, emitting INDENT/DEDENT for block structure.
Stops at the first error. Every ambiguity Python resolves by convention is rejected here instead: tabs are refused outright (the editor is a bare <textarea>, where mixed indentation is invisible on screen and the failure mode is a valve opening in the wrong branch), and the first indented line fixes the indent unit that every later indent must be an exact multiple of.
Definition at line 390 of file Lexer.cpp.
References kMaxLines, kMaxSourceBytes, ProgramTooLarge, and TooManyLines.
Referenced by parse().
| const char * fsw::script::ns_name | ( | Ns | ns | ) |
Definition at line 10 of file Parser.cpp.
References Actuator, PtSensor, and State.
Referenced by fsw::script::anonymous_namespace{Parser.cpp}::Parser::parseSimple(), and validate().
| const char * fsw::script::op_name | ( | Op | op | ) |
| ParseResult fsw::script::parse | ( | const std::string & | source | ) |
Lex and parse, applying every check that does not need config.
Stops at the first error rather than attempting recovery: this is a 200-line config language written a few lines at a time, and a cascade of speculative follow-on errors would bury the one that matters.
Definition at line 813 of file Parser.cpp.
References fsw::script::LexResult::diagnostics, lex(), fsw::script::LexResult::ok(), result, and fsw::script::LexResult::tokens.
Referenced by sequencer::load_dynamic_states(), main(), main(), and run().
| std::string fsw::script::print_canonical | ( | const ScriptProgram & | program | ) |
A stable s-expression rendering of the parsed program.
This exists for the conformance corpus. Two implementations can agree that a script is "accepted" while disagreeing about precedence — a - b - c, not a and b, -x * y — and a precedence disagreement between the validator the operator sees and the interpreter that opens the valve is the worst bug this feature can have. Pinning the shape catches it.
Definition at line 927 of file Parser.cpp.
References fsw::script::ScriptProgram::top_begin, and fsw::script::ScriptProgram::top_end.
Referenced by main().
| std::string fsw::script::slugify | ( | const std::string & | name | ) |
Canonical name -> slug: trim, uppercase, collapse internal whitespace runs to a single '_'.
The same rule the TS side already uses for sensor entity names (backend/src/sensor-config.ts:104), so the two agree by construction.
Definition at line 8 of file Slug.cpp.
Referenced by fsw::script::anonymous_namespace{ScriptConfig.cpp}::addName(), sequencer::load_dynamic_states(), main(), main(), and validate().
| const char * fsw::script::tok_name | ( | Tok | t | ) |
Definition at line 9 of file Lexer.cpp.
References Assign, Colon, Comma, Dedent, Eof, EqEq, Ge, Gt, Ident, Indent, KwAnd, KwElif, KwElse, KwIf, KwNot, KwOr, KwWhile, Le, LParen, Lt, Minus, Ne, Newline, Number, Plus, RParen, Slash, and Star.
Referenced by fsw::script::anonymous_namespace{Parser.cpp}::Parser::expect(), fsw::script::anonymous_namespace{Parser.cpp}::Parser::parsePrimary(), fsw::script::anonymous_namespace{Parser.cpp}::Parser::parseSimple(), and fsw::script::anonymous_namespace{Parser.cpp}::Parser::run().
| std::vector< Diagnostic > fsw::script::validate | ( | const ScriptProgram & | program, |
| const SlugTables & | tables ) |
Config-dependent checks.
Run after a successful parse; returns empty when the script is good.
Definition at line 69 of file Validate.cpp.
References a, Actuator, Assign, b, fsw::script::SlugRef::col, fsw::script::Stmt::col, fsw::script::Stmt::kind, fsw::script::SlugRef::line, fsw::script::Stmt::line, fsw::script::SlugRef::ns, ns_name(), PtSensor, fsw::script::SlugRef::slug, slugify(), fsw::script::ScriptProgram::slugs, State, fsw::script::ScriptProgram::stmts, tables(), TransitionNotAllowed, UnknownActuator, UnknownSensor, UnknownState, fsw::script::Stmt::var, fsw::script::ScriptProgram::variables, and VarShadowsSlug.
Referenced by sequencer::load_dynamic_states(), main(), main(), and run().
|
inlineconstexpr |
Definition at line 60 of file StateScript.hpp.
Referenced by fsw::script::anonymous_namespace{Parser.cpp}::Parser::parseExpr(), and fsw::script::anonymous_namespace{Parser.cpp}::Parser::parsePrimary().
|
inlineconstexpr |
Widest indent unit accepted.
The first indented line sets the unit; every later indent must be an exact multiple of it, which kills "3 spaces here, 4 there" without a stack of columns.
Definition at line 63 of file StateScript.hpp.
Referenced by fsw::script::anonymous_namespace{Lexer.cpp}::Lexer::handleLineStart().
|
inlineconstexpr |
Definition at line 56 of file StateScript.hpp.
|
inlineconstexpr |
Definition at line 58 of file StateScript.hpp.
Referenced by main(), and fsw::script::anonymous_namespace{Parser.cpp}::Parser::parseIndentedBlock().
|
inlineconstexpr |
Definition at line 55 of file StateScript.hpp.
|
inlineconstexpr |
Definition at line 57 of file StateScript.hpp.
Referenced by fsw::script::anonymous_namespace{Parser.cpp}::Parser::parseStatement().
|
inlineconstexpr |
Definition at line 59 of file StateScript.hpp.
Referenced by fsw::script::anonymous_namespace{Parser.cpp}::Parser::parseSimple().