WO2026056340A1 - Compiler-based automatic code upgrade method and apparatus, and storage medium - Google Patents
Compiler-based automatic code upgrade method and apparatus, and storage mediumInfo
- Publication number
- WO2026056340A1 WO2026056340A1 PCT/CN2025/096565 CN2025096565W WO2026056340A1 WO 2026056340 A1 WO2026056340 A1 WO 2026056340A1 CN 2025096565 W CN2025096565 W CN 2025096565W WO 2026056340 A1 WO2026056340 A1 WO 2026056340A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- code
- abstract syntax
- syntax tree
- new standard
- nodes
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/60—Software deployment
- G06F8/65—Updates
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/30—Semantic analysis
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/42—Syntactic analysis
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/42—Syntactic analysis
- G06F8/425—Lexical analysis
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Computational Linguistics (AREA)
- General Health & Medical Sciences (AREA)
- Health & Medical Sciences (AREA)
- Audiology, Speech & Language Pathology (AREA)
- Artificial Intelligence (AREA)
- Computer Security & Cryptography (AREA)
- Devices For Executing Special Programs (AREA)
Abstract
Description
本申请要求于2024年9月12日提交中国专利局、申请号为202411279576.6、发明名称为“基于编译器进行代码自动升级的方法、装置以及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims priority to Chinese Patent Application No. 202411279576.6, filed on September 12, 2024, entitled "Method, Apparatus and Storage Medium for Automatic Code Upgrade Based on Compiler", the entire contents of which are incorporated herein by reference.
本申请涉及计算机代码升级技术领域,例如涉及一种基于编译器进行代码自动升级的方法、装置以及存储介质。This application relates to the field of computer code upgrade technology, such as a method, apparatus, and storage medium for automatic code upgrade based on a compiler.
在软件开发领域,随着技术的不断进步和编程语言的持续演进,新的编程标准(如C++、Java、Python等语言的新版本)不断推出,为开发者提供了更为丰富、高效、安全的编程工具和特性。这些新标准往往包含了语法上的改进、性能优化、新增的库和API、更好的并发支持、内存管理机制的改进以及安全性的增强等。然而,由于项目历史遗留问题、兼容性考虑、资源限制或开发者习惯等多种原因,许多项目仍然在使用较旧的编程标准编写的代码。旧代码在面临新标准带来的优势时,往往显得力不从心。为了利用新标准提供的特性,开发者需要手动将旧代码迁移至新标准,这一过程不仅耗时费力,而且容易出错。手动迁移需要开发者对旧代码有深入地理解,同时还需要熟悉新标准的所有变化,这对开发者的技能和经验提出了很高的要求。此外,手动迁移还可能引入新的错误,特别是在处理大型、复杂的代码库时,这种风险尤为突出。In the field of software development, with the continuous advancement of technology and the ongoing evolution of programming languages, new programming standards (such as new versions of C++, Java, and Python) are constantly being introduced, providing developers with richer, more efficient, and safer programming tools and features. These new standards often include improvements in syntax, performance optimizations, new libraries and APIs, better concurrency support, improved memory management mechanisms, and enhanced security. However, due to various reasons such as legacy issues, compatibility considerations, resource constraints, or developer habits, many projects still use code written using older programming standards. Older code often falls short when faced with the advantages of new standards. To utilize the features provided by new standards, developers need to manually migrate old code to the new standard, a process that is not only time-consuming and laborious but also prone to errors. Manual migration requires developers to have a deep understanding of the old code and familiarity with all the changes in the new standard, placing high demands on their skills and experience. Furthermore, manual migration may introduce new errors, especially when dealing with large, complex codebases, where this risk is particularly pronounced.
需要说明的是,在上述背景技术部分公开的信息仅用于加强对本申请的背景的理解,因此可以包括不构成对本领域普通技术人员已知的现有技术的信息。It should be noted that the information disclosed in the background section above is only used to enhance the understanding of the background of this application, and therefore may include information that does not constitute prior art known to those skilled in the art.
为了对披露的实施例的一些方面有基本的理解,下面给出了简单的概括。所述概括不是泛泛评述,也不是要确定关键/重要组成元素或描绘这些实施例的保护范围,而是作为后面的详细说明的序言。To provide a basic understanding of some aspects of the disclosed embodiments, a brief summary is given below. This summary is not intended as a general commentary, nor is it intended to identify key/important components or describe the scope of protection of these embodiments, but rather as a prelude to the detailed description that follows.
本公开实施例提供的基于编译器进行代码自动升级的方法,包括:The method for automatic code upgrade based on compiler provided in this disclosure includes:
前端对高级编程语言进行词法分析,语法分析,生成抽象语法树,并进行语义分析,生成中间表示;The front-end performs lexical analysis and syntax analysis on high-level programming languages to generate abstract syntax trees, and performs semantic analysis to generate intermediate representations;
后端对中间表示进行优化,构建新标准的语法规则映射表,对抽象语法树进行遍历,查询抽象语法树的节点在映射表中是否可以查询到,对于查询到的节点,输出其映射到的字符串,对于未查询到的节点,则正常输出符合节点语义的代码。The backend optimizes the intermediate representation, constructs a new standard syntax rule mapping table, traverses the abstract syntax tree, and queries whether the nodes of the abstract syntax tree can be found in the mapping table. For nodes that are found, the mapped string is output; for nodes that are not found, code that conforms to the node's semantics is output normally.
其中,所述词法分析包括接收输入的源代码文本,词法分析器读取所述源代码文本,按照语言的词法规则将其分割成一系列的标记,并输出一个标记序列,并将所述标记作为后续语法分析的输入,所述标记包括关键字、标识符的类型信息以及标识符的名称、字面量的具体数值信息。The lexical analysis includes receiving input source code text, the lexical analyzer reading the source code text, segmenting it into a series of tokens according to the lexical rules of the language, outputting a token sequence, and using the tokens as input for subsequent syntax analysis. The tokens include keywords, identifier type information, and the specific numerical information of the identifier name and literal.
在一些实施例中,上述语法分析包括使用语法分析器根据语言的语法规则构建抽象语法树,使用AST作为源代码结构的树状表示,反映程序的语法结构,抽象语法树的节点代表程序的不同构造块,抽象语法树作为后续语义分析和优化的基础。In some embodiments, the above-mentioned syntax analysis includes using a syntax analyzer to construct an abstract syntax tree according to the grammatical rules of the language, using an AST as a tree-like representation of the source code structure to reflect the grammatical structure of the program, the nodes of the abstract syntax tree representing different building blocks of the program, and the abstract syntax tree serving as the basis for subsequent semantic analysis and optimization.
在一些实施例中,上述语义分析包括使用语义分析器遍历AST,检查程序的语义正确性,包括类型检查、作用域解析、变量绑定,以确保程序在语法上正确的基础上,符合语言的语义规则,并输出带有类型信息、作用域信息语义属性的AST,以用于作为后续优化和代码生成的必要语义信息。In some embodiments, the semantic analysis described above includes using a semantic analyzer to traverse the AST, checking the semantic correctness of the program, including type checking, scope resolution, and variable binding, to ensure that the program conforms to the semantic rules of the language while being syntactically correct, and outputting an AST with semantic attributes such as type information and scope information, which can be used as necessary semantic information for subsequent optimization and code generation.
在一些实施例中,上述中间表示的生成包括将AST转换为通用的中间表示,所述通用的中间表示形式不依赖于特定的源语言或目标机器,以用于后续的优化和代码生成。In some embodiments, the generation of the intermediate representation includes converting the AST into a general intermediate representation, which is independent of a specific source language or target machine, for use in subsequent optimization and code generation.
在一些实施例中,上述构建新标准的语法规则映射表,对抽象语法树进行遍历,查询抽象语法树的节点在映射表中是否可以查询到,对于查询到的节点,输出其映射到的字符串,对于未查询到的节点,则正常输出符合节点语义的代码,包括:In some embodiments, the above-described construction of the syntax rule mapping table for the new standard involves traversing the abstract syntax tree, querying whether a node of the abstract syntax tree can be found in the mapping table, and outputting the mapped string for a found node. For nodes not found, the code conforming to the node's semantics is output normally, including:
针对编程语言的新标准,构建从抽象语法树的节点到高级编程语言的新标准的映射表,所述映射表中的key为抽象语法树的节点,所述映射表中的value为具体的字符串,所述具体的字符串符合为新标准的代码;For the new standard of programming languages, a mapping table is constructed from the nodes of the abstract syntax tree to the new standard of the high-level programming language. The key in the mapping table is the node of the abstract syntax tree, the value in the mapping table is a specific string, and the specific string is the code of the new standard.
遍历抽象语法树,在新标准的映射表中查询,如果节点符合新标准,则对此节点进行标记,以检查抽象语法树的每个节点是否符合新标准的语法规则;Traverse the abstract syntax tree, query the mapping table of the new standard, and mark the node if it conforms to the new standard. Check whether each node of the abstract syntax tree conforms to the syntax rules of the new standard.
遍历匹配后的抽象语法树,使用代码生成器生成符合新标准的源代码,代码生成器根据新标准的语法和风格要求,将抽象语法树中的节点进行序列化和格式化;Traverse the matched abstract syntax tree and use a code generator to generate source code that conforms to the new standard. The code generator serializes and formats the nodes in the abstract syntax tree according to the syntax and style requirements of the new standard.
输出新标准下的源代码,将代码生成的字符串输出到文件中。Output the source code under the new standard and output the string generated by the code to a file.
本公开实施例提供的基于编译器进行代码自动升级的装置,包括:The apparatus for automatic code upgrade based on compiler provided in this disclosure includes:
前端模块,用于对高级编程语言进行词法分析,语法分析,生成抽象语法树,并进行语义分析,生成中间表示;The front-end module is used to perform lexical analysis and syntax analysis on high-level programming languages, generate abstract syntax trees, and perform semantic analysis to generate intermediate representations.
后端模块,用于对中间表示进行优化,构建新标准的语法规则映射表,对抽象语法树进行遍历,查询抽象语法树的节点在映射表中是否可以查询到,对于查询到的节点,输出其映射到的字符串,对于未查询到的节点,则正常输出符合节点语义的代码。The backend module is used to optimize the intermediate representation, build a new standard syntax rule mapping table, traverse the abstract syntax tree, query whether the node of the abstract syntax tree can be found in the mapping table, output the mapped string for the found node, and output the code that conforms to the node semantics for the node that is not found.
其中,所述词法分析包括接收输入的源代码文本,词法分析器读取所述源代码文本,按照语言的词法规则将其分割成一系列的标记,并输出一个标记序列,并将所述标记作为后续语法分析的输入,所述标记包括关键字、标识符的类型信息以及标识符的名称、字面量的具体数值信息。The lexical analysis includes receiving input source code text, the lexical analyzer reading the source code text, segmenting it into a series of tokens according to the lexical rules of the language, outputting a token sequence, and using the tokens as input for subsequent syntax analysis. The tokens include keywords, identifier type information, and the specific numerical information of the identifier name and literal.
在一些实施例中,上述后端对中间表示进行优化,指令选择,指令调度,寄存器调度,并生成可执行程序,包括:In some embodiments, the backend optimizes the intermediate representation, performs instruction selection, instruction scheduling, register scheduling, and generates an executable program, including:
针对编程语言的新标准,构建从抽象语法树的节点到高级编程语言的新标准的映射表,所述映射表中的key为抽象语法树的节点,所述映射表中的value为具体的字符串,所述具体的字符串符合为新标准的代码;For the new standard of programming languages, a mapping table is constructed from the nodes of the abstract syntax tree to the new standard of the high-level programming language. The key in the mapping table is the node of the abstract syntax tree, the value in the mapping table is a specific string, and the specific string is the code of the new standard.
遍历抽象语法树,在新标准的映射表中查询,如果节点符合新标准,则对此节点进行标记,以检查抽象语法树的每个节点是否符合新标准的语法规则;Traverse the abstract syntax tree, query the mapping table of the new standard, and mark the node if it conforms to the new standard. Check whether each node of the abstract syntax tree conforms to the syntax rules of the new standard.
遍历匹配后的抽象语法树,使用代码生成器生成符合新标准的源代码,代码生成器根据新标准的语法和风格要求,将抽象语法树中的节点进行序列化和格式化;Traverse the matched abstract syntax tree and use a code generator to generate source code that conforms to the new standard. The code generator serializes and formats the nodes in the abstract syntax tree according to the syntax and style requirements of the new standard.
输出新标准下的源代码,将代码生成的字符串输出到文件中。Output the source code under the new standard and output the string generated by the code to a file.
本公开实施例提供的存储介质,存储有程序指令,其特征在于,所述程序指令在运行时,执行上述实施例中基于编译器进行代码自动升级的方法。The storage medium provided in this embodiment stores program instructions, characterized in that, when the program instructions are executed, they perform the method for automatic code upgrade based on the compiler in the above embodiment.
本公开实施例提供的增强的基于编译器进行代码自动升级的方法、装置以及存储介质,可以实现以下技术效果:The enhanced method, apparatus, and storage medium for automatic code upgrade based on compiler provided in this disclosure can achieve the following technical effects:
通过自动遍历原始代码的抽象语法树(AST),并依据新标准的语法规则映射表进行节点匹配和转换,大大减少了人工干预的需要,提高了代码从旧标准迁移到新标准的自动化程度。这不仅可以节省大量的人力和时间成本,还能减少因人为错误导致的迁移问题。而且新标准的代码往往具有更清晰的语法结构和更规范的命名约定,通过自动转换生成的代码能够更好地符合这些要求,从而提升代码的可读性和可维护性。By automatically traversing the abstract syntax tree (AST) of the original code and performing node matching and transformation according to the new standard's syntax rule mapping table, the need for manual intervention is greatly reduced, improving the automation level of code migration from the old standard to the new standard. This not only saves significant manpower and time costs but also reduces migration problems caused by human error. Furthermore, the code of the new standard often has a clearer syntactic structure and more standardized naming conventions; the code generated through automatic transformation better meets these requirements, thereby improving code readability and maintainability.
以上的总体描述和下文中的描述仅是示例性和解释性的,不用于限制本申请。The above general description and the description below are exemplary and illustrative only and are not intended to limit this application.
一个或多个实施例通过与之对应的附图进行示例性说明,这些示例性说明和附图并不构成对实施例的限定,附图中具有相同参考数字标号的元件示为类似的元件,附图不构成比例限制,并且其中:One or more embodiments are illustrated by way of example with reference to the accompanying drawings. These illustrations and drawings do not constitute a limitation on the embodiments. Elements having the same reference numerals in the drawings are shown as similar elements. The drawings are not to be scaled. And wherein:
图1是本公开实施例提供的一种基于编译器进行代码自动升级的方法的流程示意图;Figure 1 is a flowchart illustrating a method for automatic code upgrade based on a compiler, provided in an embodiment of this disclosure.
图2是本公开实施例提供的一种前端的流程示意图;Figure 2 is a schematic diagram of a front-end process provided in an embodiment of this disclosure;
图3是本公开实施例提供的另一种基于编译器进行代码自动升级的方法的流程示意图;Figure 3 is a flowchart illustrating another method for automatic code upgrade based on a compiler, provided in an embodiment of this disclosure.
图4是本公开实施例提供的一种效果示意图;Figure 4 is a schematic diagram illustrating the effect of an embodiment of this disclosure;
图5是本公开实施例提供的一种基于编译器进行代码自动升级的装置的结构示意图;Figure 5 is a schematic diagram of the structure of a device for automatic code upgrade based on a compiler provided in an embodiment of this disclosure;
图6是本公开实施例提供的一种基于编译器进行代码自动升级的系统的结构示意图。Figure 6 is a schematic diagram of the structure of a system for automatic code upgrade based on a compiler, provided in an embodiment of this disclosure.
为了能够更加详尽地了解本公开实施例的特点与技术内容,下面结合附图对本公开实施例的实现进行详细阐述,所附附图仅供参考说明之用,并非用来限定本公开实施例。在以下的技术描述中,为方便解释起见,通过多个细节以提供对所披露实施例的充分理解。然而,在没有这些细节的情况下,一个或多个实施例仍然可以实施。在其他情况下,为简化附图,熟知的结构和装置可以简化展示。To provide a more detailed understanding of the features and technical content of the embodiments of this disclosure, the implementation of the embodiments of this disclosure will be described in detail below with reference to the accompanying drawings. The accompanying drawings are for illustrative purposes only and are not intended to limit the embodiments of this disclosure. In the following technical description, for ease of explanation, several details are used to provide a full understanding of the disclosed embodiments. However, one or more embodiments may still be implemented without these details. In other cases, well-known structures and devices may be simplified in their depiction to simplify the drawings.
本公开实施例中的术语“第一”“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的本公开实施例的实施例。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含。The terms "first," "second," etc., used in the embodiments of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate for the embodiments of this disclosure described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion.
除非另有说明,术语“多个”表示两个或两个以上。Unless otherwise stated, the term "multiple" means two or more.
本公开实施例中,字符“/”表示前后对象是一种“或”的关系。例如,A/B表示:A或B。In this embodiment of the disclosure, the character "/" indicates that the objects before and after it are in an "or" relationship. For example, A/B means: A or B.
术语“和/或”是一种描述对象的关联关系,表示可以存在三种关系。例如,A和/或B,表示:A或B,或,A和B这三种关系。The term "and/or" describes an association between objects, indicating that three relationships can exist. For example, A and/or B means: A or B, or A and B.
术语“对应”可以指的是一种关联关系或绑定关系,A与B相对应指的是A与B之间是一种关联关系或绑定关系。The term "correspondence" can refer to an association or binding relationship. The correspondence between A and B means that there is an association or binding relationship between A and B.
下面结合附图对本公开实施例提供的基于编译器进行代码自动升级的方法、装置、设备及存储介质进行说明。The method, apparatus, device, and storage medium for automatic code upgrade based on compiler provided in this disclosure will now be described with reference to the accompanying drawings.
图1是本公开实施例提供的一种基于编译器进行代码自动升级的方法的流程示意图,如图1所示,基于编译器进行代码自动升级的方法可以包括:Figure 1 is a flowchart illustrating a method for automatic code upgrade based on a compiler according to an embodiment of this disclosure. As shown in Figure 1, the method for automatic code upgrade based on a compiler may include:
S01,前端对高级编程语言进行词法分析,语法分析,生成抽象语法树,并进行语义分析,生成中间表示;S01, the front end performs lexical analysis and syntax analysis on the high-level programming language, generates an abstract syntax tree, and performs semantic analysis to generate an intermediate representation;
S02,后端对中间表示进行优化,构建新标准的语法规则映射表,对抽象语法树进行遍历,查询抽象语法树的节点在映射表中是否可以查询到,对于查询到的节点,输出其映射到的字符串,对于未查询到的节点,则正常输出符合节点语义的代码。S02, the backend optimizes the intermediate representation, constructs a new standard syntax rule mapping table, traverses the abstract syntax tree, and queries whether the nodes of the abstract syntax tree can be found in the mapping table. For nodes that are found, the mapped string is output; for nodes that are not found, code that conforms to the node's semantics is output normally.
其中,所述词法分析包括接收输入的源代码文本,词法分析器读取所述源代码文本,按照语言的词法规则将其分割成一系列的标记,并输出一个标记序列,并将所述标记作为后续语法分析的输入,所述标记包括关键字、标识符的类型信息以及标识符的名称、字面量的具体数值信息。The lexical analysis includes receiving input source code text, the lexical analyzer reading the source code text, segmenting it into a series of tokens according to the lexical rules of the language, outputting a token sequence, and using the tokens as input for subsequent syntax analysis. The tokens include keywords, identifier type information, and the specific numerical information of the identifier name and literal.
在一些实施例中,上述语法分析包括使用语法分析器根据语言的语法规则构建抽象语法树,使用AST作为源代码结构的树状表示,反映程序的语法结构,抽象语法树的节点代表程序的不同构造块,抽象语法树作为后续语义分析和优化的基础。In some embodiments, the above-mentioned syntax analysis includes using a syntax analyzer to construct an abstract syntax tree according to the grammatical rules of the language, using an AST as a tree-like representation of the source code structure to reflect the grammatical structure of the program, the nodes of the abstract syntax tree representing different building blocks of the program, and the abstract syntax tree serving as the basis for subsequent semantic analysis and optimization.
在一些实施例中,语义分析包括使用语义分析器遍历AST,检查程序的语义正确性,包括类型检查、作用域解析、变量绑定,以确保程序在语法上正确的基础上,符合语言的语义规则,并输出带有类型信息、作用域信息语义属性的AST,以用于作为后续优化和代码生成的必要语义信息。In some embodiments, semantic analysis includes using a semantic analyzer to traverse the AST, checking the semantic correctness of the program, including type checking, scope resolution, and variable binding, to ensure that the program conforms to the semantic rules of the language while being syntactically correct, and outputting an AST with semantic attributes such as type information and scope information, which can be used as necessary semantic information for subsequent optimization and code generation.
在一些实施例中,中间表示的生成包括将AST转换为通用的中间表示,所述通用的中间表示形式不依赖于特定的源语言或目标机器,以用于后续的优化和代码生成。In some embodiments, the generation of intermediate representations includes converting the AST into a generic intermediate representation, which is independent of a specific source language or target machine, for use in subsequent optimization and code generation.
在一些实施例中,上述构建新标准的语法规则映射表,对抽象语法树进行遍历,查询抽象语法树的节点在映射表中是否可以查询到,对于查询到的节点,输出其映射到的字符串,对于未查询到的节点,则正常输出符合节点语义的代码,包括:In some embodiments, the above-described construction of the syntax rule mapping table for the new standard involves traversing the abstract syntax tree, querying whether a node of the abstract syntax tree can be found in the mapping table, and outputting the mapped string for a found node. For nodes not found, the code conforming to the node's semantics is output normally, including:
针对编程语言的新标准,构建从抽象语法树的节点到高级编程语言的新标准的映射表,所述映射表中的key为抽象语法树的节点,所述映射表中的value为具体的字符串,所述具体的字符串符合为新标准的代码;For the new standard of programming languages, a mapping table is constructed from the nodes of the abstract syntax tree to the new standard of the high-level programming language. The key in the mapping table is the node of the abstract syntax tree, the value in the mapping table is a specific string, and the specific string is the code of the new standard.
遍历抽象语法树,在新标准的映射表中查询,如果节点符合新标准,则对此节点进行标记,以检查抽象语法树的每个节点是否符合新标准的语法规则;Traverse the abstract syntax tree, query the mapping table of the new standard, and mark the node if it conforms to the new standard. Check whether each node of the abstract syntax tree conforms to the syntax rules of the new standard.
遍历匹配后的抽象语法树,使用代码生成器生成符合新标准的源代码,代码生成器根据新标准的语法和风格要求,将抽象语法树中的节点进行序列化和格式化;Traverse the matched abstract syntax tree and use a code generator to generate source code that conforms to the new standard. The code generator serializes and formats the nodes in the abstract syntax tree according to the syntax and style requirements of the new standard.
输出新标准下的源代码,将代码生成的字符串输出到文件中。Output the source code under the new standard and output the string generated by the code to a file.
图2是本公开实施例提供的一种前端的流程示意图,结合图2,对图1中前端执行的过程进行进一步描述。Figure 2 is a schematic flowchart of a front-end provided in an embodiment of this disclosure. The process of front-end execution in Figure 1 will be further described in conjunction with Figure 2.
前端的流程,具体步骤如下:The front-end workflow, specifically the steps, is as follows:
1.词法分析:输入源代码文本,词法分析器(Lexer)读取源代码,按照语言的词法规则将其分割成一系列的标记(Tokens),并输出一个标记序列,每个标记包含类型(如关键字、标识符等)和可能的值(如标识符的名称、字面量的具体值),这些标记作为后续语法分析的输入。1. Lexical Analysis: Input source code text, the lexer reads the source code, segments it into a series of tokens according to the language's lexical rules, and outputs a token sequence. Each token contains a type (such as keywords, identifiers, etc.) and possible values (such as the name of the identifier, the specific value of the literal). These tokens serve as input for subsequent syntax analysis.
2.语法分析:语法分析器(Parser)根据语言的语法规则构建抽象语法树(AST)。AST是源代码结构的树状表示,反映了程序的语法结构。抽象语法树的节点代表程序的不同构造块(如表达式、语句、声明等)。抽象语法树作为后续语义分析和优化的基础。2. Syntax Analysis: The parser constructs an Abstract Syntax Tree (AST) based on the language's grammatical rules. The AST is a tree-like representation of the source code structure, reflecting the program's grammatical structure. Nodes in the AST represent different building blocks of the program (such as expressions, statements, and declarations). The AST serves as the foundation for subsequent semantic analysis and optimization.
3.语义分析:语义分析器遍历AST,检查程序的语义正确性,包括类型检查、作用域解析、变量绑定等。它确保程序在语法上正确的基础上,还符合语言的语义规则,并输出带有类型信息、作用域信息等语义属性的AST。这个增强后的AST为后续的优化和代码生成提供了必要的语义信息。3. Semantic Analysis: The semantic analyzer traverses the Abstract Syntax Tree (AST) to check the semantic correctness of the program, including type checking, scope resolution, and variable binding. It ensures that the program is not only syntactically correct but also conforms to the semantic rules of the language, outputting an AST with semantic attributes such as type and scope information. This enhanced AST provides the necessary semantic information for subsequent optimization and code generation.
4.中间表示生成:将AST转换为一种更加通用的中间表示(IR),这种表示形式不依赖于特定的源语言或目标机器,便于后续的优化和代码生成。4. Intermediate Representation Generation: The AST is converted into a more general intermediate representation (IR), which is independent of the specific source language or target machine, facilitating subsequent optimization and code generation.
本发明在上述编译器前端对代码处理生成抽象语法树的基础上,针对指定的新标准,遍历抽象语法树,此时抽象语法树的节点是与具体标准无关的表达式、语句或声明等,将其中的每个节点与新标准的语法规则相结合,生成符合新标准的代码。Based on the abstract syntax tree generated by the compiler front-end, this invention traverses the abstract syntax tree for a specified new standard. At this time, the nodes of the abstract syntax tree are expressions, statements or declarations that are independent of the specific standard. Each node is combined with the syntax rules of the new standard to generate code that conforms to the new standard.
图3是本公开实施例提供的另一种基于编译器进行代码自动升级的方法的流程示意图,结合图3,对图1中前端执行的过程进行进一步描述。Figure 3 is a flowchart illustrating another method for automatic code upgrade based on a compiler, provided in an embodiment of this disclosure. The process of front-end execution in Figure 1 will be further described in conjunction with Figure 3.
1.输入原始的源代码,这些源代码由用户提供,供编译器使用。1. Input the original source code, which is provided by the user for the compiler to use.
2.前端处理。编译器前端对源代码进行词法分析,语法分析,生成抽象语法树,并进行语义分析,确认代码在语法、语义上都是正确的。2. Front-end processing. The compiler front-end performs lexical analysis and syntax analysis on the source code, generates an abstract syntax tree, and performs semantic analysis to confirm that the code is syntactically and semantically correct.
3.构建新标准的语法规则映射表。针对编程语言的新标准,构建从抽象语法树的节点到高级编程语言的映射表,其中的key为抽象语法树的节点,例如循环语句,变量声明,赋值表达式等。其中的value为具体的字符串,这些字符串是符合新标准的代码。3. Construct a syntax rule mapping table for the new standard. For the new standard of programming languages, construct a mapping table from nodes of the abstract syntax tree to high-level programming language rules. The keys are nodes of the abstract syntax tree, such as loop statements, variable declarations, assignment expressions, etc. The values are specific strings, which are codes conforming to the new standard.
4.节点匹配。遍历抽象语法树,检查抽象语法树的每个节点是否符合新标准的语法规则。具体而言,是在新标准的映射表中查询,如果节点符合新标准,则对此节点进行标记。4. Node Matching. Traverse the abstract syntax tree (AST) and check if each node conforms to the syntax rules of the new standard. Specifically, look up the new standard's mapping table; if a node conforms to the new standard, mark it.
5.代码生成。遍历匹配后的抽象语法树,使用代码生成器生成符合新标准的源代码,代码生成器根据新标准的语法和风格要求,将抽象语法树中的节点进行序列化和格式化。5. Code Generation. Traverse the matched abstract syntax tree and use a code generator to generate source code that conforms to the new standard. The code generator serializes and formats the nodes in the abstract syntax tree according to the syntax and style requirements of the new standard.
6.输出新标准下的源代码。将代码生成的字符串输出到文件中。6. Output the source code under the new standard. Output the string generated by the code to a file.
本公开中,首先对源代码进行词法分析、语法分析、语义分析,生成抽象语法树,之后构建新标准的语法规则映射表,对抽象语法树进行遍历,查询抽象语法树的节点在映射表中是否可以查询到,对于查询到的节点,输出其映射到的字符串,对于未查询到的节点,则正常输出符合节点语义的代码。通过自动遍历原始代码的抽象语法树(AST),并依据新标准的语法规则映射表进行节点匹配和转换,大大减少了人工干预的需要,提高了代码从旧标准迁移到新标准的自动化程度。这不仅可以节省大量的人力和时间成本,还能减少因人为错误导致的迁移问题。而且新标准的代码往往具有更清晰的语法结构和更规范的命名约定,通过自动转换生成的代码能够更好地符合这些要求,从而提升代码的可读性和可维护性。This disclosure first performs lexical analysis, syntactic analysis, and semantic analysis on the source code to generate an abstract syntax tree (AST). Then, it constructs a new standard's syntax rule mapping table, traverses the AST, and checks if each node can be found in the mapping table. For found nodes, the mapped string is output; for unfounded nodes, the code conforming to the node's semantics is output normally. By automatically traversing the original code's AST and performing node matching and transformation according to the new standard's syntax rule mapping table, the need for manual intervention is greatly reduced, improving the automation of migrating code from the old standard to the new standard. This not only saves significant manpower and time costs but also reduces migration problems caused by human error. Furthermore, the code of the new standard often has a clearer syntactic structure and more standardized naming conventions; the automatically generated code better meets these requirements, thereby improving code readability and maintainability.
在一个具体的示例中,以C++编程语言为例,编译器以Clang为例,将源码从C++98标准升级到C++11标准。输入的源代码main.cpp如下:
In a specific example, using the C++ programming language and the Clang compiler, the source code is upgraded from the C++98 standard to the C++11 standard. The input source code, main.cpp, is as follows:
上述代码中使用了for循环,对函数内定义的数组进行循环,并输出数组内的每个成员。在C++11中,可以使用范围内的for循环来遍历数组,并使用auto关键字来自动推导循环变量的类型。The code above uses a for loop to iterate over an array defined within a function and output each member of the array. In C++11, a range-bound for loop can be used to iterate over an array, and the `auto` keyword can be used to automatically infer the type of the loop variable.
根据本发明提供的方法,首先构建C++11标准的语法规则映射表,包括范围内的for循环编译,对于范围内for循环编译的新特性,key为AST表达式中的for循环语句ForStmt,value为对应的范围内for循环字符串,形式如for(auto elem:arr)所示。According to the method provided by the present invention, a C++11 standard syntax rule mapping table is first constructed, including scoped for loop compilation. For the new feature of scoped for loop compilation, the key is the for loop statement ForStmt in the AST expression, and the value is the corresponding scoped for loop string, in the form of for(auto elem:arr).
之后对代码进行词法分析,语法分析,生成抽象语法树,然后进行语义分析,确认代码在语法、语义上都是正确的。根据输入的源码生成的抽象语法树中含有for循环语句节点ForStmt,变量定义语句VarDecl,赋值语句InitListExpr等。Next, lexical analysis and syntax analysis are performed on the code to generate an abstract syntax tree (AST). Semantic analysis is then conducted to confirm that the code is syntactically and semantically correct. The AST generated from the input source code contains nodes such as `ForStmt` (for loop statement), `VarDecl` (variable definition statement), and `InitListExpr` (assignment statement).
遍历抽象语法树,对抽象语法树的每个节点进行匹配,如果在C++11的语法规则映射表中查找到对应的节点,则对此节点进行标记,标记为C++11标准。如果没有查到对应的节点,则略过此节点。此处抽象语法树中含有for循环语句ForStmt,同时在C++11的语法规则映射表中也包括ForStmt,因此此处对ForStmt节点标记。The abstract syntax tree (BST) is traversed, and each node is matched. If a corresponding node is found in the C++11 syntax rule map, it is marked as a C++11 standard node. If no corresponding node is found, it is skipped. Here, the BST contains a for loop statement `ForStmt`, and `ForStmt` is also included in the C++11 syntax rule map; therefore, the `ForStmt` node is marked here.
对抽象语法树中的节点进行标记之后,开始做代码生成。对于标记为使用C++11标准进行代码生成的节点,输出语法规则映射表中存储的ForStmt对应的字符串,对于没有标记的节点,使用标准的代码生成器生成代码。After marking the nodes in the abstract syntax tree, code generation begins. For nodes marked as requiring code generation using the C++11 standard, the string corresponding to ForStmt stored in the syntax rule mapping table is output. For unmarked nodes, code is generated using the standard code generator.
使用本发明输出的代码如下所示:
The code output using this invention is shown below:
其中的for循环语句由常规的for循环变为范围内for循环,具体的实施例效果示意图如图4所示。The for loop statement is changed from a regular for loop to a range for loop. A specific implementation example is shown in Figure 4.
图5是本公开实施例提供的一种基于编译器进行代码自动升级的装置的结构示意图,如图5所示,基于编译器进行代码自动升级的装置可以包括:Figure 5 is a schematic diagram of a device for automatic code upgrade based on a compiler according to an embodiment of this disclosure. As shown in Figure 5, the device for automatic code upgrade based on a compiler may include:
前端模块501,用于对高级编程语言进行词法分析,语法分析,生成抽象语法树,并进行语义分析,生成中间表示;The front-end module 501 is used to perform lexical analysis, syntax analysis, generate abstract syntax trees, and perform semantic analysis on high-level programming languages to generate intermediate representations.
后端模块502,用于对中间表示进行优化,构建新标准的语法规则映射表,对抽象语法树进行遍历,查询抽象语法树的节点在映射表中是否可以查询到,对于查询到的节点,输出其映射到的字符串,对于未查询到的节点,则正常输出符合节点语义的代码。Backend module 502 is used to optimize the intermediate representation, build a new standard syntax rule mapping table, traverse the abstract syntax tree, query whether the node of the abstract syntax tree can be found in the mapping table, output the mapped string for the found node, and output the code that conforms to the node semantics for the node that is not found.
其中,所述词法分析包括接收输入的源代码文本,词法分析器读取所述源代码文本,按照语言的词法规则将其分割成一系列的标记,并输出一个标记序列,并将所述标记作为后续语法分析的输入,所述标记包括关键字、标识符的类型信息以及标识符的名称、字面量的具体数值信息。The lexical analysis includes receiving input source code text, the lexical analyzer reading the source code text, segmenting it into a series of tokens according to the lexical rules of the language, outputting a token sequence, and using the tokens as input for subsequent syntax analysis. The tokens include keywords, identifier type information, and the specific numerical information of the identifier name and literal.
在一些实施例中,上述语法分析包括使用语法分析器根据语言的语法规则构建抽象语法树,使用AST作为源代码结构的树状表示,反映程序的语法结构,抽象语法树的节点代表程序的不同构造块,抽象语法树作为后续语义分析和优化的基础。In some embodiments, the above-mentioned syntax analysis includes using a syntax analyzer to construct an abstract syntax tree according to the grammatical rules of the language, using an AST as a tree-like representation of the source code structure to reflect the grammatical structure of the program, the nodes of the abstract syntax tree representing different building blocks of the program, and the abstract syntax tree serving as the basis for subsequent semantic analysis and optimization.
在一些实施例中,语义分析包括使用语义分析器遍历AST,检查程序的语义正确性,包括类型检查、作用域解析、变量绑定,以确保程序在语法上正确的基础上,符合语言的语义规则,并输出带有类型信息、作用域信息语义属性的AST,以用于作为后续优化和代码生成的必要语义信息。In some embodiments, semantic analysis includes using a semantic analyzer to traverse the AST, checking the semantic correctness of the program, including type checking, scope resolution, and variable binding, to ensure that the program conforms to the semantic rules of the language while being syntactically correct, and outputting an AST with semantic attributes such as type information and scope information, which can be used as necessary semantic information for subsequent optimization and code generation.
在一些实施例中,中间表示的生成包括将AST转换为通用的中间表示,所述通用的中间表示形式不依赖于特定的源语言或目标机器,以用于后续的优化和代码生成。In some embodiments, the generation of intermediate representations includes converting the AST into a generic intermediate representation, which is independent of a specific source language or target machine, for use in subsequent optimization and code generation.
在一些实施例中,上述构建新标准的语法规则映射表,对抽象语法树进行遍历,查询抽象语法树的节点在映射表中是否可以查询到,对于查询到的节点,输出其映射到的字符串,对于未查询到的节点,则正常输出符合节点语义的代码,包括:In some embodiments, the above-described construction of the syntax rule mapping table for the new standard involves traversing the abstract syntax tree, querying whether a node of the abstract syntax tree can be found in the mapping table, and outputting the mapped string for a found node. For nodes not found, the code conforming to the node's semantics is output normally, including:
针对编程语言的新标准,构建从抽象语法树的节点到高级编程语言的新标准的映射表,所述映射表中的key为抽象语法树的节点,所述映射表中的value为具体的字符串,所述具体的字符串符合为新标准的代码;For the new standard of programming languages, a mapping table is constructed from the nodes of the abstract syntax tree to the new standard of the high-level programming language. The key in the mapping table is the node of the abstract syntax tree, the value in the mapping table is a specific string, and the specific string is the code of the new standard.
遍历抽象语法树,在新标准的映射表中查询,如果节点符合新标准,则对此节点进行标记,以检查抽象语法树的每个节点是否符合新标准的语法规则;Traverse the abstract syntax tree, query the mapping table of the new standard, and mark the node if it conforms to the new standard. Check whether each node of the abstract syntax tree conforms to the syntax rules of the new standard.
遍历匹配后的抽象语法树,使用代码生成器生成符合新标准的源代码,代码生成器根据新标准的语法和风格要求,将抽象语法树中的节点进行序列化和格式化;Traverse the matched abstract syntax tree and use a code generator to generate source code that conforms to the new standard. The code generator serializes and formats the nodes in the abstract syntax tree according to the syntax and style requirements of the new standard.
输出新标准下的源代码,将代码生成的字符串输出到文件中。Output the source code under the new standard and output the string generated by the code to a file.
需要说明的是,对于前述的各方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本公开并不受所描述的动作顺序的限制,因为依据本公开,某些步骤可以采用其他顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于可选实施例,所涉及的动作和模块并不一定是本公开所必需的。It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this disclosure is not limited to the described order of actions, because according to this disclosure, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily essential to this disclosure.
结合图6所示,本公开实施例提供了一种基于编译器进行代码自动升级的系统600,包括处理器604和存储器(memory)601。可选地,该系统还可以包括通信接口(Communication Interface)602和总线603。其中,处理器604、通信接口602、存储器601可以通过总线603完成相互间的通信。通信接口602可以用于信息传输。处理器604可以调用存储器601中的逻辑指令,以执行上述实施例中基于编译器进行代码自动升级的方法。Referring to Figure 6, this disclosure provides a system 600 for automatic code upgrades based on a compiler, including a processor 604 and a memory 601. Optionally, the system may further include a communication interface 602 and a bus 603. The processor 604, communication interface 602, and memory 601 can communicate with each other via the bus 603. The communication interface 602 can be used for information transmission. The processor 604 can call logical instructions in the memory 601 to execute the method for automatic code upgrades based on a compiler as described in the above embodiment.
此外,上述的存储器601中的逻辑指令可以通过软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。Furthermore, the logic instructions in the aforementioned memory 601 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium.
存储器601作为一种计算机可读存储介质,可用于存储软件程序、计算机可执行程序,如本公开实施例中的方法对应的程序指令/模块。处理器604通过运行存储在存储器601中的程序指令/模块,从而执行功能应用以及数据处理,即实现上述实施例中基于编译器进行代码自动升级的方法。The memory 601, as a computer-readable storage medium, can be used to store software programs and computer-executable programs, such as program instructions/modules corresponding to the methods in the embodiments of this disclosure. The processor 604 executes functional applications and data processing by running the program instructions/modules stored in the memory 601, thereby implementing the compiler-based automatic code upgrade method in the above embodiments.
存储器601可包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需的应用程序;存储数据区可存储根据终端设备的使用所创建的数据等。此外,存储器601可以包括高速随机存取存储器,还可以包括非易失性存储器。The memory 601 may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created based on the use of the terminal device. Furthermore, the memory 601 may include high-speed random access memory and may also include non-volatile memory.
本公开实施例提供了一种计算机可读存储介质,存储有计算机可执行指令,计算机可执行指令设置为执行基于编译器进行代码自动升级的方法。This disclosure provides a computer-readable storage medium storing computer-executable instructions configured to execute a method for automatic code upgrades based on a compiler.
上述的计算机可读存储介质可以是暂态计算机可读存储介质,也可以是非暂态计算机可读存储介质。The aforementioned computer-readable storage medium may be a transient computer-readable storage medium or a non-transitory computer-readable storage medium.
本公开实施例的技术方案可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括一个或多个指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本公开实施例方法的全部或部分步骤。而前述的存储介质可以是非暂态存储介质,包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等多种可以存储程序代码的介质,也可以是暂态存储介质。The technical solutions of this disclosure can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes one or more instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of this disclosure. The aforementioned storage medium can be a non-transitory storage medium, including: a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, and other media capable of storing program code; it can also be a transient storage medium.
以上描述和附图充分地示出了本公开的实施例,以使本领域的技术人员能够实践它们。其他实施例可以包括结构的、逻辑的、电气的、过程的以及其他的改变。实施例仅代表可能的变化。除非明确要求,否则单独的部件和功能是可选的,并且操作的顺序可以变化。一些实施例的部分和特征可以被包括在或替换其他实施例的部分和特征。如在实施例的描述中使用的,除非上下文清楚地表明,否则单数形式的“一个”(a)、“一个”(an)和“一个”(the)旨在同样包括复数形式。类似地,如在本申请中所使用的术语“和/或”是指包含一个或一个以上相关联的列出的任何以及所有可能的组合。另外,当用于本申请中时,术语“包括”(comprise)及其变型“包括”(comprises)和/或包括(comprising)等指陈述的特征、整体、步骤、操作、元素,和/或组件的存在,但不排除一个或一个以上其他特征、整体、步骤、操作、元素、组件和/或这些的分组的存在或添加。在没有更多限制的情况下,由语句“包括一个…”限定的要素,并不排除在包括要素的过程、方法或者设备中还存在另外的相同要素。本文中,每个实施例重点说明的可以是与其他实施例的不同之处,各个实施例之间相同相似部分可以互相参见。The foregoing description and accompanying drawings fully illustrate embodiments of the present disclosure to enable those skilled in the art to practice them. Other embodiments may include structural, logical, electrical, procedural, and other changes. The embodiments represent only possible variations. Individual components and functions are optional unless explicitly required, and the order of operation may vary. Parts and features of some embodiments may be included in or replace parts and features of other embodiments. As used in the description of the embodiments, unless the context clearly indicates otherwise, the singular forms “a,” “an,” and “the” are intended to equally include the plural forms. Similarly, the term “and/or” as used herein means including one or more of the associated listed items and all possible combinations thereof. Additionally, when used in this application, the terms “comprise” and its variations “comprises” and/or “comprising” refer to the presence of stated features, integrals, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integrals, steps, operations, elements, components, and/or groups thereof. Unless otherwise specified, an element defined by the phrase "comprising a..." does not exclude the presence of other identical elements in the process, method, or apparatus that includes that element. In this document, each embodiment may focus on describing the differences from other embodiments, and similar or identical parts between embodiments may be referred to mutually.
对于实施例公开的方法、产品等而言,如果其与实施例公开的方法部分相对应,那么相关之处可以参见方法部分的描述。For methods, products, etc., disclosed in the embodiments, if they correspond to the method portion disclosed in the embodiments, the relevant details can be found in the description of the method portion.
本领域技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件,或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,可以取决于技术方案的特定应用和设计约束条件。技术人员可以对每个特定的应用来使用不同方法以实现所描述的功能,但是这种实现不应认为超出本公开实施例的范围。技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统、装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。本文所披露的实施例中,所揭露的方法、产品(包括但不限于装置、设备等),可以通过其他的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,单元的划分,可以仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另外,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其他的形式。作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例。另外,在本公开实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the embodiments disclosed herein. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here. The methods and products (including but not limited to devices, equipment, etc.) disclosed in the embodiments herein can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of units may only be a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be electrical, mechanical, or other forms. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to implement this embodiment according to actual needs. Furthermore, the functional units in the embodiments of this disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
附图中的流程图和框图显示了根据本公开实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段或代码的一部分,模块、程序段或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个连续的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这可以依所涉及的功能而定。在附图中的流程图和框图所对应的描述中,不同的方框所对应的操作或步骤也可以以不同于描述中所披露的顺序发生,有时不同的操作或步骤之间不存在特定的顺序。例如,两个连续的操作或步骤实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这可以依所涉及的功能而定。框图和/或流程图中的每个方框,以及框图和/或流程图中的方框的组合,可以用执行规定的功能或动作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to embodiments of the present disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code, which contains one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the blocks may occur in a different order than that shown in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. In the descriptions corresponding to the flowcharts and block diagrams in the accompanying drawings, the operations or steps corresponding to different blocks may also occur in a different order than disclosed in the description, and sometimes there is no specific order between different operations or steps. For example, two consecutive operations or steps may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. Each block in a block diagram and/or flowchart, and combinations of blocks in a block diagram and/or flowchart, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
Claims (8)
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202411279576.6A CN119311289A (en) | 2024-09-12 | 2024-09-12 | Method, device and storage medium for automatic code upgrade based on compiler |
| CN202411279576.6 | 2024-09-12 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2026056340A1 true WO2026056340A1 (en) | 2026-03-19 |
Family
ID=94191486
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2025/096565 Pending WO2026056340A1 (en) | 2024-09-12 | 2025-05-22 | Compiler-based automatic code upgrade method and apparatus, and storage medium |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN119311289A (en) |
| WO (1) | WO2026056340A1 (en) |
Families Citing this family (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN119311289A (en) * | 2024-09-12 | 2025-01-14 | 山东浪潮科学研究院有限公司 | Method, device and storage medium for automatic code upgrade based on compiler |
| CN120455570B (en) * | 2025-07-14 | 2025-09-30 | 宁波市大数据投资发展有限公司 | Data multi-protocol self-adaptive analysis method, system and storage medium |
Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN110471666A (en) * | 2019-07-18 | 2019-11-19 | 五八有限公司 | Code automatic switching method and device, code converter and medium |
| CN110609693A (en) * | 2019-08-15 | 2019-12-24 | 平安国际智慧城市科技股份有限公司 | Code update method, device and terminal device based on data standardization |
| CN110825384A (en) * | 2019-10-28 | 2020-02-21 | 国电南瑞科技股份有限公司 | A LLVM-based ST language compilation method, compilation system and compiler |
| JP2021039482A (en) * | 2019-09-02 | 2021-03-11 | Kddi株式会社 | Syntax tree converter, syntax tree conversion method and syntax tree conversion program |
| CN116501330A (en) * | 2023-04-23 | 2023-07-28 | 寂山智工(苏州)科技有限公司 | Text programming language compiling method based on decoupling architecture |
| CN119311289A (en) * | 2024-09-12 | 2025-01-14 | 山东浪潮科学研究院有限公司 | Method, device and storage medium for automatic code upgrade based on compiler |
-
2024
- 2024-09-12 CN CN202411279576.6A patent/CN119311289A/en active Pending
-
2025
- 2025-05-22 WO PCT/CN2025/096565 patent/WO2026056340A1/en active Pending
Patent Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN110471666A (en) * | 2019-07-18 | 2019-11-19 | 五八有限公司 | Code automatic switching method and device, code converter and medium |
| CN110609693A (en) * | 2019-08-15 | 2019-12-24 | 平安国际智慧城市科技股份有限公司 | Code update method, device and terminal device based on data standardization |
| JP2021039482A (en) * | 2019-09-02 | 2021-03-11 | Kddi株式会社 | Syntax tree converter, syntax tree conversion method and syntax tree conversion program |
| CN110825384A (en) * | 2019-10-28 | 2020-02-21 | 国电南瑞科技股份有限公司 | A LLVM-based ST language compilation method, compilation system and compiler |
| CN116501330A (en) * | 2023-04-23 | 2023-07-28 | 寂山智工(苏州)科技有限公司 | Text programming language compiling method based on decoupling architecture |
| CN119311289A (en) * | 2024-09-12 | 2025-01-14 | 山东浪潮科学研究院有限公司 | Method, device and storage medium for automatic code upgrade based on compiler |
Also Published As
| Publication number | Publication date |
|---|---|
| CN119311289A (en) | 2025-01-14 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN110187885B (en) | Intermediate code generation method and device for quantum program compiling | |
| US9535664B1 (en) | Computerized software development process and management environment | |
| WO2026056340A1 (en) | Compiler-based automatic code upgrade method and apparatus, and storage medium | |
| CN111796831A (en) | Compiling method and device for multi-chip compatibility | |
| CN112860233B (en) | Target syntax tree generation method and related equipment | |
| US20130152061A1 (en) | Full fidelity parse tree for programming language processing | |
| Blindell | Instruction selection | |
| US20230113783A1 (en) | Cross-platform code conversion method and device | |
| CN118760437B (en) | Method for translating multi-language front end into yak byte codes of network security special compiler | |
| CN107515739A (en) | Improve the method and device of code execution performance | |
| KR102614967B1 (en) | Automation system and method for extracting intermediate representation based semantics of javascript | |
| CN114816364A (en) | Method, device and application for dynamically generating template file based on Swagger | |
| CN119166836A (en) | Method, device and server for determining corresponding original text column position after macro replacement | |
| CN117311728B (en) | An OpenCL automatic translation method | |
| CN117591095A (en) | Code generation method based on expression AST analysis and configurable template | |
| CN116150527A (en) | Component style isolation method, device, equipment, storage medium and product | |
| CN114791808A (en) | Data flow graph generation method and device | |
| CN120780664A (en) | Method and device for converting structural body and JSON data | |
| CN113961238A (en) | Object conversion method and device, electronic equipment and storage medium | |
| US8341607B2 (en) | Condensing pattern matcher generation for intermediate language patterns | |
| CN111796832A (en) | Hot patch file generation method, device, equipment and storage medium | |
| CN118733007A (en) | Python-based code automatic generation and automatic checking method | |
| CN118445198A (en) | A method, device, terminal device and storage medium for determining air space | |
| CN114416050B (en) | Swift code processing method, device, electronic device and storage medium | |
| CN118103815A (en) | Compilation method and device for compiling |