示例#1
0
    void operator() (utree const& ut) const {
        
        using spirit::utree_type;

        switch (ut.which()) {
            case utree_type::reference_type:
                return (*this)(ut.deref());

            case utree_type::range_type:
            case utree_type::list_type:
                if (annotations[ut.tag()].second == json_object) {
                    print_object(ut);
                    return;
                }
                else if (annotations[ut.tag()].second == json_array) {
                    print_array(ut);
                    return;
                }
                else if (annotations[ut.tag()].second == json_pair) {
                    print_member_pair(ut);
                    return;
                }

                default:
                    break;
        }

        utree::visit(ut, *this);
    }
    void operator() (utree const& ut){
        
        using spirit::utree_type;
        typedef utree::const_iterator iterator;
        
        int id = cur_id;
        n_id++;
        
        switch (ut.which()) {
            case utree_type::reference_type:
                out << prefix << id << " [label=\"[reference]\"];\n"; 
                out << prefix << id << " -> " << prefix << cur_id << ";\n";
                (*this)(ut.deref());
                return;

            case utree_type::range_type:
            case utree_type::list_type:
            {    
                iterator it, end;
                
                int start_id = n_id;
                
                if (annotations[ut.tag()].second == json_object) {
                    out << prefix << id << " [label=\"[object]\"];\n"; 
                    it    = ut.front().begin();
                    end   = ut.front().end();
                    n_id += ut.front().size();
                } else {
                    if (annotations[ut.tag()].second == json_array) {
                        out << prefix << id << " [label=\"[array]\"];\n"; 
                    } else if (annotations[ut.tag()].second == json_pair) {
                        out << prefix << id << " [label=\"[pair]\"];\n"; 
                    } else {
                        BOOST_ASSERT(false);
                        return;
                    }
                    it    = ut.begin();
                    end   = ut.end();
                    n_id += ut.size();
                }
                
                for (int i=0; it != end; ++it, ++i) {
                    
                    cur_id = start_id+i; 
                    out << prefix << id << " -> " << prefix << cur_id << ";\n";
                    (*this)(*it);   
                }
                
                return;
            }    
            default:
                break;
        }

        utree::visit(ut, *this);
    }
示例#3
0
 static type call (utree const& ut, parse_tree<Tag> const& pt) {
   using fusion::at_c;
   switch (ut.which()) {
     case utree_type::reference_type:
       return call(ut.deref());
     case utree_type::range_type:
     case utree_type::list_type:
       return at_c<1>(pt.annotations()[ut.tag()]);
     default:
       return -1; 
   }
 }
示例#4
0
            static bool is_valid(utree const& attr)
            {
                switch (traits::which(attr))
                {
                case utree_type::reference_type:
                    return is_valid(attr.deref());

                case utree_type::binary_type:
                    return true;

                default:
                    return false;
                }
            }
    void operator() (utree const& ut){
        
        using spirit::utree_type;
        typedef utree::const_iterator iterator;
        
        int id = cur_id;
        n_id++;
        
        switch (ut.which()) {
            case utree_type::reference_type:
                out << prefix << id << " [label=\"[reference]\"];\n"; 
                out << prefix << id << " -> " << prefix << cur_id << ";\n";
                (*this)(ut.deref());
                return;

            case utree_type::range_type:
            case utree_type::list_type:
            {    
                iterator it, end;
                
                int start_id = n_id;
                carto_node_type nope_type = annotations[ut.tag()].second;

                /*if (annotations[ut.tag()].second == json_object) {
                    out << prefix << id << " [label=\"[object]\"];\n"; 
                    it    = ut.front().begin();
                    end   = ut.front().end();
                    n_id += ut.front().size();
                }*/
                
                out << prefix << id << " [label=\"[";
                switch(node_type) {
                    case CARTO_UNDEFINED:
                        out << "";
                        break;
                    case CARTO_VARIABLE:
                        out << "variable";
                        break;
                    case CARTO_MIXIN:
                        OUT << "mixin";
                        break;
                    case CARTO_STYLE:
                        out << "style";
                        break;
                    case CARTO_FUNCTION:
                        out << "function";
                        break;
                    case CARTO_ATTRIBUTE:
                        out << "attribute";
                        break;
                    case CARTO_COLOR:
                        out << "color";
                        break;
                    case CARTO_FILTER:
                        out << "filter";
                        break;
                    default:
                        std::cout << node_type << std::endl;
                        BOOST_ASSERT(false);
                        //return;
                }
                out << "]\"];\n";
                
                it    = ut.begin();
                end   = ut.end();
                n_id += ut.size();
                
                if (node_type == CARTO_FILTER) {
                    for (int i=0; it != end; ++it, ++i) {
                    
                        cur_id = start_id+i;
                        out << prefix << id << " -> " << prefix << cur_id << ";\n";
                    
                        out << prefix << cur_id << " [label=\"";
                        generate_filter(*it,annotations,style_env(),out);
                        out << "\"];\n";
                    }
                    
                } else {                
                    for (int i=0; it != end; ++it, ++i) {
                    
                        cur_id = start_id+i; 
                        out << prefix << id << " -> " << prefix << cur_id << ";\n";
                        (*this)(*it);   
                    }
                }
                
                return;
            }    
            default:
                break;
        }
        
        utree::visit(ut, *this);
    }
    void operator() (utree const& ut){
        
        using spirit::utree_type;
        typedef utree::const_iterator iterator;
        
        int id = cur_id;
        n_id++;
        
        switch (ut.which()) {
            case utree_type::reference_type:
                out << prefix << id << " [label=\"[reference]\"];\n"; 
                out << prefix << id << " -> " << prefix << cur_id << ";\n";
                (*this)(ut.deref());
                return;

            case utree_type::range_type:
            case utree_type::list_type:
            {    
                iterator it, end;
                
                int start_id = n_id;
                
                /*if (annotations[ut.tag()].second == json_object) {
                    out << prefix << id << " [label=\"[object]\"];\n"; 
                    it    = ut.front().begin();
                    end   = ut.front().end();
                    n_id += ut.front().size();
                }*/
                
                out << prefix << id << " [label=\"[";
                switch(annotations[ut.tag()].second) {
                    case carto_undefined:
                        out << "";
                        break;
                    case carto_variable:
                        out << "variable";
                        break;
                    case carto_mixin:
                        out << "mixin";
                        break;
                    case carto_style:
                        out << "style";
                        break;
                    case carto_function:
                        out << "function";
                        break;
                    case carto_attribute:
                        out << "attribute";
                        break;
                    case carto_color:
                        out << "color";
                        break;
                    case carto_filter:
                        out << "filter";
                        break;
                    default:
                        std::cout << annotations[ut.tag()].second << std::endl;
                        BOOST_ASSERT(false);
                        //return;
                }
                out << "]\"];\n";
                
                it    = ut.begin();
                end   = ut.end();
                n_id += ut.size();
                
                if (annotations[ut.tag()].second == carto_filter) {
                    for (int i=0; it != end; ++it, ++i) {
                    
                        cur_id = start_id+i;
                        out << prefix << id << " -> " << prefix << cur_id << ";\n";
                    
                        out << prefix << cur_id << " [label=\"";
                        generate_filter(*it,annotations,style_env(),out);
                        out << "\"];\n";
                    }
                    
                } else {                
                    for (int i=0; it != end; ++it, ++i) {
                    
                        cur_id = start_id+i; 
                        out << prefix << id << " -> " << prefix << cur_id << ";\n";
                        (*this)(*it);   
                    }
                }
                
                return;
            }    
            default:
                break;
        }
        
        utree::visit(ut, *this);
    }