[go: up one dir, main page]

CN115858019A - Data processing method, system, electronic device and storage medium for expressions - Google Patents

Data processing method, system, electronic device and storage medium for expressions Download PDF

Info

Publication number
CN115858019A
CN115858019A CN202211693291.8A CN202211693291A CN115858019A CN 115858019 A CN115858019 A CN 115858019A CN 202211693291 A CN202211693291 A CN 202211693291A CN 115858019 A CN115858019 A CN 115858019A
Authority
CN
China
Prior art keywords
node
data type
data
expression
type
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
Application number
CN202211693291.8A
Other languages
Chinese (zh)
Inventor
李士成
莫文盼
蔡路
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Eastcompeace Technology Co Ltd
Original Assignee
Eastcompeace Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Eastcompeace Technology Co Ltd filed Critical Eastcompeace Technology Co Ltd
Priority to CN202211693291.8A priority Critical patent/CN115858019A/en
Publication of CN115858019A publication Critical patent/CN115858019A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application provides a data processing method, a system, an electronic device and a storage medium aiming at an expression, wherein the method comprises the following steps: acquiring an expression to be analyzed, and generating an abstract syntax tree by using the expression to be analyzed; traversing the abstract syntax tree, and determining the data types of all nodes, wherein the data types comprise a first data type and a second data type, and the occupied bytes of the first data type are more than the occupied bytes of the second data type; in response to a first node having a first data type, determining a node to be adjusted associated with the first node; converting the data type of the node to be adjusted into a first data type; and constructing an expression statement by using the updated abstract syntax tree. The method and the device aim to reduce the occupied space of the expression and improve the running efficiency of the resource-limited operating system on the expression.

Description

针对表达式的数据处理方法、系统、电子设备及存储介质Data processing method, system, electronic device and storage medium for expressions

技术领域technical field

本申请涉及计算机技术领域,尤其涉及一种针对表达式的数据处理方法、系统、电子设备及存储介质。The present application relates to the field of computer technology, in particular to a data processing method, system, electronic equipment and storage medium for expressions.

背景技术Background technique

操作系统中一般数据的数据类型分为int类型和其他类型,其中,int类型所占用的空间为32bit,而其他类型所占用的空间为16bit,不同类型的所占用空间相差一倍。在基于寄存器的目标代码生成时,合理选择数据类型对虚拟机的指令速率和空间利用率有很大的影响。同时在资源受限的操作系统中,资源的合理分配至关重要。The data types of general data in the operating system are divided into int type and other types. Among them, the space occupied by the int type is 32bit, while the space occupied by other types is 16bit, and the space occupied by different types is doubled. When generating register-based object code, choosing a reasonable data type has a great influence on the instruction rate and space utilization of the virtual machine. At the same time, in a resource-constrained operating system, the rational allocation of resources is very important.

目前,相关技术中的Java虚拟机最基本的存储单元是变量槽slot,而每个变量槽占用的空间为32bit,使得所有的变量和指令都是基于int类型进行计算。针对于表达式中部分为byte类型或者short类型等仅占用16bit的数据也需要基于int类型进行计算,占用较多的空间。尤其是复杂的算术表达式中出现多个字面量数据的情况下,每个字面量数据均占用32bit空间,会严重浪费空间,影响数据运行效率。由于在运算过程中需要部分运算指令仅支持相同类型的运算,占用空间小的数据类型可以转换为占用空间大的数据类型,而占用空间大的数据类型无法转换为占用空间小的数据类型。如果将各个字面量数据以其可实现的最小占用空间进行存储,则在与占用空间大的数据类型的数据进行运算时需要额外增加类型转换指令,影响表达式运行效率。因此,如何在资源受限的操作系统中提高表达式的运行效率,成为了亟待解决的技术问题。At present, the most basic storage unit of the Java virtual machine in the related art is a variable slot, and each variable slot occupies a space of 32 bits, so that all variables and instructions are calculated based on the int type. For some data in the expression that only occupies 16 bits, such as byte type or short type, it also needs to be calculated based on int type, which takes up more space. Especially when multiple literal data appear in complex arithmetic expressions, each literal data takes up 32 bits of space, which will seriously waste space and affect the efficiency of data operation. Since some operation instructions only support the same type of operation during the operation, a data type with a small footprint can be converted to a data type with a large footprint, but a data type with a large footprint cannot be converted to a data type with a small footprint. If each literal data is stored in its achievable minimum footprint, additional type conversion instructions need to be added when performing operations with data types that occupy a large space, which will affect the efficiency of expression operations. Therefore, how to improve the operating efficiency of expressions in resource-constrained operating systems has become an urgent technical problem to be solved.

发明内容Contents of the invention

以下是对本文详细描述的主题的概述。本概述并非是为了限制权利要求的保护范围。The following is an overview of the topics described in detail in this article. This summary is not intended to limit the scope of the claims.

本申请实施例的主要目的在于提出一种针对表达式的数据处理方法、系统、电子设备及存储介质,旨在减少表达式的占用空间,提高资源受限的操作系统对表达式的运行效率。The main purpose of the embodiments of the present application is to provide a data processing method, system, electronic device and storage medium for expressions, aiming at reducing the occupied space of expressions and improving the operation efficiency of expressions in resource-constrained operating systems.

为实现上述目的,本申请实施例的第一方面提出了一种针对表达式的数据处理方法,所述方法包括:In order to achieve the above purpose, the first aspect of the embodiment of the present application proposes a data processing method for expressions, the method comprising:

获取待解析表达式,利用所述待解析表达式生成抽象语法树;Obtain an expression to be parsed, and use the expression to be parsed to generate an abstract syntax tree;

对所述抽象语法树进行遍历,确定所有节点的数据类型,所述数据类型包括第一数据类型和第二数据类型,所述第一数据类型的占用字节多于所述第二数据类型的占用字节;Traversing the abstract syntax tree to determine the data types of all nodes, the data types include a first data type and a second data type, and the first data type occupies more bytes than the second data type occupied bytes;

响应于存在所述第一数据类型的第一节点,确定与所述第一节点关联的待调整节点;In response to the presence of a first node of the first data type, determining a node to be adjusted associated with the first node;

将所述待调整节点的数据类型转换为所述第一数据类型;converting the data type of the node to be adjusted into the first data type;

利用更新后的抽象语法树构建表达式语句。Build expression statements using the updated abstract syntax tree.

在一些实施例中,所述数据处理方法还包括:In some embodiments, the data processing method also includes:

响应于不存在所述第一数据类型的第一节点,将所有目标节点的数据类型转换为所述第二数据类型,各个所述目标节点由所述待解析表达式中的各个字面量数据一一对应生成。In response to the absence of the first node of the first data type, converting the data types of all target nodes into the second data type, each of the target nodes is represented by each literal data in the expression to be parsed One-to-one correspondence is generated.

在一些实施例中,所述第一节点包括由所述待解析表达式中的变量数据生成的变量节点,以及由所述待解析表达式中的字面量数据生成的字面量节点中的至少一种。In some embodiments, the first node includes at least one of a variable node generated from variable data in the expression to be parsed and a literal node generated from literal data in the expression to be parsed kind.

在一些实施例中,所述响应于存在所述第一数据类型的第一节点,确定与所述第一节点关联的待调整节点,包括:In some embodiments, the determining a node to be adjusted associated with the first node in response to the presence of the first node of the first data type includes:

