载入中...
搜索中...
未找到
DnutParser.cpp
浏览该文件的文档.
49 PoolBlockParser(const std::vector<eve::dnut::DnutToken>& tokens, const eve::dnut::DnutBlock& block)
94 bool atEnd() const { return index_ >= end_ || cur().kind == eve::dnut::DnutTokenKind::EndOfFile; }
106 [[noreturn]] void fail(std::string message) const { throw PoolParseError(cur(), std::move(message)); }
125 return value.isInt64() ? DataValue::integer(-value.asInt()) : DataValue::number(-value.asDouble());
160 {{"var", DataValue::string(variable)}, {"op", DataValue::string(mapped)}, {"value", parseLiteral()}});
242 if (name != "weight" && name != "i18n" && name != "id") fail("unknown pool line attribute '" + name + "'");
247 DataValue parseLine(const std::string& poolId, int lineIndex, const DataValue* inheritedCondition) {
279void addError(std::vector<ConversationDiagnostic>& diagnostics, const std::string& path, int line, int column,
292 if (tokens.size() < 5 || tokens[0].kind != eve::dnut::DnutTokenKind::Identifier || tokens[0].text != "schema" ||
293 tokens[1].kind != eve::dnut::DnutTokenKind::String || tokens[2].kind != eve::dnut::DnutTokenKind::Identifier ||
296 addError(diagnostics, path, token.line, token.column, "expected schema \"eve.dnut\" and version 1");
302 addError(diagnostics, path, tokens[0].line, tokens[0].column, "unsupported dnut schema or version",
331 eve::DiagnosticCode::UnknownVersion, diagnostics.back().message, path, {}, "dialogue.dnut.parse"));
363 eve::dnut::DnutCompileOutput compiled = eve::dnut::compileDnutConversations(source, path, registry);
Dialogue payload codecs for L1 sequence assets.
Shared top-level block discovery for `.dnut` dialects.
Registry-driven compiler for the `.dnut` story dialect.
Shared lexer for every `.dnut` dialect.
std::unordered_map< const Graphics *, std::shared_ptr< Lifetime > > tokens
Definition GraphicsLifetime.cpp:13
A structured explanation of a failed, degraded, or noteworthy result.
Definition Diagnostic.h:94
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
static Value string(std::string value)
Compatibility factory for a string value.
Definition Value.h:110
static Value integer(std::int64_t value)
Compatibility factory for an Int64 value.
Definition Value.h:104
Value * find(const std::string &key) noexcept
Return an object member, or nullptr when absent.
Definition Value.cpp:124
Canonical step vocabulary owner and runtime handler router.
Definition StepKindRegistry.h:108
Definition ConversationAuthoring.cpp:12
eve::Result< DnutDocument > parseDnutDocument(const std::string &source, const std::string &path, std::vector< ConversationDiagnostic > &diagnostics)
Parse pools and conversations from one versioned dnut token stream.
Definition DnutParser.cpp:311
eve::Value DataValue
Canonical data value used by dialogue pools, conditions and scripts.
Definition Dialogue.h:36
eve::Result< void > registerDialogueSequenceSteps(eve::dnut::StepKindRegistry ®istry)
Register dialogue's line, choice, and command contracts and validators.
Definition DialogueSequence.cpp:161
eve::Result< std::vector< DnutBlock > > scanDnutBlocks(const std::vector< DnutToken > &tokens, const std::string &path)
Discover balanced top-level dialect blocks in one lexed document.
Definition DnutBlockScanner.cpp:22
eve::Result< std::vector< DnutToken > > lexDnut(std::string_view source, const std::string &path)
Lex one .dnut source buffer into owned tokens.
Definition DnutLexer.cpp:97
@ Identifier
Bare word: keyword, field name, identifier, or bare enum value.
@ Punctuator
One- or two-character punctuator such as {, =, ==, ->.
@ Number
Unsigned numeric literal; sign handling belongs to the parser.
DnutCompileOutput compileDnutConversations(std::string_view source, const std::string &path, const StepKindRegistry ®istry)
Compile legacy conversation blocks into canonical sequence assets.
Definition ConversationDialect.cpp:301
@ UnknownVersion
@ ParseError
Definition Container.h:602
UI-neutral syntax tree produced by the single dnut parser.
Definition DnutDocument.h:32
static constexpr int CurrentVersion
Definition DnutDocument.h:33
One top-level dialect block in a shared token buffer.
Definition DnutBlockScanner.h:21
Owning outcome of compiling one .dnut document.
Definition DnutCompiler.h:24
std::vector< DnutDiagnostic > diagnostics
Definition DnutCompiler.h:26