CN114089960A - Object processing method and device - Google Patents

Object processing method and device Download PDF

Info

Publication number
CN114089960A
CN114089960A CN202111182648.1A CN202111182648A CN114089960A CN 114089960 A CN114089960 A CN 114089960A CN 202111182648 A CN202111182648 A CN 202111182648A CN 114089960 A CN114089960 A CN 114089960A
Authority
CN
China
Prior art keywords
function
target
node
tree
tree node
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
CN202111182648.1A
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.)
Alibaba China Co Ltd
Alibaba Cloud Computing Ltd
Original Assignee
Alibaba China Co Ltd
Alibaba Cloud Computing 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 Alibaba China Co Ltd, Alibaba Cloud Computing Ltd filed Critical Alibaba China Co Ltd
Priority to CN202111182648.1A priority Critical patent/CN114089960A/en
Publication of CN114089960A publication Critical patent/CN114089960A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/20Software design
    • G06F8/24Object-oriented
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • G06F8/425Lexical analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • G06F8/427Parsing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/43Checking; Contextual analysis
    • G06F8/436Semantic checking

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

An embodiment of the present specification provides an object processing method and an object processing apparatus, where the object processing method includes: the method comprises the steps of obtaining an initial object of an initial language type to be compiled, conducting semantic analysis on the initial object, and generating a corresponding abstract syntax tree, wherein the abstract syntax tree comprises a plurality of tree nodes, the tree nodes correspond to a syntax structure in the initial object, traversing the tree nodes, configuring at least one target function for each tree node according to the syntax structure type corresponding to each tree node, determining a function label corresponding to the at least one target function, and compiling the initial object according to the syntax structure type corresponding to each tree node and the function label to generate a target object of a target language type.

Description