响应于存在所述第一数据类型的第一节点,将所述第一节点的兄弟节点和祖先节点确定为待调整节点。In response to the existence of the first node of the first data type, determine sibling nodes and ancestor nodes of the first node as nodes to be adjusted.

在一些实施例中,所述确定与所述第一节点关联的待调整节点,包括:In some embodiments, the determining the node to be adjusted associated with the first node includes:

根据所述抽象语法树的深度,依次将所述第一节点的祖先节点确定为待调整节点,直至下一个所述祖先节点为特殊节点,所述特殊节点表征为所述数据类型固定的节点。According to the depth of the abstract syntax tree, the ancestor nodes of the first node are sequentially determined as nodes to be adjusted until the next ancestor node is a special node, and the special node is characterized as a node with a fixed data type.

在一些实施例中,所述确定与所述第一节点关联的待调整节点,包括:In some embodiments, the determining the node to be adjusted associated with the first node includes:

在所述第一节点的父节点不为特殊节点的情况下,将所述第一节点的兄弟节点确定为待调整节点,所述特殊节点表征为所述数据类型固定的节点。If the parent node of the first node is not a special node, determine the sibling node of the first node as the node to be adjusted, and the special node is characterized as a node whose data type is fixed.

在一些实施例中,所述将所述待调整节点的数据类型转换为所述第一数据类型之后,包括:In some embodiments, after converting the data type of the node to be adjusted into the first data type, it includes:

对更新后的抽象语法树进行遍历,对所述第一数据类型的节点的子节点转换为所述第一数据类型。The updated abstract syntax tree is traversed, and the child nodes of the nodes of the first data type are converted to the first data type.

为实现上述目的,本申请实施例的第二方面提出了一种针对表达式的数据处理系统,所述系统包括:In order to achieve the above purpose, the second aspect of the embodiment of the present application proposes a data processing system for expressions, and the system includes:

数据生成模块,用于获取待解析表达式,利用所述待解析表达式生成抽象语法树;A data generation module, configured to obtain an expression to be parsed, and use the expression to be parsed to generate an abstract syntax tree;

类型确定模块,用于对所述抽象语法树进行遍历,确定所有节点的数据类型,所述数据类型包括第一数据类型和第二数据类型,所述第一数据类型的占用字节多于所述第二数据类型的占用字节;A type determination module, configured to traverse the abstract syntax tree to determine the data types of all nodes, the data types include a first data type and a second data type, and the first data type occupies more bytes than the Occupied bytes of the second data type;

关联确定模块,用于响应于存在所述第一数据类型的第一节点,确定与所述第一节点关联的待调整节点;an association determination module, configured to determine a node to be adjusted associated with the first node in response to the existence of the first node of the first data type;

类型转换模块,用于将所述待调整节点的数据类型转换为所述第一数据类型;a type conversion module, configured to convert the data type of the node to be adjusted into the first data type;

语句构建模块,用于利用更新后的抽象语法树构建表达式语句。A statement building module for constructing expression statements using the updated abstract syntax tree.

为实现上述目的,本申请实施例的第三方面提出了一种电子设备,所述电子设备包括存储器和处理器,所述存储器存储有计算机程序,所述处理器执行所述计算机程序时实现上述第一方面所述的针对表达式的数据处理方法。In order to achieve the above purpose, the third aspect of the embodiments of the present application proposes an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the above-mentioned computer program when executing the computer program. The data processing method for expressions described in the first aspect.

为实现上述目的,本申请实施例的第四方面提出了一种存储介质,所述存储介质为计算机可读存储介质,所述存储介质存储有计算机程序,所述计算机程序被处理器执行时实现上述第一方面所述的针对表达式的数据处理方法。In order to achieve the above purpose, the fourth aspect of the embodiments of the present application proposes a storage medium, the storage medium is a computer-readable storage medium, the storage medium stores a computer program, and the computer program is implemented when the computer program is executed by a processor. The data processing method for expressions described in the first aspect above.

本申请提供了一种针对表达式的数据处理方法、系统、电子设备及存储介质,方法包括:获取待解析表达式,利用待解析表达式生成抽象语法树;对抽象语法树进行遍历,确定所有节点的数据类型,数据类型包括第一数据类型和第二数据类型,第一数据类型的占用字节多于第二数据类型的占用字节;响应于存在第一数据类型的第一节点,确定与第一节点关联的待调整节点;将待调整节点的数据类型转换为第一数据类型;利用更新后的抽象语法树构建表达式语句。根据本申请的技术方案,通过将表达式转换为抽象语法树,逐一确定出各个节点的数据类型,即表达式中的变量数据和字面量数据各自在生成中间语言时可以进行储存的数据类型。对抽象语法树各个节点的数据类型进行判断,是否存在第一数据类型的节点。在存在第一数据类型的第一节点的情况下,将与第一节点相关联的节点的数据类型均转换为第一数据类型,即将与第一节点进行运算的相关节点均转换为第一数据类型,从而无需在运算时额外添加类型转换指令。而与第一节点不相关联的节点均可以以第二数据类型进行存储,节省占用空间。相较于相关技术中全部采用第一数据类型的数据进行运算的技术方案,本申请方案能够有效减小表达式数据的占用空间,从而能够在资源受限的操作系统中提高表达式的运行效率。The application provides a data processing method, system, electronic device and storage medium for expressions. The method includes: obtaining an expression to be parsed, generating an abstract syntax tree by using the expression to be parsed; traversing the abstract syntax tree to determine all The data type of the node, the data type includes a first data type and a second data type, and the occupied bytes of the first data type are more than the occupied bytes of the second data type; in response to the existence of the first node of the first data type, it is determined The node to be adjusted associated with the first node; the data type of the node to be adjusted is converted into the first data type; and an expression statement is constructed by using the updated abstract syntax tree. According to the technical solution of the present application, by converting the expression into an abstract syntax tree, the data type of each node is determined one by one, that is, the data type of variable data and literal data in the expression that can be stored when generating the intermediate language. The data type of each node of the abstract syntax tree is judged to determine whether there is a node of the first data type. If there is a first node of the first data type, convert the data types of the nodes associated with the first node to the first data type, that is, convert the related nodes that perform operations with the first node to the first data type, so that there is no need to add additional type conversion instructions during operation. Nodes that are not associated with the first node can all be stored in the second data type, saving occupied space. Compared with the technical solutions in the related art that all use the data of the first data type for calculation, the solution of the present application can effectively reduce the space occupied by the expression data, thereby improving the operation efficiency of the expression in the resource-constrained operating system .

附图说明Description of drawings

图1是本申请一个实施例提供的针对表达式的数据处理方法的步骤流程图;FIG. 1 is a flow chart of the steps of a data processing method for expressions provided by an embodiment of the present application;

图2是本申请另一个实施例提供的步骤S120之后的具体步骤流程图;FIG. 2 is a flowchart of specific steps after step S120 provided by another embodiment of the present application;

图3是本申请另一个实施例提供一个强转表达式所形成的抽象语法树的示意图;Fig. 3 is a schematic diagram of an abstract syntax tree formed by a coerced expression provided by another embodiment of the present application;

图4是本申请另一个实施例提供的步骤S130的具体步骤流程图;FIG. 4 is a flow chart of specific steps of step S130 provided by another embodiment of the present application;

图5是本申请另一个实施例提供的步骤S130的具体步骤流程图;FIG. 5 is a flow chart of specific steps of step S130 provided by another embodiment of the present application;

图6是本申请另一个实施例提供的步骤S130的具体步骤流程图;FIG. 6 is a flow chart of specific steps of step S130 provided by another embodiment of the present application;

图7是本申请另一个实施例提供的一个逻辑运算表达式所形成的抽象语法树的示意图;Fig. 7 is a schematic diagram of an abstract syntax tree formed by a logical operation expression provided by another embodiment of the present application;

图8是本申请另一个实施例提供的步骤S140之后的具体步骤流程图Fig. 8 is a flow chart of specific steps after step S140 provided by another embodiment of the present application

图9是本申请另一个实施例提供的一个待解析表达式所形成的抽象语法树的示意图Fig. 9 is a schematic diagram of an abstract syntax tree formed by an expression to be parsed provided by another embodiment of the present application

图10是本申请实施例提供的针对表达式的数据处理系统的模块示意图;FIG. 10 is a block diagram of a data processing system for expressions provided by an embodiment of the present application;

图11是本申请实施例提供的电子设备的硬件结构示意图。FIG. 11 is a schematic diagram of a hardware structure of an electronic device provided by an embodiment of the present application.

具体实施方式Detailed ways

为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅用以解释本申请,并不用于限定本申请。In order to make the purpose, technical solution and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described here are only used to explain the present application, not to limit the present application.

需要说明的是,虽然在系统示意图中进行了功能模块划分,在流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于系统中的模块划分,或流程图中的顺序执行所示出或描述的步骤。说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。It should be noted that although the functional modules are divided in the system schematic diagram and the logical order is shown in the flow chart, in some cases, it can be executed in a different order than the module division in the system or the flow chart steps shown or described. The terms "first", "second" and the like in the specification and claims and the above drawings are used to distinguish similar objects, and not necessarily used to describe a specific sequence or sequence.

除非另有定义,本文所使用的所有的技术和科学术语与属于本申请的技术领域的技术人员通常理解的含义相同。本文中所使用的术语只是为了描述本申请实施例的目的,不是旨在限制本申请。Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the technical field to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of the present application, and are not intended to limit the present application.

本申请实施例提供的针对表达式的数据处理方法可应用于终端中,也可应用于服务器端中,还可以是运行于终端或服务器端中的软件。在一些实施例中,终端可以是智能手机、平板电脑、笔记本电脑、台式计算机等;服务器端可以配置成独立的物理服务器,也可以配置成多个物理服务器构成的服务器集群或者分布式系统,还可以配置成提供云服务、云数据库、云计算、云函数、云存储、网络服务、云通信、中间件服务、域名服务、安全服务、内容分发网络(Content Delivery Network,CDN)以及大数据和人工智能平台等基础云计算服务的云服务器;软件可以是实现针对表达式的数据处理方法的应用等,但并不局限于以上形式。The expression-oriented data processing method provided in the embodiment of the present application can be applied to a terminal, can also be applied to a server, and can also be software running on a terminal or a server. In some embodiments, the terminal can be a smart phone, a tablet computer, a notebook computer, a desktop computer, etc.; the server end can be configured as an independent physical server, or can be configured as a server cluster or a distributed system composed of multiple physical servers, or It can be configured to provide cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery network (Content Delivery Network, CDN) and big data and artificial Cloud servers for basic cloud computing services such as intelligent platforms; software can be applications that implement data processing methods for expressions, but are not limited to the above forms.

本申请可用于众多通用或专用的计算机系统环境或配置中。例如:个人计算机、服务器计算机、手持设备或便携式设备、平板型设备、多处理器系统、基于微处理器的系统、置顶盒、可编程的消费电子设备、网络PC、小型计算机、大型计算机、包括以上任何系统或设备的分布式计算环境等等。本申请可以在由计算机执行的计算机可执行指令的一般上下文中描述,例如程序模块。一般地,程序模块包括执行特定任务或实现特定抽象数据类型的例程、程序、对象、组件、数据结构等等。也可以在分布式计算环境中实践本申请,在这些分布式计算环境中,由通过通信网络而被连接的远程处理设备来执行任务。在分布式计算环境中,程序模块可以位于包括存储设备在内的本地和远程计算机存储介质中。The application can be used in numerous general purpose or special purpose computer system environments or configurations. Examples: personal computers, server computers, handheld or portable devices, tablet-type devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, including A distributed computing environment for any of the above systems or devices, etc. This application may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The application may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including storage devices.

下面结合附图对本申请实施例进行介绍。Embodiments of the present application will be described below in conjunction with the accompanying drawings.

第一方面,图1是本申请实施例提供的针对表达式的数据处理方法的一个可选的流程图,图1中针对表达式的数据处理方法可以包括但不限于包括步骤S110至步骤S150:In the first aspect, FIG. 1 is an optional flow chart of the data processing method for expressions provided in the embodiment of the present application. The data processing method for expressions in FIG. 1 may include but not limited to steps S110 to S150:

步骤S110,获取待解析表达式,利用待解析表达式生成抽象语法树;Step S110, obtaining an expression to be parsed, and using the expression to be parsed to generate an abstract syntax tree;

步骤S120,对抽象语法树进行遍历,确定所有节点的数据类型;Step S120, traversing the abstract syntax tree to determine the data types of all nodes;

步骤S130,响应于存在第一数据类型的第一节点,确定与第一节点关联的待调整节点;Step S130, in response to the existence of the first node of the first data type, determine the node to be adjusted associated with the first node;

步骤S140,将待调整节点的数据类型转换为第一数据类型;Step S140, converting the data type of the node to be adjusted into the first data type;

步骤S150,利用更新后的抽象语法树构建表达式语句。Step S150, using the updated abstract syntax tree to construct an expression statement.

可以理解的是,对需要进行解析运算的表达式进行获取,其中,表达式包括有变量、字面量以及运算逻辑符。利用待解析表达式生成抽象语法树,即表达式中的变量、字面量以及运算逻辑符根据相应的逻辑关系转化生成抽象语法树的节点。对由待解析表达式生成的抽象语法树进行遍历,确定出所有节点的数据类型,即表达式中的变量数据和字面量数据各自在生成中间语言时可以使用的数据类型,相当于在对表达式生成中间语言构建语句之前,超前扫描表达式。其中,数据类型包括第一数据类型和第二数据类型,而第一数据类型的占用字节多余第二数据类型的占用字节,即第一数据类型可以为占用32字节的int类型,而第二数据类型可以为占用16字节的short类型。It can be understood that the expression that needs to be analyzed and calculated is acquired, wherein the expression includes variables, literals and operation logic symbols. The expression to be parsed is used to generate an abstract syntax tree, that is, the variables, literals, and operational logic symbols in the expression are transformed according to the corresponding logical relationship to generate the nodes of the abstract syntax tree. Traverse the abstract syntax tree generated by the expression to be parsed, and determine the data types of all nodes, that is, the data types of the variable data and literal data in the expression that can be used when generating the intermediate language, which is equivalent to the expression Expressions are scanned ahead before the intermediate language construction statement is generated. Wherein, the data type includes the first data type and the second data type, and the occupied bytes of the first data type are more than the occupied bytes of the second data type, that is, the first data type can be an int type occupying 32 bytes, and The second data type may be a short type occupying 16 bytes.

对抽象语法树各个节点的数据类型进行判断,是否存在第一数据类型的节点,即判断是否存在int类型的数据,包括字面量数据和变量数据。由于在运算过程中需要部分运算指令仅支持相同类型的运算,占用空间小的数据类型可以转换为占用空间大的数据类型,而占用空间大的数据类型无法转换为占用空间小的数据类型。如果将各个字面量数据或变量数据以其可实现的最小占用空间进行存储,则在与占用空间大的数据类型的数据进行运算时需要额外增加类型转换指令,影响表达式运行效率。因此,在存在第一数据类型的第一节点的情况下,将与第一节点相关联的待调整节点的数据类型均转换为第一数据类型,即将与第一节点进行运算的相关节点均转换为第一数据类型,从而无需在运算时额外添加类型转换指令。待调整节点可以是由字面量数据和/或变量数据生成的节点。而与第一节点不相关联的节点均可以以第二数据类型进行存储,节省占用空间,达到数据占用空间与表达式运行效率两者均衡。Judging the data type of each node of the abstract syntax tree, whether there is a node of the first data type, that is, judging whether there is int type data, including literal data and variable data. Since some operation instructions only support the same type of operation during the operation, a data type with a small footprint can be converted to a data type with a large footprint, but a data type with a large footprint cannot be converted to a data type with a small footprint. If each literal data or variable data is stored in its achievable minimum occupied space, additional type conversion instructions need to be added when operating with data of a large space-occupied data type, which will affect the operating efficiency of the expression. Therefore, if there is a first node of the first data type, the data types of the nodes to be adjusted associated with the first node are all converted to the first data type, that is, all related nodes that perform operations with the first node are converted to It is the first data type, so there is no need to add additional type conversion instructions during operation. The node to be adjusted may be a node generated by literal data and/or variable data. Nodes that are not associated with the first node can all be stored in the second data type, which saves space and achieves a balance between data space and expression operation efficiency.

相较于相关技术中全部采用第一数据类型即int类型的数据进行运算的技术方案,本申请方法在构建中间语言的过程中,通过对算术运算即待解析表达式的抽象语法树进行遍历,超前扫描分析抽象语法树的所有节点即字面量数据和变量数据,分配合适的数据类型,通过扫描后确定的数据类型构建中间语言或者目标指令,可以使数据运算更准确,减少溢出情况出现,同时减少空间的占用,有助于提高资源受限的操作系统对表达式的运算效率。Compared with the technical solutions in the related art that all use the first data type, that is, int type data for calculation, the method of the present application traverses the abstract syntax tree of the expression to be parsed, that is, the arithmetic operation, in the process of constructing the intermediate language, Scanning ahead analyzes all nodes of the abstract syntax tree, namely literal data and variable data, assigns appropriate data types, and constructs intermediate language or target instructions through the data types determined after scanning, which can make data operations more accurate and reduce overflow situations. Reducing the space occupied helps to improve the operation efficiency of expressions in resource-constrained operating systems.

请参阅图2,在一些实施例中,在执行图1步骤S120之后,本申请实施例提供的针对表达式的数据处理方法还可以包括但不限于包括步骤S210:Please refer to FIG. 2. In some embodiments, after step S120 in FIG. 1 is performed, the data processing method for expressions provided by the embodiment of the present application may also include but not limited to include step S210:

步骤S210,响应于不存在第一数据类型的第一节点,将所有目标节点的数据类型转换为第二数据类型,各个目标节点由待解析表达式中的各个字面量数据一一对应生成。Step S210, in response to the fact that there is no first node of the first data type, the data types of all target nodes are converted into the second data type, and each target node is generated in one-to-one correspondence with each literal data in the expression to be parsed.

可以理解的是,在抽象语法树中不存在有第一数据类型的第一节点的情况下,即不包含有int类型的数据,则可以认为抽象语法树中的所有字面量都可以是short类型,即第二数据类型。因此,将所有目标节点的数据类型都转换为第二数据类型,而目标节点是由待解析表达式中的各个字面量数据对应生成的,相当于将待解析表达式中所有的字面量数据均默认为short类型,仅占用16bit,无需采用第一数据类型,减少空间的占用。同时,多个第二数据类型运算得出的结果也为第二数据类型。It can be understood that, in the case that there is no first node of the first data type in the abstract syntax tree, that is, it does not contain data of type int, it can be considered that all literals in the abstract syntax tree can be of type short , the second data type. Therefore, the data types of all target nodes are converted into the second data type, and the target nodes are correspondingly generated from each literal data in the expression to be parsed, which is equivalent to converting all the literal data in the expression to be parsed The default is the short type, which only occupies 16 bits, and there is no need to use the first data type to reduce the space occupied. At the same time, the result obtained from multiple operations of the second data type is also the second data type.

参考图3,图3表示为一个强转表达式所形成的抽象语法树的示意图,该强转表达式为short result4=(short)(a+0xFF-b)。可以看出,当变量节点a,即变量数据a的数据类型为第二数据类型,由于变量节点a和字面量节点0xFF均与特殊节点short关联,无论(a+0xFF)计算得出的数值是否超过32767,即不考虑数据溢出的情况,得到的结果都为short类型,即第二数据类型,从而字面量节点0xFF的数据类型可以被认为第二数据类型。Referring to FIG. 3 , FIG. 3 shows a schematic diagram of an abstract syntax tree formed by a forced expression, and the forced expression is short result4=(short)(a+0xFF-b). It can be seen that when the variable node a, that is, the data type of the variable data a is the second data type, since both the variable node a and the literal node 0xFF are associated with the special node short, no matter whether the value calculated by (a+0xFF) is Exceeding 32767, that is, regardless of the data overflow, the obtained results are all short types, that is, the second data type, so the data type of the literal node 0xFF can be regarded as the second data type.

需要说明的是,第一节点包括有变量节点和/或字面量节点,即说明待解析表达式中可以仅包括有第一数据类型的变量数据,也可以仅包括有第一数据类型的字面量数据,还可以同时包括有第一数据类型的变量数据和字面量数据。变量节点是由待解析表达式中的变量数据生成的,而字面量节点是由待解析表达式中的字面量数据生成的。It should be noted that the first node includes variable nodes and/or literal nodes, which means that the expression to be parsed may only include variable data of the first data type, or may only include literals of the first data type The data may also include variable data and literal data of the first data type at the same time. Variable nodes are generated from variable data in the expression to be parsed, and literal nodes are generated from literal data in the expression to be parsed.

字面量数据的默认数据类型可以通过字面量数据所表征的数值大小确定,例如,当字面量数据所表示的数值不超过32767,则可以认为该字面量数据可以采用第二数据类型,也可以采用第一数据类型,默认数据类型是第二数据类型,即可采用占用空间最小的数据类型。而当字面量数据所表示的数值超过32767,则可以认为该字面量数据仅可以采用第一数据类型,即该字面量数据的默认数据类型是第一数据类型,可以认为该字面量数据所生成的节点为第一节点。The default data type of literal data can be determined by the numerical value represented by the literal data. For example, when the value represented by the literal data does not exceed 32767, it can be considered that the literal data can adopt the second data type or the The first data type, the default data type is the second data type, that is, the data type that occupies the smallest space can be used. And when the value represented by the literal data exceeds 32767, it can be considered that the literal data can only adopt the first data type, that is, the default data type of the literal data is the first data type, and it can be considered that the literal data generated The node of is the first node.

请参阅图4,在一些实施例中,在图1步骤S130还可以包括但不限于包括步骤S310:Referring to FIG. 4, in some embodiments, step S130 in FIG. 1 may also include but not limited to include step S310:

步骤S310,响应于存在第一数据类型的第一节点,将第一节点的兄弟节点和祖先节点确定为待调整节点。Step S310, in response to the existence of the first node of the first data type, determine the sibling nodes and ancestor nodes of the first node as nodes to be adjusted.

可以理解的是,在对待解析表达式进行解析之前,利用抽象语法树的深度优先遍历算法,遍历抽象语法树的各个节点,如果存在有第一数据类型的第一节点,则确定出与第一节点相关联的待调整节点,即用于与第一节点所表征的数据进行运算的数据,包括第一节点的兄弟节点和祖先节点,祖先节点包括父节点、父节点的父节点等,相当于在运算的操作数中存在第一数据类型的情况下,其运算的结果均为第一数据类型,同时与该操作数参与运算的数据也调整为第一数据类型。其中,兄弟节点和祖先节点可以由待解析表达式的字面量数据生成,也可以由变量数据生成。由于待调整节点需要与第一节点进行运算,而部分运算指令仅支持相同类型的运算,因此,可以将待调整节点均调整为与第一节点数据类型相同的第一数据类型,从而有助于提高数据运算的准确率,无需额外增加类型转换指令,提高对表达式的运行效率。It can be understood that, before parsing the expression to be parsed, the depth-first traversal algorithm of the abstract syntax tree is used to traverse each node of the abstract syntax tree, and if there is a first node of the first data type, then determine the The node to be adjusted associated with the node is the data used to perform operations on the data represented by the first node, including the sibling nodes and ancestor nodes of the first node. The ancestor nodes include the parent node, the parent node of the parent node, etc., which is equivalent to If the operands of the operation have the first data type, the results of the operation are all of the first data type, and at the same time, the data participating in the operation with the operand is also adjusted to the first data type. Among them, the sibling nodes and ancestor nodes can be generated from the literal data of the expression to be parsed, and can also be generated from variable data. Since the nodes to be adjusted need to perform operations with the first node, and some operation instructions only support the same type of operations, the nodes to be adjusted can be adjusted to the same first data type as the first node data type, thus facilitating Improve the accuracy of data operations, without adding additional type conversion instructions, and improve the operating efficiency of expressions.

请参阅图5,在一些实施例中,在图1步骤S130可以包括但不限于包括步骤S410:Referring to FIG. 5, in some embodiments, step S130 in FIG. 1 may include but not limited to include step S410:

步骤S410,根据抽象语法树的深度,依次将第一节点的祖先节点确定为待调整节点,直至下一个祖先节点为特殊节点。Step S410, according to the depth of the abstract syntax tree, successively determine the ancestor nodes of the first node as nodes to be adjusted until the next ancestor node is a special node.

可以理解的是,利用抽象语法树的深度,依次查找第一节点在抽象语法树中的祖先节点,并将这些祖先节点确定为待调整节点,直至遇到数据类型固定的特殊节点,则停止查找祖先节点。特殊节点可以为强转运算符形成的节点,也可以为赋值运算符形成的节点,而由于强转运算符所转换的数据类型和赋值运算符所被赋值的数据类型均能够被确定的,相当于特殊节点的祖先节点的数据类型是可以确定的,因此,无需将其确定为待调整节点。It can be understood that, using the depth of the abstract syntax tree, the ancestor nodes of the first node in the abstract syntax tree are searched in turn, and these ancestor nodes are determined as nodes to be adjusted, until a special node with a fixed data type is encountered, the search is stopped ancestor node. The special node can be a node formed by a coercion operator, or a node formed by an assignment operator, and since the data type converted by the coercion operator and the data type assigned by the assignment operator can be determined, it is quite The data type of the ancestor node of the special node can be determined, so it is not necessary to determine it as the node to be adjusted.

请参阅图6,在一些实施例中,在图1步骤S130可以包括但不限于包括步骤S510:Referring to FIG. 6, in some embodiments, step S130 in FIG. 1 may include but not limited to include step S510:

步骤S510,在第一节点的父节点不为特殊节点的情况下,将第一节点的兄弟节点确定为待调整节点。Step S510, if the parent node of the first node is not a special node, determine the sibling node of the first node as the node to be adjusted.

可以理解的是,在第一节点的父节点不为特殊节点的情况下,相当于针对于其他节点与第一节点进行处理后的输出结果的数据类型不作限制,为了提高运算的精度,可以将第一节点的兄弟节点确定为待调整节点,即将第一节点的兄弟节点的数据类型调整为第一数据类型,使得两者的数据类型相同,从而在解析表达式的情况下,无需为兄弟节点增加类型转换指令,提高运算效率。It can be understood that, in the case that the parent node of the first node is not a special node, it is equivalent to no restriction on the data type of the output result after processing other nodes and the first node. In order to improve the accuracy of the operation, the The sibling node of the first node is determined as the node to be adjusted, that is, the data type of the sibling node of the first node is adjusted to the first data type, so that the data types of the two are the same, so in the case of parsing the expression, there is no need to be a sibling node Add type conversion instructions to improve operation efficiency.

参考图7,图7表示为一个逻辑运算表达式所形成的抽象语法树的示意图,该逻辑运算表达式为boolean ressult4=a<1。可以看出,字面量节点1的数据类型取决于变量节点a的数据类型。当变量节点a的数据类型为第一数据类型,变量节点a的父节点也非特殊节点,则可以认为字面量节点1的数据类型为第一数据类型。即使字面量节点1的数据可以采用第二数据类型进行存储,但由于操作系统中指令的操作数的数据类型必须是相同的,字面量节点1采用第一数据类型进行存储可以减少类型转换指令的执行。当变量节点a的数据类型为第二数据类型,则字面量节点1可以采用第二数据类型进行存储。Referring to FIG. 7, FIG. 7 shows a schematic diagram of an abstract syntax tree formed by a logical operation expression, and the logical operation expression is boolean ressult4=a<1. It can be seen that the data type of literal node 1 depends on the data type of variable node a. When the data type of the variable node a is the first data type, and the parent node of the variable node a is not a special node, the data type of the literal node 1 can be considered as the first data type. Even though the data of the literal node 1 can be stored in the second data type, since the data types of the operands of the instructions in the operating system must be the same, the literal node 1 can be stored in the first data type to reduce the number of type conversion instructions. implement. When the data type of the variable node a is the second data type, the literal node 1 can use the second data type for storage.

请参阅图8,在一些实施例中,在图1步骤S140之后可以包括但不限于包括步骤S610:Referring to FIG. 8 , in some embodiments, after step S140 in FIG. 1 , step S610 may be included but not limited to:

步骤S610,对更新后的抽象语法树进行遍历,对第一数据类型的节点的子节点转换为第一数据类型。Step S610, traverse the updated abstract syntax tree, and convert the child nodes of the nodes of the first data type to the first data type.

