void Palette::realize(const ByteArray *text, Token *objectToken) { scopeName_ = resourceContext()->top()->fileName(); if (scopeName_ == "default") { scope_ = SyntaxDefinition::scope(scopeName_); for (int i = 0; i < children()->count(); ++i) { Style *style = cast<Style>(children()->at(i)); style->rule_ = defaultRuleByName(style->ruleName()); if (style->rule_ == Undefined) { Token *token = childToken(objectToken, i); token = valueToken(text, token, "name"); throw SemanticError( Format("Undefined default style '%%'") << style->ruleName(), text, token->i1() ); } styleByRule_->establish(style->rule_, style); } return; } Language *language = 0; if (!registry()->lookupLanguageByName(scopeName_, &language)) throw SemanticError(Format("Undefined language '%%'") << scopeName_); const SyntaxDefinition *syntax = language->highlightingSyntax(); scope_ = syntax->id(); for (int i = 0; i < children()->count(); ++i) { Style *style = cast<Style>(children()->at(i)); try { style->rule_ = syntax->ruleByName(style->ruleName()); styleByRule_->insert(style->rule_, style); } catch (DebugError &ex) { Token *token = childToken(objectToken, i); token = valueToken(text, token, "name"); throw SemanticError(ex.message(), text, token->i1()); } } }