// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> bool FocalMechanism::updateChild(Object* child) { Comment* commentChild = Comment::Cast(child); if ( commentChild != NULL ) { Comment* commentElement = comment(commentChild->index()); if ( commentElement != NULL ) { *commentElement = *commentChild; commentElement->update(); return true; } return false; } MomentTensor* momentTensorChild = MomentTensor::Cast(child); if ( momentTensorChild != NULL ) { MomentTensor* momentTensorElement = MomentTensor::Cast(PublicObject::Find(momentTensorChild->publicID())); if ( momentTensorElement && momentTensorElement->parent() == this ) { *momentTensorElement = *momentTensorChild; momentTensorElement->update(); return true; } return false; } return false; }
void Decoder::decodeTextSection(MoveNode* node, ByteStream& text) { for ( ; node; node = node->next()) { if (node->hasSupplement()) { if (uint8_t flag = node->commentFlag()) { mstl::string buf; Comment comment; if (flag & comm::Ante) { text.get(buf); comment.swap(buf, bool(flag & comm::Ante_Eng), bool(flag & comm::Ante_Oth)); node->setComment(comment, move::Ante); } if (flag & comm::Post) { text.get(buf); comment.swap(buf, bool(flag & comm::Post_Eng), bool(flag & comm::Post_Oth)); node->setComment(comment, move::Post); } } for (unsigned i = 0; i < node->variationCount(); ++i) decodeTextSection(node->variation(i), text); } } }
void Writer::visitComment(const Comment& comment) const { if(d_preservecomments && d_commentchar && ( !comment.isDeleted() || d_preservedeleted )) { *d_outputstream << d_commentchar << comment.getComment() << "\n"; } }
void LineEditDialog::handleInitDialogMsg(HWND p_dlg) { s8 str[1024]; ModuleInfo* info = g_dbg->code_window()->GetCurModule(); if (info == NULL) return; RECT rect; GetWindowRect(p_dlg, &rect); SetWindowPos(p_dlg, NULL, rect.left, rect.top - (rect.bottom - rect.top + 20), 0, 0, SWP_NOSIZE | SWP_NOZORDER); u32 va = info->addr() + g_dbg->code_window()->select() * 4; u32 opcode = *((u32*)VA2PA(va)); sprintf(str, "%08x", opcode); SetDlgItemText(p_dlg, IDC_OPCODE, str); g_dbg->setFontToFixed(GetDlgItem(p_dlg, IDC_OPCODE)); disasm_plain(va, opcode, str); SetDlgItemText(p_dlg, IDC_ASM, str); g_dbg->setFontToFixed(GetDlgItem(p_dlg, IDC_ASM)); Comment* comment = g_dbg->find_comment(va); SetDlgItemText(p_dlg, IDC_COMMENT, comment ? comment->text() : ""); Label* label = g_dbg->find_codelabel(va); SetDlgItemText(p_dlg, IDC_LABEL, label ? label->text() : ""); SetFocus(GetDlgItem(p_dlg, IDC_LABEL)); }
Comment * Comment::create(const JsonObject &data, QObject *parent) { if (!isValid(data)) { return 0; } Comment * comment = new Comment(parent); comment->setData(data, false); return comment; }
void PrettyGherkin::AppendOriginalComment(int currentLineNo) { Comment* pComment = GetComment(m_noOfNextCommentToAppend); while ((pComment != nullptr) && (pComment->Location().Line() < currentLineNo)) { m_FormattedFeature .append(pComment->Text()) .append(NEWLINE); m_noOfNextCommentToAppend++; pComment = GetComment(m_noOfNextCommentToAppend); } }
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> bool Pick::updateChild(Object* child) { Comment* commentChild = Comment::Cast(child); if ( commentChild != NULL ) { Comment* commentElement = comment(commentChild->index()); if ( commentElement != NULL ) { *commentElement = *commentChild; return true; } return false; } return false; }
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> bool StationMagnitude::updateChild(Object* child) { Comment* commentChild = Comment::Cast(child); if ( commentChild != NULL ) { Comment* commentElement = comment(commentChild->index()); if ( commentElement != NULL ) { *commentElement = *commentChild; commentElement->update(); return true; } return false; } return false; }
//парсит комментарии из треда. void addCommentFromWeb(Container* parent, string thread) { Container* currentParent = parent; int parentIDEndPos = 0; do { //current comment id string commentIDBeginTag = "<div id='cmtbar"; int commentIdBeginPos = thread.find(commentIDBeginTag, parentIDEndPos); if (commentIdBeginPos == -1) return; //no comments commentIdBeginPos += commentIDBeginTag.length(); int commentIdEndPos = thread.find("'", commentIdBeginPos); string str_currCommentID = thread.substr(commentIdBeginPos, commentIdEndPos - commentIdBeginPos); int currCommentID = atoi(str_currCommentID.c_str()); //current comment text string commentBeginTag = "<div class='talk-comment-box'>"; string commentEndTag = "<p style='margin: 0.7em 0 0.2em 0'>"; int commentBeginPos = thread.find(commentBeginTag, commentIdEndPos) + commentBeginTag.length(); int commentEndPos = thread.find(commentEndTag, commentBeginPos); string currCommentText = thread.substr(commentBeginPos, commentEndPos - commentBeginPos); //current comment parent id string replyBeginTag = "?replyto"; int replyTagBeginPos = thread.find(replyBeginTag, commentEndPos) + replyBeginTag.length(); int parentIDBeginPos = thread.find("#t", replyTagBeginPos) + 2; parentIDEndPos = thread.find("'", parentIDBeginPos); int parentID = atoi( thread.substr(parentIDBeginPos, parentIDEndPos - parentIDBeginPos).c_str()); Comment* currentComment = new Comment(currCommentText, currCommentID); currentComment->setURL(url_ + "?thread=" + str_currCommentID); //в этот момент предком может быть либо текущий комментарий, либо кто-то из его предков. находим его while (currentParent->getParent() != NULL) { if (currentParent->getID() == parentID) break; currentParent = currentParent->getParent(); } currentParent->addSubComment(currentComment); currentParent = currentComment; } while (true); }
void Consumer::sendTrailingComment(Comment const& comment, bool variationIsEmpty) { if (!comment.isEmpty()) { #ifndef ALLOW_EMPTY_VARS if (variationIsEmpty) putMove(m_move = Move::null()); #endif if (m_danglingEndMarker) { m_strm.put(token::End_Marker); m_danglingEndMarker--; } Byte flag = writeComment(comm::Post, comment); //M_ASSERT(flag); m_strm.put(token::Comment); m_data.put(flag); m_endOfRun = true; if (isMainline()) m_lastCommentPos = plyCount() + 1; } }
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> bool Origin::updateChild(Object* child) { Comment* commentChild = Comment::Cast(child); if ( commentChild != NULL ) { Comment* commentElement = comment(commentChild->index()); if ( commentElement != NULL ) { *commentElement = *commentChild; return true; } return false; } // Do not know how to fetch child of type CompositeTime without an index Arrival* arrivalChild = Arrival::Cast(child); if ( arrivalChild != NULL ) { Arrival* arrivalElement = arrival(arrivalChild->index()); if ( arrivalElement != NULL ) { *arrivalElement = *arrivalChild; return true; } return false; } StationMagnitude* stationMagnitudeChild = StationMagnitude::Cast(child); if ( stationMagnitudeChild != NULL ) { StationMagnitude* stationMagnitudeElement = StationMagnitude::Cast(PublicObject::Find(stationMagnitudeChild->publicID())); if ( stationMagnitudeElement && stationMagnitudeElement->parent() == this ) { *stationMagnitudeElement = *stationMagnitudeChild; return true; } return false; } Magnitude* magnitudeChild = Magnitude::Cast(child); if ( magnitudeChild != NULL ) { Magnitude* magnitudeElement = Magnitude::Cast(PublicObject::Find(magnitudeChild->publicID())); if ( magnitudeElement && magnitudeElement->parent() == this ) { *magnitudeElement = *magnitudeChild; return true; } return false; } return false; }
/* * Runs the test case. */ void runTest() { Document doc; Comment newCommentNode; String newCommentValue; String newCommentName; int newCommentType; doc = (Document) baseT::load("hc_staff", true); newCommentNode = doc.createComment(SA::construct_from_utf8("This is a new Comment node")); newCommentValue = newCommentNode.getNodeValue(); baseT::assertEquals("This is a new Comment node", newCommentValue, __LINE__, __FILE__); newCommentName = newCommentNode.getNodeName(); baseT::assertEquals("#comment", newCommentName, __LINE__, __FILE__); newCommentType = (int) newCommentNode.getNodeType(); baseT::assertEquals(8, newCommentType, __LINE__, __FILE__); }
Byte Consumer::writeComment(Byte position, Comment const& comment) { //M_ASSERT(position == comm::Ante || position == comm::Post); Byte flag = 0; if (!comment.isEmpty()) { if (comment.engFlag()) flag |= comm::Ante_Eng; if (comment.othFlag()) flag |= comm::Ante_Oth; flag |= position; m_text.put(comment.content(), comment.size() + 1); } return flag; }
void CommentView::save() { dbo::Transaction t(session_); bool isNew = comment_.id() == -1; Comment *comment = comment_.modify(); comment->setText(editArea_->text()); if (isNew) { session_.add(comment_); comment->date = WDateTime::currentDateTime(); comment->author = session_.user(); session_.commentsChanged().emit(comment_); } renderView(); t.commit(); }
void MainTest::createPost2() { Post *newPost = new Post; newPost->setTitle("post title"); newPost->setSaveDate(QDateTime::currentDateTime()); db.posts()->append(newPost); db.saveChanges(); for(int i = 0 ; i < 3; i++){ Comment *comment = new Comment; comment->setMessage("comment #" + QString::number(i)); comment->setSaveDate(QDateTime::currentDateTime()); comment->setPostId(newPost->id()); db.comments()->append(comment); } db.saveChanges(); QTEST_ASSERT(newPost->id() != 0); qDebug() << "New post2 inserted with id:" << newPost->id(); }
Mode7::Mode7(const Comment &comment) : sprite(nullptr) { Q_ASSERT(comment.mode == 7); QJsonArray data = QJsonDocument::fromJson(comment.string.toUtf8()).array(); int l = data.size(); if (l < 5){ throw format_unrecognized(); } QSize size = lApp->findObject<ARender>()->getActualSize(); auto getDouble = [&data](int i){return data.at(i).toVariant().toDouble(); }; double scale = getScale(comment.mode, comment.date, size); bPos = QPointF(getDouble(0), getDouble(1)); ePos = l < 8 ? bPos : QPointF(getDouble(7), getDouble(8)); int w = size.width(), h = size.height(); if (bPos.x() < 1 && bPos.y() < 1 && ePos.x() < 1 && ePos.y() < 1){ bPos.rx() *= w; ePos.rx() *= w; bPos.ry() *= h; ePos.ry() *= h; scale = 1; } else if (scale == 0){ scale = 1; } else{ QSizeF player = getPlayer(comment.date); QPoint offset = QPoint((w - player.width()*scale) / 2, (h - player.height()*scale) / 2); bPos = bPos*scale + offset; ePos = ePos*scale + offset; } QStringList alpha = data[2].toString().split('-'); bAlpha = alpha[0].toDouble(); eAlpha = alpha[1].toDouble(); life = getDouble(3); QJsonValue v = l < 12 ? QJsonValue(true) : data[11]; int effect = (v.isString() ? v.toString() == "true" : v.toVariant().toBool()) ? Config::getValue("/Danmaku/Effect", 5) / 2 : -1; QFont font = getFont(scale ? comment.font*scale : comment.font, l < 13 ? Utils::defaultFont(true) : data[12].toString()); QString string = data[4].toString(); sprite = lApp->findObject<ARender>()->getSprite(); sprite->setAlpha(1.0); sprite->setColor(QColor::fromRgb(comment.color)); sprite->setEffect(effect); sprite->setFont(font); sprite->setFrame(comment.isLocal()); sprite->setText(string); zRotate = l < 6 ? 0 : getDouble(5); yRotate = l < 7 ? 0 : getDouble(6); wait = l < 11 ? 0 : getDouble(10) / 1000; stay = l < 10 ? 0 : life - wait - getDouble(9) / 1000; source = &comment; time = 0; }
/*! * @brief Find space where a comment is put * @param cmt Comment * @return Position where comment can be put, <0 if error */ int CommentManager::findSpace(Comment &cmt){ const int xmargin = 5; const int ymargin = 5; int i; int cur_space; int cur_index; std::vector<int> space; int size = (int) std::ceil((double)(pimg->rows)/(cmt.getSize().height+ymargin)); std::list<Comment>::iterator it = CmtList.begin(); if(size<=0){return -1;} space.resize(size,0); while(it != CmtList.end()){ //for each comment cur_space = pimg->cols - ((*it).getPosition().x+(*it).getSize().width+xmargin); //caclurate right space cur_index = ((*it).getPosition().y-(*it).getSize().height)/(cmt.getSize().height+ymargin); //calculate the index if(space[cur_index] > cur_space){ //if smaller space space[cur_index] = cur_space; //update the space (i.e. consider only the worst case.) } it++; } cur_index = 0; cur_space = space[0]; for(i=0;i<size;i++){ if(space[i]==0){ //if enough space return (i+1)*(cmt.getSize().height+ymargin); }else{ if(cur_space<space[i]){ //if larger space found cur_space = space[i]; //store the data cur_index = i; } } } return (cur_index+1)*(cmt.getSize().height+ymargin); }
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> bool MomentTensor::updateChild(Object* child) { Comment* commentChild = Comment::Cast(child); if ( commentChild != NULL ) { Comment* commentElement = comment(commentChild->index()); if ( commentElement != NULL ) { *commentElement = *commentChild; return true; } return false; } // Do not know how to fetch child of type DataUsed without an index MomentTensorPhaseSetting* momentTensorPhaseSettingChild = MomentTensorPhaseSetting::Cast(child); if ( momentTensorPhaseSettingChild != NULL ) { MomentTensorPhaseSetting* momentTensorPhaseSettingElement = momentTensorPhaseSetting(momentTensorPhaseSettingChild->index()); if ( momentTensorPhaseSettingElement != NULL ) { *momentTensorPhaseSettingElement = *momentTensorPhaseSettingChild; return true; } return false; } MomentTensorStationContribution* momentTensorStationContributionChild = MomentTensorStationContribution::Cast(child); if ( momentTensorStationContributionChild != NULL ) { MomentTensorStationContribution* momentTensorStationContributionElement = MomentTensorStationContribution::Cast(PublicObject::Find(momentTensorStationContributionChild->publicID())); if ( momentTensorStationContributionElement && momentTensorStationContributionElement->parent() == this ) { *momentTensorStationContributionElement = *momentTensorStationContributionChild; return true; } return false; } return false; }
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> bool ParameterSet::updateChild(Object* child) { Parameter* parameterChild = Parameter::Cast(child); if ( parameterChild != NULL ) { Parameter* parameterElement = Parameter::Cast(PublicObject::Find(parameterChild->publicID())); if ( parameterElement && parameterElement->parent() == this ) { *parameterElement = *parameterChild; return true; } return false; } Comment* commentChild = Comment::Cast(child); if ( commentChild != NULL ) { Comment* commentElement = comment(commentChild->index()); if ( commentElement != NULL ) { *commentElement = *commentChild; return true; } return false; } return false; }
void CommentStore::addComment( Comment comment ) { CommentSet::iterator it = m_comments.find( comment ); if( it != m_comments.end() ) { if( comment.isSame( *it ) ) return; ///@todo comment-merging? /* Comment c = *it; c += comment; comment = c;*/ //m_comments.erase( it ); } /* kDebug() << "size" << m_comments.size();*/ m_comments.insert( comment ); /* kDebug() << "added comment in line" << comment.line() << "token" << comment.token() << "new count" << m_comments.size();*/ }
/*! * @brief Add comment to comment list * @param cmt Comment to be added * @return 0 if no error */ int CommentManager::addComment(Comment &cmt){ int res; if(pimg==NULL){ std::cerr << "Image not specified" << std::endl; return -1; } //std::cerr << cmt.getPosition().x << ' ' << cmt.getPosition().y << std::endl; if(cmt.getPosition().x == -1){ cmt.changePositionAbsoluteX(pimg->cols); } if(cmt.getPosition().y == -1){ res = findSpace(cmt); if(res<0){ return -2; } cmt.changePositionAbsoluteY(res); } //std::cerr << cmt.getPosition().x << ' ' << cmt.getPosition().y << std::endl; CmtList.push_back(cmt); return 0; }
bool processComment(const QChar *chars, int length, Comment &comment) { // Try to match the logic of the QtScript parser. if (!length) return comment.isValid(); if (*chars == QLatin1Char(':') && chars[1].isSpace()) { comment.extracomment += QString(chars+1, length-1); } else if (*chars == QLatin1Char('=') && chars[1].isSpace()) { comment.msgid = QString(chars+2, length-2).simplified(); } else if (*chars == QLatin1Char('~') && chars[1].isSpace()) { QString text = QString(chars+2, length-2).trimmed(); int k = text.indexOf(QLatin1Char(' ')); if (k > -1) comment.extra.insert(text.left(k), text.mid(k + 1).trimmed()); } else if (*chars == QLatin1Char('%') && chars[1].isSpace()) { comment.sourcetext.reserve(comment.sourcetext.length() + length-2); ushort *ptr = (ushort *)comment.sourcetext.data() + comment.sourcetext.length(); int p = 2, c; forever { if (p >= length) break; c = chars[p++].unicode(); if (isspace(c)) continue; if (c != '"') break; forever { if (p >= length) break; c = chars[p++].unicode(); if (c == '"') break; if (c == '\\') { if (p >= length) break; c = chars[p++].unicode(); if (c == '\n') break; *ptr++ = '\\'; } *ptr++ = c; } } comment.sourcetext.resize(ptr - (ushort *)comment.sourcetext.data()); }
int SinaApiProvider::updateComment(Comment& comment) { int ret = 0; string queryUrl; QList<PostParameter*> paras; Response response; PostParameter para; /* add parameter: text */ paras.append(new PostParameter(PARA_NAME_COMMENT, comment.getText().toStdString().c_str())); /* add parameter: status id to reply */ paras.append(new PostParameter(PARA_NAME_SID, comment.getReplyStatusId().toStdString().c_str())); /* add parameter: comment id to reply */ paras.append(new PostParameter(PARA_NAME_CID, comment.getReplyCommentId().toStdString().c_str())); /* add parameter: without_metion */ if (comment.getNoMention()) { paras.append(new PostParameter(PARA_NAME_NO_MENTION, comment.getNoMention())); } /* add parameter: comment original */ if (comment.getCommentOri()) { paras.append(new PostParameter(PARA_NAME_COMMENT_ORI, comment.getCommentOri())); } SinaApi *api = new SinaApi(FAMILY_NAME, "comment", HTTP_METHOD_POST); queryUrl = api->toString(paras); #if API_PROVIDER_DEBUG cout << "query url:" <<queryUrl<<endl; #endif this->oauth->Request(queryUrl, HTTP_METHOD_POST, &response); #if API_PROVIDER_DEBUG cout << "result :" <<response.responseAsDocument()->toString().toStdString()<<endl; #endif if (response.responseAsDocument()->elementsByTagName(NODE_COMMENT_ROOT).count() == 0) { ret = -1; } return ret; }
inline void debug_ast(AST_Node* node, std::string ind, Env* env) { if (node == 0) return; if (ind == "") std::cerr << "####################################################################\n"; if (dynamic_cast<Bubble*>(node)) { Bubble* bubble = dynamic_cast<Bubble*>(node); std::cerr << ind << "Bubble " << bubble; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " " << bubble->tabs(); std::cerr << std::endl; } else if (dynamic_cast<At_Root_Block*>(node)) { At_Root_Block* root_block = dynamic_cast<At_Root_Block*>(node); std::cerr << ind << "At_Root_Block " << root_block; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " " << root_block->tabs(); std::cerr << std::endl; debug_ast(root_block->expression(), ind + ":", env); debug_ast(root_block->block(), ind + " ", env); } else if (dynamic_cast<Selector_List*>(node)) { Selector_List* selector = dynamic_cast<Selector_List*>(node); std::cerr << ind << "Selector_List " << selector; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " <" << selector->hash() << ">"; std::cerr << " [@media:" << selector->media_block() << "]"; std::cerr << (selector->is_optional() ? " [is_optional]": " -"); std::cerr << (selector->has_parent_ref() ? " [has-parent]": " -"); std::cerr << (selector->has_line_break() ? " [line-break]": " -"); std::cerr << (selector->has_line_feed() ? " [line-feed]": " -"); std::cerr << std::endl; for(auto i : selector->elements()) { debug_ast(i, ind + " ", env); } // } else if (dynamic_cast<Expression*>(node)) { // Expression* expression = dynamic_cast<Expression*>(node); // std::cerr << ind << "Expression " << expression << " " << expression->concrete_type() << std::endl; } else if (dynamic_cast<Parent_Selector*>(node)) { Parent_Selector* selector = dynamic_cast<Parent_Selector*>(node); std::cerr << ind << "Parent_Selector " << selector; // if (selector->not_selector()) cerr << " [in_declaration]"; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " <" << selector->hash() << ">"; std::cerr << " <" << prettyprint(selector->pstate().token.ws_before()) << ">" << std::endl; // debug_ast(selector->selector(), ind + "->", env); } else if (dynamic_cast<Complex_Selector*>(node)) { Complex_Selector* selector = dynamic_cast<Complex_Selector*>(node); std::cerr << ind << "Complex_Selector " << selector << " (" << pstate_source_position(node) << ")" << " <" << selector->hash() << ">" << " [weight:" << longToHex(selector->specificity()) << "]" << " [@media:" << selector->media_block() << "]" << (selector->is_optional() ? " [is_optional]": " -") << (selector->has_parent_ref() ? " [has parent]": " -") << (selector->has_line_feed() ? " [line-feed]": " -") << (selector->has_line_break() ? " [line-break]": " -") << " -- "; std::string del; switch (selector->combinator()) { case Complex_Selector::PARENT_OF: del = ">"; break; case Complex_Selector::PRECEDES: del = "~"; break; case Complex_Selector::ADJACENT_TO: del = "+"; break; case Complex_Selector::ANCESTOR_OF: del = " "; break; case Complex_Selector::REFERENCE: del = "//"; break; } // if (del = "/") del += selector->reference()->perform(&to_string) + "/"; std::cerr << " <" << prettyprint(selector->pstate().token.ws_before()) << ">" << std::endl; debug_ast(selector->head(), ind + " " /* + "[" + del + "]" */, env); if (selector->tail()) { debug_ast(selector->tail(), ind + "{" + del + "}", env); } else if(del != " ") { std::cerr << ind << " |" << del << "| {trailing op}" << std::endl; } SourcesSet set = selector->sources(); // debug_sources_set(set, ind + " @--> "); } else if (dynamic_cast<Compound_Selector*>(node)) { Compound_Selector* selector = dynamic_cast<Compound_Selector*>(node); std::cerr << ind << "Compound_Selector " << selector; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " <" << selector->hash() << ">"; std::cerr << " [weight:" << longToHex(selector->specificity()) << "]"; std::cerr << " [@media:" << selector->media_block() << "]"; std::cerr << (selector->extended() ? " [extended]": " -"); std::cerr << (selector->is_optional() ? " [is_optional]": " -"); std::cerr << (selector->has_parent_ref() ? " [has-parent]": " -"); std::cerr << (selector->has_line_break() ? " [line-break]": " -"); std::cerr << (selector->has_line_feed() ? " [line-feed]": " -"); std::cerr << " <" << prettyprint(selector->pstate().token.ws_before()) << ">" << std::endl; for(auto i : selector->elements()) { debug_ast(i, ind + " ", env); } } else if (dynamic_cast<Propset*>(node)) { Propset* selector = dynamic_cast<Propset*>(node); std::cerr << ind << "Propset " << selector; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " " << selector->tabs() << std::endl; if (selector->block()) for(auto i : selector->block()->elements()) { debug_ast(i, ind + " ", env); } } else if (dynamic_cast<Wrapped_Selector*>(node)) { Wrapped_Selector* selector = dynamic_cast<Wrapped_Selector*>(node); std::cerr << ind << "Wrapped_Selector " << selector; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " <" << selector->hash() << ">"; std::cerr << " <<" << selector->ns_name() << ">>"; std::cerr << (selector->is_optional() ? " [is_optional]": " -"); std::cerr << (selector->has_parent_ref() ? " [has-parent]": " -"); std::cerr << (selector->has_line_break() ? " [line-break]": " -"); std::cerr << (selector->has_line_feed() ? " [line-feed]": " -"); std::cerr << std::endl; debug_ast(selector->selector(), ind + " () ", env); } else if (dynamic_cast<Pseudo_Selector*>(node)) { Pseudo_Selector* selector = dynamic_cast<Pseudo_Selector*>(node); std::cerr << ind << "Pseudo_Selector " << selector; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " <" << selector->hash() << ">"; std::cerr << " <<" << selector->ns_name() << ">>"; std::cerr << (selector->is_optional() ? " [is_optional]": " -"); std::cerr << (selector->has_parent_ref() ? " [has-parent]": " -"); std::cerr << (selector->has_line_break() ? " [line-break]": " -"); std::cerr << (selector->has_line_feed() ? " [line-feed]": " -"); std::cerr << std::endl; debug_ast(selector->expression(), ind + " <= ", env); } else if (dynamic_cast<Attribute_Selector*>(node)) { Attribute_Selector* selector = dynamic_cast<Attribute_Selector*>(node); std::cerr << ind << "Attribute_Selector " << selector; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " <" << selector->hash() << ">"; std::cerr << " <<" << selector->ns_name() << ">>"; std::cerr << (selector->is_optional() ? " [is_optional]": " -"); std::cerr << (selector->has_parent_ref() ? " [has-parent]": " -"); std::cerr << (selector->has_line_break() ? " [line-break]": " -"); std::cerr << (selector->has_line_feed() ? " [line-feed]": " -"); std::cerr << std::endl; debug_ast(selector->value(), ind + "[" + selector->matcher() + "] ", env); } else if (dynamic_cast<Selector_Qualifier*>(node)) { Selector_Qualifier* selector = dynamic_cast<Selector_Qualifier*>(node); std::cerr << ind << "Selector_Qualifier " << selector; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " <" << selector->hash() << ">"; std::cerr << " <<" << selector->ns_name() << ">>"; std::cerr << (selector->is_optional() ? " [is_optional]": " -"); std::cerr << (selector->has_parent_ref() ? " [has-parent]": " -"); std::cerr << (selector->has_line_break() ? " [line-break]": " -"); std::cerr << (selector->has_line_feed() ? " [line-feed]": " -"); std::cerr << std::endl; } else if (dynamic_cast<Type_Selector*>(node)) { Type_Selector* selector = dynamic_cast<Type_Selector*>(node); std::cerr << ind << "Type_Selector " << selector; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " <" << selector->hash() << ">"; std::cerr << " <<" << selector->ns_name() << ">>"; std::cerr << (selector->is_optional() ? " [is_optional]": " -"); std::cerr << (selector->has_parent_ref() ? " [has-parent]": " -"); std::cerr << (selector->has_line_break() ? " [line-break]": " -"); std::cerr << (selector->has_line_feed() ? " [line-feed]": " -"); std::cerr << " <" << prettyprint(selector->pstate().token.ws_before()) << ">"; std::cerr << std::endl; } else if (dynamic_cast<Selector_Placeholder*>(node)) { Selector_Placeholder* selector = dynamic_cast<Selector_Placeholder*>(node); std::cerr << ind << "Selector_Placeholder [" << selector->ns_name() << "] " << selector << " <" << selector->hash() << ">" << " [@media:" << selector->media_block() << "]" << (selector->is_optional() ? " [is_optional]": " -") << (selector->has_line_break() ? " [line-break]": " -") << (selector->has_line_feed() ? " [line-feed]": " -") << std::endl; } else if (dynamic_cast<Simple_Selector*>(node)) { Simple_Selector* selector = dynamic_cast<Simple_Selector*>(node); std::cerr << ind << "Simple_Selector " << selector; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << (selector->has_line_break() ? " [line-break]": " -") << (selector->has_line_feed() ? " [line-feed]": " -") << std::endl; } else if (dynamic_cast<Selector_Schema*>(node)) { Selector_Schema* selector = dynamic_cast<Selector_Schema*>(node); std::cerr << ind << "Selector_Schema " << selector; std::cerr << " (" << pstate_source_position(node) << ")" << (selector->at_root() && selector->at_root() ? " [@ROOT]" : "") << " [@media:" << selector->media_block() << "]" << (selector->has_line_break() ? " [line-break]": " -") << (selector->has_line_feed() ? " [line-feed]": " -") << std::endl; debug_ast(selector->contents(), ind + " "); // for(auto i : selector->elements()) { debug_ast(i, ind + " ", env); } } else if (dynamic_cast<Selector*>(node)) { Selector* selector = dynamic_cast<Selector*>(node); std::cerr << ind << "Selector " << selector; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << (selector->has_line_break() ? " [line-break]": " -") << (selector->has_line_feed() ? " [line-feed]": " -") << std::endl; } else if (dynamic_cast<Media_Query_Expression*>(node)) { Media_Query_Expression* block = dynamic_cast<Media_Query_Expression*>(node); std::cerr << ind << "Media_Query_Expression " << block; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << (block->is_interpolated() ? " [is_interpolated]": " -") << std::endl; debug_ast(block->feature(), ind + " feature) "); debug_ast(block->value(), ind + " value) "); } else if (dynamic_cast<Media_Query*>(node)) { Media_Query* block = dynamic_cast<Media_Query*>(node); std::cerr << ind << "Media_Query " << block; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << (block->is_negated() ? " [is_negated]": " -") << (block->is_restricted() ? " [is_restricted]": " -") << std::endl; debug_ast(block->media_type(), ind + " "); for(auto i : block->elements()) { debug_ast(i, ind + " ", env); } } else if (dynamic_cast<Media_Block*>(node)) { Media_Block* block = dynamic_cast<Media_Block*>(node); std::cerr << ind << "Media_Block " << block; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " " << block->tabs() << std::endl; debug_ast(block->media_queries(), ind + " =@ "); if (block->block()) for(auto i : block->block()->elements()) { debug_ast(i, ind + " ", env); } } else if (dynamic_cast<Supports_Block*>(node)) { Supports_Block* block = dynamic_cast<Supports_Block*>(node); std::cerr << ind << "Supports_Block " << block; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " " << block->tabs() << std::endl; debug_ast(block->condition(), ind + " =@ "); } else if (dynamic_cast<Supports_Operator*>(node)) { Supports_Operator* block = dynamic_cast<Supports_Operator*>(node); std::cerr << ind << "Supports_Operator " << block; std::cerr << " (" << pstate_source_position(node) << ")" << std::endl; debug_ast(block->left(), ind + " left) "); debug_ast(block->right(), ind + " right) "); } else if (dynamic_cast<Supports_Negation*>(node)) { Supports_Negation* block = dynamic_cast<Supports_Negation*>(node); std::cerr << ind << "Supports_Negation " << block; std::cerr << " (" << pstate_source_position(node) << ")" << std::endl; debug_ast(block->condition(), ind + " condition) "); } else if (dynamic_cast<Supports_Declaration*>(node)) { Supports_Declaration* block = dynamic_cast<Supports_Declaration*>(node); std::cerr << ind << "Supports_Declaration " << block; std::cerr << " (" << pstate_source_position(node) << ")" << std::endl; debug_ast(block->feature(), ind + " feature) "); debug_ast(block->value(), ind + " value) "); } else if (dynamic_cast<Block*>(node)) { Block* root_block = dynamic_cast<Block*>(node); std::cerr << ind << "Block " << root_block; std::cerr << " (" << pstate_source_position(node) << ")"; if (root_block->is_root()) std::cerr << " [root]"; std::cerr << " " << root_block->tabs() << std::endl; if (root_block->block()) for(auto i : root_block->block()->elements()) { debug_ast(i, ind + " ", env); } } else if (dynamic_cast<Warning*>(node)) { Warning* block = dynamic_cast<Warning*>(node); std::cerr << ind << "Warning " << block; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " " << block->tabs() << std::endl; } else if (dynamic_cast<Error*>(node)) { Error* block = dynamic_cast<Error*>(node); std::cerr << ind << "Error " << block; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " " << block->tabs() << std::endl; } else if (dynamic_cast<Debug*>(node)) { Debug* block = dynamic_cast<Debug*>(node); std::cerr << ind << "Debug " << block; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " " << block->tabs() << std::endl; } else if (dynamic_cast<Comment*>(node)) { Comment* block = dynamic_cast<Comment*>(node); std::cerr << ind << "Comment " << block; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " " << block->tabs() << " <" << prettyprint(block->pstate().token.ws_before()) << ">" << std::endl; debug_ast(block->text(), ind + "// ", env); } else if (dynamic_cast<If*>(node)) { If* block = dynamic_cast<If*>(node); std::cerr << ind << "If " << block; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " " << block->tabs() << std::endl; debug_ast(block->predicate(), ind + " = "); debug_ast(block->block(), ind + " <>"); debug_ast(block->alternative(), ind + " ><"); } else if (dynamic_cast<Return*>(node)) { Return* block = dynamic_cast<Return*>(node); std::cerr << ind << "Return " << block; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " " << block->tabs() << std::endl; } else if (dynamic_cast<Extension*>(node)) { Extension* block = dynamic_cast<Extension*>(node); std::cerr << ind << "Extension " << block; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " " << block->tabs() << std::endl; debug_ast(block->selector(), ind + "-> ", env); } else if (dynamic_cast<Content*>(node)) { Content* block = dynamic_cast<Content*>(node); std::cerr << ind << "Content " << block; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " " << block->tabs() << std::endl; } else if (dynamic_cast<Import_Stub*>(node)) { Import_Stub* block = dynamic_cast<Import_Stub*>(node); std::cerr << ind << "Import_Stub " << block; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " " << block->tabs() << std::endl; } else if (dynamic_cast<Import*>(node)) { Import* block = dynamic_cast<Import*>(node); std::cerr << ind << "Import " << block; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " " << block->tabs() << std::endl; debug_ast(block->media_queries(), ind + " @ "); // std::vector<std::string> files_; for (auto imp : block->urls()) debug_ast(imp, "@ ", env); } else if (dynamic_cast<Assignment*>(node)) { Assignment* block = dynamic_cast<Assignment*>(node); std::cerr << ind << "Assignment " << block; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " <<" << block->variable() << ">> " << block->tabs() << std::endl; debug_ast(block->value(), ind + "=", env); } else if (dynamic_cast<Declaration*>(node)) { Declaration* block = dynamic_cast<Declaration*>(node); std::cerr << ind << "Declaration " << block; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " " << block->tabs() << std::endl; debug_ast(block->property(), ind + " prop: ", env); debug_ast(block->value(), ind + " value: ", env); } else if (dynamic_cast<Keyframe_Rule*>(node)) { Keyframe_Rule* has_block = dynamic_cast<Keyframe_Rule*>(node); std::cerr << ind << "Keyframe_Rule " << has_block; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " " << has_block->tabs() << std::endl; if (has_block->selector()) debug_ast(has_block->selector(), ind + "@"); if (has_block->block()) for(auto i : has_block->block()->elements()) { debug_ast(i, ind + " ", env); } } else if (dynamic_cast<At_Rule*>(node)) { At_Rule* block = dynamic_cast<At_Rule*>(node); std::cerr << ind << "At_Rule " << block; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " [" << block->keyword() << "] " << block->tabs() << std::endl; debug_ast(block->selector(), ind + "~", env); debug_ast(block->value(), ind + "+", env); if (block->block()) for(auto i : block->block()->elements()) { debug_ast(i, ind + " ", env); } } else if (dynamic_cast<Each*>(node)) { Each* block = dynamic_cast<Each*>(node); std::cerr << ind << "Each " << block; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " " << block->tabs() << std::endl; if (block->block()) for(auto i : block->block()->elements()) { debug_ast(i, ind + " ", env); } } else if (dynamic_cast<For*>(node)) { For* block = dynamic_cast<For*>(node); std::cerr << ind << "For " << block; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " " << block->tabs() << std::endl; if (block->block()) for(auto i : block->block()->elements()) { debug_ast(i, ind + " ", env); } } else if (dynamic_cast<While*>(node)) { While* block = dynamic_cast<While*>(node); std::cerr << ind << "While " << block; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " " << block->tabs() << std::endl; if (block->block()) for(auto i : block->block()->elements()) { debug_ast(i, ind + " ", env); } } else if (dynamic_cast<Definition*>(node)) { Definition* block = dynamic_cast<Definition*>(node); std::cerr << ind << "Definition " << block; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " [name: " << block->name() << "] "; std::cerr << " [type: " << (block->type() == Sass::Definition::Type::MIXIN ? "Mixin " : "Function ") << "] "; // this seems to lead to segfaults some times? // std::cerr << " [signature: " << block->signature() << "] "; std::cerr << " [native: " << block->native_function() << "] "; std::cerr << " " << block->tabs() << std::endl; debug_ast(block->parameters(), ind + " params: ", env); if (block->block()) for(auto i : block->block()->elements()) { debug_ast(i, ind + " ", env); } } else if (dynamic_cast<Mixin_Call*>(node)) { Mixin_Call* block = dynamic_cast<Mixin_Call*>(node); std::cerr << ind << "Mixin_Call " << block << " " << block->tabs(); std::cerr << " [" << block->name() << "]"; std::cerr << " [has_content: " << block->has_content() << "] " << std::endl; debug_ast(block->arguments(), ind + " args: "); if (block->block()) for(auto i : block->block()->elements()) { debug_ast(i, ind + " ", env); } } else if (Ruleset* ruleset = dynamic_cast<Ruleset*>(node)) { std::cerr << ind << "Ruleset " << ruleset; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " [indent: " << ruleset->tabs() << "]"; std::cerr << (ruleset->at_root() ? " [@ROOT]" : ""); std::cerr << (ruleset->is_root() ? " [root]" : ""); std::cerr << std::endl; debug_ast(ruleset->selector(), ind + ">"); debug_ast(ruleset->block(), ind + " "); } else if (dynamic_cast<Block*>(node)) { Block* block = dynamic_cast<Block*>(node); std::cerr << ind << "Block " << block; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " [indent: " << block->tabs() << "]" << std::endl; for(auto i : block->elements()) { debug_ast(i, ind + " ", env); } } else if (dynamic_cast<Textual*>(node)) { Textual* expression = dynamic_cast<Textual*>(node); std::cerr << ind << "Textual "; if (expression->type() == Textual::NUMBER) std::cerr << " [NUMBER]"; else if (expression->type() == Textual::PERCENTAGE) std::cerr << " [PERCENTAGE]"; else if (expression->type() == Textual::DIMENSION) std::cerr << " [DIMENSION]"; else if (expression->type() == Textual::HEX) std::cerr << " [HEX]"; std::cerr << expression << " [" << expression->value() << "]"; std::cerr << " [interpolant: " << expression->is_interpolant() << "] "; if (expression->is_delayed()) std::cerr << " [delayed]"; std::cerr << std::endl; } else if (dynamic_cast<Variable*>(node)) { Variable* expression = dynamic_cast<Variable*>(node); std::cerr << ind << "Variable " << expression; std::cerr << " [interpolant: " << expression->is_interpolant() << "] "; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " [" << expression->name() << "]" << std::endl; std::string name(expression->name()); if (env && env->has(name)) debug_ast(static_cast<Expression*>((*env)[name]), ind + " -> ", env); } else if (dynamic_cast<Function_Call_Schema*>(node)) { Function_Call_Schema* expression = dynamic_cast<Function_Call_Schema*>(node); std::cerr << ind << "Function_Call_Schema " << expression; std::cerr << " [interpolant: " << expression->is_interpolant() << "] "; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << "" << std::endl; debug_ast(expression->name(), ind + "name: ", env); debug_ast(expression->arguments(), ind + " args: ", env); } else if (dynamic_cast<Function_Call*>(node)) { Function_Call* expression = dynamic_cast<Function_Call*>(node); std::cerr << ind << "Function_Call " << expression; std::cerr << " [interpolant: " << expression->is_interpolant() << "] "; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " [" << expression->name() << "]"; if (expression->is_delayed()) std::cerr << " [delayed]"; if (expression->is_interpolant()) std::cerr << " [interpolant]"; std::cerr << std::endl; debug_ast(expression->arguments(), ind + " args: ", env); } else if (dynamic_cast<Arguments*>(node)) { Arguments* expression = dynamic_cast<Arguments*>(node); std::cerr << ind << "Arguments " << expression; if (expression->is_delayed()) std::cerr << " [delayed]"; std::cerr << " (" << pstate_source_position(node) << ")"; if (expression->has_named_arguments()) std::cerr << " [has_named_arguments]"; if (expression->has_rest_argument()) std::cerr << " [has_rest_argument]"; if (expression->has_keyword_argument()) std::cerr << " [has_keyword_argument]"; std::cerr << std::endl; for(auto i : expression->elements()) { debug_ast(i, ind + " ", env); } } else if (dynamic_cast<Argument*>(node)) { Argument* expression = dynamic_cast<Argument*>(node); std::cerr << ind << "Argument " << expression; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " [" << expression->value() << "]"; std::cerr << " [name: " << expression->name() << "] "; std::cerr << " [rest: " << expression->is_rest_argument() << "] "; std::cerr << " [keyword: " << expression->is_keyword_argument() << "] " << std::endl; debug_ast(expression->value(), ind + " value: ", env); } else if (dynamic_cast<Parameters*>(node)) { Parameters* expression = dynamic_cast<Parameters*>(node); std::cerr << ind << "Parameters " << expression; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " [has_optional: " << expression->has_optional_parameters() << "] "; std::cerr << " [has_rest: " << expression->has_rest_parameter() << "] "; std::cerr << std::endl; for(auto i : expression->elements()) { debug_ast(i, ind + " ", env); } } else if (dynamic_cast<Parameter*>(node)) { Parameter* expression = dynamic_cast<Parameter*>(node); std::cerr << ind << "Parameter " << expression; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " [name: " << expression->name() << "] "; std::cerr << " [default: " << expression->default_value() << "] "; std::cerr << " [rest: " << expression->is_rest_parameter() << "] " << std::endl; } else if (dynamic_cast<Unary_Expression*>(node)) { Unary_Expression* expression = dynamic_cast<Unary_Expression*>(node); std::cerr << ind << "Unary_Expression " << expression; std::cerr << " [interpolant: " << expression->is_interpolant() << "] "; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " [" << expression->type() << "]" << std::endl; debug_ast(expression->operand(), ind + " operand: ", env); } else if (dynamic_cast<Binary_Expression*>(node)) { Binary_Expression* expression = dynamic_cast<Binary_Expression*>(node); std::cerr << ind << "Binary_Expression " << expression; if (expression->is_interpolant()) std::cerr << " [is interpolant] "; if (expression->is_left_interpolant()) std::cerr << " [left interpolant] "; if (expression->is_right_interpolant()) std::cerr << " [right interpolant] "; std::cerr << " [delayed: " << expression->is_delayed() << "] "; std::cerr << " [ws_before: " << expression->op().ws_before << "] "; std::cerr << " [ws_after: " << expression->op().ws_after << "] "; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " [" << expression->type_name() << "]" << std::endl; debug_ast(expression->left(), ind + " left: ", env); debug_ast(expression->right(), ind + " right: ", env); } else if (dynamic_cast<Map*>(node)) { Map* expression = dynamic_cast<Map*>(node); std::cerr << ind << "Map " << expression; std::cerr << " [interpolant: " << expression->is_interpolant() << "] "; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " [Hashed]" << std::endl; for (auto i : expression->elements()) { debug_ast(i.first, ind + " key: "); debug_ast(i.second, ind + " val: "); } } else if (dynamic_cast<List*>(node)) { List* expression = dynamic_cast<List*>(node); std::cerr << ind << "List " << expression; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " (" << expression->length() << ") " << (expression->separator() == SASS_COMMA ? "Comma " : expression->separator() == SASS_HASH ? "Map" : "Space ") << " [delayed: " << expression->is_delayed() << "] " << " [interpolant: " << expression->is_interpolant() << "] " << " [arglist: " << expression->is_arglist() << "] " << " [hash: " << expression->hash() << "] " << std::endl; for(auto i : expression->elements()) { debug_ast(i, ind + " ", env); } } else if (dynamic_cast<Content*>(node)) { Content* expression = dynamic_cast<Content*>(node); std::cerr << ind << "Content " << expression; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " [Statement]" << std::endl; } else if (dynamic_cast<Boolean*>(node)) { Boolean* expression = dynamic_cast<Boolean*>(node); std::cerr << ind << "Boolean " << expression; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " [interpolant: " << expression->is_interpolant() << "] "; std::cerr << " [" << expression->value() << "]" << std::endl; } else if (dynamic_cast<Color*>(node)) { Color* expression = dynamic_cast<Color*>(node); std::cerr << ind << "Color " << expression; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " [interpolant: " << expression->is_interpolant() << "] "; std::cerr << " [" << expression->r() << ":" << expression->g() << ":" << expression->b() << "@" << expression->a() << "]" << std::endl; } else if (dynamic_cast<Number*>(node)) { Number* expression = dynamic_cast<Number*>(node); std::cerr << ind << "Number " << expression; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " [interpolant: " << expression->is_interpolant() << "] "; std::cerr << " [" << expression->value() << expression->unit() << "]" << " [hash: " << expression->hash() << "] " << std::endl; } else if (dynamic_cast<String_Quoted*>(node)) { String_Quoted* expression = dynamic_cast<String_Quoted*>(node); std::cerr << ind << "String_Quoted " << expression; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " [" << prettyprint(expression->value()) << "]"; if (expression->is_delayed()) std::cerr << " [delayed]"; if (expression->sass_fix_1291()) std::cerr << " [sass_fix_1291]"; if (expression->is_interpolant()) std::cerr << " [interpolant]"; if (expression->quote_mark()) std::cerr << " [quote_mark: " << expression->quote_mark() << "]"; std::cerr << " <" << prettyprint(expression->pstate().token.ws_before()) << ">" << std::endl; } else if (dynamic_cast<String_Constant*>(node)) { String_Constant* expression = dynamic_cast<String_Constant*>(node); std::cerr << ind << "String_Constant " << expression; if (expression->concrete_type()) { std::cerr << " " << expression->concrete_type(); } std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " [" << prettyprint(expression->value()) << "]"; if (expression->is_delayed()) std::cerr << " [delayed]"; if (expression->sass_fix_1291()) std::cerr << " [sass_fix_1291]"; if (expression->is_interpolant()) std::cerr << " [interpolant]"; std::cerr << " <" << prettyprint(expression->pstate().token.ws_before()) << ">" << std::endl; } else if (dynamic_cast<String_Schema*>(node)) { String_Schema* expression = dynamic_cast<String_Schema*>(node); std::cerr << ind << "String_Schema " << expression; std::cerr << " " << expression->concrete_type(); if (expression->is_delayed()) std::cerr << " [delayed]"; if (expression->is_interpolant()) std::cerr << " [is interpolant]"; if (expression->has_interpolant()) std::cerr << " [has interpolant]"; if (expression->is_left_interpolant()) std::cerr << " [left interpolant] "; if (expression->is_right_interpolant()) std::cerr << " [right interpolant] "; std::cerr << " <" << prettyprint(expression->pstate().token.ws_before()) << ">" << std::endl; for(auto i : expression->elements()) { debug_ast(i, ind + " ", env); } } else if (dynamic_cast<String*>(node)) { String* expression = dynamic_cast<String*>(node); std::cerr << ind << "String " << expression; std::cerr << " " << expression->concrete_type(); std::cerr << " (" << pstate_source_position(node) << ")"; if (expression->sass_fix_1291()) std::cerr << " [sass_fix_1291]"; if (expression->is_interpolant()) std::cerr << " [interpolant]"; std::cerr << " <" << prettyprint(expression->pstate().token.ws_before()) << ">" << std::endl; } else if (dynamic_cast<Expression*>(node)) { Expression* expression = dynamic_cast<Expression*>(node); std::cerr << ind << "Expression " << expression; std::cerr << " (" << pstate_source_position(node) << ")"; switch (expression->concrete_type()) { case Expression::Concrete_Type::NONE: std::cerr << " [NONE]"; break; case Expression::Concrete_Type::BOOLEAN: std::cerr << " [BOOLEAN]"; break; case Expression::Concrete_Type::NUMBER: std::cerr << " [NUMBER]"; break; case Expression::Concrete_Type::COLOR: std::cerr << " [COLOR]"; break; case Expression::Concrete_Type::STRING: std::cerr << " [STRING]"; break; case Expression::Concrete_Type::LIST: std::cerr << " [LIST]"; break; case Expression::Concrete_Type::MAP: std::cerr << " [MAP]"; break; case Expression::Concrete_Type::SELECTOR: std::cerr << " [SELECTOR]"; break; case Expression::Concrete_Type::NULL_VAL: std::cerr << " [NULL_VAL]"; break; case Expression::Concrete_Type::C_WARNING: std::cerr << " [C_WARNING]"; break; case Expression::Concrete_Type::C_ERROR: std::cerr << " [C_ERROR]"; break; case Expression::Concrete_Type::NUM_TYPES: std::cerr << " [NUM_TYPES]"; break; } std::cerr << std::endl; } else if (dynamic_cast<Has_Block*>(node)) { Has_Block* has_block = dynamic_cast<Has_Block*>(node); std::cerr << ind << "Has_Block " << has_block; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " " << has_block->tabs() << std::endl; if (has_block->block()) for(auto i : has_block->block()->elements()) { debug_ast(i, ind + " ", env); } } else if (dynamic_cast<Statement*>(node)) { Statement* statement = dynamic_cast<Statement*>(node); std::cerr << ind << "Statement " << statement; std::cerr << " (" << pstate_source_position(node) << ")"; std::cerr << " " << statement->tabs() << std::endl; } if (ind == "") std::cerr << "####################################################################\n"; }
inline void debug_ast(AST_Node* node, string ind = "", Env* env = 0) { if (node == 0) return; if (ind == "") cerr << "####################################################################\n"; if (dynamic_cast<Bubble*>(node)) { Bubble* bubble = dynamic_cast<Bubble*>(node); cerr << ind << "Bubble " << bubble << " " << bubble->tabs() << endl; } else if (dynamic_cast<At_Root_Block*>(node)) { At_Root_Block* root_block = dynamic_cast<At_Root_Block*>(node); cerr << ind << "At_Root_Block " << root_block << " " << root_block->tabs() << endl; if (root_block->block()) for(auto i : root_block->block()->elements()) { debug_ast(i, ind + " ", env); } } else if (dynamic_cast<Selector_List*>(node)) { Selector_List* selector = dynamic_cast<Selector_List*>(node); cerr << ind << "Selector_List " << selector << " [block:" << selector->last_block() << "]" << (selector->last_block() && selector->last_block()->is_root() ? " [root]" : "") << " [@media:" << selector->media_block() << "]" << (selector->is_optional() ? " [is_optional]": " -") << (selector->has_line_break() ? " [line-break]": " -") << (selector->has_line_feed() ? " [line-feed]": " -") << endl; for(auto i : selector->elements()) { debug_ast(i, ind + " ", env); } // } else if (dynamic_cast<Expression*>(node)) { // Expression* expression = dynamic_cast<Expression*>(node); // cerr << ind << "Expression " << expression << " " << expression->concrete_type() << endl; } else if (dynamic_cast<Parent_Selector*>(node)) { Parent_Selector* selector = dynamic_cast<Parent_Selector*>(node); cerr << ind << "Parent_Selector " << selector; cerr << " <" << prettyprint(selector->pstate().token.ws_before()) << ">" << endl; debug_ast(selector->selector(), ind + "->", env); } else if (dynamic_cast<Complex_Selector*>(node)) { Complex_Selector* selector = dynamic_cast<Complex_Selector*>(node); cerr << ind << "Complex_Selector " << selector << " [block:" << selector->last_block() << "]" << " [weight:" << longToHex(selector->specificity()) << "]" << (selector->last_block() && selector->last_block()->is_root() ? " [root]" : "") << " [@media:" << selector->media_block() << "]" << (selector->is_optional() ? " [is_optional]": " -") << (selector->has_line_break() ? " [line-break]": " -") << (selector->has_line_feed() ? " [line-feed]": " -") << " -> "; switch (selector->combinator()) { case Complex_Selector::PARENT_OF: cerr << "{>}"; break; case Complex_Selector::PRECEDES: cerr << "{~}"; break; case Complex_Selector::ADJACENT_TO: cerr << "{+}"; break; case Complex_Selector::ANCESTOR_OF: cerr << "{ }"; break; } cerr << " <" << prettyprint(selector->pstate().token.ws_before()) << ">" << endl; debug_ast(selector->head(), ind + " ", env); debug_ast(selector->tail(), ind + "-", env); } else if (dynamic_cast<Compound_Selector*>(node)) { Compound_Selector* selector = dynamic_cast<Compound_Selector*>(node); cerr << ind << "Compound_Selector " << selector; cerr << " [block:" << selector->last_block() << "]"; cerr << " [weight:" << longToHex(selector->specificity()) << "]"; // cerr << (selector->last_block() && selector->last_block()->is_root() ? " [root]" : ""); cerr << " [@media:" << selector->media_block() << "]"; cerr << (selector->is_optional() ? " [is_optional]": " -"); cerr << (selector->has_line_break() ? " [line-break]": " -"); cerr << (selector->has_line_feed() ? " [line-feed]": " -"); cerr << " <" << prettyprint(selector->pstate().token.ws_before()) << ">" << endl; for(auto i : selector->elements()) { debug_ast(i, ind + " ", env); } } else if (dynamic_cast<Propset*>(node)) { Propset* selector = dynamic_cast<Propset*>(node); cerr << ind << "Propset " << selector << " " << selector->tabs() << endl; if (selector->block()) for(auto i : selector->block()->elements()) { debug_ast(i, ind + " ", env); } } else if (dynamic_cast<Wrapped_Selector*>(node)) { Wrapped_Selector* selector = dynamic_cast<Wrapped_Selector*>(node); cerr << ind << "Wrapped_Selector " << selector << " <<" << selector->name() << ">>" << (selector->has_line_break() ? " [line-break]": " -") << (selector->has_line_feed() ? " [line-feed]": " -") << endl; debug_ast(selector->selector(), ind + " () ", env); } else if (dynamic_cast<Pseudo_Selector*>(node)) { Pseudo_Selector* selector = dynamic_cast<Pseudo_Selector*>(node); cerr << ind << "Pseudo_Selector " << selector << " <<" << selector->name() << ">>" << (selector->has_line_break() ? " [line-break]": " -") << (selector->has_line_feed() ? " [line-feed]": " -") << endl; debug_ast(selector->expression(), ind + " <= ", env); } else if (dynamic_cast<Attribute_Selector*>(node)) { Attribute_Selector* selector = dynamic_cast<Attribute_Selector*>(node); cerr << ind << "Attribute_Selector " << selector << " <<" << selector->name() << ">>" << (selector->has_line_break() ? " [line-break]": " -") << (selector->has_line_feed() ? " [line-feed]": " -") << endl; debug_ast(selector->value(), ind + "[" + selector->matcher() + "] ", env); } else if (dynamic_cast<Selector_Qualifier*>(node)) { Selector_Qualifier* selector = dynamic_cast<Selector_Qualifier*>(node); cerr << ind << "Selector_Qualifier " << selector << " <<" << selector->name() << ">>" << (selector->has_line_break() ? " [line-break]": " -") << (selector->has_line_feed() ? " [line-feed]": " -") << endl; } else if (dynamic_cast<Type_Selector*>(node)) { Type_Selector* selector = dynamic_cast<Type_Selector*>(node); cerr << ind << "Type_Selector " << selector << " <<" << selector->name() << ">>" << (selector->has_line_break() ? " [line-break]": " -") << " <" << prettyprint(selector->pstate().token.ws_before()) << ">" << endl; } else if (dynamic_cast<Selector_Placeholder*>(node)) { Selector_Placeholder* selector = dynamic_cast<Selector_Placeholder*>(node); cerr << ind << "Selector_Placeholder [" << selector->name() << "] " << selector << " [block:" << selector->last_block() << "]" << " [@media:" << selector->media_block() << "]" << (selector->is_optional() ? " [is_optional]": " -") << (selector->has_line_break() ? " [line-break]": " -") << (selector->has_line_feed() ? " [line-feed]": " -") << endl; } else if (dynamic_cast<Selector_Reference*>(node)) { Selector_Reference* selector = dynamic_cast<Selector_Reference*>(node); cerr << ind << "Selector_Reference " << selector << " @ref " << selector->selector() << endl; } else if (dynamic_cast<Simple_Selector*>(node)) { Simple_Selector* selector = dynamic_cast<Simple_Selector*>(node); cerr << ind << "Simple_Selector " << selector << (selector->has_line_break() ? " [line-break]": " -") << (selector->has_line_feed() ? " [line-feed]": " -") << endl; } else if (dynamic_cast<Selector_Schema*>(node)) { Selector_Schema* selector = dynamic_cast<Selector_Schema*>(node); cerr << ind << "Selector_Schema " << selector << " [block:" << selector->last_block() << "]" << (selector->last_block() && selector->last_block()->is_root() ? " [root]" : "") << " [@media:" << selector->media_block() << "]" << (selector->has_line_break() ? " [line-break]": " -") << (selector->has_line_feed() ? " [line-feed]": " -") << endl; debug_ast(selector->contents(), ind + " "); // for(auto i : selector->elements()) { debug_ast(i, ind + " ", env); } } else if (dynamic_cast<Selector*>(node)) { Selector* selector = dynamic_cast<Selector*>(node); cerr << ind << "Selector " << selector << (selector->has_line_break() ? " [line-break]": " -") << (selector->has_line_feed() ? " [line-feed]": " -") << endl; } else if (dynamic_cast<Media_Query_Expression*>(node)) { Media_Query_Expression* block = dynamic_cast<Media_Query_Expression*>(node); cerr << ind << "Media_Query_Expression " << block << (block->is_interpolated() ? " [is_interpolated]": " -") << endl; debug_ast(block->feature(), ind + " f) "); debug_ast(block->value(), ind + " v) "); } else if (dynamic_cast<Media_Query*>(node)) { Media_Query* block = dynamic_cast<Media_Query*>(node); cerr << ind << "Media_Query " << block << (block->is_negated() ? " [is_negated]": " -") << (block->is_restricted() ? " [is_restricted]": " -") << endl; debug_ast(block->media_type(), ind + " "); for(auto i : block->elements()) { debug_ast(i, ind + " ", env); } } else if (dynamic_cast<Media_Block*>(node)) { Media_Block* block = dynamic_cast<Media_Block*>(node); cerr << ind << "Media_Block " << block << " " << block->tabs() << endl; debug_ast(block->media_queries(), ind + " =@ "); debug_ast(block->selector(), ind + " -@ "); if (block->block()) for(auto i : block->block()->elements()) { debug_ast(i, ind + " ", env); } } else if (dynamic_cast<Feature_Block*>(node)) { Feature_Block* block = dynamic_cast<Feature_Block*>(node); cerr << ind << "Feature_Block " << block << " " << block->tabs() << endl; if (block->block()) for(auto i : block->block()->elements()) { debug_ast(i, ind + " ", env); } } else if (dynamic_cast<Block*>(node)) { Block* root_block = dynamic_cast<Block*>(node); cerr << ind << "Block " << root_block << " " << root_block->tabs() << endl; if (root_block->block()) for(auto i : root_block->block()->elements()) { debug_ast(i, ind + " ", env); } } else if (dynamic_cast<Warning*>(node)) { Warning* block = dynamic_cast<Warning*>(node); cerr << ind << "Warning " << block << " " << block->tabs() << endl; } else if (dynamic_cast<Error*>(node)) { Error* block = dynamic_cast<Error*>(node); cerr << ind << "Error " << block << " " << block->tabs() << endl; } else if (dynamic_cast<Debug*>(node)) { Debug* block = dynamic_cast<Debug*>(node); cerr << ind << "Debug " << block << " " << block->tabs() << endl; } else if (dynamic_cast<Comment*>(node)) { Comment* block = dynamic_cast<Comment*>(node); cerr << ind << "Comment " << block << " " << block->tabs() << " <" << prettyprint(block->pstate().token.ws_before()) << ">" << endl; debug_ast(block->text(), ind + "// ", env); } else if (dynamic_cast<If*>(node)) { If* block = dynamic_cast<If*>(node); cerr << ind << "If " << block << " " << block->tabs() << endl; } else if (dynamic_cast<Return*>(node)) { Return* block = dynamic_cast<Return*>(node); cerr << ind << "Return " << block << " " << block->tabs() << endl; } else if (dynamic_cast<Extension*>(node)) { Extension* block = dynamic_cast<Extension*>(node); cerr << ind << "Extension " << block << " " << block->tabs() << endl; debug_ast(block->selector(), ind + "-> ", env); } else if (dynamic_cast<Content*>(node)) { Content* block = dynamic_cast<Content*>(node); cerr << ind << "Content " << block << " " << block->tabs() << endl; } else if (dynamic_cast<Import_Stub*>(node)) { Import_Stub* block = dynamic_cast<Import_Stub*>(node); cerr << ind << "Import_Stub " << block << " " << block->tabs() << endl; } else if (dynamic_cast<Import*>(node)) { Import* block = dynamic_cast<Import*>(node); cerr << ind << "Import " << block << " " << block->tabs() << endl; // vector<string> files_; for (auto imp : block->urls()) debug_ast(imp, "@ ", env); } else if (dynamic_cast<Assignment*>(node)) { Assignment* block = dynamic_cast<Assignment*>(node); cerr << ind << "Assignment " << block << " <<" << block->variable() << ">> " << block->tabs() << endl; debug_ast(block->value(), ind + "=", env); } else if (dynamic_cast<Declaration*>(node)) { Declaration* block = dynamic_cast<Declaration*>(node); cerr << ind << "Declaration " << block << " " << block->tabs() << endl; debug_ast(block->property(), ind + " prop: ", env); debug_ast(block->value(), ind + " value: ", env); } else if (dynamic_cast<Keyframe_Rule*>(node)) { Keyframe_Rule* has_block = dynamic_cast<Keyframe_Rule*>(node); cerr << ind << "Keyframe_Rule " << has_block << " " << has_block->tabs() << endl; if (has_block->selector()) debug_ast(has_block->selector(), ind + "@"); if (has_block->block()) for(auto i : has_block->block()->elements()) { debug_ast(i, ind + " ", env); } } else if (dynamic_cast<At_Rule*>(node)) { At_Rule* block = dynamic_cast<At_Rule*>(node); cerr << ind << "At_Rule " << block << " [" << block->keyword() << "] " << block->tabs() << endl; debug_ast(block->value(), ind + "+", env); debug_ast(block->selector(), ind + "~", env); if (block->block()) for(auto i : block->block()->elements()) { debug_ast(i, ind + " ", env); } } else if (dynamic_cast<Each*>(node)) { Each* block = dynamic_cast<Each*>(node); cerr << ind << "Each " << block << " " << block->tabs() << endl; if (block->block()) for(auto i : block->block()->elements()) { debug_ast(i, ind + " ", env); } } else if (dynamic_cast<For*>(node)) { For* block = dynamic_cast<For*>(node); cerr << ind << "For " << block << " " << block->tabs() << endl; if (block->block()) for(auto i : block->block()->elements()) { debug_ast(i, ind + " ", env); } } else if (dynamic_cast<While*>(node)) { While* block = dynamic_cast<While*>(node); cerr << ind << "While " << block << " " << block->tabs() << endl; if (block->block()) for(auto i : block->block()->elements()) { debug_ast(i, ind + " ", env); } } else if (dynamic_cast<Definition*>(node)) { Definition* block = dynamic_cast<Definition*>(node); cerr << ind << "Definition " << block << " " << block->tabs() << endl; if (block->block()) for(auto i : block->block()->elements()) { debug_ast(i, ind + " ", env); } } else if (dynamic_cast<Mixin_Call*>(node)) { Mixin_Call* block = dynamic_cast<Mixin_Call*>(node); cerr << ind << "Mixin_Call " << block << " " << block->tabs() << endl; if (block->block()) for(auto i : block->block()->elements()) { debug_ast(i, ind + " ", env); } } else if (dynamic_cast<Ruleset*>(node)) { Ruleset* ruleset = dynamic_cast<Ruleset*>(node); cerr << ind << "Ruleset " << ruleset << " " << ruleset->tabs() << endl; debug_ast(ruleset->selector(), ind + " "); if (ruleset->block()) for(auto i : ruleset->block()->elements()) { debug_ast(i, ind + " ", env); } } else if (dynamic_cast<Block*>(node)) { Block* block = dynamic_cast<Block*>(node); cerr << ind << "Block " << block << " " << block->tabs() << endl; for(auto i : block->elements()) { debug_ast(i, ind + " ", env); } } else if (dynamic_cast<Textual*>(node)) { Textual* expression = dynamic_cast<Textual*>(node); cerr << ind << "Textual "; if (expression->type() == Textual::NUMBER) cerr << " [NUMBER]"; else if (expression->type() == Textual::PERCENTAGE) cerr << " [PERCENTAGE]"; else if (expression->type() == Textual::DIMENSION) cerr << " [DIMENSION]"; else if (expression->type() == Textual::HEX) cerr << " [HEX]"; cerr << expression << " [" << expression->value() << "]" << endl; } else if (dynamic_cast<Variable*>(node)) { Variable* expression = dynamic_cast<Variable*>(node); cerr << ind << "Variable " << expression << " [" << expression->name() << "]" << endl; string name(expression->name()); if (env && env->has(name)) debug_ast(static_cast<Expression*>((*env)[name]), ind + " -> ", env); } else if (dynamic_cast<Function_Call_Schema*>(node)) { Function_Call_Schema* expression = dynamic_cast<Function_Call_Schema*>(node); cerr << ind << "Function_Call_Schema " << expression << "]" << endl; debug_ast(expression->name(), ind + "name: ", env); debug_ast(expression->arguments(), ind + " args: ", env); } else if (dynamic_cast<Function_Call*>(node)) { Function_Call* expression = dynamic_cast<Function_Call*>(node); cerr << ind << "Function_Call " << expression << " [" << expression->name() << "]" << endl; debug_ast(expression->arguments(), ind + " args: ", env); } else if (dynamic_cast<Arguments*>(node)) { Arguments* expression = dynamic_cast<Arguments*>(node); cerr << ind << "Arguments " << expression << "]" << endl; for(auto i : expression->elements()) { debug_ast(i, ind + " ", env); } } else if (dynamic_cast<Argument*>(node)) { Argument* expression = dynamic_cast<Argument*>(node); cerr << ind << "Argument " << expression << " [" << expression->value() << "]" << endl; debug_ast(expression->value(), ind + " value: ", env); } else if (dynamic_cast<Unary_Expression*>(node)) { Unary_Expression* expression = dynamic_cast<Unary_Expression*>(node); cerr << ind << "Unary_Expression " << expression << " [" << expression->type() << "]" << endl; debug_ast(expression->operand(), ind + " operand: ", env); } else if (dynamic_cast<Binary_Expression*>(node)) { Binary_Expression* expression = dynamic_cast<Binary_Expression*>(node); cerr << ind << "Binary_Expression " << expression << " [" << expression->type() << "]" << endl; debug_ast(expression->left(), ind + " left: ", env); debug_ast(expression->right(), ind + " right: ", env); } else if (dynamic_cast<Map*>(node)) { Map* expression = dynamic_cast<Map*>(node); cerr << ind << "Map " << expression << " [Hashed]" << endl; } else if (dynamic_cast<List*>(node)) { List* expression = dynamic_cast<List*>(node); cerr << ind << "List " << expression << " (" << expression->length() << ") " << (expression->separator() == Sass::List::Separator::COMMA ? "Comma " : "Space ") << " [delayed: " << expression->is_delayed() << "] " << " [interpolant: " << expression->is_interpolant() << "] " << endl; for(auto i : expression->elements()) { debug_ast(i, ind + " ", env); } } else if (dynamic_cast<Content*>(node)) { Content* expression = dynamic_cast<Content*>(node); cerr << ind << "Content " << expression << " [Statement]" << endl; } else if (dynamic_cast<Boolean*>(node)) { Boolean* expression = dynamic_cast<Boolean*>(node); cerr << ind << "Boolean " << expression << " [" << expression->value() << "]" << endl; } else if (dynamic_cast<Color*>(node)) { Color* expression = dynamic_cast<Color*>(node); cerr << ind << "Color " << expression << " [" << expression->r() << ":" << expression->g() << ":" << expression->b() << "@" << expression->a() << "]" << endl; } else if (dynamic_cast<Number*>(node)) { Number* expression = dynamic_cast<Number*>(node); cerr << ind << "Number " << expression << " [" << expression->value() << expression->unit() << "]" << endl; } else if (dynamic_cast<String_Quoted*>(node)) { String_Quoted* expression = dynamic_cast<String_Quoted*>(node); cerr << ind << "String_Quoted : " << expression << " [" << prettyprint(expression->value()) << "]" << (expression->is_delayed() ? " {delayed}" : "") << (expression->sass_fix_1291() ? " {sass_fix_1291}" : "") << (expression->quote_mark() != 0 ? " {qm:" + string(1, expression->quote_mark()) + "}" : "") << " <" << prettyprint(expression->pstate().token.ws_before()) << ">" << endl; } else if (dynamic_cast<String_Constant*>(node)) { String_Constant* expression = dynamic_cast<String_Constant*>(node); cerr << ind << "String_Constant : " << expression << " [" << prettyprint(expression->value()) << "]" << (expression->is_delayed() ? " {delayed}" : "") << (expression->sass_fix_1291() ? " {sass_fix_1291}" : "") << " <" << prettyprint(expression->pstate().token.ws_before()) << ">" << endl; } else if (dynamic_cast<String_Schema*>(node)) { String_Schema* expression = dynamic_cast<String_Schema*>(node); cerr << ind << "String_Schema " << expression << " " << expression->concrete_type() << (expression->has_interpolants() ? " {has_interpolants}" : "") << endl; for(auto i : expression->elements()) { debug_ast(i, ind + " ", env); } } else if (dynamic_cast<String*>(node)) { String* expression = dynamic_cast<String*>(node); cerr << ind << "String " << expression << expression->concrete_type() << " " << (expression->sass_fix_1291() ? "{sass_fix_1291}" : "") << endl; } else if (dynamic_cast<Expression*>(node)) { Expression* expression = dynamic_cast<Expression*>(node); cerr << ind << "Expression " << expression; switch (expression->concrete_type()) { case Expression::Concrete_Type::NONE: cerr << " [NONE]"; break; case Expression::Concrete_Type::BOOLEAN: cerr << " [BOOLEAN]"; break; case Expression::Concrete_Type::NUMBER: cerr << " [NUMBER]"; break; case Expression::Concrete_Type::COLOR: cerr << " [COLOR]"; break; case Expression::Concrete_Type::STRING: cerr << " [STRING]"; break; case Expression::Concrete_Type::LIST: cerr << " [LIST]"; break; case Expression::Concrete_Type::MAP: cerr << " [MAP]"; break; case Expression::Concrete_Type::SELECTOR: cerr << " [SELECTOR]"; break; case Expression::Concrete_Type::NULL_VAL: cerr << " [NULL_VAL]"; break; case Expression::Concrete_Type::NUM_TYPES: cerr << " [NUM_TYPES]"; break; } cerr << endl; } else if (dynamic_cast<Has_Block*>(node)) { Has_Block* has_block = dynamic_cast<Has_Block*>(node); cerr << ind << "Has_Block " << has_block << " " << has_block->tabs() << endl; if (has_block->block()) for(auto i : has_block->block()->elements()) { debug_ast(i, ind + " ", env); } } else if (dynamic_cast<Statement*>(node)) { Statement* statement = dynamic_cast<Statement*>(node); cerr << ind << "Statement " << statement << " " << statement->tabs() << endl; } if (ind == "") cerr << "####################################################################\n"; }
virtual void endVisit(AST::CallExpression *node) { m_bSource.clear(); if (AST::IdentifierExpression *idExpr = AST::cast<AST::IdentifierExpression *>(node->base)) { if (idExpr->name->asString() == QLatin1String("qsTr") || idExpr->name->asString() == QLatin1String("QT_TR_NOOP")) { if (!node->arguments) return; AST::BinaryExpression *binary = AST::cast<AST::BinaryExpression *>(node->arguments->expression); if (binary) { if (!createString(binary)) m_bSource.clear(); } AST::StringLiteral *literal = AST::cast<AST::StringLiteral *>(node->arguments->expression); if (literal || !m_bSource.isEmpty()) { const QString source = literal ? literal->value->asString() : m_bSource; QString comment; bool plural = false; AST::ArgumentList *commentNode = node->arguments->next; if (commentNode && AST::cast<AST::StringLiteral *>(commentNode->expression)) { literal = AST::cast<AST::StringLiteral *>(commentNode->expression); comment = literal->value->asString(); AST::ArgumentList *nNode = commentNode->next; if (nNode) plural = true; } QString id; QString extracomment; TranslatorMessage::ExtraData extra; Comment scomment = findComment(node->firstSourceLocation().startLine); if (scomment.isValid()) { extracomment = scomment.extracomment; extra = scomment.extra; id = scomment.msgid; } TranslatorMessage msg(m_component, source, comment, QString(), m_fileName, node->firstSourceLocation().startLine, QStringList(), TranslatorMessage::Unfinished, plural); msg.setExtraComment(extracomment.simplified()); msg.setId(id); msg.setExtras(extra); m_translator->extend(msg); } } else if (idExpr->name->asString() == QLatin1String("qsTranslate") || idExpr->name->asString() == QLatin1String("QT_TRANSLATE_NOOP")) { if (node->arguments && AST::cast<AST::StringLiteral *>(node->arguments->expression)) { AST::StringLiteral *literal = AST::cast<AST::StringLiteral *>(node->arguments->expression); const QString context = literal->value->asString(); QString source; QString comment; bool plural = false; AST::ArgumentList *sourceNode = node->arguments->next; if (!sourceNode) return; literal = AST::cast<AST::StringLiteral *>(sourceNode->expression); AST::BinaryExpression *binary = AST::cast<AST::BinaryExpression *>(sourceNode->expression); if (binary) { if (!createString(binary)) m_bSource.clear(); } if (!literal && m_bSource.isEmpty()) return; QString id; QString extracomment; TranslatorMessage::ExtraData extra; Comment scomment = findComment(node->firstSourceLocation().startLine); if (scomment.isValid()) { extracomment = scomment.extracomment; extra = scomment.extra; id = scomment.msgid; } source = literal ? literal->value->asString() : m_bSource; AST::ArgumentList *commentNode = sourceNode->next; if (commentNode && AST::cast<AST::StringLiteral *>(commentNode->expression)) { literal = AST::cast<AST::StringLiteral *>(commentNode->expression); comment = literal->value->asString(); AST::ArgumentList *nNode = commentNode->next; if (nNode) plural = true; } TranslatorMessage msg(context, source, comment, QString(), m_fileName, node->firstSourceLocation().startLine, QStringList(), TranslatorMessage::Unfinished, plural); msg.setExtraComment(extracomment.simplified()); msg.setId(id); msg.setExtras(extra); m_translator->extend(msg); } } else if (idExpr->name->asString() == QLatin1String("qsTrId") || idExpr->name->asString() == QLatin1String("QT_TRID_NOOP")) { if (!node->arguments) return; AST::StringLiteral *literal = AST::cast<AST::StringLiteral *>(node->arguments->expression); if (literal) { QString extracomment; QString sourcetext; TranslatorMessage::ExtraData extra; Comment comment = findComment(node->firstSourceLocation().startLine); if (comment.isValid()) { extracomment = comment.extracomment; sourcetext = comment.sourcetext; extra = comment.extra; } const QString id = literal->value->asString(); bool plural = node->arguments->next; TranslatorMessage msg(QString(), sourcetext, QString(), QString(), m_fileName, node->firstSourceLocation().startLine, QStringList(), TranslatorMessage::Unfinished, plural); msg.setExtraComment(extracomment.simplified()); msg.setId(id); msg.setExtras(extra); m_translator->extend(msg); } } } }
void ScrapbookUI::viewBlog(int index) { erase(); bool isBlog = checkType(index); if( !isBlog){ endwin(); return; } bool commenting = true; int offset=0; int row = 2; int max, displayNumber=7; while(commenting){ std::vector<Post*> wholeScrapbook = scrapbook->getAllPosts(); erase(); refresh(); Blog* currentBlog; currentBlog = (Blog*) wholeScrapbook[index]; QString *currentContent = new QString(currentBlog->getContent()); std::vector<Comment*> allComments = currentBlog->getAllComments(); erase(); endwin(); erase(); mvprintw(0, 0, "Press up or down to scroll or Enter to post comment."); mvprintw(2,0, "Blog Title: "); printw(currentBlog->getTitle().toStdString().c_str()); mvprintw(3,0, "Content: "); printw(currentContent->toStdString().c_str()); mvprintw(12, 0, "Comments:"); refresh(); row=13; if(allComments.size() < displayNumber) max = allComments.size(); else max = offset+displayNumber; for(int i=offset;i<max;i++){ Comment *currentComment = allComments.at(i); QString currentContent = currentComment->getAuthorUsername() + ": " + currentComment->getContent(); mvprintw(row, 0, currentContent.toStdString().c_str()); refresh(); row++; } int ch= getch(); if(ch==KEY_DOWN && !((allComments.size())==(max))) offset++; else if(ch==KEY_UP && offset>0) offset--; else if(ch==KEY_UP); else if(ch==KEY_DOWN); else if(ch==10){//enter key postComment(index); if(allComments.size() > displayNumber) offset=allComments.size()-displayNumber - 1; } else commenting=false; } }
void main() { try { std::stack<PNode<XMLValue>*> *nStack = new std::stack<PNode<XMLValue>*>; PNode<XMLValue>* rootnode = new PNode<XMLValue>(XMLValue(XMLValue::TAG,"Document")); XMLTree* xtree = new XMLTree(rootnode); ParserState* ps = new ParserState; Toker* pToker = new Toker; pToker->setMode(Toker::xml); //XML parser mode XmlParts* pSemi = new XmlParts(pToker); Parser* pParser = new Parser(pSemi); ElementEnd* pElementendrule = new ElementEnd(nStack,ps); ElementStart* pElementstartrule = new ElementStart(nStack,ps); ElementSelfClosed* pElementselfcrule = new ElementSelfClosed(nStack,ps); Text* ptextrule = new Text(nStack,ps); Comment* pCommentrule = new Comment(nStack,ps); ProcInstr* pIinstrrule = new ProcInstr(nStack,ps); EndFound* pEndact = new EndFound(nStack,xtree); StartFound* pStartact = new StartFound(nStack,xtree); SelfClosedFound* pSelfClosedact = new SelfClosedFound(nStack,xtree); TextFound* pTextact = new TextFound(nStack,xtree); CommentFound* pCommentact = new CommentFound(nStack,xtree); ProcInstrFound* pInstract = new ProcInstrFound(nStack,xtree); pElementendrule->addAction(pEndact); pElementstartrule->addAction(pStartact); pElementselfcrule->addAction(pSelfClosedact); ptextrule->addAction(pTextact); pCommentrule->addAction(pCommentact); pIinstrrule->addAction(pInstract); pParser->addRule(pElementendrule); pParser->addRule(pElementstartrule); pParser->addRule(pElementselfcrule); pParser->addRule(ptextrule); pParser->addRule(pCommentrule); pParser->addRule(pIinstrrule); nStack->push(rootnode); if(pParser) { if(! pToker->attach("..\\LectureNote.xml")) { std::cout << "\n could not open file " << std::endl; return; } } while(pParser->next()) pParser->parse(); //display the tree and the rebuilt xml XMLDisplay disply(xtree); //generate the string of tree and rebuilt xml disply.buildTreeDisplay(); disply.rebuildXML(); //attach the output file to the display object disply.AttachFile("..\\output.txt"); //display them std::cout<<"=======================Parser Tree====================="<<std::endl; std::cout<<disply.OutputTree(); std::cout << "\n\n"; std::cout<<"=====================Rebuild XML====================="<<std::endl; std::cout<<disply.OutputXML(); delete pEndact; delete pStartact; delete pSelfClosedact; delete pTextact; delete pCommentact; delete pInstract; delete pElementendrule; delete pElementstartrule; delete pElementselfcrule; delete ptextrule; delete pCommentrule; delete pIinstrrule; delete pToker; delete pSemi; delete pParser; delete ps; delete nStack; xtree->remove(xtree->getroot()); std::vector< PNode<XMLValue>* > deletednodes = xtree->getdeletednodes(); for(size_t i = 0; i < deletednodes.size(); ++i) delete deletednodes[i]; delete xtree; } catch(std::exception& ex) { std::cout << "\n\n " << ex.what() << "\n\n"; } ::system("pause"); }
void XmlWriter::WriteComment(const Comment& rComment) { WriteIndent(); m_rStream << "<!--" << EscapeString(rComment.GetValue()) << "-->"; }
void Decoder::decodeVariation(Consumer& consumer, util::ByteStream& data, ByteStream& text) { MarkSet marks; MoveInfoSet moveInfo; Annotation annotation; mstl::string buf; Comment comment; Comment preComment; bool hasNote(false); // satisfies the compiler unsigned pieceNum(0); // satisfies the compiler Move move; Move lastMove; while (true) { Byte b = m_strm.get(); if (__builtin_expect(b > token::Last, 1)) { if (move) { if (hasNote) { consumer.putMove(move, annotation, preComment, comment, marks); if (!moveInfo.isEmpty()) { consumer.putMoveInfo(moveInfo); moveInfo.clear(); } marks.clear(); annotation.clear(); comment.clear(); preComment.clear(); hasNote = false; } else { consumer.putMove(move); } m_position.doMove(move, pieceNum); } else { if (lastMove) { m_position.doMove(lastMove, pieceNum); lastMove.clear(); } if (hasNote) { consumer.putPrecedingComment(comment, annotation, marks); marks.clear(); annotation.clear(); comment.clear(); hasNote = false; } } pieceNum = decodeMove(b, move); } else { switch (b) { case token::End_Marker: if (move) { if (hasNote) { consumer.putMove(move, annotation, preComment, comment, marks); if (!moveInfo.isEmpty()) consumer.putMoveInfo(moveInfo); } else { consumer.putMove(move); } } else if (hasNote) { consumer.putPrecedingComment(comment, annotation, marks); hasNote = false; } switch (m_strm.get()) { case token::Comment: { uint8_t flag = data.get(); buf.clear(); text.get(buf); comment.swap(buf, bool(flag & comm::Ante_Eng), bool(flag & comm::Ante_Oth)); consumer.putTrailingComment(comment); break; } case token::End_Marker: break; default: return; //IO_RAISE(Game, Corrupted, "unexpected token"); } return; case token::Start_Marker: if (move) { if (hasNote) { consumer.putMove(move, annotation, preComment, comment, marks); if (!moveInfo.isEmpty()) { consumer.putMoveInfo(moveInfo); moveInfo.clear(); } marks.clear(); annotation.clear(); comment.clear(); preComment.clear(); hasNote = false; } else { consumer.putMove(move); } lastMove = move; move.clear(); } //M_ASSERT(!hasNote); m_position.push(); m_position.board().undoMove(lastMove); consumer.startVariation(); decodeVariation(consumer, data, text); consumer.finishVariation(); m_position.pop(); break; case token::Nag: { nag::ID nag = nag::ID(m_strm.get()); if (nag == 0) { move.setLegalMove(false); } else { annotation.add(nag); hasNote = true; } } break; case token::Mark: if (data.peek() & 0x80) moveInfo.add().decode(data); else marks.add().decode(data); hasNote = true; break; case token::Comment: { uint8_t flag = data.get(); if (flag & comm::Ante) { buf.clear(); text.get(buf); preComment.swap(buf, bool(flag & comm::Ante_Eng), bool(flag & comm::Ante_Oth)); } if (flag & comm::Post) { buf.clear(); text.get(buf); comment.swap(buf, bool(flag & comm::Post_Eng), bool(flag & comm::Post_Oth)); } hasNote = true; } break; } } } }