编程实战:类C语法的编译型脚本解释器(九)编译语句

系列入口:编程实战:类C语法的编译型脚本解释器(系列)-CSDN博客

        前文已经介绍了编译入口,核心就是语句,本文介绍语句的编译。

目录

一、代码概览

二、辅助函数

2.1 tokens.IsPosNotToken(pos)

2.2 tokens.MoveCurrentToken(pToken, pos)

2.3 tokens.IsDelimiter(pos, ";")

2.4 tokens.MoveNextToken(pToken, pos)

2.5 tokens.IsOperator(pos, "(")

三、流程分析


一、代码概览

 

        代码太长,直接贴:

		bool GetSentence(CTokens& tokens, T_VARIABLE_S& vars, Sentence& sentence, Token*& pToken, size_t& pos){sentence.clear();Expression* pExpression;if (tokens.IsPosNotToken(pos))return false;sentence.source_start = tokens.TokenStart(pos);sentence.source_end = tokens.TokenStart(pos);tokens.MoveCurrentToken(pToken, pos);switch (pToken->type){case Token::IDENTIFIER:case Token::NUMBER:case Token::STRING:case Token::OPERATOR:sentence.type = Sentence::EXPRESSION;pExpression = GetExpression(tokens, vars, NULL, pos, ";");if (!tokens.IsPosNotToken(pos) && tokens.IsDelimiter(pos, ";")){tokens.MoveNextToken(pToken, pos);}sentence.expressions.reserve(1);sentence.expressions.push_back(*pExpression);break;case Token::DELIMITER:if (pToken->text == "{"){sentence.type = Sentence::BLOCK;tokens.MoveNextToken(pToken, pos);while (true){if (tokens.IsPosNotToken(pos))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "未期待的脚本结束,块语句未结束");if (tokens.IsDelimiter(pos, "}")){tokens.MoveNextToken(pToken, pos);break;}Sentence tmpsentence;if (!GetSentence(tokens, vars, tmpsentence, pToken, pos))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "获取块语句的语句出错");sentence.sentences.reserve(sentence.sentences.size() + 1);sentence.sentences.push_back(tmpsentence);}}else if (pToken->text == "}"){CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "未期待的块语句结束标记");}else if (pToken->text == ";"){sentence.type = Sentence::NULLSENTENCE;tokens.MoveNextToken(pToken, pos);}else{CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "尚未支持的分隔符");}break;case Token::KEYWORD:if (pToken->text == "return"){sentence.type = Sentence::RETURN;tokens.MoveNextToken(pToken, pos);pExpression = GetExpression(tokens, vars, NULL, pos, ";");Expression null_expression;if (NULL == pExpression){pExpression = &null_expression;}if (!tokens.IsPosNotToken(pos) && tokens.IsDelimiter(pos, ";")){tokens.MoveNextToken(pToken, pos);}sentence.expressions.reserve(1);sentence.expressions.push_back(*pExpression);}else if (pToken->text == "if"){sentence.type = Sentence::IF;tokens.MoveNextToken(pToken, pos);if (tokens.IsPosNotToken(pos))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "未期待的脚本结束,期待左括号");if (!tokens.IsOperator(pos, "("))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "期待左括号");tokens.MoveNextToken(pToken, pos);if (tokens.IsPosNotToken(pos))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "未期待的脚本结束,期待条件表达式");if (NULL == (pExpression = GetExpression(tokens, vars, NULL, pos, ")")))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "条件表达式为空");if (tokens.IsPosNotToken(pos))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "未期待的脚本结束,期待右括号");if (!tokens.IsOperator(pos, ")"))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "期待右括号");sentence.expressions.reserve(1);sentence.expressions.push_back(*pExpression);tokens.MoveNextToken(pToken, pos);sentence.sentences.reserve(2);Sentence if_sentence;if (!GetSentence(tokens, vars, if_sentence, pToken, pos))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "分析if块的执行语句出错");sentence.sentences.push_back(if_sentence);if (!tokens.IsPosNotToken(pos)){if (pToken->type == Token::KEYWORD && pToken->text == "else"){tokens.MoveNextToken(pToken, pos);Sentence else_sentence;if (!GetSentence(tokens, vars, else_sentence, pToken, pos))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "分析else块的执行语句出错");sentence.sentences.push_back(else_sentence);}}}else if (pToken->text == "do"){sentence.type = Sentence::DO;tokens.MoveNextToken(pToken, pos);sentence.sentences.reserve(1);Sentence if_sentence;if (!GetSentence(tokens, vars, if_sentence, pToken, pos))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "分析do块的执行语句出错");sentence.sentences.push_back(if_sentence);if (tokens.IsPosNotToken(pos))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "未期待的脚本结束,期待while");if (pToken->type != Token::KEYWORD || pToken->text != "while")CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "期待while");tokens.MoveNextToken(pToken, pos);if (tokens.IsPosNotToken(pos))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "未期待的脚本结束,期待左括号");if (!tokens.IsOperator(pos, "("))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "期待左括号");tokens.MoveNextToken(pToken, pos);if (tokens.IsPosNotToken(pos))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "未期待的脚本结束,期待条件表达式");if (NULL == (pExpression = GetExpression(tokens, vars, NULL, pos, ")")))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "条件表达式为空");tokens.MoveCurrentToken(pToken, pos);if (tokens.IsPosNotToken(pos))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "未期待的脚本结束,期待右括号");if (!tokens.IsOperator(pos, ")"))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "期待右括号");sentence.expressions.reserve(1);sentence.expressions.push_back(*pExpression);tokens.MoveNextToken(pToken, pos);if (tokens.IsPosNotToken(pos))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "未期待的脚本结束,期待分号");if (!tokens.IsDelimiter(pos, ";"))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "期待分号");tokens.MoveNextToken(pToken, pos);}else if (pToken->text == "while"){sentence.type = Sentence::WHILE;tokens.MoveNextToken(pToken, pos);if (tokens.IsPosNotToken(pos))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "未期待的脚本结束,期待左括号");if (!tokens.IsOperator(pos, "("))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "期待左括号");tokens.MoveNextToken(pToken, pos);if (tokens.IsPosNotToken(pos))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "未期待的脚本结束,期待条件表达式");if (NULL == (pExpression = GetExpression(tokens, vars, NULL, pos, ")")))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "条件表达式为空");if (tokens.IsPosNotToken(pos))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "未期待的脚本结束,期待右括号");if (!tokens.IsOperator(pos, ")"))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "期待右括号");sentence.expressions.reserve(1);sentence.expressions.push_back(*pExpression);tokens.MoveNextToken(pToken, pos);sentence.sentences.reserve(1);Sentence if_sentence;if (!GetSentence(tokens, vars, if_sentence, pToken, pos))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "分析while块的执行语句出错");sentence.sentences.push_back(if_sentence);}else if (pToken->text == "for"){sentence.type = Sentence::FOR;//第一个分号前面是一个语句sentence.expressions.reserve(2);sentence.sentences.reserve(2);tokens.MoveNextToken(pToken, pos);if (tokens.IsPosNotToken(pos))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "未期待的脚本结束,期待左括号");if (!tokens.IsOperator(pos, "("))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "期待左括号");tokens.MoveNextToken(pToken, pos);if (tokens.IsPosNotToken(pos))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "未期待的脚本结束,期待初始化表达式");Sentence init_sentence;if (!GetSentence(tokens, vars, init_sentence, pToken, pos))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "分析for块的初始化语句出错");sentence.sentences.push_back(init_sentence);if (tokens.IsPosNotToken(pos))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "未期待的脚本结束,期待条件表达式");if (NULL == (pExpression = GetExpression(tokens, vars, NULL, pos, ";")))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "获取条件表达式出错");if (tokens.IsPosNotToken(pos))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "未期待的脚本结束,期待分号");if (!tokens.IsDelimiter(pos, ";"))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "期待分号");sentence.expressions.push_back(*pExpression);tokens.MoveNextToken(pToken, pos);if (tokens.IsPosNotToken(pos))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "未期待的脚本结束,期待循环递增表达式");if (NULL == (pExpression = GetExpression(tokens, vars, NULL, pos, ")")))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "获取循环递增表达式出错");if (tokens.IsPosNotToken(pos))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "未期待的脚本结束,期待右括号");if (!tokens.IsOperator(pos, ")"))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "期待右括号");sentence.expressions.push_back(*pExpression);tokens.MoveNextToken(pToken, pos);Sentence for_sentence;if (!GetSentence(tokens, vars, for_sentence, pToken, pos))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "分析for块的执行语句出错");sentence.sentences.push_back(for_sentence);}else if ("break" == pToken->text){sentence.type = Sentence::BREAK;tokens.MoveNextToken(pToken, pos);if (tokens.IsPosNotToken(pos))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "未期待的脚本结束,期待分号");if (!tokens.IsDelimiter(pos, ";"))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "期待分号");tokens.MoveNextToken(pToken, pos);}else if ("continue" == pToken->text){sentence.type = Sentence::CONTINUE;tokens.MoveNextToken(pToken, pos);if (tokens.IsPosNotToken(pos))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "未期待的脚本结束,期待分号");if (!tokens.IsDelimiter(pos, ";"))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "期待分号");tokens.MoveNextToken(pToken, pos);}else if ("long" == pToken->text || "double" == pToken->text || "int" == pToken->text || "float" == pToken->text || "string" == pToken->text){//声明语句sentence.type = Sentence::DECLARE;Variable var;if ("long" == pToken->text || "int" == pToken->text)var.type = Variable::LONG;else if ("double" == pToken->text || "float" == pToken->text)var.type = Variable::DOUBLE;else var.type = Variable::STRING;tokens.MoveNextToken(pToken, pos);if (tokens.IsPosNotToken(pos))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "未期待的脚本结束,期待变量名");if (tokens.IsDelimiter(pos, ";"))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "未期待的分号,期待变量名");if (pToken->type != Token::IDENTIFIER)CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "期待标识符");sentence.expressions.resize(1);sentence.expressions[0].type = Expression::DEFINE;sentence.expressions[0].VariableName = pToken->text;sentence.expressions[0].m_variable = var;sentence.expressions[0].source_start = sentence.source_start;sentence.expressions[0].source_end = tokens.TokenStart(pos + 1);tokens.MoveNextToken(pToken, pos);if (tokens.IsPosNotToken(pos)){}else if (tokens.IsOperator(pos, "=")){//带有初始值tokens.MoveNextToken(pToken, pos);if (tokens.IsPosNotToken(pos))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "未期待的脚本结束,期待初始化表达式");if (NULL == (pExpression = GetExpression(tokens, vars, NULL, pos, ";")))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "获取初始化表达式出错");if (tokens.IsPosNotToken(pos))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "未期待的脚本结束,期待分号");if (!tokens.IsDelimiter(pos, ";"))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "期待分号");tokens.MoveNextToken(pToken, pos);sentence.expressions[0].AddLeftOperand(*pExpression);}else if (tokens.IsOperator(pos, "(")){//函数for (long i = 0; i < (long)m_functions.size(); ++i){if (m_functions[i].script_name == sentence.expressions[0].VariableName)CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "函数重名");}m_functions.resize(m_functions.size() + 1);CScript* pFunction = &m_functions[m_functions.size() - 1];pFunction->FromParent(*this, sentence.expressions[0].VariableName);pFunction->return_type = var.type;pFunction->count_global_variable = vars.getGlobalCount();tokens.MoveNextToken(pToken, pos);while (!tokens.IsOperator(pos, ")")){Variable param;if ("long" == pToken->text || "int" == pToken->text)param.type = Variable::LONG;else if ("double" == pToken->text || "float" == pToken->text)param.type = Variable::DOUBLE;else if("string"== pToken->text)param.type = Variable::STRING;else CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "期待参数类型");tokens.MoveNextToken(pToken, pos);if (tokens.IsPosNotToken(pos))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "未期待的脚本结束,期待参数名");if (pToken->type != Token::IDENTIFIER)CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "期待标识符");if (!pFunction->m_EnvVariables.AddVariable(pToken->text, param))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "函数参数重名");if (NULL!=vars.FindVariable(pToken->text))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "函数参数与全局变量或环境变量重名");tokens.MoveNextToken(pToken, pos);if (tokens.IsPosNotToken(pos))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "未期待的脚本结束,期待)");if (tokens.IsOperator(pos, ","))tokens.MoveNextToken(pToken, pos);else break;}if (!tokens.IsOperator(pos, ")"))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "期待)");tokens.MoveNextToken(pToken, pos);if (!tokens.IsDelimiter(pos, "{"))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "期待{");tokens.MoveNextToken(pToken, pos);T_VARIABLE_S tmpvars;tmpvars.FromParentVars(vars, pFunction->count_global_variable, &pFunction->m_EnvVariables);if (!pFunction->Build(tokens, tmpvars, pos)){m_msg += "编译失败\r\n";return false;}if (!tokens.IsDelimiter(pos, "}"))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "期待}");tokens.MoveNextToken(pToken, pos);if (!tokens.IsDelimiter(pos, ";"))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "期待分号");tokens.MoveNextToken(pToken, pos);return GetSentence(tokens, vars, sentence, pToken, pos);}else if (!tokens.IsDelimiter(pos, ";")){CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "期待分号,一个语句只能定义一个变量");}}else{CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "非期待的的关键字,是否前面缺少分号?");}break;default:CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "未支持的标记类型");break;}sentence.source_end = tokens.TokenStart(pos);return sentence.source_end != sentence.source_start;}

        整个过程通过pos贯穿,pos是当前的Token位置,大部分函数使用的都是pos的引用,在内部会修改pos,函数返回时pos总是处于下一个未处理的Token位置。 

二、辅助函数

        里面用到一些功能比较小的函数。

2.1 tokens.IsPosNotToken(pos)

        这个判断是否pos已经到达结束位置。

2.2 tokens.MoveCurrentToken(pToken, pos)

        这个将pToken指向pos处的Token,方便后面使用。

2.3 tokens.IsDelimiter(pos, ";")

        这个函数判断pos是否是给定的分隔符,需要同时判断Token类型和文本。

2.4 tokens.MoveNextToken(pToken, pos)

        同时将pToken和pos指向下一个Token。

2.5 tokens.IsOperator(pos, "(")

        这个函数判断是否是给定的操作符,需要同时判断Token类型和文本。

三、流程分析

        流程处理相对简单,根据获取到的第一个Token的类型做分支处理,每个分支根据各自的语法要求获取语句或变量。

        如果是标识符、数字、字符串、操作符,就是一个表达式,调用GetExpression()函数获取一个表达式,生成一个表达式语句:

			case Token::IDENTIFIER:case Token::NUMBER:case Token::STRING:case Token::OPERATOR:sentence.type = Sentence::EXPRESSION;pExpression = GetExpression(tokens, vars, NULL, pos, ";");if (!tokens.IsPosNotToken(pos) && tokens.IsDelimiter(pos, ";")){tokens.MoveNextToken(pToken, pos);}sentence.expressions.reserve(1);sentence.expressions.push_back(*pExpression);break;

        如果是分隔符,只有一种合法类型,“{”,是块语句,循环获取语句直到遇到“}”:

			case Token::DELIMITER:if (pToken->text == "{"){sentence.type = Sentence::BLOCK;tokens.MoveNextToken(pToken, pos);while (true){if (tokens.IsPosNotToken(pos))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "未期待的脚本结束,块语句未结束");if (tokens.IsDelimiter(pos, "}")){tokens.MoveNextToken(pToken, pos);break;}Sentence tmpsentence;if (!GetSentence(tokens, vars, tmpsentence, pToken, pos))CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "获取块语句的语句出错");sentence.sentences.reserve(sentence.sentences.size() + 1);sentence.sentences.push_back(tmpsentence);}}else if (pToken->text == "}"){CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "未期待的块语句结束标记");}else if (pToken->text == ";"){sentence.type = Sentence::NULLSENTENCE;tokens.MoveNextToken(pToken, pos);}else{CException::Throw(__FILE__, __LINE__, m_source, tokens.TokenStart(pos), "尚未支持的分隔符");}break;

        剩下的就是关键字,对关键字再分别处理,虽然稍微负责一些,但用到的东西和上面的差不多。

        剩下的未介绍的部分就是表达式编译了。

