67#include <unordered_map>
70namespace ZenitUI::ZMarkup
80 std::string_view
trim(std::string_view s);
91 std::vector<std::string_view>
splitBy(std::string_view s,
char sep);
94 std::vector<std::string_view>
splitWs(std::string_view s);
127 std::string_view keyRaw,
128 std::string_view valRaw,
131 bool strict =
false);
154 std::vector<SimpleSelector> chain;
156 std::vector<Declaration> decls;
158 std::optional<MediaQuery> media;
160 std::vector<Rule> rules;
166 std::vector<Declaration> decls;
174 std::vector<KfFrame> frames;
177 std::vector<KfRule> keyframes;
179 std::unordered_map<std::string, std::string> vars;
180 std::vector<Declaration> rootDecls;
210 std::string fileName;
212 bool strict_ =
false;
214 const Registry *registry_ =
nullptr;
221 SourceSpan spanFrom(
int l,
int c, std::uint32_t length = 0)
const;
224 bool atEnd()
const {
return p >= src.size(); }
225 char peek()
const {
return atEnd() ?
'\0' : src[p]; }
228 bool matchStr(std::string_view s);
230 std::string readIdent();
233 void parseKeyframes();
235 MediaQuery parseMediaQuery(
const std::string &s);
236 static float parseAspectRatio(
const std::string &s);
237 void parseRuleWithMedia(
const MediaQuery &media);
238 void parseRule(
const MediaQuery *media =
nullptr);
271 bool strict =
false);
300 const std::string &fileName =
"<string>",
303 const Registry *registry =
nullptr);
313 const Registry *registry =
nullptr);
Centralized standard library includes used throughout ZenitUI.
Structured diagnostics for the CSS parser and style resolver.
The Style / ComputedStyle pair and all style-related value types.
Global stylesheet storage and rule matching.
Abstract destination for diagnostics.
Definition Diagnostics.hpp:127
Per-context stylesheet: rules, keyframes, and root style.
Definition Theme.hpp:164
Tag → factory map plus the prefab table (either per-UIContext or standalone/global).
Definition ZMarkup.hpp:215
StyleParser(std::string_view src, std::string fileName, DiagnosticSink &sink)
Construct a parser reporting diagnostics into sink.
void setRegistry(const Registry *reg) noexcept
Use a specific Registry for part validation (defaults to global registry).
Definition StyleParser.hpp:203
StyleSheet parse()
Parse the whole source into a StyleSheet.
StyleParser(std::string_view src, std::string fileName)
Construct a parser logging warnings through Logger.
void setStrict(bool s) noexcept
Enable strict mode: unknown properties and pseudo-classes become errors.
Definition StyleParser.hpp:200
bool loadStyleString(std::string_view src, Theme &theme, const std::string &fileName="<string>", DiagnosticSink *sink=nullptr, bool strict=false, const Registry *registry=nullptr)
Parse src and apply it to theme.
void applyStyleSheet(const StyleSheet &sheet, Theme &theme, DiagnosticSink *sink=nullptr, bool strict=false)
Apply a parsed StyleSheet to a Theme.
DiagnosticSeverity
Diagnostic severity level.
Definition Diagnostics.hpp:52
bool loadStyleFile(const std::filesystem::path &path, Theme &theme, DiagnosticSink *sink=nullptr, bool strict=false, const Registry *registry=nullptr)
Load a stylesheet from a file and apply it to theme.
void lintStyleSheet(const StyleSheet &sheet, DiagnosticSink &sink, const StyleLintOptions &opts={})
Run static semantic checks on a parsed StyleSheet.
std::vector< std::string_view > splitWs(std::string_view s)
Split s on any ASCII whitespace.
void normalizeKeyframes(KeyframeAnimation &anim, const SourceSpan &loc)
Fill missing properties in every keyframe from neighbouring frames.
std::vector< std::string_view > splitBy(std::string_view s, char sep)
Split s on every occurrence of sep.
std::string stripComments(std::string_view src)
Strip // line and block comments from src.
float parseDurationSec(std::string_view s)
Parse a CSS duration ("200ms" → 0.2, "1.5s" → 1.5).
void applyStyleDeclaration(Style &st, std::string_view keyRaw, std::string_view valRaw, const SourceSpan &loc, DiagnosticSink *sink=nullptr, bool strict=false)
Apply one declaration to st.
std::string_view trim(std::string_view s)
Trim leading and trailing ASCII whitespace.
A named list of keyframes, keyed by name in Theme::keyframes.
Definition AnimPrimitives.hpp:115
Source location for a diagnostic.
Definition Diagnostics.hpp:41
Sparse style: every property is Opt<T>, unset by default.
Definition Style.hpp:932
One parsed key: value; declaration, with source location.
Definition StyleParser.hpp:135
Parsed representation of one markup node.
Definition ZMarkup.hpp:35
Options controlling static semantic linting in lintStyleSheet().
Definition StyleParser.hpp:275
bool checkSelectorTags
Emit UnknownSelectorTag with suggestions.
Definition StyleParser.hpp:279
bool checkVariables
Emit UnresolvedVariable and UnusedVariable.
Definition StyleParser.hpp:278
const Element * markupRoot
Optional parsed ZMarkup AST for SelectorMatchesNothing.
Definition StyleParser.hpp:277
bool strict
Report findings as Error instead of Warning.
Definition StyleParser.hpp:281
bool checkSelectorMatches
Emit SelectorMatchesNothing when markupRoot != nullptr.
Definition StyleParser.hpp:280
const Registry * registry
Registry for UnknownSelectorTag (defaults to global registry).
Definition StyleParser.hpp:276
One from/to/N% frame inside @keyframes.
Definition StyleParser.hpp:164
One @keyframes name { ... } block.
Definition StyleParser.hpp:172
One selector-plus-declarations entry.
Definition StyleParser.hpp:153
Intermediate representation: parsed rules, keyframes and root vars.
Definition StyleParser.hpp:150