CN112541002A - Program language conversion method, device, electronic equipment and storage medium - Google Patents

Program language conversion method, device, electronic equipment and storage medium Download PDF

Info

Publication number
CN112541002A
CN112541002A CN202011448598.2A CN202011448598A CN112541002A CN 112541002 A CN112541002 A CN 112541002A CN 202011448598 A CN202011448598 A CN 202011448598A CN 112541002 A CN112541002 A CN 112541002A
Authority
CN
China
Prior art keywords
statement
preset
abstract syntax
syntax tree
sql
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
CN202011448598.2A
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.)
Beijing QIYI Century Science and Technology Co Ltd
Original Assignee
Beijing QIYI Century Science and 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 Beijing QIYI Century Science and Technology Co Ltd filed Critical Beijing QIYI Century Science and Technology Co Ltd
Priority to CN202011448598.2A priority Critical patent/CN112541002A/en
Publication of CN112541002A publication Critical patent/CN112541002A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2452Query translation
    • G06F16/24528Standardisation; Simplification

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

The embodiment of the invention provides a program language conversion method, a device, electronic equipment and a storage medium, wherein the method comprises the following steps: receiving a program language conversion request and extracting a domain language statement carried in the program language conversion request; analyzing the domain language statement into an abstract syntax tree by using a preset statement analyzer; generating an object corresponding to the abstract syntax tree based on the abstract syntax tree and a preset data model; and processing the objects by using a preset dynamic SQL splicing method, and splicing into SQL sentences executable by the database. Therefore, the field language statements are converted into the SQL statements which can be executed by the database, and the field language statements can be converted into the SQL which can be identified by the database.

Description