(这里是结束,但不是整个系列的结束)

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/203742.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

LT8668SXC DP转VBO/HDMI2.1/EDP 最高可支持到8k60hz

DP1.4a/eDP1.4b Receiver ▪ Compliant with DisplayPort specification 1.4a for 1.62Gbps, 2.7Gbps, 5.4Gbps and 8.1Gbps ▪ Compliant with Embedded DisplayPort specification version 1.4b ▪ Support DisplayPort 1/2/4 lanes ▪ Support HDCP 1.3/2.3 ▪ …

JVM 执行引擎篇

机器码、指令、汇编语言 机器码 各种用二进制编码方式表示的指令&#xff0c;叫做机器指令码。开始&#xff0c;人们就用它采编写程序&#xff0c;这就是机器语言。机器语言虽然能够被计算机理解和接受&#xff0c;但和人们的语言差别太大&#xff0c;不易被人们理解和记忆&a…

德迅抗D盾是如何防护攻击的

德迅抗D盾是针对游戏行业面对的DDoS、CC攻击推出的针对性的网络安全解决方案&#xff0c;相比高防IP&#xff0c;除了能针对大型DDoS攻击&#xff08;T级别&#xff09;进行有效防御外&#xff0c;还具备彻底解决游戏行业特有的TCP协议的CC攻击问题能力&#xff0c;防护成本更低…