Object processing method and device
Technical Field
The embodiment of the specification relates to the technical field of computers, in particular to an object processing method.
Background
The data processing service is widely applied to the field of log processing of mass data. Due to popularization of mobile equipment and the Internet of things, the types and the number of logs are rapidly improved, and the requirements on functions and performance of data processing services are high. At present, data processing services provided by related mechanisms are widely applied, internal services and external customer requirements of various mechanisms are supported, and the number of deployed servers is large at present. How to realize a high-performance DSL engine with rich semantics is an urgent problem to be solved aiming at the log storage data processing service of a mechanism.
Disclosure of Invention
In view of this, the embodiments of the present specification provide an object processing method. One or more embodiments of the present specification also relate to an object processing apparatus, a computing device, a computer-readable storage medium, and a computer program, so as to solve the technical deficiencies of the prior art.
According to a first aspect of embodiments of the present specification, there is provided an object processing method including:
acquiring an initial object of an initial language type to be compiled, performing semantic analysis on the initial object, and generating a corresponding abstract syntax tree, wherein the abstract syntax tree comprises a plurality of tree nodes, and the tree nodes correspond to a syntax structure in the initial object;
traversing the plurality of tree nodes, configuring at least one objective function for each tree node according to the syntactic structure type corresponding to each tree node, and determining a function label corresponding to the at least one objective function;
and compiling the initial object according to the grammar structure type corresponding to each tree node and the function label to generate a target object of a target language type.
Optionally, the configuring, according to the syntactic structure type corresponding to each tree node, at least one objective function for each tree node, and determining a function label corresponding to the at least one objective function includes:
under the condition that a node function corresponding to a target tree node belongs to a target function type according to a syntactic structure type corresponding to the target tree node, acquiring a function name of the node function, wherein the target tree node is one of the plurality of tree nodes;
and under the condition that the node function is determined to be the first function according to the function name, configuring a first target function for the target tree node, and determining a function label corresponding to the first target function according to parameter attribute information of parameters contained in the node function.
Optionally, the first objective function is that the property of the partial parameter is a constant;
correspondingly, the determining a function label corresponding to the first objective function according to the parameter attribute information of the parameter included in the node function includes:
determining whether a first target parameter contained in the node function is a constant according to parameter attribute information of parameters contained in the node function;
if yes, determining that the function label corresponding to the first target function is yes;
and if not, determining that the function label corresponding to the first target function is not.
Optionally, the object processing method further includes:
under the condition that the node function is determined to be a second function according to the function name, configuring a first target function for the target tree node;
determining whether a second target parameter contained in the node function is a constant according to parameter attribute information of the parameter contained in the node function;
if yes, determining that the function label corresponding to the first target function is yes;
and if not, determining that the function label corresponding to the first target function is not.
Optionally, the object processing method further includes:
under the condition that the node function is determined to be a third function according to the function name, configuring a first target function for the target tree node;
determining whether the parameters contained in the node function are all constants according to the parameter attribute information of the parameters contained in the node function;
if yes, determining that the function label corresponding to the first target function is yes;
and if not, determining that the function label corresponding to the first target function is not.
Optionally, the configuring, according to the syntactic structure type corresponding to each tree node, at least one objective function for each tree node, and determining a function label corresponding to the at least one objective function includes:
under the condition that a node function corresponding to a target tree node belongs to a target function type according to a syntactic structure type corresponding to the target tree node, acquiring a function name of the node function, wherein the target tree node is one of the plurality of tree nodes;
under the condition that the node function is determined to be a fourth function according to the function name, configuring a second target function for the target tree node, and determining whether a function label corresponding to the second target function is negative;
and under the condition that the node function is determined to be a constant function according to the function name, configuring a second target function for the target tree node, and determining that a function label corresponding to the second target function is yes, wherein the function name of the node function, which is the second target function, is the constant function name.
Optionally, the configuring, according to the syntactic structure type corresponding to each tree node, at least one objective function for each tree node, and determining a function label corresponding to the at least one objective function includes:
under the condition that the parameter corresponding to the target tree node belongs to the variable parameter according to the grammar structure type corresponding to the target tree node, configuring a third target function for the target tree node, and determining whether a function label corresponding to the third target function is negative, wherein the parameter of the third target function is a constant.
Optionally, the configuring, according to attribute information of a node function corresponding to each tree node, at least one objective function for each tree node, and determining a function label corresponding to the at least one objective function, includes:
configuring a fourth objective function for a target tree node, wherein the target tree node is one of the plurality of tree nodes;
determining whether the parameters contained in the node function are all constants according to the parameter attribute information of the parameters contained in the node function of the target tree node;
if yes, determining that a function label corresponding to the fourth target function is yes;
and if not, determining that the function label corresponding to the fourth target function is negative.
Optionally, the compiling the initial object according to the syntactic structure type and the function label corresponding to each tree node to generate a target object of a target language type includes:
under the condition that a node function corresponding to a target tree node belongs to a target function type according to a syntactic structure type corresponding to the target tree node, acquiring a function name of the node function, wherein the target tree node is one of the plurality of tree nodes;
and compiling the initial object according to the function name and the function label of the first target function, the second target function and/or the third target function configured by the target tree node to generate a target object of a target language type.
Optionally, after traversing the plurality of tree nodes, before configuring at least one objective function for each tree node according to the syntax structure type corresponding to each tree node, the method further includes:
and under the condition that the node function corresponding to the target tree node belongs to the search function and the number of parameters contained in the node function is equal to 1 according to the syntactic structure type corresponding to the target tree node, replacing the function name of the node function by using a single field value function.
According to a second aspect of embodiments herein, there is provided an object processing apparatus comprising:
the system comprises an acquisition module, a semantic analysis module and a semantic analysis module, wherein the acquisition module is configured to acquire an initial object of an initial language type to be compiled, perform semantic analysis on the initial object and generate a corresponding abstract syntax tree, and the abstract syntax tree comprises a plurality of tree nodes which correspond to a syntax structure in the initial object;
the determining module is configured to traverse the plurality of tree nodes by Chinese, configure at least one target function for each tree node according to the syntactic structure type corresponding to each tree node, and determine a function label corresponding to the at least one target function;
and the compiling module is configured to compile the initial object according to the grammar structure type corresponding to each tree node and the function label to generate a target object of a target language type.
According to a third aspect of embodiments herein, there is provided a computing device comprising:
a memory and a processor;
the memory is to store computer-executable instructions, and the processor is to execute the computer-executable instructions to:
acquiring an initial object program of a field specific initial language type to be compiled, performing semantic analysis on the initial object of the field specific language program, and generating a corresponding abstract syntax tree, wherein the abstract syntax tree comprises a plurality of tree nodes, and the tree nodes correspond to a syntax structure in the initial object;
traversing the plurality of tree nodes, configuring parameters of at least one objective function for each tree node configuration according to the syntactic structure type corresponding to each tree node, and determining a function label corresponding to the at least one objective function;
compiling the initial object of the field specific language program according to the attribute information of the function corresponding to each tree node and the parameter configuration result function label to generate a target object program of a target type language target language type.
According to a fourth aspect of embodiments herein, there is provided a computer-readable storage medium storing computer-executable instructions that, when executed by a processor, implement the steps of any one of the object processing methods.
According to a fifth aspect of embodiments of the present specification, there is provided a computer program, wherein when the computer program is executed in a computer, the computer is caused to execute the steps of the above object processing method.
In an embodiment of the present specification, an initial object of an initial language type to be compiled is obtained, semantic analysis is performed on the initial object, and a corresponding abstract syntax tree is generated, where the abstract syntax tree includes a plurality of tree nodes, the tree nodes correspond to a syntax structure in the initial object, the tree nodes are traversed, at least one target function is configured for each tree node according to a syntax structure type corresponding to each tree node, a function tag corresponding to the at least one target function is determined, and the initial object is compiled according to the syntax structure type corresponding to each tree node and the function tag, so as to generate a target object of a target language type.
After the abstract syntax tree corresponding to the initial object is generated, corresponding target functions are configured for each tree node according to the syntax structure type corresponding to each tree node in the abstract syntax tree, and the function tag of each target function is determined, so that the initial object is compiled according to the syntax structure type and the function tag.
Drawings
Fig. 1 is a flowchart of an object processing method provided in an embodiment of the present specification;
fig. 2 is a flowchart illustrating a processing procedure of an object processing method according to an embodiment of the present disclosure;
fig. 3 is a schematic structural diagram of an object processing apparatus according to an embodiment of the present specification;
fig. 4 is a block diagram of a computing device according to an embodiment of the present disclosure.
Detailed Description
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present description. This description may be embodied in many different forms and should not be construed as limited to the embodiments set forth herein, as those skilled in the art will be able to make and use the present disclosure without departing from the spirit and scope of the present disclosure.
The terminology used in the description of the one or more embodiments is for the purpose of describing the particular embodiments only and is not intended to be limiting of the description of the one or more embodiments. As used in one or more embodiments of the present specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used in one or more embodiments of the present specification refers to and encompasses any and all possible combinations of one or more of the associated listed items.
It will be understood that, although the terms first, second, etc. may be used herein in one or more embodiments to describe various information, these information should not be limited by these terms. These terms are only used to distinguish one type of information from another. For example, a first can also be referred to as a second and, similarly, a second can also be referred to as a first without departing from the scope of one or more embodiments of the present description. The word "if" as used herein may be interpreted as "at … …" or "when … …" or "in response to a determination", depending on the context.
In the present specification, an object processing method is provided, and the present specification relates to an object processing apparatus, a computing device, and a computer-readable storage medium, which are described in detail one by one in the following embodiments.
The DSL (Domain-Specific Language) facing the data processing field does not need a user to write a more complex common program Language, has better user experience and is more widely applied. How to translate the DSL into a machine executable program is a problem to be faced by each DSL, and the traditional DSL translation usually adopts an intuitive translation mode, and the execution efficiency is low during the operation.
Based on this, embodiments of the present specification provide an object processing method, where different compiling schemes are respectively designed for different DSL functions, that is, code translation optimization algorithms are respectively implemented for various functions, so that not only is semantic correctness ensured, but also the execution efficiency of codes obtained by compiling during running is high, the throughput of data in unit time is increased, and the real-time processing requirement of mass data in the cloud computing field is effectively met.
Fig. 1 is a flowchart illustrating an object processing method according to an embodiment of the present specification, which specifically includes the following steps.
102, obtaining an initial object of an initial language type to be compiled, performing semantic analysis on the initial object, and generating a corresponding abstract syntax tree, wherein the abstract syntax tree comprises a plurality of tree nodes, and the tree nodes correspond to a syntax structure in the initial object.
Specifically, the initial language type may be a domain-specific language DSL, and the initial object may be a code to be compiled that is generated by encoding according to the domain-specific language.
In the embodiment of the present specification, the specific-domain language DSL needs to be compiled into other types of machine-executable programs, for example, SQL, and therefore, after an initial object of an initial language type to be compiled is obtained, syntax and semantic analysis needs to be performed on the initial object, so as to parse the initial object based on an analysis result to generate a corresponding abstract syntax tree, and target function configuration is performed on each tree node in the abstract syntax tree, so as to compile the initial object according to a configuration result.
Before the initial object is obtained, language design can be carried out, namely, a specific domain language oriented to the data processing service is designed. In practical application, two or more than two hundred functions supported by the specific domain language oriented to data processing can be divided into 5 classes, which are respectively an event processing function, a value processing function, an operator function, a resource pool function and a type correlation function, and the 5 classes of functions are utilized to construct an initial object of the specific domain language.
Where event handling functions denote functions that handle a current event, such functions all beginning with e _ and omitting default parameters that denote "current event", such as: a function that operates on the entire event, a function that operates on some attribute of the event, a field extraction function, an event checking function, and so on.
A value handling function means a function that handles a value, which may be any data type, and the first parameters of such a function are "handling values", such as: a json extraction function, a json conversion function, an ip information enrichment function, a regular expression function, and the like.
Operator functions represent functions related to general flow control, arithmetic calculations, logic, numerical comparisons, etc., and such functions all begin with op _ s.
The resource pool function represents that external resources which can be maintained by a user can be loaded to the data processing service, and meanwhile, loading interval time is provided to meet the real-time requirement of the user, and the loaded external resources comprise: databases, OSS stores, SLS stores, and the like.
The type-dependent function means a function closely related to the type of data, such as: type conversion functions, arithmetic functions, character string functions, date and time functions, list functions, dictionary functions, and the like.
In one or more embodiments, after the initial object is constructed based on the aforementioned 5-type function, a syntax analyzer (Parser) and a lexical analyzer (Lexer) may be used to convert the text of the initial object into an Abstract Syntax Tree (AST), so as to represent the syntax structure in the text of the initial object in a Tree form.
Wherein, the parser can be used to analyze and judge whether the composition of the input word sequence (e.g. sentence) is in accordance with the given grammar, and determine the structure of the sentence and the relationship between the grammar components of each hierarchy by constructing the grammar tree, i.e. determine which words in a sentence constitute a phrase and which words are the subject or object of the verb; and a lexical analyzer may be used to translate high-level instructions of a computer language into instructions that a physical machine or virtual machine can run. A single "word" may be separated from the input character stream for use by the parser.
In addition, the abstract syntax tree is a tree representation of the abstract syntax structure of the initial object, and the abstract syntax tree represents the syntax structure of the programming language in a tree form, wherein each tree node on the abstract syntax tree can be used for representing one syntax structure in the source code, and the syntax structure includes but is not limited to functions or parameters.
After the initial object is parsed and semantically analyzed to generate a corresponding abstract syntax tree, a target function may be configured for each tree node in the abstract syntax tree, so that the initial object is compiled based on a configuration result to generate a target object (a machine-executable program) of a target language type.
And 104, traversing the plurality of tree nodes, configuring at least one objective function for each tree node according to the syntactic structure type corresponding to each tree node, and determining a function label corresponding to the at least one objective function.
Specifically, the abstract syntax tree is a tree structure formed by a plurality of tree nodes, wherein a tree node is a data structure and can be used for representing functions, parameters and the like. Therefore, the syntax structure type includes, but is not limited to, function call, key value pair (parameter), or the like.
In the process of traversing the abstract syntax tree, when the current tree node is traversed and the syntax structure type corresponding to the current tree node is determined to be the function call, the function name of the current tree node is further determined, so as to configure the target function according to the function name as the current tree node, which can be specifically realized by the following modes:
under the condition that a node function corresponding to a target tree node belongs to a target function type according to a syntactic structure type corresponding to the target tree node, acquiring a function name of the node function, wherein the target tree node is one of the plurality of tree nodes;
and under the condition that the node function is determined to be the first function according to the function name, configuring a first target function for the target tree node, and determining a function label corresponding to the first target function according to parameter attribute information of parameters contained in the node function.
Further, the first objective function is that the property of a part of the parameters is a constant;
correspondingly, the determining a function label corresponding to the first objective function according to the parameter attribute information of the parameter included in the node function includes:
determining whether a first target parameter contained in the node function is a constant according to parameter attribute information of parameters contained in the node function;
if yes, determining that the function label corresponding to the first target function is yes;
and if not, determining that the function label corresponding to the first target function is not.
Specifically, the target tree node is a current tree node and is one of a plurality of tree nodes in the abstract syntax tree; the type of the target function is a function call; the first function is a type-related function, and may specifically be a string function "str _ format"; the first objective function is that the attribute of partial parameter is constant, specifically, part _ const _ attr; the function label is the result of the characterization function, specifically, yes or no; the parameter attribute information includes, but is not limited to, the number of parameters and the type of the parameters, that is, the parameters, is constant or variable.
Under the condition that the function of the target tree node is determined to be a function call, the function name of the node function of the target tree node can be obtained, and if the function name is 'str _ format', the parameter attribute information of the parameter contained in the node function is the parameter type of the first parameter (first target parameter) of the first function; if the first parameter is a constant, setting "whether the attribute of a part of the parameters is constant part _ const _ attr" as True (determining that the function label corresponding to the first objective function is yes), otherwise, setting "whether the attribute of a part of the parameters is constant part _ const _ attr" as False (determining that the function label corresponding to the first objective function is no).
In practical application, the abstract syntax tree is generated according to an initial object to be compiled, and the initial object may contain a plurality of different functions, in this case, the abstract syntax tree corresponding to the initial object can represent the different functions through the connection relationship between one or at least two tree nodes. Therefore, in the abstract syntax tree, if a tree node of a certain level is taken as a father node, a node in a connection relationship with the father node in the next level of the level where the father node is located is a child node of the father node, the father node can be a function, the child node of the father node can represent the parameter of the function, and a nested dependency relationship is formed between the father node and the child node. If the current tree node is a father node and the node function of the father node is a first function, a first objective function is configured for the father node, and under the condition that a function label corresponding to the first objective function of the father node needs to be determined, the child nodes under the father node can be traversed first, and the objective function of the father node is configured according to the feedback result of the child nodes.
If the parent node represents the function format and the actual function expression is format (name, age), then there are two child nodes under the parent node, which are respectively the child node 1 and the child node 2, where the child node 1 and the child node 2 both represent parameters, and the child node 1 and the child node 2 may both represent parameters by the form of key value pairs, for example, the Parameter representation form of the child node 1 is Parameter first name and the Parameter representation form of the child node 2 is Parameter second name.
Therefore, if a function label corresponding to the first objective function of the parent node needs to be determined, the parameter type of the first child node characterization parameter of the parent node needs to be determined, in this embodiment of the present specification, the parameter characterized by the child node 1 is name, and belongs to a constant, so that "whether the attribute of part of the parameter is constant part _ const _ attr" can be set to True for the parent node; if the parameter characterized by the child node 1 is a variable, the parent node may be set to "whether the attribute of the partial parameter is constant part _ const _ attr" as False.
Further, when the target tree node is a parent node and the parent node is configured with the first objective function, the syntax structure type corresponding to the child node of the parent node may be traversed, and the objective function is configured for the child node, specifically, under the condition that it is determined according to the syntax structure type corresponding to the target tree node that the parameter corresponding to the target tree node belongs to the variable parameter, a third objective function is configured for the target tree node, and it is determined that the function tag corresponding to the third objective function is no, where the third objective function is a constant parameter.
Specifically, under the condition that the target function is configured for the child node, the target tree node is the child node, and the child node can represent the parameter in the form of the key value pair, so that under the condition that the syntax structure type of the child node is determined to be the key value pair, whether the parameter corresponding to the child node belongs to the variable parameter or the constant parameter can be determined according to the key value in the key value pair.
For example, if the Parameter representation form of the child node 1 is Parameter first ═ x, where Parameter first is a keyword, and x is a key value, since the key value x belongs to a variable Parameter, a third objective function "Parameter is a constant" may be configured for the target tree node, and it is determined that a function tag corresponding to the third objective function is no; and determining that the function label corresponding to the third objective function is yes under the condition that the key value belongs to the constant parameter.
After configuring the target function for the child node and determining the function label corresponding to the target function, the function label of the child node may be returned to the parent node at the previous stage, and the parent node may set the function label of the first target function to yes when receiving the function label returned by the first child node and determining that the function label of the third target function of the child node is yes.
Further, when it is determined that the syntax structure type corresponding to the current tree node is a function call, the function name of the current tree node is further determined, and a target function is configured for the current tree node according to the function name, which can be specifically realized by the following method:
under the condition that the node function is determined to be a second function according to the function name, configuring a first target function for the target tree node;
determining whether a second target parameter contained in the node function is a constant according to parameter attribute information of the parameter contained in the node function;
if yes, determining that the function label corresponding to the first target function is yes;
and if not, determining that the function label corresponding to the first target function is not.
Specifically, the second function may be a value handling function, and may be "json _ select/regex/regex _ select/regex _ findall/\ regex _ match/regex _ place/regex _ split", and the second target parameter is a parameter type of another parameter except for a first parameter included in the second function.
And determining that the node function is a second function according to the function name, and determining that other parameters in the parameters contained in the second function are all constant except the first parameter, setting whether the attribute of part of the parameters is constant part _ const _ attr "as True, and otherwise, setting whether the attribute of part of the parameters is constant part _ const _ attr" as False.
Similarly, as described above, if the current tree node is a parent node and the node function of the parent node is a second function, a first objective function is configured for the parent node, and under the condition that a function label corresponding to the first objective function of the parent node needs to be determined, a child node under the parent node may be traversed first to configure a third objective function for the child node, then a function label of the third objective function is determined, and the function label is returned to the parent node at the upper stage, and when it is determined that all the function labels of the third objective functions of other child nodes under the parent node except for the first child node are all yes, it may be set "whether the attribute of a part of parameters is constant part _ const _ attr" to be True, "otherwise, it is set whether the attribute of a part of parameters is constant part _ const _ attr" to be False.
Furthermore, when it is determined that the syntax structure type corresponding to the current tree node is a function call, the function name of the current tree node is further determined, and a target function is configured according to the function name as the current tree node, which can be specifically realized by the following method:
under the condition that the node function is determined to be a third function according to the function name, configuring a first target function for the target tree node;
determining whether the parameters contained in the node function are all constants according to the parameter attribute information of the parameters contained in the node function;
if yes, determining that the function label corresponding to the first target function is yes;
and if not, determining that the function label corresponding to the first target function is not.
Specifically, the third function may be an event processing function, and specifically may be "e _ set/dt _ fromlmestamp" or the like.
Similarly, if the current tree node is a parent node, the node function of the parent node is a third function, and after the parent node is configured with the first objective function, under the condition that the function label of the first objective function needs to be determined, the child node under the parent node may be traversed first, the third objective function is configured for the child node, then the function label of the third objective function is determined, and the function label is returned to the parent node at the upper stage, and when it is determined that the function labels of the third objective functions of the child nodes under the parent node are all yes, it may be set "whether the attribute of a part of the parameters is constant part _ const _ attr" as True, "or" whether the attribute of a part of the parameters is constant part _ const _ attr "as False.
Through the above process, it can be correctly set for the target tree node whether the attribute of the partial parameter is the constant part _ const _ attr.
The setting mode of the first objective function of other tree nodes in the abstract syntax tree is similar to that of the target tree node, and is not repeated here.
In addition to configuring the first objective function for the target tree node in the foregoing manner, a second objective function may also be configured for the target tree node, which may specifically be implemented in the following manner:
under the condition that a node function corresponding to a target tree node belongs to a target function type according to a syntactic structure type corresponding to the target tree node, acquiring a function name of the node function, wherein the target tree node is one of the plurality of tree nodes;
under the condition that the node function is determined to be a fourth function according to the function name, configuring a second target function for the target tree node, and determining whether a function label corresponding to the second target function is negative;
and under the condition that the node function is determined to be a constant function according to the function name, configuring a second target function for the target tree node, and determining that a function label corresponding to the second target function is yes, wherein the function name of the node function, which is the second target function, is the constant function name.
Specifically, the target tree node is a current tree node, and the type of the target function is a function call; the fourth function includes but is not limited to an event handling function, a function related to the current time and a resource pool function requiring a timing update; the second objective function, namely, the function name of the node function is called a constant function name, specifically, the const _ func _ name.
In the embodiment of the present specification, in the case that it is determined that the syntax structure type corresponding to the target tree node or the node function corresponding to the target tree node belongs to the type of function call, acquiring a function name of the node function, and under the condition that the node function is determined to be a fourth function according to the function name, since the event processing function, the function related to the current time and the resource pool function needing to be updated regularly in the fourth function are all not constant functions, therefore, the "function name of the node function is set to constant function name const _ func _ name" as False, otherwise the "function name of the node function is set to constant function name const _ func _ name" as True, namely, under the condition that the node function is determined to be a constant function according to the function name, a second objective function is configured for the target tree node, and the function label corresponding to the second objective function is determined to be yes.
Alternatively, there is a partial function, which has no parameter itself, or whose parameter is constant, but whose function value belongs to a variable rather than a constant, for example, a certain function is: determining the current time, wherein the time is constantly changing, and the function value of the function is consistently in a changing state along with the change of the time, or the function value of the function may also have a difference due to the difference of the regions, in this case, a second objective function may be configured for the function, and it is determined whether the function label of the second objective function is negative.
In addition to configuring the first objective function, the second objective function and/or the third objective function for the target tree node in the foregoing manner, a fourth objective function may also be configured for the target tree node, which may specifically be implemented in the following manner:
configuring a fourth objective function for a target tree node, wherein the target tree node is one of the plurality of tree nodes;
determining whether the parameters contained in the node function are all constants according to the parameter attribute information of the parameters contained in the node function of the target tree node;
if yes, determining that a function label corresponding to the fourth target function is yes;
and if not, determining that the function label corresponding to the fourth target function is negative.
Specifically, the fourth objective function is: the parameters included in the fourth function are all constants, specifically "const _ attr"; under the condition that the syntactic structure type of the target tree node does not belong to the function call or the parameter type, a fourth target function can be configured for the target tree node, and a function label of the fourth target function is determined. The process of determining the function label is similar to the process of determining the function labels of the first target function and the second target function, the target tree node can be used as a father node, a child node of the father node is determined, then a third target function is configured for the child node under the condition that the language structure type of the child node is a parameter type, the function label of the third target function is determined, then the function label is returned to the father node, and under the condition that the returned function labels are determined to be yes, whether the parameters contained in the node function of the target tree node are all constants or not can be determined; thus, the function label corresponding to the fourth objective function may be determined to be yes; otherwise, determining that the function label corresponding to the fourth target function is negative.
For example, the node function of a certain target tree node is: determining the length of the set {1,2,3,2,2,2,5}, in which case, the syntax structure type of the tree nodes in the abstract syntax tree is a list, that is, the parameters in the set are stored in the form of a list, so after configuring a fourth objective function for the target tree node, the list of the target tree node needs to be traversed, and it is determined whether the parameters in the list are constants (a third objective function is configured for each parameter in the list, and a function tag of the third objective function is determined), if yes, setting "the parameters included in the fourth function are constants const _ attr" to True, and returning to True, otherwise, setting "the parameters included in the fourth function are constants const _ attr" to False, and returning to False.
In specific implementation, after traversing the plurality of tree nodes, before configuring at least one objective function for each tree node according to the syntax structure type corresponding to each tree node, the method further includes:
and under the condition that the node function corresponding to the target tree node belongs to the search function and the number of parameters contained in the node function is equal to 1 according to the syntactic structure type corresponding to the target tree node, replacing the function name of the node function by using a single field value function.
Specifically, before configuring the target function for each tree node, preprocessing may be performed on each tree node, that is, traversing the abstract syntax tree, to determine whether the node function corresponding to each tree node is a lookup function, that is, a vlookup function, and if it is determined that the node function of the current tree node is a lookup function and there is only one function parameter, replacing the function name of the current tree node with a single field value function, that is, an "e _ single _ field _ value" function.
The search function realizes a data search function, and when only one parameter exists, the parameter list does not need to be traversed circularly, thereby being beneficial to improving the processing performance.
Traversing the abstract syntax tree in the manner, configuring a function for each tree node, wherein the function name of the function of the node function is a constant function name const _ func _ name, the parameters contained in the fourth function are all constant const _ attr, and/or the attribute of partial parameter is constant part _ const _ attr, and compiling the initial object according to the configuration result to generate the target object of the target language type.
And 106, compiling the initial object according to the syntactic structure type corresponding to each tree node and the function label to generate a target object of a target language type.
In specific implementation, the initial object is compiled according to the syntax structure type corresponding to each tree node and the function tag, so as to generate a target object of a target language type, which can be specifically implemented in the following manner:
under the condition that a node function corresponding to a target tree node belongs to a target function type according to a syntactic structure type corresponding to the target tree node, acquiring a function name of the node function, wherein the target tree node is one of the plurality of tree nodes;
and compiling the initial object according to the function name and the function label of the first target function, the second target function and/or the third target function configured by the target tree node to generate a target object of a target language type.
Specifically, after the target function is configured for the tree nodes in the abstract syntax tree, the initial object can still be compiled in a mode of traversing the abstract syntax tree according to the function tags corresponding to the target functions of the tree nodes, and a runtime code, that is, a program executable by the machine, is generated.
In practical applications, if the function name of the node function of the current tree node is "op _ and/op _ or", to implement a logical operation short circuit, the two functions are translated into if operations.
On this basis, if the function label of the fourth target function of the current tree node, namely the fourth function, is True with the parameters of constant const _ attr ', or the function label of the first target function, namely the partial parameters of the fourth target function, is True with the attribute of constant part _ const _ attr', common mode initialization extraction is performed on the functions of op _ and/op _ or and the like, and the common mode initialization extraction is only performed once in the mode matching process.
Because repeated operation exists in part of functions in the actual program execution process, taking the matching function of the regular expression as an example, the processing process of the function comprises two parts, wherein one part is a data structure for compiling the matching function of the regular expression into an automaton, and the other part is used for carrying out data matching according to the compiling result; the first part is that the compiling of the expression into the automaton is equivalent to a repetitive operation, and the compiling process can be independently extracted as a common operation under the condition that part or all parameters in the expression are constants, so that the previous compiling process is required to be carried out for multiple times and is converted into the compiling process which is only required to be carried out once, the time required by the compiling is favorably shortened, and the execution efficiency of the program is improved.
Alternatively, for resource pool functions with timed refresh function res _ rds _ mysql, and res _ log _ logstore _ pull/res _ oss _ file, etc., a result pointer is returned, and then the resource pool is updated in real time through a read-write lock.
Because the resource pool needs to pull data from the database, and in the process, if the amount of the data pulled each time is large, a large amount of time is consumed, so the resource pool can be used as a common operation, the data pulling is only needed to be performed once in the whole program execution process, then the result pointer is returned, and then the resource pool is updated in real time according to the data pulling result through the read-write lock.
Or, for the ultrahigh frequency function e _ set, the number and constant attributes of the parameters are respectively processed, if all key value pairs of the function are constant, the function is converted into the KeyValueConstSetTransformer, if all keys of the function are constant, the function is converted into the KeyConstSetTransformer, and if the keys of the function are constant, the function is converted into the SetTransformer, otherwise, the function is converted into the SetTransformer.
In addition, if the node function of the current tree node is an extended class function, for example: e _ split, e _ coutput, such functions need to be converted to iterator loop accesses.
Based on this, if the function name of the second objective function "node function" of the current tree node is the constant function name const _ func _ name "and the function labels of the fourth objective function" fourth function "whose parameters are all the constants const _ attr" are True, it indicates that the execution result of the node function of the current tree node is a constant, and the node function can be extracted as the global shared variable.
If the node function of the current tree node is "dt _ now/dt _ today" and there is no parameter, time zone processing is not needed, and the function is converted into "DtNowExpression/DtTodayExpression".
Meanwhile, all event handling functions need to add a parameter event indicating the current event.
The embodiment of the specification respectively performs optimization processing aiming at different function types, extracts the public part of data processing which only needs to be executed once as much as possible, and improves the event processing speed. Different compiling schemes are respectively designed aiming at different functions of the initial language type, so that the accuracy of the target object semantics of the target language type generated by compiling is guaranteed.
After the target object of the target language type is generated by compiling, the target object can be issued and operated, and specifically, the result of code translation and input and output can be combined and packaged into an application program which can be operated. And the program sends the running log to the message queue at regular time, then the detection program reads the monitoring log in the message queue, and finally a monitoring interface which is convenient for a user to use is generated.
In an embodiment of the present specification, an initial object of an initial language type to be compiled is obtained, semantic analysis is performed on the initial object, and a corresponding abstract syntax tree is generated, where the abstract syntax tree includes a plurality of tree nodes, the tree nodes correspond to a syntax structure in the initial object, the tree nodes are traversed, at least one target function is configured for each tree node according to a syntax structure type corresponding to each tree node, a function tag corresponding to the at least one target function is determined, and the initial object is compiled according to the syntax structure type corresponding to each tree node and the function tag, so as to generate a target object of a target language type.
After an abstract syntax tree corresponding to an initial object is generated, corresponding target functions are configured for each tree node according to a syntax structure type corresponding to each tree node in the abstract syntax tree, a function label of each target function is determined, the initial object is compiled according to the syntax structure type and the function label, different compiling schemes are designed for different functions of the initial language types, accordingly, the accuracy of the semantics of the target object of the target language type generated by compiling is guaranteed, and the execution efficiency of the compiled runtime code is high.
In addition, the domain language oriented to data processing supports two or more than two hundred functions, has richer semantics, can meet the requirements of wide data processing application, and various functions respectively realize a code translation optimization algorithm, so that not only is the correctness of the semantics ensured, but also the execution efficiency of the compiled running code is higher, and the data volume processed in unit time is favorably improved, thereby improving the throughput rate of data processing services and effectively solving the real-time processing requirements of mass data in the field of cloud computing.
The following description will be given, with reference to fig. 2, taking as an example an application of the object processing method provided in the present specification to compiling a domain-specific language. Fig. 2 shows a processing flow chart of an object processing method provided in an embodiment of the present specification, and specifically includes the following steps.
Step 202, designing a specific domain language oriented to data processing service.
Specifically, the DSL with rich functions is formed by 5 types of basic functions (event processing function, value processing function, operator function, resource pool function, and type correlation function), which are basic constituent units of a specific domain language.
Step 204, parsing the language of the specific field into an abstract syntax tree through lexical grammar.
Step 206, traversing the abstract syntax tree, and determining whether the current tree node is a "v" function and only one parameter is provided.
If yes, go to step 208; if not, go to step 210.
In step 208, the function name "v" is replaced with "single field value".
Specifically, the function name "v" is replaced with "e _ single _ field _ value".
After step 208 is performed, step 210 is continued.
Step 210, traversing the abstract syntax tree, configuring at least one objective function for each tree node according to the syntax structure type corresponding to each tree node, and determining a function label corresponding to the at least one objective function.
Specifically, if the function name of the current node is "str _ format" and the first parameter is a constant character string, "it sets" whether all partial parameters are constant part _ const _ attr "to True, otherwise, it sets" whether all partial parameters are constant part _ const _ attr "to False.
If the function name is "json _ select \ regex \ regex _ select \ regex _ findall \ regex _ match", or "regex _ replace \ regex _ split", and the second parameter is a constant string, and the following other parameters are also constants, then setting "whether part of the parameters are constant part _ const _ attr" as True, or setting "whether part of the parameters are constant part _ const _ attr" as False.
If the function name is "e _ set \ dt _ from _ time _ set" and all the parameters are constant, setting "whether all partial parameters are constant part _ const _ attr" as True, otherwise setting "whether all partial parameters are constant part _ const _ attr" as False.
If the function of the current node is an event processing function, a function related to the current time and a resource pool function needing to be updated regularly, setting 'whether the function is the constant function name const _ func _ name' as False, and otherwise, setting 'whether the function is the constant function name const _ func _ name' as True.
If the parameters of the function are not all constant, False is returned, otherwise "whether it is a constant function name const _ func _ name" is returned as the result.
And if the parameter of the current node is the variable name, returning False, otherwise, returning True.
And traversing the parameters of the current node, and if the parameter type is a list, traversing the list elements. And if the traversal results of the parameters are True, setting whether all the parameters are constant const _ attr as True and returning to True, otherwise, setting whether all the parameters are constant const _ attr as False and returning to False.
Step 212, traverse the abstract syntax tree, and determine whether the function name of the current node is op _ and or op _ or.
If yes, go to step 214; if not, go to step 216.
At step 214, the op _ and or op _ or function is translated as an if operation.
In step 216, it is determined whether the function label of the first objective function is yes.
Specifically, whether all the partial parameters are constant part _ const _ attr is judged to be True or not;
if yes, go to step 218; if not, go to step 220.
At step 218, common mode initialization extraction is performed for different function types respectively.
Step 220, determine whether the function label of the third objective function is yes.
Specifically, whether the parameters are all constant const _ attr is judged to be True or not; if yes, go to step 218; if not, go to step 222.
In step 222, it is determined whether the function of the current node is an extended class function.
If yes, go to step 224; if not, go to step 226.
Step 224, convert the extended class function to an iterator loop access.
Step 226, determine whether the function labels of the second objective function and the third objective function are both yes.
Specifically, it is determined whether "constant function name const _ func _ name" and "constant const _ attr" are both True, if yes, step 228 is executed; if not, go to step 230.
Step 228, extract as global shared variable.
Specifically, when the function labels of the second objective function and the third objective function are both yes, it indicates that the result of the function is a constant, and the result can be extracted as the global shared variable.
In step 230, it is determined whether the time function is a time function and no parameter exists.
Specifically, whether the function of the current node is dt _ now or dt _ today is judged, and no parameter exists;
if yes, go to step 232; if not, the processing is not required.
Step 232, the time function is converted into a function expression of the target type.
Specifically, Dt _ Now or Dt _ Today is converted to "Dt Now Expression \ Dt _ Today Expression".
At step 234, a parameter event representing the current event is added to the event handling function, and runtime code is generated.
After steps 214, 218, 224, 228, and 232 are completed, step 234 may be executed.
The embodiment of the specification designs a domain language taking functions as basic units, has rich semantics, supports multi-scene application requirements, performs optimization processing on different types of functions respectively, effectively extracts a public calculation part needing repeated execution, translates to generate a better runtime code, accelerates data processing speed, shortens processing delay, reduces the number of servers, saves operation cost, and further improves the overall competitiveness of products.
Corresponding to the above method embodiment, the present specification further provides an embodiment of an object processing apparatus, and fig. 3 shows a schematic structural diagram of an object processing apparatus provided in an embodiment of the present specification. As shown in fig. 3, the apparatus includes:
an obtaining module 302, configured to obtain an initial object of an initial language type to be compiled, perform semantic analysis on the initial object, and generate a corresponding abstract syntax tree, where the abstract syntax tree includes a plurality of tree nodes, and the tree nodes correspond to a syntax structure in the initial object;
a determining module 304, configured to traverse the plurality of tree nodes with chinese, configure at least one objective function for each tree node according to the syntactic structure type corresponding to each tree node, and determine a function tag corresponding to the at least one objective function;
and the compiling module 306 is configured to compile the initial object according to the syntax structure type and the function tag corresponding to each tree node, and generate a target object of a target language type.
Optionally, the determining module 304 includes:
the obtaining submodule is configured to obtain a function name of a node function under the condition that the node function corresponding to a target tree node belongs to a target function type according to a grammar structure type corresponding to the target tree node, wherein the target tree node is one of the plurality of tree nodes;
the determining submodule is configured to configure a first objective function for the target tree node under the condition that the node function is determined to be the first function according to the function name, and determine a function label corresponding to the first objective function according to parameter attribute information of parameters contained in the node function.
Optionally, the first objective function is that the property of the partial parameter is a constant;
accordingly, the determining sub-module is further configured to:
determining whether a first target parameter contained in the node function is a constant according to parameter attribute information of parameters contained in the node function;
if yes, determining that the function label corresponding to the first target function is yes;
and if not, determining that the function label corresponding to the first target function is not.
Optionally, the determining module 304 further includes a first configuration submodule configured to:
under the condition that the node function is determined to be a second function according to the function name, configuring a first target function for the target tree node;
determining whether a second target parameter contained in the node function is a constant according to parameter attribute information of the parameter contained in the node function;
if yes, determining that the function label corresponding to the first target function is yes;
and if not, determining that the function label corresponding to the first target function is not.
Optionally, the determining module 304 further includes a second configuration submodule configured to:
under the condition that the node function is determined to be a third function according to the function name, configuring a first target function for the target tree node;
determining whether the parameters contained in the node function are all constants according to the parameter attribute information of the parameters contained in the node function;
if yes, determining that the function label corresponding to the first target function is yes;
and if not, determining that the function label corresponding to the first target function is not.
Optionally, the determining module 304 is further configured to:
under the condition that a node function corresponding to a target tree node belongs to a target function type according to a syntactic structure type corresponding to the target tree node, acquiring a function name of the node function, wherein the target tree node is one of the plurality of tree nodes;
under the condition that the node function is determined to be a fourth function according to the function name, configuring a second target function for the target tree node, and determining whether a function label corresponding to the second target function is negative;
and under the condition that the node function is determined to be a constant function according to the function name, configuring a second target function for the target tree node, and determining that a function label corresponding to the second target function is yes, wherein the function name of the node function, which is the second target function, is the constant function name.
Optionally, the determining module 304 is further configured to:
under the condition that the parameter corresponding to the target tree node belongs to the variable parameter according to the grammar structure type corresponding to the target tree node, configuring a third target function for the target tree node, and determining whether a function label corresponding to the third target function is negative, wherein the parameter of the third target function is a constant.
Optionally, the determining module 304 is further configured to:
configuring a fourth objective function for a target tree node, wherein the target tree node is one of the plurality of tree nodes;
determining whether the parameters contained in the node function are all constants according to the parameter attribute information of the parameters contained in the node function of the target tree node;
if yes, determining that a function label corresponding to the fourth target function is yes;
and if not, determining that the function label corresponding to the fourth target function is negative.
Optionally, the compiling module 306 is further configured to:
under the condition that a node function corresponding to a target tree node belongs to a target function type according to a syntactic structure type corresponding to the target tree node, acquiring a function name of the node function, wherein the target tree node is one of the plurality of tree nodes;
and compiling the initial object according to the function name and the function label of the first target function, the second target function and/or the third target function configured by the target tree node to generate a target object of a target language type.
Optionally, the object processing apparatus further includes:
the replacing module is configured to replace the function name of the node function by using a single field value function under the condition that the node function corresponding to the target tree node belongs to the searching function and the number of parameters contained in the node function is equal to 1 according to the grammar structure type corresponding to the target tree node.
The above is a schematic configuration of an object processing apparatus of the present embodiment. It should be noted that the technical solution of the object processing apparatus and the technical solution of the object processing method belong to the same concept, and for details that are not described in detail in the technical solution of the object processing apparatus, reference may be made to the description of the technical solution of the object processing method.
FIG. 4 illustrates a block diagram of a computing device 400 provided in accordance with one embodiment of the present description. The components of the computing device 400 include, but are not limited to, a memory 410 and a processor 420. Processor 420 is coupled to memory 410 via bus 430 and database 450 is used to store data.
Computing device 400 also includes access device 440, access device 440 enabling computing device 400 to communicate via one or more networks 460. Examples of such networks include the Public Switched Telephone Network (PSTN), a Local Area Network (LAN), a Wide Area Network (WAN), a Personal Area Network (PAN), or a combination of communication networks such as the internet. The access device 440 may include one or more of any type of network interface (e.g., a Network Interface Card (NIC)) whether wired or wireless, such as an IEEE802.11 Wireless Local Area Network (WLAN) wireless interface, a worldwide interoperability for microwave access (Wi-MAX) interface, an ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a bluetooth interface, a Near Field Communication (NFC) interface, and so forth.
In one embodiment of the present description, the above-described components of computing device 400, as well as other components not shown in FIG. 4, may also be connected to each other, such as by a bus. It should be understood that the block diagram of the computing device architecture shown in FIG. 4 is for purposes of example only and is not limiting as to the scope of the present description. Those skilled in the art may add or replace other components as desired.
Computing device 400 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., tablet, personal digital assistant, laptop, notebook, netbook, etc.), mobile phone (e.g., smartphone), wearable computing device (e.g., smartwatch, smartglasses, etc.), or other type of mobile device, or a stationary computing device such as a desktop computer or PC. Computing device 400 may also be a mobile or stationary server.
Wherein the processor 420 is configured to execute computer-executable instructions that, when executed by the processor, implement the steps of the object processing method described above.
The above is an illustrative scheme of a computing device of the present embodiment. It should be noted that the technical solution of the computing device and the technical solution of the object processing method belong to the same concept, and details that are not described in detail in the technical solution of the computing device can be referred to the description of the technical solution of the object processing method.
An embodiment of the present specification also provides a computer-readable storage medium storing computer-executable instructions, which when executed by a processor, implement the steps of the above-mentioned object processing method.
The above is an illustrative scheme of a computer-readable storage medium of the present embodiment. It should be noted that the technical solution of the storage medium belongs to the same concept as the technical solution of the object processing method, and details that are not described in detail in the technical solution of the storage medium can be referred to the description of the technical solution of the object processing method.
An embodiment of the present specification further provides a computer program, wherein when the computer program is executed in a computer, the computer is caused to execute the steps of the object processing method.
The above is an illustrative scheme of a computer program of the present embodiment. It should be noted that the technical solution of the computer program is the same concept as the technical solution of the object processing method, and details that are not described in detail in the technical solution of the computer program can be referred to the description of the technical solution of the object processing method.
The foregoing description has been directed to specific embodiments of this disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
The computer instructions comprise computer program code which may be in the form of source code, object code, an executable file or some intermediate form, or the like. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.
It should be noted that, for the sake of simplicity, the foregoing method embodiments are described as a series of acts, but those skilled in the art should understand that the present embodiment is not limited by the described acts, because some steps may be performed in other sequences or simultaneously according to the present embodiment. Further, those skilled in the art should also appreciate that the embodiments described in this specification are preferred embodiments and that acts and modules referred to are not necessarily required for an embodiment of the specification.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
The preferred embodiments of the present specification disclosed above are intended only to aid in the description of the specification. Alternative embodiments are not exhaustive and do not limit the invention to the precise embodiments described. Obviously, many modifications and variations are possible in light of the above teaching. The embodiments were chosen and described in order to best explain the principles of the embodiments and the practical application, to thereby enable others skilled in the art to best understand and utilize the embodiments. The specification is limited only by the claims and their full scope and equivalents.