可以理解的是,在确定了第一节点相关联的待调整节点,并且将待调整节点的数据类型转换为第一数据类型之后,抽象语法树初步完成了各个节点的数据类型的分配。为了提高运算效率,提高数据运算的精度,对更新后的抽象语法树进行遍历,再次确定出第一数据类型的节点,并将第一数据类型的子节点转化为第一数据类型,相当于在输出结果为第一数据类型的情况下,操作数也可以采用第一数据类型。It can be understood that after the node to be adjusted associated with the first node is determined, and the data type of the node to be adjusted is converted into the first data type, the abstract syntax tree initially completes the allocation of the data type of each node. In order to improve the operation efficiency and the precision of the data operation, the updated abstract syntax tree is traversed, the nodes of the first data type are determined again, and the child nodes of the first data type are converted into the first data type, which is equivalent to When the output result is the first data type, the operand can also use the first data type.

参考图9,图9表示为一个待解析表达式所形成的抽象语法树的示意图,该待解析表达式为int result=0xFF+((short)((b+0xFFFF)-(b+0xFF))+(short)(b+0xFF))。对抽象语法树进行扫描,并根据待解析表达式的情况划分为多个子树。其中,变量数据b的默认数据类型为第二数据类型,即节点十一、节点十三和节点十六均为第二数据类型,而节点二则为第一数据类型。可以看出,节点十二所表示的字面量数据为0xFFF,所代表的数值大于32767,因此,无法采用第二数据类型进行存储,即节点十二仅能够为第一数据类型,相当于节点十二为第一节点。而作为第一节点的兄弟节点——节点十一虽然是已知的第二数据类型,但由于节点十一与节点十二的输出结果应当满足第一数据类型,因此,节点九和节点十一均为需要转换为第一数据类型的待调整节点。节点八作为节点十二的祖先节点,因此,节点八也为需要转换为第一数据类型的待调整节点。With reference to Fig. 9, Fig. 9 represents the synoptic diagram of the abstract syntax tree that a to-be-parsed expression forms, and this to-be-parsed expression is int result=0xFF+((short)((b+0xFFFF)-(b+0xFF))+ (short)(b+0xFF)). The abstract syntax tree is scanned and divided into multiple subtrees according to the expression to be parsed. Wherein, the default data type of variable data b is the second data type, that is, node eleven, node thirteen and node sixteen are all of the second data type, while node two is of the first data type. It can be seen that the literal data represented by node twelve is 0xFFF, and the value represented is greater than 32767. Therefore, the second data type cannot be used for storage, that is, node twelve can only be the first data type, which is equivalent to node ten Two is the first node. As the sibling node of the first node——node eleven is a known second data type, but since the output results of nodes eleven and twelve should satisfy the first data type, therefore, nodes nine and nodes eleven Both are nodes to be adjusted that need to be converted to the first data type. Node eight is the ancestor node of node twelve, therefore, node eight is also a node to be adjusted that needs to be converted to the first data type.

相应地,节点十作为节点八的子节点,在节点八和节点九均为第一数据类型的情况下,节点十也为待调整节点,即需要转换为第一数据类型。而节点十三和节点十四同为第一节点——节点十的子节点,节点十三和节点十四也为需要转换为第一数据类型的待调整节点。Correspondingly, node ten is a child node of node eight, and when nodes eight and nine are both of the first data type, node ten is also a node to be adjusted, that is, it needs to be converted to the first data type. Node thirteen and node fourteen are both the first node—child nodes of node ten, and node thirteen and node fourteen are also nodes to be adjusted that need to be converted into the first data type.

另外,由于节点十六的默认数据类型为第二数据类型,而节点十七所表示的字面量数据为0xFF,即所代表的数据不超过32767,因此,节点十七和节点十六可以为第二数据类型,而相应的父节点——节点十五也为第二数据类型。In addition, since the default data type of node 16 is the second data type, and the literal data represented by node 17 is 0xFF, that is, the represented data does not exceed 32767, therefore, node 17 and node 16 can be the first The second data type, and the corresponding parent node—node fifteen is also the second data type.

由于节点六和节点七为强转功能的特殊节点,即节点五为第二数据类型,同样,节点四所表示的字面量数据为0xFF,即所代表的数据不超过32767,节点四可以为第二数据类型。但由于节点一为赋值功能的特殊节点,节点一、节点二和节点三均为第一数据类型,因此,节点四也可以为第一数据类型。而在节点四采用第二数据类型的情况下,在构建表达式语句如中间语言或目标指令的情况下,需要增加类型转换指令。Since node 6 and node 7 are special nodes with strong transfer function, that is, node 5 is the second data type. Similarly, the literal data represented by node 4 is 0xFF, that is, the data represented does not exceed 32767. Node 4 can be the second data type. Two data types. However, since Node 1 is a special node with an assignment function, Node 1, Node 2 and Node 3 are all of the first data type, therefore, Node 4 may also be of the first data type. In the case that node 4 adopts the second data type, when constructing an expression statement such as an intermediate language or an object instruction, it is necessary to add a type conversion instruction.

第二方面,请参阅图10,图10是本申请实施例提供的针对表达式的数据处理系统的模块示意图,本申请实施例还提供一种针对表达式的数据处理系统1000,可以实现上述针对表达式的数据处理方法,该系统包括:For the second aspect, please refer to FIG. 10. FIG. 10 is a block diagram of a data processing system for expressions provided by the embodiment of the present application. The embodiment of the present application also provides a data processing system 1000 for expressions, which can realize the above-mentioned A data processing method for expressions, the system includes:

数据生成模块1010,用于获取待解析表达式,利用待解析表达式生成抽象语法树;The data generation module 1010 is used to obtain the expression to be parsed, and generate an abstract syntax tree by using the expression to be parsed;

类型确定模块1020,用于对抽象语法树进行遍历,确定所有节点的数据类型,数据类型包括第一数据类型和第二数据类型,第一数据类型的占用字节多于第二数据类型的占用字节;The type determination module 1020 is configured to traverse the abstract syntax tree to determine the data types of all nodes, the data types include the first data type and the second data type, and the occupied bytes of the first data type are more than those occupied by the second data type byte;

关联确定模块1030,用于响应于存在第一数据类型的第一节点,确定与第一节点关联的待调整节点;An association determination module 1030, configured to determine a node to be adjusted associated with the first node in response to the existence of the first node of the first data type;

类型转换模块1040,用于将待调整节点的数据类型转换为第一数据类型;A type conversion module 1040, configured to convert the data type of the node to be adjusted into a first data type;

语句构建模块1050,用于利用更新后的抽象语法树构建表达式语句。A statement construction module 1050, configured to use the updated abstract syntax tree to construct an expression statement.

需要说明的是,该针对表达式的数据处理系统1000的具体实施方式与上述针对表达式的数据处理方法的具体实施例基本相同,在此不再赘述。It should be noted that the specific implementation manner of the expression-oriented data processing system 1000 is basically the same as the specific embodiment of the above-mentioned expression-oriented data processing method, and will not be repeated here.

第三方面,本申请实施例还提供了一种电子设备,电子设备包括存储器和处理器,存储器存储有计算机程序,处理器执行计算机程序时实现上述针对表达式的数据处理方法。该电子设备可以为包括平板电脑、车载电脑等任意智能终端。In a third aspect, the embodiment of the present application further provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the above data processing method for expressions when executing the computer program. The electronic device may be any intelligent terminal including a tablet computer, a vehicle-mounted computer, and the like.

请参阅图11,图11示意了另一实施例的电子设备的硬件结构,电子设备包括:Please refer to FIG. 11. FIG. 11 illustrates a hardware structure of an electronic device in another embodiment. The electronic device includes:

