⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 parse.cxx

📁 移植到WLIT项目的redboot源代码
💻 CXX
📖 第 1 页 / 共 3 页
字号:
        } else {                    // The command is valid, turn it into a property.            // The property has been parsed successfully. Add it to the current node            CdlNode current_node = interp->get_node();            CYG_ASSERTC(0 != current_node);            new_property = CdlProperty_MinimalBody::make(current_node, name, argc, argv, options);            if (0 != final_parser) {                (*final_parser)(interp, new_property);            }        }    } catch(...) {                if (0 != new_property) {            delete new_property;        }        throw;    }        return TCL_OK;}//}}}//{{{  parse_string_property()          // ----------------------------------------------------------------------------intCdlParse::parse_string_property(CdlInterpreter interp, int argc, char** argv, std::string name,                                char** options_desc, void (*final_parser)(CdlInterpreter, CdlProperty_String)){    CYG_REPORT_FUNCNAME("parse_string_property");    CYG_PRECONDITION_CLASSC(interp);        CdlProperty_String new_property = 0;        try {        std::vector<std::pair<std::string,std::string> > options;        int data_index = CdlParse::parse_options(interp, property_string + argv[0], options_desc, argc, argv, 1, options);        if (data_index == argc) {            CdlParse::report_property_parse_error(interp, argv[0], "Missing argument.");        } else if ((data_index + 1) < argc) {            CdlParse::report_property_parse_error(interp, argv[0], std::string("Too many arguments, expecting just one."));        } else {                    CdlNode current_node = interp->get_node();            CYG_ASSERTC(0 != current_node);            new_property = CdlProperty_StringBody::make(current_node, name, argv[data_index], argc, argv, options);            if (0 != final_parser) {                (*final_parser)(interp, new_property);            }        }    } catch(...) {        if (0 != new_property) {            delete new_property;        }        throw;    }        return TCL_OK;}//}}}//{{{  parse_tclcode_property()         // ----------------------------------------------------------------------------intCdlParse::parse_tclcode_property(CdlInterpreter interp, int argc, char** argv, std::string name,                                 char** options_desc, void (*final_parser)(CdlInterpreter, CdlProperty_TclCode)){    CYG_REPORT_FUNCNAME("parse_tclcode_property");    CYG_PRECONDITION_CLASSC(interp);        CdlProperty_TclCode new_property = 0;    try {        std::vector<std::pair<std::string,std::string> > options;        int data_index      = CdlParse::parse_options(interp, property_string + argv[0], options_desc, argc, argv, 1, options);                if (data_index == argc) {            CdlParse::report_property_parse_error(interp, argv[0], "Missing Tcl code.");        } else if ((data_index + 1) < argc) {            CdlParse::report_property_parse_error(interp, argv[0], std::string("Invalid number of arguments.\n") +                                         "Expecting one argument, a Tcl code fragment.");        } else if (!Tcl_CommandComplete(argv[data_index])) {            CdlParse::report_property_parse_error(interp, argv[0], "Incomplete Tcl code fragment.");        } else {                    CdlNode current_node = interp->get_node();            CYG_ASSERTC(0 != current_node);            new_property = CdlProperty_TclCodeBody::make(current_node, name, argv[data_index], argc, argv, options);            if (0 != final_parser) {                (*final_parser)(interp, new_property);            }        }     } catch(...) {        if (0 != new_property) {            delete new_property;        }        throw;    }        return TCL_OK;}//}}}//{{{  parse_stringvector_property()    // ----------------------------------------------------------------------------intCdlParse::parse_stringvector_property(CdlInterpreter interp, int argc, char** argv, std::string name,                                      char** options_desc, void (*final_parser)(CdlInterpreter, CdlProperty_StringVector),                                      bool allow_empty){    CYG_REPORT_FUNCNAME("parse_tclcode_property");    CYG_PRECONDITION_CLASSC(interp);        CdlProperty_StringVector new_property = 0;    try {        std::vector<std::pair<std::string,std::string> > options;        int data_index      = CdlParse::parse_options(interp, property_string + argv[0], options_desc, argc, argv, 1, options);                if (!allow_empty && (data_index == argc)) {            CdlParse::report_property_parse_error(interp, argv[0], "Missing arguments.");        } else {            // Creating the property requires a vector of strings.            std::vector<std::string>  strings;            for ( ; data_index < argc; data_index++) {                strings.push_back(argv[data_index]);            }            CdlNode current_node = interp->get_node();            CYG_ASSERTC(0 != current_node);            new_property = CdlProperty_StringVectorBody::make(current_node, name, strings, argc, argv, options);            if (0 != final_parser) {                (*final_parser)(interp, new_property);            }        }    } catch(...) {        if (0 != new_property) {            delete new_property;        }        throw;    }        return TCL_OK;}//}}}//{{{  parse_reference_property()       // ----------------------------------------------------------------------------intCdlParse::parse_reference_property(CdlInterpreter interp, int argc, char** argv, std::string name,                                   char** options_desc, void (*final_parser)(CdlInterpreter, CdlProperty_Reference),                                   CdlUpdateHandler update_handler){    CYG_REPORT_FUNCNAME("parse_reference_property");    CYG_PRECONDITION_CLASSC(interp);        CdlProperty_Reference new_property = 0;    try {        std::vector<std::pair<std::string,std::string> > options;        int data_index = CdlParse::parse_options(interp, property_string + argv[0], options_desc, argc, argv, 1, options);                if (data_index == argc) {            CdlParse::report_property_parse_error(interp, argv[0], "Missing argument.");        } else if ((data_index + 1) < argc) {            CdlParse::report_property_parse_error(interp, argv[0], "Too many arguments, expecting just one.");        } else {            std::string refname = argv[data_index];            if (!Cdl::is_valid_cdl_name(refname)) {                CdlParse::report_property_parse_error(interp, argv[0], "`" + refname + "' is not a valid CDL name");            } else {                CdlNode current_node = interp->get_node();                CYG_ASSERTC(0 != current_node);                new_property = CdlProperty_ReferenceBody::make(current_node, name, refname,                                                               update_handler, argc, argv, options);                if (0 != final_parser) {                    (*final_parser)(interp, new_property);                }            }        }    } catch(...) {        if (0 != new_property) {            delete new_property;        }        throw;    }        return TCL_OK;}//}}}//{{{  parse_expression_property()      // ----------------------------------------------------------------------------intCdlParse::parse_expression_property(CdlInterpreter interp, int argc, char** argv, std::string name,                                    char** options_desc, void (*final_parser)(CdlInterpreter, CdlProperty_Expression),                                    CdlUpdateHandler update_handler){    CYG_REPORT_FUNCNAME("parse_expression_property");    CYG_PRECONDITION_CLASSC(interp);        CdlProperty_Expression new_property = 0;    CdlExpression expr = 0;    try {        std::vector<std::pair<std::string,std::string> > options;        int data_index = CdlParse::parse_options(interp, property_string + argv[0], options_desc, argc, argv, 1, options);                std::string all_args = CdlParse::concatenate_argv(argc, argv, data_index);        if ("" == all_args) {            CdlParse::report_property_parse_error(interp, argv[0], "Missing expression data.");        } else {                    // The CdlExpression class has its own parsing routine. This            // will raise an exception if there are any problems. It is            // desirable to catch the exception and report the error via            // the normal reporting mechanisms, which may allow parsing to            // continue.            try {                expr = CdlExpressionBody::parse(all_args);            } catch(CdlParseException e) {                CdlParse::report_property_parse_error(interp, argv[0], e.get_message());            }            if (0 != expr) {                CdlNode current_node = interp->get_node();                CYG_ASSERTC(0 != current_node);                new_property = CdlProperty_ExpressionBody::make(current_node, name, expr, update_handler, argc, argv, options);                if (0 != final_parser) {                    (*final_parser)(interp, new_property);                }            }        }    } catch(...) {        if (0 != expr) {            delete expr;        }        if (0 != new_property) {            delete new_property;        }        throw;    }        if (0 != expr) {        delete expr;    }    return TCL_OK;}//}}}//{{{  parse_list_expression_property() // ----------------------------------------------------------------------------intCdlParse::parse_listexpression_property(CdlInterpreter interp, int argc, char** argv, std::string name,                                        char** options_desc, void (*final_parser)(CdlInterpreter, CdlProperty_ListExpression),                                        CdlUpdateHandler update_handler){    CYG_REPORT_FUNCNAME("parse_list_expression_property");    CYG_PRECONDITION_CLASSC(interp);        CdlProperty_ListExpression new_property = 0;    CdlListExpression expr = 0;    try {        std::vector<std::pair<std::string,std::string> > options;        int data_index = CdlParse::parse_options(interp, property_string + argv[0], options_desc, argc, argv, 1, options);        std::string all_args = CdlParse::concatenate_argv(argc, argv, data_index);        if ("" == all_args) {            CdlParse::report_property_parse_error(interp, argv[0], "Missing list expression data.");        } else {                    try {                expr = CdlListExpressionBody::parse(all_args);            } catch(CdlParseException e) {                CdlParse::report_property_parse_error(interp, argv[0], e.get_message());            }            if (0 != expr) {                CdlNode current_node = interp->get_node();                CYG_ASSERTC(0 != current_node);                new_property = CdlProperty_ListExpressionBody::make(current_node, name, expr, update_handler,                                                                    argc, argv, options);                if (0 != final_parser) {                    (*final_parser)(interp, new_property);                }            }        }    } catch(...) {        if (0 != expr) {            delete expr;        }        if (0 != new_property) {            delete new_property;        }        throw;    }    if (0 != expr) {        delete expr;    }    return TCL_OK;}//}}}//{{{  parse_goalexpression_property()  // ----------------------------------------------------------------------------intCdlParse::parse_goalexpression_property(CdlInterpreter interp, int argc, char** argv, std::string name,                                        char** options_desc, void (*final_parser)(CdlInterpreter, CdlProperty_GoalExpression),                                        CdlUpdateHandler update_handler){    CYG_REPORT_FUNCNAMETYPE("parse_goal_expression_property", "result %d");    CYG_PRECONDITION_CLASSC(interp);        CdlProperty_GoalExpression new_property = 0;    CdlGoalExpression expr = 0;    try {        std::vector<std::pair<std::string,std::string> > options;        int data_index = CdlParse::parse_options(interp, property_string + argv[0], options_desc, argc, argv, 1, options);        std::string all_args = CdlParse::concatenate_argv(argc, argv, data_index);        if ("" == all_args) {            CdlParse::report_property_parse_error(interp, argv[0], "Missing goal expression data.");        } else {            try {                expr = CdlGoalExpressionBody::parse(all_args);            } catch(CdlParseException e) {                CdlParse::report_property_parse_error(interp, argv[0], e.get_message());            }            if (0 != expr) {                CdlNode current_node = interp->get_node();                CYG_ASSERTC(0 != current_node);                new_property = CdlProperty_GoalExpressionBody::make(current_node, name, expr, update_handler,                                                                    argc, argv, options);                if (0 != final_parser) {                    (*final_parser)(interp, new_property);                }            }        }    } catch(...) {        if (0 != expr) {            delete expr;        }        if (0 != new_property) {            delete new_property;        }        throw;    }    if (0 != expr) {        delete expr;    }    return TCL_OK;}//}}}//}}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -