ref_t ModuleScope :: mapTemplateClass(ident_t ns, ident_t templateName, bool& alreadyDeclared) { ReferenceNs forwardName; // NOTE : the nested namespace is not included into the weak name forwardName.append(TEMPLATE_PREFIX_NS); forwardName.append(templateName); if (emptystr(project->resolveForward(templateName))) { ReferenceNs fullName(module->Name()); if (!emptystr(ns)) fullName.combine(ns); fullName.combine(templateName); project->addForward(templateName, fullName); mapNewIdentifier(ns, templateName, false); alreadyDeclared = false; } else alreadyDeclared = true; return module->mapReference(forwardName); }
size_t CFParser :: defineGrammarRule(_ScriptReader& reader, ScriptBookmark& bm, size_t parentRuleId, size_t nonterminal, size_t terminal) { ReferenceNs ns; int index = 0; do { ns.copy(retrieveKey(_names.start(), parentRuleId, DEFAULT_STR)); ns.append('.'); ns.appendHex(index++); if (!_names.exist(ns)) break; } while (true); size_t ruleId = mapRuleId(ns); Rule rule; rule.nonterminal = nonterminal; rule.terminal = terminal; defineGrammarRule(reader, bm, rule, ruleId); addRule(ruleId, rule); return ruleId; }