STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
StateScript.hpp File Reference
#include <cstdint>
#include <map>
#include <set>
#include <string>
#include <vector>
Include dependency graph for StateScript.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  fsw::script::SlugRef
 One slug reference, with its source span so a rename can rewrite exactly this token. More...
struct  fsw::script::Stmt
struct  fsw::script::Expr
struct  fsw::script::ScriptProgram
 A parsed script, as a flat arena. More...
struct  fsw::script::Diagnostic
struct  fsw::script::ParseResult
struct  fsw::script::SlugTables
 What a script's slugs are allowed to name, built from the loaded config. More...

Namespaces

namespace  fsw
 Motorized ball valve position: raw ADC counts -> % open.
namespace  fsw::script

Enumerations

enum class  fsw::script::Ns : uint8_t { fsw::script::Actuator , fsw::script::PtSensor , fsw::script::State }
 Which table a slug is resolved against. More...
enum class  fsw::script::StmtKind : uint8_t {
  fsw::script::Assign , fsw::script::OpenValve , fsw::script::CloseValve , fsw::script::Delay ,
  fsw::script::TransitionTo , fsw::script::If , fsw::script::While
}
enum class  fsw::script::ExprKind : uint8_t {
  fsw::script::Number , fsw::script::Var , fsw::script::Pressure , fsw::script::Elapsed ,
  fsw::script::Unary , fsw::script::Binary
}
enum class  fsw::script::Op : uint8_t {
  fsw::script::Neg , fsw::script::Not , fsw::script::Add , fsw::script::Sub ,
  fsw::script::Mul , fsw::script::Div , fsw::script::Lt , fsw::script::Le ,
  fsw::script::Gt , fsw::script::Ge , fsw::script::Eq , fsw::script::Ne ,
  fsw::script::And , fsw::script::Or
}
enum class  fsw::script::Diag : uint16_t {
  fsw::script::TabIndent = 1 , fsw::script::BadIndentUnit , fsw::script::BadDedent , fsw::script::UnexpectedIndent ,
  fsw::script::UnexpectedChar , fsw::script::BadNumber , fsw::script::ExpectedColon , fsw::script::ExpectedLParen ,
  fsw::script::ExpectedRParen , fsw::script::ExpectedNewline , fsw::script::ExpectedName , fsw::script::ExpectedExpr ,
  fsw::script::ExpectedBlock , fsw::script::UnknownCall , fsw::script::ChainedComparison , fsw::script::CallNotAStatement ,
  fsw::script::AssignToCall , fsw::script::ProgramTooLarge , fsw::script::TooManyLines , fsw::script::TooDeep ,
  fsw::script::TooManyStatements , fsw::script::TooManyVariables , fsw::script::ExprTooDeep , fsw::script::DelayNotPositive ,
  fsw::script::LoopWithoutDelay , fsw::script::VarUsedBeforeAssign , fsw::script::DivideByZeroLiteral , fsw::script::UnknownActuator ,
  fsw::script::UnknownSensor , fsw::script::UnknownState , fsw::script::TransitionNotAllowed , fsw::script::VarShadowsSlug
}
 Diagnostic codes. More...

Functions

const char * fsw::script::ns_name (Ns ns)
const char * fsw::script::op_name (Op op)
const char * fsw::script::diag_name (Diag d)
ParseResult fsw::script::parse (const std::string &source)
 Lex and parse, applying every check that does not need config.
std::vector< Diagnostic > fsw::script::validate (const ScriptProgram &program, const SlugTables &tables)
 Config-dependent checks.
std::string fsw::script::slugify (const std::string &name)
 Canonical name -> slug: trim, uppercase, collapse internal whitespace runs to a single '_'.
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_]*$.
std::string fsw::script::print_canonical (const ScriptProgram &program)
 A stable s-expression rendering of the parsed program.

Variables

constexpr size_t fsw::script::kMaxSourceBytes = 4096
constexpr uint32_t fsw::script::kMaxLines = 200
constexpr uint32_t fsw::script::kMaxStatements = 500
constexpr uint32_t fsw::script::kMaxNestingDepth = 8
constexpr uint32_t fsw::script::kMaxVariables = 32
constexpr uint32_t fsw::script::kMaxExprDepth = 32
constexpr uint32_t fsw::script::kMaxIndentUnit = 8
 Widest indent unit accepted.