Claims (14)

1. An object processing method, comprising:
acquiring an initial object of an initial language type to be compiled, performing semantic analysis on the initial object, and generating a corresponding abstract syntax tree, wherein the abstract syntax tree comprises a plurality of tree nodes, and the tree nodes correspond to a syntax structure in the initial object;
traversing the plurality of tree nodes, configuring at least one objective function for each tree node according to the syntactic structure type corresponding to each tree node, and determining a function label corresponding to the at least one objective function;
and compiling the initial object according to the grammar structure type corresponding to each tree node and the function label to generate a target object of a target language type.
2. The object processing method according to claim 1, wherein the configuring, according to the syntactic structure type corresponding to each tree node, at least one objective function for each tree node, and determining a function label corresponding to the at least one objective function, comprises:
under the condition that a node function corresponding to a target tree node belongs to a target function type according to a syntactic structure type corresponding to the target tree node, acquiring a function name of the node function, wherein the target tree node is one of the plurality of tree nodes;
and under the condition that the node function is determined to be the first function according to the function name, configuring a first target function for the target tree node, and determining a function label corresponding to the first target function according to parameter attribute information of parameters contained in the node function.
3. The object processing method according to claim 2, wherein the first objective function is that an attribute of a partial parameter is a constant;
correspondingly, the determining a function label corresponding to the first objective function according to the parameter attribute information of the parameter included in the node function includes:
determining whether a first target parameter contained in the node function is a constant according to parameter attribute information of parameters contained in the node function;
if yes, determining that the function label corresponding to the first target function is yes;
and if not, determining that the function label corresponding to the first target function is not.
4. The object processing method according to claim 2, further comprising:
under the condition that the node function is determined to be a second function according to the function name, configuring a first target function for the target tree node;
determining whether a second target parameter contained in the node function is a constant according to parameter attribute information of the parameter contained in the node function;
if yes, determining that the function label corresponding to the first target function is yes;
and if not, determining that the function label corresponding to the first target function is not.
5. The object processing method according to claim 2 or 4, further comprising:
under the condition that the node function is determined to be a third function according to the function name, configuring a first target function for the target tree node;
determining whether the parameters contained in the node function are all constants according to the parameter attribute information of the parameters contained in the node function;
if yes, determining that the function label corresponding to the first target function is yes;
and if not, determining that the function label corresponding to the first target function is not.
6. The object processing method according to claim 1, wherein the configuring, according to the syntactic structure type corresponding to each tree node, at least one objective function for each tree node, and determining a function label corresponding to the at least one objective function, comprises:
under the condition that a node function corresponding to a target tree node belongs to a target function type according to a syntactic structure type corresponding to the target tree node, acquiring a function name of the node function, wherein the target tree node is one of the plurality of tree nodes;
under the condition that the node function is determined to be a fourth function according to the function name, configuring a second target function for the target tree node, and determining whether a function label corresponding to the second target function is negative;
and under the condition that the node function is determined to be a constant function according to the function name, configuring a second target function for the target tree node, and determining that a function label corresponding to the second target function is yes, wherein the function name of the node function, which is the second target function, is the constant function name.
7. The object processing method according to claim 1, wherein the configuring, according to the syntactic structure type corresponding to each tree node, at least one objective function for each tree node, and determining a function label corresponding to the at least one objective function, comprises:
under the condition that the parameter corresponding to the target tree node belongs to the variable parameter according to the grammar structure type corresponding to the target tree node, configuring a third target function for the target tree node, and determining whether a function label corresponding to the third target function is negative, wherein the parameter of the third target function is a constant.
8. The object processing method according to claim 1, wherein the configuring, according to attribute information of a node function corresponding to each tree node, at least one objective function for each tree node and determining a function label corresponding to the at least one objective function, comprises:
configuring a fourth objective function for a target tree node, wherein the target tree node is one of the plurality of tree nodes;
determining whether the parameters contained in the node function are all constants according to the parameter attribute information of the parameters contained in the node function of the target tree node;
if yes, determining that a function label corresponding to the fourth target function is yes;
and if not, determining that the function label corresponding to the fourth target function is negative.
9. The object processing method according to claim 1, wherein the compiling the initial object according to the syntactic structure type and the function tag corresponding to each tree node to generate a target object of a target language type comprises:
under the condition that a node function corresponding to a target tree node belongs to a target function type according to a syntactic structure type corresponding to the target tree node, acquiring a function name of the node function, wherein the target tree node is one of the plurality of tree nodes;
and compiling the initial object according to the function name and the function label of the first target function, the second target function and/or the third target function configured by the target tree node to generate a target object of a target language type.
10. The object processing method according to claim 1, wherein after traversing the plurality of tree nodes, before configuring at least one objective function for each tree node according to the syntax structure type corresponding to the each tree node, the method further comprises:
and under the condition that the node function corresponding to the target tree node belongs to the search function and the number of parameters contained in the node function is equal to 1 according to the syntactic structure type corresponding to the target tree node, replacing the function name of the node function by using a single field value function.
11. An object processing apparatus comprising:
the system comprises an acquisition module, a semantic analysis module and a semantic analysis module, wherein the acquisition module is configured to acquire an initial object of an initial language type to be compiled, perform semantic analysis on the initial object and generate a corresponding abstract syntax tree, and the abstract syntax tree comprises a plurality of tree nodes which correspond to a syntax structure in the initial object;
the determining module is configured to traverse the plurality of tree nodes by Chinese, configure at least one target function for each tree node according to the syntactic structure type corresponding to each tree node, and determine a function label corresponding to the at least one target function;
and the compiling module is configured to compile the initial object according to the grammar structure type corresponding to each tree node and the function label to generate a target object of a target language type.
12. A computing device, comprising:
a memory and a processor;
the memory is for storing computer-executable instructions, and the processor is for executing the computer-executable instructions, which when executed by the processor, implement the steps of the object processing method of any one of claims 1 to 10.
13. A computer-readable storage medium storing computer-executable instructions which, when executed by a processor, implement the steps of the object processing method of any one of claims 1 to 10.
14. A computer program which, when executed on a computer, causes the computer to perform the steps of the object processing method of any one of claims 1 to 10.
CN202111182648.1A 2021-10-11 2021-10-11 Object processing method and device Pending CN114089960A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111182648.1A CN114089960A (en) 2021-10-11 2021-10-11 Object processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111182648.1A CN114089960A (en) 2021-10-11 2021-10-11 Object processing method and device