处理器1110,可以采用通用的CPU(CentralProcessingUnit,中央处理器)、微处理器、应用专用集成电路(ApplicationSpecificIntegratedCircuit,ASIC)、或者一个或多个集成电路等方式实现,用于执行相关程序,以实现本申请实施例所提供的技术方案;The processor 1110 may be implemented by using a general-purpose CPU (Central Processing Unit, central processing unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, and is used to execute related programs to realize The technical solutions provided by the embodiments of the present application;

存储器1120,可以采用只读存储器(ReadOnlyMemory,ROM)、静态存储设备、动态存储设备或者随机存取存储器(RandomAccessMemory,RAM)等形式实现。存储器1120可以存储操作系统和其他应用程序,在通过软件或者固件来实现本说明书实施例所提供的技术方案时,相关的程序代码保存在存储器1120中,并由处理器1110来调用执行本申请实施例的针对表达式的数据处理方法,例如,执行以上描述的图1中的方法步骤S110至步骤S150、图2中的方法步骤S210、图4中的方法步骤S310、图5中的方法步骤S410、图6中的方法步骤S510以及图8中的方法步骤S610;The memory 1120 may be implemented in the form of a read-only memory (ReadOnlyMemory, ROM), a static storage device, a dynamic storage device, or a random access memory (RandomAccessMemory, RAM). The memory 1120 can store operating systems and other application programs. When implementing the technical solutions provided by the embodiments of this specification through software or firmware, the relevant program codes are stored in the memory 1120 and called by the processor 1110 to execute the implementation of this application. The data processing method for the expression of the example, for example, execute the method step S110 to step S150 in Fig. 1 described above, the method step S210 in Fig. 2, the method step S310 in Fig. 4, the method step S410 in Fig. 5 , the method step S510 in FIG. 6 and the method step S610 in FIG. 8;

输入/输出接口1130,用于实现信息输入及输出;The input/output interface 1130 is used to realize information input and output;

通信接口1140,用于实现本设备与其他设备的通信交互,可以通过有线方式(例如USB、网线等)实现通信,也可以通过无线方式(例如移动网络、WIFI、蓝牙等)实现通信;The communication interface 1140 is used to realize the communication and interaction between this device and other devices, and the communication can be realized through a wired method (such as USB, network cable, etc.), or can be realized through a wireless method (such as a mobile network, WIFI, Bluetooth, etc.);

总线1150,在设备的各个组件(例如处理器1110、存储器1120、输入/输出接口1130和通信接口1140)之间传输信息;bus 1150, to transfer information between various components of the device (eg, processor 1110, memory 1120, input/output interface 1130, and communication interface 1140);

其中处理器1110、存储器1120、输入/输出接口1130和通信接口1140通过总线1150实现彼此之间在设备内部的通信连接。The processor 1110 , the memory 1120 , the input/output interface 1130 and the communication interface 1140 are connected to each other within the device through the bus 1150 .

第四方面,本申请实施例还提供了一种计算机可读存储介质,该计算机可读存储介质存储有计算机程序,该计算机程序被处理器执行时实现上述针对表达式的数据处理方法。In a fourth aspect, the embodiment of the present application further provides a computer-readable storage medium, where a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the above data processing method for expressions is implemented.

存储器作为一种非暂态计算机可读存储介质,可用于存储非暂态软件程序以及非暂态性计算机可执行程序。此外,存储器可以包括高速随机存取存储器,还可以包括非暂态存储器,例如至少一个磁盘存储器件、闪存器件、或其他非暂态固态存储器件。在一些实施方式中,存储器可选包括相对于处理器远程设置的存储器,这些远程存储器可以通过网络连接至该处理器。上述网络的实例包括但不限于互联网、企业内部网、局域网、移动通信网及其组合。As a non-transitory computer-readable storage medium, memory can be used to store non-transitory software programs and non-transitory computer-executable programs. In addition, the memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid-state storage devices. In some embodiments, the memory optionally includes memory located remotely from the processor, and these remote memories may be connected to the processor via a network. Examples of the aforementioned networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.

实现上述实施例中的针对表达式的数据处理方法所需的非暂态软件程序以及指令存储在存储器中,当被一个或者多个处理器执行时,执行上述实施例中的针对表达式的数据处理方法,例如,执行以上描述的图1中的方法步骤S110至步骤S150、图2中的方法步骤S210、图4中的方法步骤S310、图5中的方法步骤S410、图6中的方法步骤S510以及图8中的方法步骤S610。The non-transitory software programs and instructions required to implement the data processing method for expressions in the above embodiments are stored in the memory, and when executed by one or more processors, the data for expressions in the above embodiments are executed. Processing method, for example, carry out method step S110 to step S150 in Fig. 1 described above, method step S210 in Fig. 2, method step S310 in Fig. 4, method step S410 in Fig. 5, method step in Fig. 6 S510 and method step S610 in FIG. 8 .

本申请实施例描述的实施例是为了更加清楚的说明本申请实施例的技术方案,并不构成对于本申请实施例提供的技术方案的限定,本领域技术人员可知,随着技术的演变和新应用场景的出现,本申请实施例提供的技术方案对于类似的技术问题,同样适用。The embodiments described in the embodiments of the present application are to illustrate the technical solutions of the embodiments of the present application more clearly, and do not constitute a limitation to the technical solutions provided by the embodiments of the present application. Those skilled in the art know that with the evolution of technology and new For the emergence of application scenarios, the technical solutions provided by the embodiments of the present application are also applicable to similar technical problems.

本领域技术人员可以理解的是,图中示出的技术方案并不构成对本申请实施例的限定,可以包括比图示更多或更少的步骤,或者组合某些步骤,或者不同的步骤。Those skilled in the art can understand that the technical solution shown in the figure does not constitute a limitation to the embodiment of the present application, and may include more or less steps than those shown in the figure, or combine some steps, or different steps.

以上所描述的系统实施例仅仅是示意性的,其中作为分离部件说明的单元可以是或者也可以不是物理上分开的,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。The system embodiments described above are only illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place, or may be distributed to multiple network units. Part or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

本领域普通技术人员可以理解,上文中所公开方法中的全部或某些步骤、系统、设备中的功能模块/单元可以被实施为软件、固件、硬件及其适当的组合。Those of ordinary skill in the art can understand that all or some of the steps in the methods disclosed above, the functional modules/units in the system, and the device can be implemented as software, firmware, hardware, and an appropriate combination thereof.

本申请的说明书及上述附图中的术语“第一”、“第二”、“第三”、“第四”等(如果存在)是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的本申请的实施例能够以除了在这里图示或描述的那些以外的顺序实施。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。The terms "first", "second", "third", "fourth", etc. (if any) in the description of the present application and the above drawings are used to distinguish similar objects and not necessarily to describe specific sequence or sequence. It is to be understood that the data so used are interchangeable under appropriate circumstances such that the embodiments of the application described herein can be practiced in sequences other than those illustrated or described herein. Furthermore, the terms "comprising" and "having", as well as any variations thereof, are intended to cover a non-exclusive inclusion, for example, a process, method, system, product or device comprising a sequence of steps or elements is not necessarily limited to the expressly listed instead, may include other steps or elements not explicitly listed or inherent to the process, method, product or apparatus.

应当理解,在本申请中,“多个”是指两个或两个以上。字符“/”一般表示前后关联对象是一种“或”的关系。It should be understood that in this application, "plurality" means two or more. The character "/" generally indicates that the contextual objects are an "or" relationship.

在本申请所提供的几个实施例中,应该理解到,所揭露的系统和方法,可以通过其它的方式实现。例如,以上所描述的系统实施例仅仅是示意性的,例如,上述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,系统或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed system and method can be implemented in other ways. For example, the above-described system embodiments are only illustrative. For example, the division of the above-mentioned units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or can be Integrate into another system, or some features may be ignored, or not implemented. In another point, 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 systems or units may be in electrical, mechanical or other forms.

上述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, each unit may exist separately physically, or two or more units may be integrated into one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.

集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括多指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例的方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read-Only Memory,简称ROM)、随机存取存储器(Random Access Memory,简称RAM)、磁碟或者光盘等各种可以存储程序的介质。If the integrated unit is realized in the form of a software function unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or part of the contribution to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium , including multiple instructions to make a computer device (which may be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the method in each embodiment of the present application. The aforementioned storage media include: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM for short), random access memory (Random Access Memory, RAM for short), magnetic disk or optical disk, etc., which can store programs. medium.