Program language conversion method, device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of program language conversion processing technologies, and in particular, to a program language conversion method and apparatus, an electronic device, and a storage medium.
Background
With the continuous development of internet technology, the internet environment of enterprises is more and more complex, and IT devices and related basic services with large quantity and variety are difficult to be effectively managed. Meanwhile, the internet environment of the enterprise is changing constantly, and how to evaluate the influence caused by accidents and changes of certain IT equipment or service and how to provide current accurate configuration information of IT resources for other processes are significant challenges for the enterprise. The CMDB (Configuration Management Database) is created to solve these problems, and the CMDB manages all Configuration information in the service in a unified manner, and is an important data base source in the operation and maintenance system.
In the related art, most users using the CMDB are operation and maintenance personnel inside an enterprise, and if the operation and maintenance personnel use a conventional database to perform data Query, they need to learn SQL (Structured Query Language), which is a high learning cost, especially complex multi-table connection Query, and also need to be familiar with a data table structure.
Disclosure of Invention
The embodiment of the invention aims to provide a program language conversion method, a program language conversion device, electronic equipment and a storage medium, so as to realize the beneficial effect of converting a domain language into SQL which can be identified by a database. The specific technical scheme is as follows:
in a first aspect of the embodiments of the present invention, there is provided a program language conversion method, including:
receiving a program language conversion request and extracting a domain language statement carried in the program language conversion request;
analyzing the domain language statement into an abstract syntax tree by using a preset statement analyzer;
generating an object corresponding to the abstract syntax tree based on the abstract syntax tree and a preset data model;
and processing the objects by using a preset dynamic SQL splicing method, and splicing into SQL sentences executable by the database.
In an optional embodiment, the parsing the domain language statement into an abstract syntax tree using a preset statement parser includes:
carrying out accuracy check on the domain language sentences by utilizing a preset syntax analyzer and a lexical analyzer;
and if the domain language statement passes the accuracy check, analyzing the domain language statement into an abstract syntax tree by using a preset statement analyzer.
In an optional embodiment, the method further comprises:
if the domain language sentence does not pass the accuracy check, acquiring error information fed back by the preset syntax analyzer and the lexical analyzer;
and sending the error information to a sender corresponding to the program language conversion request.
In an optional embodiment, the generating, based on the abstract syntax tree and a preset data model, an object corresponding to the abstract syntax tree includes:
for any node in the abstract syntax tree, searching a corresponding characteristic attribute from a preset data model;
and packaging the characteristic attributes into objects corresponding to the abstract syntax trees by an object packaging method.
In an optional embodiment, the processing the object by using a preset dynamic SQL splicing method to splice into an SQL statement executable by a database includes:
and replacing the object in the preset SQL sentence with the object by using a preset dynamic SQL splicing method, and splicing the object into the database executable SQL sentence.
In an optional embodiment, the method further comprises:
sending the SQL statement to the database, and receiving data returned by the database according to the SQL statement;
and sending the data to the sender corresponding to the program language conversion request.
In a second aspect of the embodiments of the present invention, there is also provided a program language conversion apparatus, including:
the request receiving module is used for receiving a program language conversion request;
the statement extraction module is used for extracting the domain language statements carried in the program language conversion request;
the statement parsing module is used for parsing the domain language statement into an abstract syntax tree by using a preset statement parser;
the object generation module is used for generating an object corresponding to the abstract syntax tree based on the abstract syntax tree and a preset data model;
and the statement splicing module is used for processing the objects by utilizing a preset dynamic SQL splicing method and splicing the objects into SQL statements which can be executed by the database.
In an optional embodiment, the statement parsing module is specifically configured to:
carrying out accuracy check on the domain language sentences by utilizing a preset syntax analyzer and a lexical analyzer;
and if the domain language statement passes the accuracy check, analyzing the domain language statement into an abstract syntax tree by using a preset statement analyzer.
In a third aspect of the embodiments of the present invention, there is further provided an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus;
a memory for storing a computer program;
a processor, configured to implement the program language conversion method according to any one of the first aspect described above when executing the program stored in the memory.
In a fourth aspect of the embodiments of the present invention, there is also provided a storage medium having instructions stored therein, which when run on a computer, cause the computer to execute the program language conversion method according to any one of the first aspects.
In a fifth aspect of the embodiments of the present invention, there is also provided a computer program product containing instructions, which when run on a computer, causes the computer to execute the program language conversion method described in any one of the above first aspects.
According to the technical scheme provided by the embodiment of the invention, a program language conversion request is received, a field language statement carried in the program language conversion request is extracted, the field language statement is analyzed into an abstract syntax tree by using a preset statement analyzer, an object corresponding to the abstract syntax tree is generated based on the abstract syntax tree and a preset data model, the object is processed by using a preset dynamic SQL splicing method, and the SQL statement executable by a database is spliced. Therefore, the field language statements are converted into the SQL statements which can be executed by the database, and the field language statements can be converted into the SQL which can be identified by the database.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and together with the description, serve to explain the principles of the invention.
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without inventive exercise.
FIG. 1 is a flowchart illustrating an implementation of a programming language conversion method according to an embodiment of the present invention;
fig. 2 is a schematic diagram of an application scenario shown in the embodiment of the present invention;
FIG. 3 is a diagram illustrating an example of a domain language statement shown in an embodiment of the present invention;
FIG. 4 is a flow chart illustrating another implementation of a program language conversion method according to an embodiment of the present invention;
FIG. 5 is a flow chart illustrating another implementation of a program language conversion method according to an embodiment of the present invention;
FIG. 6 is a schematic structural diagram of a programming language conversion device shown in an embodiment of the present invention;
fig. 7 is a schematic structural diagram of an electronic device shown in the embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be obtained by a person skilled in the art without any inventive step based on the embodiments of the present invention, are within the scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
As shown in fig. 1, an implementation flow diagram of a program language conversion method provided in an embodiment of the present invention is shown, where the method may be used in a server, and specifically may include the following steps:
s101, receiving a program language conversion request and extracting a domain language statement carried in the program language conversion request.
In the embodiment of the invention, a user-defined domain language needs to be designed, the domain language needs to be popular and easy to understand, the data model in the CMDB is abstracted, and a user (such as an operation and maintenance worker) can easily write a domain language sentence meeting the requirement of the user through the domain language by combining the data model and the domain language.
Therefore, the domain language statements can be packaged to generate a program language conversion request and then sent to the back-end server, so that the server can receive the program language conversion request and extract the domain language statements carried in the program language conversion request.
For example, the operation and maintenance person a packages the domain language statements on the personal computer, generates a program language conversion request, and sends the program language conversion request to the back-end server 1, as shown in fig. 2. For the server 1, a program language conversion request may be received, and a domain language statement carried in the program language conversion request may be extracted, where the domain language statement is shown in fig. 3.
And S102, analyzing the field language statement into an abstract syntax tree by using a preset statement analyzer.
For a domain language statement, in the embodiment of the present invention, the domain language statement may be parsed into an abstract syntax tree by using a preset statement parser. For an abstract syntax tree, it represents the syntactic structure of a domain language statement in the form of a tree, with each node on the tree representing a structure in the domain language statement.
For the preset statement parser, the preset statement parser may specifically be ANTLR in the embodiment of the present invention, where ANTLR refers to an open source parser that may automatically generate a syntax tree according to an input and visually display, and the ANTLR may be used to parse a domain language statement as shown in fig. 3 into an abstract syntax tree.
S103, generating an object corresponding to the abstract syntax tree based on the abstract syntax tree and a preset data model.
And abstracting the data model in the CMDB to obtain a preset data model, so that an object corresponding to the abstract syntax tree can be generated based on the abstract syntax tree and the preset data model. The concrete example here may be to combine the abstract syntax tree with a preset data model to generate an object corresponding to the abstract syntax tree.
For the Object corresponding to the abstract syntax tree, the Object may specifically be a POJO (Plain organization Java Object), which is actually Ordinary Java beans in the embodiment of the present invention, and the embodiment of the present invention does not limit this.
And S104, processing the objects by using a preset dynamic SQL splicing method, and splicing into SQL sentences executable by the database.
For the object corresponding to the generated abstract syntax tree, the embodiment of the present invention can specifically utilize a preset dynamic SQL splicing method to process the object and splice the object into an SQL statement executable by the database.
For the preset dynamic SQL splicing method, the embodiment of the present invention may specifically be a dynamic SQL splicing method of a MyBatis framework, which is not limited in the embodiment of the present invention.
For example, the packaged POJO is processed by a dynamic SQL splicing method of a MyBatis framework, and the POJO is spliced into an SQL statement that can be executed by MySQL of a bottom-layer database.
According to the technical scheme provided by the embodiment of the invention, the program language conversion request is received, the field language statements carried in the program language conversion request are extracted, the field language statements are analyzed into the abstract syntax tree by using the preset statement analyzer, the objects corresponding to the abstract syntax tree are generated based on the abstract syntax tree and the preset data model, the objects are processed by using the preset dynamic SQL splicing method, and the SQL statements executable by the database are spliced. Therefore, the field language statements are converted into the SQL statements which can be executed by the database, and the field language statements can be converted into the SQL which can be identified by the database.
As shown in fig. 4, an implementation flow diagram of another program language conversion method provided in the embodiment of the present invention is shown, where the method may be used in a server, and specifically may include the following steps:
s401, receiving a program language conversion request, and extracting a domain language statement carried in the program language conversion request.
In the embodiment of the present invention, this step is similar to the step S101, and the details of the embodiment of the present invention are not repeated herein.
S402, using a preset grammar analyzer and a lexical analyzer to carry out accuracy check on the domain language sentences.
In the embodiment of the invention, in order to ensure that the domain language statements can be successfully analyzed into the abstract syntax tree and avoid the occurrence of analysis failure, the accuracy of the domain language statements can be checked, specifically, the accuracy of the domain language statements can be checked by using the preset syntax analyzer and the lexical analyzer, and whether the grammar and lexical usage of the domain language statements meet the specifications or not can be checked.
As for the preset Parser, in the embodiment of the present invention, the preset Parser may specifically be a Parser (Parser) in ANTLR, in which a certain syntax rule is pre-embedded, and the embodiment of the present invention does not limit this.
The preset lexical analyzer may be specifically a lexical analyzer (Lexer) in ANTLR in the embodiment of the present invention, in which a certain lexical rule is pre-embedded, which is not limited in the embodiment of the present invention.
For example, as shown in the example of the domain language statement in fig. 3, the parser and the lexical parser in ANTLR are used to perform an accuracy check to ensure that the syntax and lexical usage involved in the domain language statement are in compliance with the specification.
And S403, if the domain language statement passes the accuracy check, analyzing the domain language statement into an abstract syntax tree by using a preset statement analyzer.
And for the field language statement, carrying out accuracy verification on the field language statement by using a preset syntax analyzer and a lexical analyzer, and if the field language statement passes the accuracy verification, analyzing the field language statement into an abstract syntax tree by using a preset statement analyzer.
For example, as shown in the example of the domain language sentence shown in fig. 3, the syntax parser and the lexical parser in the ANTLR are used to perform the accuracy check, and if the domain language sentence passes the accuracy check, it indicates that the usage of the lexical and grammatical rules in the domain language sentence is in compliance with the specification, so that the domain language sentence can be parsed into the abstract syntax tree by the ANTLR.
S404, generating an object corresponding to the abstract syntax tree based on the abstract syntax tree and a preset data model.
In the embodiment of the present invention, this step is similar to the step S103, and the details of the embodiment of the present invention are not repeated herein.
And S405, processing the objects by using a preset dynamic SQL splicing method, and splicing into SQL sentences executable by the database.
In the embodiment of the present invention, this step is similar to the step S104, and the details of the embodiment of the present invention are not repeated herein.
S406, if the domain language sentence does not pass the accuracy check, acquiring error information fed back by the preset syntax analyzer and the lexical analyzer.
And for the domain language sentence, carrying out accuracy check on the domain language sentence by using a preset syntax analyzer and a lexical analyzer, and if the domain language sentence fails to pass the accuracy check, indicating that errors exist in grammar and lexical use in the domain language sentence, and acquiring error information fed back by the preset syntax analyzer and the lexical analyzer.
For example, as shown in the example of the domain language statement in FIG. 3, assume that a punctuation symbol is absent between "Cluster" and "Cluster": "the syntax analyzer and the lexical analyzer in the ANTLR are used to perform accuracy check, and the domain language sentence does not pass the accuracy check, so that the error information fed back by the syntax analyzer and the lexical analyzer in the ANTLR can be obtained: the lack of punctuation between "Cluster" and "Cluster": ".
S407, sending the error information to a sender corresponding to the program language conversion request.
In the embodiment of the present invention, the issuer corresponding to the program language conversion request may be determined, so that the error information fed back by the obtained preset syntax analyzer and the lexical analyzer may be sent to the issuer.
For example, for the error information fed back by the parser and the lexical parser in ANTLR: the lack of punctuation between "Cluster" and "Cluster": ", it may be determined that the issuer to which the program language conversion request corresponds: the operation and maintenance person a can send the error information to the operation and maintenance person a.
As shown in fig. 5, an implementation flow diagram of another program language conversion method provided in the embodiment of the present invention is shown, where the method may be used in a server, and specifically may include the following steps:
s501, receiving a program language conversion request and extracting a domain language statement carried in the program language conversion request.
In the embodiment of the present invention, this step is similar to the step S101, and the details of the embodiment of the present invention are not repeated herein.
And S502, carrying out accuracy check on the field language sentence by utilizing a preset grammar analyzer and a lexical analyzer.
In the embodiment of the present invention, this step is similar to the step S402, and the details of the embodiment of the present invention are not repeated herein.
And S503, if the domain language statement passes the accuracy check, analyzing the domain language statement into an abstract syntax tree by using a preset statement analyzer.
In the embodiment of the present invention, this step is similar to the step S403, and details of the embodiment of the present invention are not repeated herein.
S504, for any node in the abstract syntax tree, searching a corresponding characteristic attribute from a preset data model.
For an abstract syntax tree, it represents the syntactic structure of a domain language statement in the form of a tree, with each node on the tree representing a structure in the domain language statement. And for any node in the abstract syntax tree, searching corresponding characteristic attributes from a preset data model.
For example, for the "Machine" field corresponding to node 1 in the abstract syntax tree, for the "Machine" attribute existing in the preset data model, the "Machine" attribute can be found to correspond to the "Machine" field of node 1.
For another example, for node 2 (where node 1 is connected to node 2) in the abstract syntax tree, there is a corresponding "IP" attribute for the preset data model, so that the "IP" attribute can be found to correspond to the "IP" field of node 1.
And S505, packaging the characteristic attribute into an object corresponding to the abstract syntax tree by using an object packaging method.
For any node in the abstract syntax tree, the corresponding characteristic attribute is searched from the preset data model, so that the characteristic attribute can be packaged into an object corresponding to the abstract syntax tree by an object packaging method.
For example, the "Machine" attribute corresponding to the node 1 and the "IP" attribute corresponding to the node 2 in the abstract syntax tree may be encapsulated into the POJO corresponding to the abstract syntax tree by an object encapsulation method.
S506, replacing the object in the preset SQL sentence with the object by using a preset dynamic SQL splicing method, and splicing into the database executable SQL sentence.
For the object corresponding to the abstract syntax tree, the embodiment of the invention can replace the object in the preset SQL statement with the object corresponding to the abstract syntax tree by using a preset dynamic SQL splicing method, thereby splicing the SQL statement executable by the database.
For example, an SQL query statement exists in the dynamic SQL splicing method of the MyBatis framework, a default object 1 exists in the SQL query statement, and the default object 1 in the SQL search statement is replaced by a POJO corresponding to the abstract syntax tree by the dynamic SQL splicing method of the MyBatis framework, so that SQL statements for querying "Machine" and "IP" can be spliced.
And S507, if the domain language sentence does not pass the accuracy check, acquiring error information fed back by the preset syntax analyzer and the lexical analyzer.
In the embodiment of the present invention, this step is similar to the step S406, and the details of the embodiment of the present invention are not repeated herein.
S508, the error information is sent to the sender corresponding to the program language conversion request.
In the embodiment of the present invention, this step is similar to the step S407, and the embodiment of the present invention is not described herein again.
In addition, after the SQL sentences executable by the database are spliced, the embodiment of the invention can interact with the database through the SQL sentences executable by the database to query corresponding data. Specifically, the SQL statements executable by the database may be sent to the database, data returned by the database according to the SQL statements may be received, and the data may be sent to the issuer corresponding to the domain language statements.
For example, for the SQL statements executable by the database MySQL, the SQL statements may be sent to the database MySQL, data returned by the database MySQL is received, the operation and maintenance person a of the issuer corresponding to the domain language statements is determined, and the data is sent to the operation and maintenance person a, so that the query of the data is completed.
Corresponding to the foregoing method embodiment, an embodiment of the present invention further provides a program language conversion apparatus, which is applied to a server, and as shown in fig. 6, the apparatus may include: a request receiving module 610, a statement extracting module 620, a statement parsing module 630, an object generating module 640, and a statement splicing module 650.
A request receiving module 610, configured to receive a program language conversion request;
a statement extracting module 620, configured to extract a domain language statement carried in the program language conversion request;
a statement parsing module 630, configured to parse the domain language statement into an abstract syntax tree by using a preset statement parser;
an object generating module 640, configured to generate an object corresponding to the abstract syntax tree based on the abstract syntax tree and a preset data model;
and the statement splicing module 650 is configured to process the objects by using a preset dynamic SQL splicing method, and splice the objects into SQL statements executable by the database.
In a specific implementation manner of the embodiment of the present invention, the statement parsing module 630 is specifically configured to:
carrying out accuracy check on the domain language sentences by utilizing a preset syntax analyzer and a lexical analyzer;
and if the domain language statement passes the accuracy check, analyzing the domain language statement into an abstract syntax tree by using a preset statement analyzer.
In a specific implementation manner of the embodiment of the present invention, the apparatus further includes:
the information acquisition module is used for acquiring error information fed back by the preset syntax analyzer and the lexical analyzer if the domain language statements do not pass accuracy verification;
and sending the error information to a sender corresponding to the program language conversion request.
In a specific implementation manner of the embodiment of the present invention, the object generation module 640 is specifically configured to:
for any node in the abstract syntax tree, searching a corresponding characteristic attribute from a preset data model;
and packaging the characteristic attributes into objects corresponding to the abstract syntax trees by an object packaging method.
In a specific implementation manner of the embodiment of the present invention, the sentence splicing module 650 is specifically configured to:
and replacing the object in the preset SQL sentence with the object by using a preset dynamic SQL splicing method, and splicing the object into the database executable SQL sentence.
In a specific implementation manner of the embodiment of the present invention, the apparatus further includes:
the data query module is used for sending the SQL statement to the database and receiving data returned by the database according to the SQL statement;
and sending the data to the sender corresponding to the program language conversion request.
The embodiment of the present invention further provides an electronic device, as shown in fig. 7, which includes a processor 71, a communication interface 72, a memory 73 and a communication bus 74, where the processor 71, the communication interface 72, and the memory 73 complete mutual communication through the communication bus 74,
a memory 73 for storing a computer program;
the processor 71, when executing the program stored in the memory 73, implements the following steps:
receiving a program language conversion request and extracting a domain language statement carried in the program language conversion request; analyzing the domain language statement into an abstract syntax tree by using a preset statement analyzer; generating an object corresponding to the abstract syntax tree based on the abstract syntax tree and a preset data model; and processing the objects by using a preset dynamic SQL splicing method, and splicing into SQL sentences executable by the database.
The communication bus mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the electronic equipment and other equipment.
The Memory may include a Random Access Memory (RAM) or a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the Integrated Circuit may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, a discrete Gate or transistor logic device, or a discrete hardware component.
In another embodiment of the present invention, a storage medium is further provided, where instructions are stored, and when the storage medium runs on a computer, the instructions cause the computer to execute the program language conversion method in any one of the above embodiments.
In yet another embodiment of the present invention, there is also provided a computer program product containing instructions which, when run on a computer, cause the computer to perform the program language conversion method described in any of the above embodiments.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the invention to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored on a storage medium or transmitted from one storage medium to another, for example, from one website, computer, server, or data center to another website, computer, server, or data center via wire (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The storage medium may be any available medium that can be accessed by a computer or a data storage device including one or more available media integrated servers, data centers, and the like. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

Claims (10)

1. A program language conversion method, the method comprising:
receiving a program language conversion request and extracting a domain language statement carried in the program language conversion request;
analyzing the domain language statement into an abstract syntax tree by using a preset statement analyzer;
generating an object corresponding to the abstract syntax tree based on the abstract syntax tree and a preset data model;
and processing the objects by using a preset dynamic SQL splicing method, and splicing into SQL sentences executable by the database.
2. The method of claim 1, wherein parsing the domain language statement into an abstract syntax tree using a preset statement parser comprises:
carrying out accuracy check on the domain language sentences by utilizing a preset syntax analyzer and a lexical analyzer;
and if the domain language statement passes the accuracy check, analyzing the domain language statement into an abstract syntax tree by using a preset statement analyzer.
3. The method of claim 2, further comprising:
if the domain language sentence does not pass the accuracy check, acquiring error information fed back by the preset syntax analyzer and the lexical analyzer;
and sending the error information to a sender corresponding to the program language conversion request.
4. The method according to claim 1, wherein generating the object corresponding to the abstract syntax tree based on the abstract syntax tree and a preset data model comprises:
for any node in the abstract syntax tree, searching a corresponding characteristic attribute from a preset data model;
and packaging the characteristic attributes into objects corresponding to the abstract syntax trees by an object packaging method.
5. The method according to claim 1, wherein the processing the objects by using the preset dynamic SQL splicing method to splice into SQL statements executable by the database comprises:
and replacing the object in the preset SQL sentence with the object by using a preset dynamic SQL splicing method, and splicing the object into the database executable SQL sentence.
6. The method according to any one of claims 1 to 5, further comprising:
sending the SQL statement to the database, and receiving data returned by the database according to the SQL statement;
and sending the data to the sender corresponding to the program language conversion request.
7. A program language conversion apparatus, characterized in that the apparatus comprises:
the request receiving module is used for receiving a program language conversion request;
the statement extraction module is used for extracting the domain language statements carried in the program language conversion request;
the statement parsing module is used for parsing the domain language statement into an abstract syntax tree by using a preset statement parser;
the object generation module is used for generating an object corresponding to the abstract syntax tree based on the abstract syntax tree and a preset data model;
and the statement splicing module is used for processing the objects by utilizing a preset dynamic SQL splicing method and splicing the objects into SQL statements which can be executed by the database.
8. The apparatus of claim 7, wherein the statement parsing module is specifically configured to:
carrying out accuracy check on the domain language sentences by utilizing a preset syntax analyzer and a lexical analyzer;
and if the domain language statement passes the accuracy check, analyzing the domain language statement into an abstract syntax tree by using a preset statement analyzer.
9. An electronic device is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing mutual communication by the memory through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any one of claims 1 to 6 when executing a program stored in the memory.
10. A storage medium on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1-6.
CN202011448598.2A 2020-12-09 2020-12-09 Program language conversion method, device, electronic equipment and storage medium Pending CN112541002A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011448598.2A CN112541002A (en) 2020-12-09 2020-12-09 Program language conversion method, device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011448598.2A CN112541002A (en) 2020-12-09 2020-12-09 Program language conversion method, device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN112541002A true CN112541002A (en) 2021-03-23

Family

ID=75020010

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011448598.2A Pending CN112541002A (en) 2020-12-09 2020-12-09 Program language conversion method, device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112541002A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113467778A (en) * 2021-06-23 2021-10-01 中国海洋大学 Algorithm conversion method and system in heterogeneous many-core processor
CN113821496A (en) * 2021-11-22 2021-12-21 深圳市明源云科技有限公司 Database migration method, system, device and computer readable storage medium
CN114386373A (en) * 2022-01-13 2022-04-22 未鲲(上海)科技服务有限公司 Code statement conversion method and device, computer equipment and storage medium
CN114547067A (en) * 2022-01-20 2022-05-27 北京元年科技股份有限公司 SQL query statement generation method, device and equipment based on general query structure
CN114780104A (en) * 2022-04-27 2022-07-22 中国银行股份有限公司 MYSQL (MySQL structured query language) and ORACLE (ORACLE language) statement mutual translation method and device
CN115469875A (en) * 2022-08-22 2022-12-13 西安衍舆航天科技有限公司 Method and device for compiling domain-specific language DSL based on remote operation

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20010011371A1 (en) * 1998-09-29 2001-08-02 Min-Mei Tang Compilation of embedded language statements in a source code program
CN101788992A (en) * 2009-05-06 2010-07-28 厦门东南融通系统工程有限公司 Method and system for converting query sentence of database
CN111143403A (en) * 2019-12-10 2020-05-12 跬云(上海)信息科技有限公司 SQL conversion method and device and storage medium
CN111949541A (en) * 2020-08-14 2020-11-17 中国工商银行股份有限公司 Multi-source database statement checking method and device

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20010011371A1 (en) * 1998-09-29 2001-08-02 Min-Mei Tang Compilation of embedded language statements in a source code program
CN101788992A (en) * 2009-05-06 2010-07-28 厦门东南融通系统工程有限公司 Method and system for converting query sentence of database
CN111143403A (en) * 2019-12-10 2020-05-12 跬云(上海)信息科技有限公司 SQL conversion method and device and storage medium
CN111949541A (en) * 2020-08-14 2020-11-17 中国工商银行股份有限公司 Multi-source database statement checking method and device

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113467778A (en) * 2021-06-23 2021-10-01 中国海洋大学 Algorithm conversion method and system in heterogeneous many-core processor
CN113467778B (en) * 2021-06-23 2024-01-09 中国海洋大学 Algorithm conversion method and system in heterogeneous many-core processor
CN113821496A (en) * 2021-11-22 2021-12-21 深圳市明源云科技有限公司 Database migration method, system, device and computer readable storage medium
CN113821496B (en) * 2021-11-22 2022-03-01 深圳市明源云科技有限公司 Database migration method, system, device and computer readable storage medium
CN114386373A (en) * 2022-01-13 2022-04-22 未鲲(上海)科技服务有限公司 Code statement conversion method and device, computer equipment and storage medium
CN114547067A (en) * 2022-01-20 2022-05-27 北京元年科技股份有限公司 SQL query statement generation method, device and equipment based on general query structure
CN114780104A (en) * 2022-04-27 2022-07-22 中国银行股份有限公司 MYSQL (MySQL structured query language) and ORACLE (ORACLE language) statement mutual translation method and device
CN115469875A (en) * 2022-08-22 2022-12-13 西安衍舆航天科技有限公司 Method and device for compiling domain-specific language DSL based on remote operation
CN115469875B (en) * 2022-08-22 2023-08-15 西安衍舆航天科技有限公司 Compiling method and device of domain-specific language DSL based on remote control operation

Similar Documents

Publication Publication Date Title
CN112541002A (en) Program language conversion method, device, electronic equipment and storage medium
CN108156022B (en) Service calling method and device and electronic equipment
CN110321154B (en) Micro-service interface information display method and device and electronic equipment
CN109522341B (en) Method, device and equipment for realizing SQL-based streaming data processing engine
CN112015430A (en) JavaScript code translation method and device, computer equipment and storage medium
CN110688307B (en) JavaScript code detection method, device, equipment and storage medium
CN110209700B (en) Data stream association method and device, electronic equipment and storage medium
CN110673839B (en) Distributed tool configuration construction generation method and system
CN111125064A (en) Method and device for generating database mode definition statement
CN108959294B (en) Method and device for accessing search engine
CN115599386A (en) Code generation method, device, equipment and storage medium
CN110888794A (en) Interface test method and device
CN112000690B (en) Method and device for analyzing structured operation statement
CN113885876A (en) Parameter checking method, device, storage medium and computer system
CN113778897A (en) Automatic test method, device, equipment and storage medium of interface
CN110795646A (en) Request processing method and device, electronic equipment and computer-readable storage medium
CN110717134A (en) Product description issuing method and device, storage medium and electronic equipment
CN116382640A (en) Method, device, equipment and storage medium for managing micro-service
US11068376B2 (en) Analytics engine selection management
CN115640279A (en) Method and device for constructing data blood relationship
CN114416776A (en) Data self-defined query statistical method
CN111061627B (en) Webpage embedding method and device, electronic equipment and storage medium
CN113934430A (en) Data retrieval analysis method and device, electronic equipment and storage medium
CN113419738A (en) Interface document generation method and device and interface management equipment
CN113138767A (en) Code language conversion method, device, electronic equipment and storage medium

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