Publications (1)

Publication Number Publication Date
CN114089960A true CN114089960A (en) 2022-02-25

Family

ID=80296704

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111182648.1A Pending CN114089960A (en) 2021-10-11 2021-10-11 Object processing method and device

Country Status (1)

Country Link
CN (1) CN114089960A (en)

Similar Documents

Publication Publication Date Title
JP7346609B2 (en) Systems and methods for performing semantic exploration using natural language understanding (NLU) frameworks
CN110704479A (en) Task processing method and device, electronic equipment and storage medium
US20240143562A1 (en) Automatic splitting of a column into multiple columns
EP3671526B1 (en) Dependency graph based natural language processing
US11281864B2 (en) Dependency graph based natural language processing
CN110909016B (en) Repeated association detection method, device, equipment and storage medium based on database
CN111914534B (en) Method and system for constructing semantic mapping of knowledge graph
CN110555205B (en) Negative semantic recognition method and device, electronic equipment and storage medium
WO2021201953A1 (en) Natural language code search
JP2022091986A (en) Intelligent interactive method, device, electronic apparatus and storage medium
JP2023047318A (en) Code enrichment for training language models relating to computer programming
CN115221191A (en) Virtual column construction method based on data lake and data query method
CN112527272B (en) Method for docking TVM (transient voltage management) and related equipment
CN113032366A (en) SQL syntax tree analysis method based on Flex and Bison
CN110008448B (en) Method and device for automatically converting SQL code into Java code
CN116400910A (en) Code performance optimization method based on API substitution
CN114089960A (en) Object processing method and device
CN114282529A (en) Grammar inquiry method, system and computer storage medium
CN107341021B (en) Software network representation, storage and retrieval method for large complex software with constraint logic attribute
CN112988778A (en) Method and device for processing database query script
CN113297199B (en) Method and device for using spatiotemporal data engine and Cassandra database system
CN113297306B (en) Data processing method and device
EP3944127A1 (en) Dependency graph based natural language processing
CN112162746B (en) Automatic program construction method based on network knowledge convergence and iterative search
CN114547236A (en) Data searching method, device, electronic equipment, medium and program product

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