以上参照附图说明了本申请实施例的优选实施例,并非因此局限本申请实施例的权利范围。本领域技术人员不脱离本申请实施例的范围和实质内所作的任何修改、等同替换和改进,均应在本申请实施例的权利范围之内。The preferred embodiments of the embodiments of the present application have been described above with reference to the accompanying drawings, which does not limit the scope of rights of the embodiments of the present application. Any modifications, equivalent replacements and improvements made by those skilled in the art without departing from the scope and essence of the embodiments of the present application shall fall within the scope of rights of the embodiments of the present application.

Claims (10)

1. A data processing method for an expression, the data processing method comprising:
acquiring an expression to be analyzed, and generating an abstract syntax tree by using the expression to be analyzed;
traversing the abstract syntax tree, and determining the data types of all nodes, wherein the data types comprise a first data type and a second data type, and the occupied bytes of the first data type are more than the occupied bytes of the second data type;
in response to a first node of the first data type being present, determining a node to be adjusted associated with the first node;
converting the data type of the node to be adjusted into the first data type;
and constructing an expression statement by using the updated abstract syntax tree.
2. The data processing method of claim 1, further comprising:
and responding to the absence of the first node of the first data type, converting the data types of all target nodes into the second data type, wherein each target node is generated by corresponding literal data in the expression to be analyzed.
3. The data processing method of claim 1, wherein the first node comprises at least one of a variable node generated from variable data in the expression to be parsed and a literal node generated from literal data in the expression to be parsed.
4. The data processing method of claim 1, wherein the determining the node to be adjusted associated with the first node in response to the first node having the first data type comprises:
in response to a first node of the first data type being present, sibling and ancestor nodes of the first node are determined to be nodes to be adjusted.
5. The data processing method of claim 1, wherein the determining the node to be adjusted associated with the first node comprises:
and sequentially determining ancestor nodes of the first node as nodes to be adjusted according to the depth of the abstract syntax tree until the next ancestor node is a special node, wherein the special node is characterized as a node with a fixed data type.
6. The data processing method of claim 1, wherein the determining the node to be adjusted associated with the first node comprises:
and under the condition that the parent node of the first node is not a special node, determining the brother node of the first node as a node to be adjusted, wherein the special node is characterized as a node with a fixed data type.
7. The data processing method according to claim 1, wherein after converting the data type of the node to be adjusted into the first data type, the method comprises:
traversing the updated abstract syntax tree, and converting the child nodes of the first data type into the first data type.
8. A data processing system for expressions, the system comprising:
the data generation module is used for acquiring an expression to be analyzed and generating an abstract syntax tree by using the expression to be analyzed;
the type determining module is used for traversing the abstract syntax tree and determining the data types of all nodes, wherein the data types comprise a first data type and a second data type, and the occupied bytes of the first data type are more than the occupied bytes of the second data type;
the association determining module is used for responding to a first node with the first data type, and determining a node to be adjusted associated with the first node;
the type conversion module is used for converting the data type of the node to be adjusted into the first data type;
and the statement construction module is used for constructing the expression statement by using the updated abstract syntax tree.
9. An electronic device, comprising a memory storing a computer program and a processor implementing the data processing method for an expression of any one of claims 1 to 7 when the computer program is executed by the processor.
10. A computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the data processing method for an expression of any one of claims 1 to 7.
CN202211693291.8A 2022-12-28 2022-12-28 Data processing method, system, electronic device and storage medium for expressions Pending CN115858019A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211693291.8A CN115858019A (en) 2022-12-28 2022-12-28 Data processing method, system, electronic device and storage medium for expressions

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211693291.8A CN115858019A (en) 2022-12-28 2022-12-28 Data processing method, system, electronic device and storage medium for expressions

Publications (1)

Publication Number Publication Date
CN115858019A true CN115858019A (en) 2023-03-28

Family

ID=85655339

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211693291.8A Pending CN115858019A (en) 2022-12-28 2022-12-28 Data processing method, system, electronic device and storage medium for expressions

Country Status (1)

Country Link
CN (1) CN115858019A (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113434625A (en) * 2021-08-27 2021-09-24 中汽研(天津)汽车信息咨询有限公司 Patent retrieval type coding method, device and storage medium
CN113504900A (en) * 2021-07-26 2021-10-15 中国工商银行股份有限公司 Programming language conversion method and device

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113504900A (en) * 2021-07-26 2021-10-15 中国工商银行股份有限公司 Programming language conversion method and device
CN113434625A (en) * 2021-08-27 2021-09-24 中汽研(天津)汽车信息咨询有限公司 Patent retrieval type coding method, device and storage medium

Similar Documents

Publication Publication Date Title
CN106407201B (en) A data processing method, apparatus and computer readable storage medium
US11146286B2 (en) Compression of JavaScript object notation data using structure information
CN106970820B (en) Code storage method and code storage device
US20110219357A1 (en) Compressing source code written in a scripting language
CN110941655B (en) A data format conversion method and device
CN110727417B (en) A data processing method and device
CN109902274A (en) A kind of method and system converting json character string to thrift binary stream
CN112926008B (en) Method, device, electronic equipment and storage medium for generating form page
CN112947900A (en) Web application development method and device, server and development terminal
CN114760369A (en) Protocol metadata extraction method, device, equipment and storage medium
CN114611500A (en) Expression processing method and device, electronic equipment and computer readable storage medium
CN116346777A (en) Dictionary tree domain name matching method, device, equipment and storage medium
CN112130860B (en) JSON object analysis method and device, electronic equipment and storage medium
CN119179520B (en) Conversion method, device and storage medium based on RISC-V architecture built-in function
CN112650502A (en) Batch processing task processing method and device, computer equipment and storage medium
CN107643906B (en) Data processing method and device
CN115576603A (en) Method and device for acquiring variable values in code segments
US7895347B2 (en) Compact encoding of arbitrary length binary objects
CN114489594B (en) A command parsing processing method and device
CN110764768B (en) Method and device for interconverting model object and JSON object
CN114385186A (en) Data type conversion method, device, equipment and storage medium
CN115858019A (en) Data processing method, system, electronic device and storage medium for expressions
CN105793842A (en) Conversion method and device between serialized messages
CN114995719A (en) List rendering method, device, equipment and storage medium
CN109754087B (en) Quantum program transformation method, device and electronic device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20230328