基于Java SSM框架实现超市管理系统项目【项目源码+论文说明】计算机毕业设计

基于java的SSM框架实现超市管理系统演示 摘要 21世纪的今天&#xff0c;随着社会的不断发展与进步&#xff0c;人们对于信息科学化的认识&#xff0c;已由低层次向高层次发展&#xff0c;由原来的感性认识向理性认识提高&#xff0c;管理工作的重要性已逐渐被人们所认识&#…

多人聊天作业

服务端 import java.io.*; import java.net.*; import java.util.ArrayList; public class Server{public static ServerSocket server_socket;public static ArrayList<Socket> socketListnew ArrayList<Socket>(); public static void main(String []args){try{…

如何评估数据资产的价值?哪种方法更容易实现?

今年可以称之为数据年&#xff0c;从去年年底党中央发布《数据20条》&#xff0c;对数据领域的一系列的制度建设做了提纲起领的作用。在财经领域今年的下半年&#xff0c;密集出台一系列跟数据资产相关的政策&#xff0c;包括8月21日发布的《企业数据资源会计处理的暂行规定》以…

最小生成树算法与二分图算法

文章目录 概述 P r i m Prim Prim 算法 - 稠密图 - O ( n 2 ) O(n^2) O(n2)思路概述时间复杂度分析AcWing 858. Prim算法求最小生成树CODE K r u s k a l Kruskal Kruskal 算法 - 稀疏图 - O ( m l o g m ) O(mlogm) O(mlogm)思路解析时间复杂度分析AcWing 859. Kruskal算法求…

探索HarmonyOS_开发软件安装

随着华为推出HarmonyOS NEXT 宣布将要全面启用鸿蒙原声应用&#xff0c;不在兼容安卓应用&#xff0c; 现在开始探索鸿蒙原生应用的开发。 HarmonyOS应用开发官网 - 华为HarmonyOS打造全场景新服务 鸿蒙官网 开发软件肯定要从这里下载 第一个为微软系统(windows)&#xff0c;第…

逆向修改Unity的安卓包资源并重新打包

在上一篇文章中,我已经讲过如何逆向获取unity打包出来的源代码和资源了,那么这一节我将介绍如何将解密出来的源代码进行修改并重新压缩到apk中。 其实在很多时候,我们不仅仅想要看Unity的源码,我们还要对他们的客户端源码进行修改和调整,比如替换资源,替换服务器连接地址…

【C/C++】函数参数默认值

创作不易&#xff0c;本篇文章如果帮助到了你&#xff0c;还请点赞 关注支持一下♡>&#x16966;<)!! 主页专栏有更多知识&#xff0c;如有疑问欢迎大家指正讨论&#xff0c;共同进步&#xff01; &#x1f525;c系列专栏&#xff1a;C/C零基础到精通 &#x1f525; 给大…

深度学习实战64-黑白照片着色的模型应用,快速部署实现黑白图片快速上色的功能

大家好,我是微学AI,今天给大家介绍一下深度学习实战64-黑白照片着色的模型应用,快速部署实现黑白图片快速上色的功能。图片上色是一个具有多模态不确定性和高度不适定性的挑战性问题。直接训练深度神经网络通常会导致错误的语义颜色和低色彩丰富度。虽然基于Transformer的方…

人工智能AIGC培训讲师叶梓介绍及AI强化学习培训提纲

叶梓&#xff0c;上海交通大学计算机专业博士毕业&#xff0c;高级工程师。主研方向&#xff1a;数据挖掘、机器学习、人工智能。历任国内知名上市IT企业的AI技术总监、资深技术专家&#xff0c;市级行业大数据平台技术负责人。个人主页&#xff1a;大数据人工智能AI培训讲师叶…

9大高效的前端测试工具与框架!

在每个Web应用程序中&#xff0c;作为用户直接可见的应用程序外观&#xff0c;“前端”包括&#xff1a;图形化的用户界面、相应的功能、及其整体站点的可用性。我们可以毫不夸张地说&#xff1a;如果前端无法正常工作&#xff0c;您将无法“拉新”网站的潜在用户。这也正是我们…

MySQL:update set的坑

目录 一、问题描述 二、为何会出现这样的问题&#xff1f; 三、正确的方案 一、问题描述 我在修改mysql数据表时&#xff0c;看到下面的现象。 我表中原始数据如下&#xff1a; 执行了下面的修改&#xff0c;显示执行成功。 update user_function_record_entity set open_…

MySQL_1. mysql数据库介绍

shell脚本差不多快完结了接下来会为大家更新MySQL系列的相关的基础知识笔记&#xff0c;希望对大家有所帮助&#xff0c;好废话不多说&#xff0c;接下来开始正题&#xff01; 1.mysql数据库介绍 mysql 是一款安全、跨平台、高效的&#xff0c;并与 PHP、Java 等主流编程语言…

AI写作工具有哪些?原创我AI写作工具推荐

人工智能&#xff08;AI&#xff09;的广泛应用不仅改变了我们的工作方式&#xff0c;也对文学创作领域产生了深远的影响。其中&#xff0c;AI写作技术在提高工作效率和文章创作方面发挥着越来越重要的角色。然而&#xff0c;伴随着这一技术的兴起&#xff0c;一个备受关注的问…

机器学习实验五:集成学习

系列文章目录 机器学习实验一&#xff1a;线性回归机器学习实验二&#xff1a;决策树模型机器学习实验三&#xff1a;支持向量机模型机器学习实验四&#xff1a;贝叶斯分类器机器学习实验五&#xff1a;集成学习机器学习实验六&#xff1a;聚类 文章目录 系列文章目录一、实验…

docker基本管理和相关概念

1、docker是什么&#xff1f; docker是开源的应用容器引擎。基于go语言开发的&#xff0c;运行在Linux系统当中开源轻量级的“虚拟机”。 docker可以在一台主机上轻松的为任何应用创建一个轻量级的&#xff0c;可移植的&#xff0c;自给自足的容器。docker的宿主机是Linux系统…

【PID学习笔记 7 】控制系统的性能指标之三

写在前面 控制系统性能指标有单项指标和综合指标两类&#xff0c;上文重点介绍了单项指标&#xff0c;本文将介绍系统阶跃响应的综合性能指标。 一、系统阶跃响应的综合性能指标 单项指标虽然清晰明了&#xff0c;但如何统筹考虑比较困难。而偏差幅度和偏差存在的时间都与偏…