void saveReference(_ScriptReader& scriptReader, CFParser* parser, ref_t ptr, ScriptLog& log) { ScriptBookmark bm; parser->readScriptBookmark(ptr, bm); log.write(scriptReader.lookup(bm)); }
void CFParser :: generateOutput(int offset, _ScriptReader& scriptReader, ScriptLog& log) { if (offset == 0) return; MemoryReader reader(&_body, offset); Stack<TraceItem> stack(TraceItem(0)); TraceItem item; reader.read(&item, sizeof(TraceItem)); while (true) { stack.push(item); if (item.previous == 0) break; reader.seek(item.previous); reader.read(&item, sizeof(TraceItem)); } Stack<size_t> postfixes; while (stack.Count() > 0) { TraceItem item = stack.pop(); if (item.ruleKey == 0) { size_t ptr = postfixes.pop(); if (ptr) log.write(getBodyText(ptr)); } else { ident_t keyName = retrieveKey(_names.start(), item.ruleKey >> 8, DEFAULT_STR); Rule rule = _table.get(item.ruleKey); if (rule.prefixPtr != 0) { log.write(getBodyText(rule.prefixPtr)); if (rule.saveTo != NULL) rule.saveTo(scriptReader, this, item.terminal, log); // HOTFIX: to prevent too long line log.write('\n'); } postfixes.push(rule.postfixPtr); } } log.write((char)0); }