Ejemplo n.º 1
0
  Node complexSelectorToNode(Complex_Selector_Ptr pToConvert, Context& ctx) {
    if (pToConvert == NULL) {
      return Node::createNil();
    }
    Node node = Node::createCollection();
    node.got_line_feed = pToConvert->has_line_feed();
    bool has_lf = pToConvert->has_line_feed();

    // unwrap the selector from parent ref
    if (pToConvert->head() && pToConvert->head()->has_parent_ref()) {
      Complex_Selector_Obj tail = pToConvert->tail();
      if (tail) tail->has_line_feed(pToConvert->has_line_feed());
      pToConvert = tail;
    }

    while (pToConvert) {

      bool empty_parent_ref = pToConvert->head() && pToConvert->head()->is_empty_reference();

      if (pToConvert->head() || empty_parent_ref) {
      }

      // the first Complex_Selector may contain a dummy head pointer, skip it.
      if (pToConvert->head() && !empty_parent_ref) {
        node.collection()->push_back(Node::createSelector(pToConvert, ctx));
        if (has_lf) node.collection()->back().got_line_feed = has_lf;
        has_lf = false;
      }

      if (pToConvert->combinator() != Complex_Selector::ANCESTOR_OF) {
        node.collection()->push_back(Node::createCombinator(pToConvert->combinator()));
        if (has_lf) node.collection()->back().got_line_feed = has_lf;
        has_lf = false;
      }

      if (pToConvert && empty_parent_ref && pToConvert->tail()) {
        // pToConvert->tail()->has_line_feed(pToConvert->has_line_feed());
      }

      pToConvert = pToConvert->tail();
    }

    return node;
  }
Ejemplo n.º 2
0
  Node Node::createSelector(Complex_Selector_Ptr pSelector, Context& ctx) {
    NodeDequePtr null;

    Complex_Selector_Ptr pStripped = SASS_MEMORY_COPY(pSelector);
    pStripped->tail(NULL);
    pStripped->combinator(Complex_Selector::ANCESTOR_OF);

    Node n(SELECTOR, Complex_Selector::ANCESTOR_OF, pStripped, null /*pCollection*/);
    if (pSelector) n.got_line_feed = pSelector->has_line_feed();
    return n;
  }
Ejemplo n.º 3
0
  Expression_Ptr Listize::operator()(Complex_Selector_Ptr sel)
  {
    List_Obj l = SASS_MEMORY_NEW(List, sel->pstate(), 2);
    l->from_selector(true);
    Compound_Selector_Obj head = sel->head();
    if (head && !head->is_empty_reference())
    {
      Expression_Ptr hh = head->perform(this);
      if (hh) l->append(hh);
    }

    std::string reference = ! sel->reference() ? ""
      : sel->reference()->to_string();
    switch(sel->combinator())
    {
      case Complex_Selector::PARENT_OF:
        l->append(SASS_MEMORY_NEW(String_Quoted, sel->pstate(), ">"));
      break;
      case Complex_Selector::ADJACENT_TO:
        l->append(SASS_MEMORY_NEW(String_Quoted, sel->pstate(), "+"));
      break;
      case Complex_Selector::REFERENCE:
        l->append(SASS_MEMORY_NEW(String_Quoted, sel->pstate(), "/" + reference + "/"));
      break;
      case Complex_Selector::PRECEDES:
        l->append(SASS_MEMORY_NEW(String_Quoted, sel->pstate(), "~"));
      break;
      case Complex_Selector::ANCESTOR_OF:
      break;
    }

    Complex_Selector_Obj tail = sel->tail();
    if (tail)
    {
      Expression_Obj tt = tail->perform(this);
      if (List_Ptr ls = SASS_MEMORY_CAST(List, tt))
      { l->concat(ls); }
    }
    if (l->length() == 0) return 0;
    return l.detach();
  }