Rule file creation method, device, equipment and computer readable storage medium

By acquiring, parsing, and compiling rule files, generating dynamic libraries, and maintaining them, the problems of inflexible rule file calls and high energy consumption in existing technologies are solved, achieving flexible and convenient rule file calls and energy saving.

CN112667287BActive Publication Date: 2025-10-21WEBANK (CHINA)
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202011595574.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-28
Publication Date
2025-10-21
Estimated Expiration
2040-12-28

AI Technical Summary

Technical Problem

In existing technologies, hard-coding is not flexible enough, and preloading configuration files requires parsing the configuration file into source code files before each data processing, which makes the processing program cumbersome and consumes a lot of computing power.

Method used

The rule management module obtains file rules and generates rule files; the syntax tree parsing module performs syntax parsing to obtain source code files; the compilation engine compiles the source code files into dynamic libraries, which are then maintained by the version control module.

Benefits of technology

It improves the flexibility and convenience of calling rule files and saves energy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112667287B_ABST
    Figure CN112667287B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of data management in financial technology, and discloses a rule file calling method, device and equipment and a computer readable storage medium, the method comprising the following steps: obtaining file rules through a rule management module, and generating a rule file; performing syntax analysis on the rule file through a syntax tree analysis module to obtain a source code file of the rule file; compiling the source code file into a dynamic library through a compiling engine, and pushing the dynamic library to a version library module; and maintaining the dynamic library through the version library module. The obtained file rules are parsed into a source code file, the source code file is compiled into a dynamic library, and then the dynamic library is maintained by the version library module, so that the dynamic library can be directly called when data of a calling party needs to be processed, the flexibility and convenience of calling the rule file are improved, and energy consumption is saved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data management technology in Fintech, and in particular to a method, apparatus, device and computer-readable storage medium for creating a rule file. Background Art

[0002] With the development of computer technology, more and more technologies (blockchain, big data, distributed) are being applied in the financial field. The traditional financial industry is gradually transforming into financial technology (Fintech). However, due to the security and real-time requirements of the financial industry, higher requirements are also placed on technology.

[0003] Currently, pre-configured rule files are primarily invoked through hard-coding or pre-loading configuration files to process relevant data in messages. However, the hard-coding method is inflexible, and the pre-loading configuration file method requires parsing the configuration file into source code before each data processing, making the processing process cumbersome and computationally expensive. Summary of the Invention

[0004] The present invention provides a method, device, equipment and computer-readable storage medium for calling a rule file, aiming to improve the flexibility and convenience of calling a rule file and save energy consumption.

[0005] To achieve the above object, the present invention provides a method for creating a rule file, the method comprising:

[0006] Obtain file rules through the rule management module and generate rule files;

[0007] Performing syntax analysis on the rule file by using a syntax tree analysis module to obtain a source code file of the rule file;

[0008] Compile the source code file into a dynamic library through a compilation engine, and push the dynamic library to the version library module;

[0009] The dynamic library is maintained through the version library module.

[0010] Optionally, the performing syntax parsing on the rule file by a syntax tree parsing module to obtain a source code file of the rule file includes:

[0011] Mapping the rule file into a syntax tree by the syntax tree parsing module, wherein the syntax tree includes a declaration node, a sub-declaration node, and a sub-expression node;

[0012] The declaration node, the sub-declaration node, and the sub-expression node are converted in sequence according to a preset data abstraction paradigm, and the converted content is saved as a source code file.

[0013] Optionally, the step of converting the declaration node, the sub-declaration node, and the sub-expression node in sequence according to a preset data abstraction paradigm, and saving the converted content as a source code file, further includes:

[0014] The code content in the source code file is checked based on the language constraint specification in the data abstraction paradigm to find out the code content that does not comply with the language constraint specification.

[0015] Optionally, maintaining the dynamic library through the version library module includes:

[0016] Calculating a first hash value of the dynamic library by the version library module, and comparing the first hash value with a second hash value calculated by the compilation engine to determine whether the dynamic library has been modified; and / or

[0017] Performing version verification according to the version number pre-embedded in the dynamic library through the version library module, and comparing the functions in the dynamic library with the preset functions set in the data abstraction paradigm to perform version and function verification;

[0018] If the dynamic library has not been modified and / or the version and function verification are successful, the dynamic library is saved.

[0019] Optionally, the step of obtaining the pending file rules through the rule management module further includes:

[0020] The rule information of the file rule is saved, and the rule information is sent to a distributed open source service cluster.

[0021] Optionally, the maintaining the dynamic library by the version library module further includes:

[0022] Traversing the distributed open source service cluster based on the version number through the execution engine, and when a new version dynamic library is found, linking the calling function to the new version dynamic library;

[0023] The new function call format in the new version dynamic library is converted into a preset function call format.

[0024] Optionally, the maintaining the dynamic library by the version library module further includes:

[0025] When receiving a call request from a caller, obtaining a target port number in the call request to determine a corresponding target dynamic library;

[0026] The function in the target dynamic library is called by the execution engine to process the data in the calling request according to the function to obtain a processing result.

[0027] In addition, to achieve the above-mentioned purpose, the present invention further provides a rule file device, the rule file device comprising:

[0028] The acquisition module is used to obtain file rules through the rule management module and generate rule files;

[0029] A parsing module, configured to perform syntax parsing on the rule file through a syntax tree parsing module to obtain a source code file of the rule file;

[0030] A compilation module, configured to compile the source code file into a dynamic library through a compilation engine, and push the dynamic library to a version library module;

[0031] A maintenance module is used to maintain the dynamic library through the version library module.

[0032] In addition, to achieve the above-mentioned purpose, the present invention also provides a rule file creation device, which includes a processor, a memory, and a rule file creation program stored in the memory. When the rule file creation program is run by the processor, the steps of the rule file creation method described above are implemented.

[0033] In addition, to achieve the above objectives, the present invention also provides a computer-readable storage medium, which stores a rule file creation program. When the rule file creation program is executed by a processor, the steps of the rule file creation method described above are implemented.

[0034] Compared to the prior art, the present invention provides a method, apparatus, device, and computer-readable storage medium for calling a rule file. The method obtains file rules and generates a rule file through a rule management module. A syntax tree parsing module performs syntax parsing on the rule file to obtain a source code file for the rule file. A compilation engine compiles the source code file into a dynamic library, which is then pushed to a version library module. The version library module maintains the dynamic library. The obtained file rules are parsed into a source code file, which is then compiled into a dynamic library. The version library module then maintains the dynamic library, allowing the dynamic library to be directly called when processing the caller's data is required. This improves the flexibility and convenience of calling rule files and saves energy. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] Figure 1 Schematic diagram of the hardware structure of a device for creating a rule file involved in various embodiments of the present invention;

[0036] Figure 2This is a flow chart of a first embodiment of a method for creating a rule file according to the present invention;

[0037] Figure 3 is an example diagram of a syntax tree involved in the first embodiment of the method for creating a rule file of the present invention;

[0038] Figure 4 is a schematic diagram of an execution framework involved in the first embodiment of the method for creating a rule file of the present invention;

[0039] Figure 5 It is a functional module diagram of the first embodiment of the device for creating a rule file of the present invention.

[0040] The purpose, features and advantages of the present invention will be further described with reference to the accompanying drawings and in conjunction with the embodiments. DETAILED DESCRIPTION

[0041] It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0042] The rule file creation device mainly involved in the embodiments of the present invention refers to a network connection device that can achieve network connection. The rule file creation device can be a server, a cloud platform, etc.

[0043] Reference Figure 1 , Figure 1 Schematic diagram of the hardware structure of the rule file creation device involved in each embodiment of the present invention. In the embodiment of the present invention, the rule file creation device may include a processor 1001 (such as a central processing unit, CPU), a communication bus 1002, an input port 1003, an output port 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize the connection and communication between these components; the input port 1003 is used for data input; the output port 1004 is used for data output, and the memory 1005 can be a high-speed RAM memory or a stable memory (non-volatile memory), such as a disk memory. The memory 1005 can optionally be a storage device independent of the aforementioned processor 1001. Those skilled in the art will understand that Figure 1 The hardware structure shown in the figure does not constitute a limitation of the present invention, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0044] Continue to refer to Figure 1 , Figure 1 The memory 1005 as a computer-readable storage medium may include an operating system, a network communication module, an application module, and a program for creating a rule file. Figure 1In the embodiment, the network communication module is mainly used to connect to the server and perform data communication with the server; and the processor 1001 can call the creation program of the rule file stored in the memory 1005 and execute the creation method of the rule file provided in the embodiment of the present invention.

[0045] An embodiment of the present invention provides a method for creating a rule file.

[0046] Reference Figure 2 , Figure 2 It is a flowchart of the first embodiment of the method for creating a rule file of the present invention.

[0047] In this embodiment, the rule file creation method is applied to a rule file creation device, and the method includes:

[0048] Step S101, obtaining file rules through the rule management module and generating a rule file;

[0049] The rule management module is set up based on a web service. The rule management module includes a visual rule editing interface for technicians to edit input fields, output fields and data processing processes in the writing area on the rule editing interface, wherein the input field includes the name and type of the input field, and the output field includes the name and type of the output field. The data processing process refers to the process of processing the call request of the caller, including data type conversion, string interception, case conversion, etc. Among them, the data processing process can be implemented by writing custom rule code or by calling a preset function. It can be understood that the data processing process can include multiple sub-processes, each of which can correspond to a different processing method, thereby flexibly implementing a complex data processing process.

[0050] After the technician completes the writing of the rules in the rule editing interface and confirms the submission, the rule management module obtains the file rules and sets rule information such as ID (identification), processing port, version number, etc. for the file rules to generate a rule file.

[0051] Furthermore, the rule information of the file rule is saved, and the rule information is sent to the distributed open source service cluster.

[0052] In this embodiment, rule information such as the ID, processing port, and version number of the file rule is saved for subsequent update and rollback.

[0053] A complete example of document rules is as follows:

[0054]

[0055]

[0056] In the file rule example, x and y are the names of the input fields, and z is the name of the output field. Both the input and output fields are of type Integer. The "Start" field, "Json (JavaScript Object Notation) request," declares the input data, "End" field, "Json response" declares the output field, and "Handler" field, "processing function," represents the processing of the data field. In this example, the processing is to multiply the integer fields x and y in the input fields, calculate the product z, convert z's type to global to string, and use it as a String result. The result is then added to the output data.

[0057] In this embodiment, the distributed open source service cluster can be a Zookeeper cluster. Zookeeper is a distributed, open source distributed application coordination service, providing consistency services for distributed applications. Its functions include configuration maintenance, domain name services, distributed synchronization, group services, etc. After the rule information is sent to the Zookeeper cluster, the Zookeeper cluster assigns a znode to the rule information and marks the ID in the rule information and the znode as the path of the rule information; the data in the Zookeeper cluster is the version number of the rule file.

[0058] Step S102, performing syntax analysis on the rule file by a syntax tree analysis module to obtain a source code file of the rule file;

[0059] After the rule file is obtained, the rule file is parsed using a syntax tree parsing module. Specifically, step S102 includes:

[0060] Mapping the rule file into a syntax tree by the syntax tree parsing module, wherein the syntax tree includes a declaration node, a sub-declaration node, and a sub-expression node;

[0061] The declaration node, the sub-declaration node, and the sub-expression node are converted in sequence according to a preset data abstraction paradigm, and the converted content is saved as a source code file.

[0062] In this embodiment, the syntax tree parsing module complies with a preset data abstraction paradigm, wherein the data abstraction paradigm specifies the format of the input field, the format of the output field, the mapping between the field type and the corresponding target language type, the preset function call format, the grammar of the target language, and the constraint specifications of the target language.

[0063] The syntax tree parsing module performs syntax analysis on the rule file based on a Bison parser to obtain a corresponding syntax tree. The syntax tree includes declaration nodes, sub-declaration nodes, and sub-expression nodes.

[0064] A syntax tree is a structured model generated by deducing a language under a certain grammatical specification. It can represent the logical relationships between words in a language and serves as the intermediate bridge for compiling from a source language to a target language.

[0065] The Bison parser first divides the syntax tree into Start, End, and Handler declaration nodes. Each declaration node contains a series of child declaration nodes and child expression nodes. Child declaration nodes represent the naming and type definitions of input fields, output fields, and intermediate variables, while child expression nodes represent the assignment, logical operations, and function operations performed on fields or intermediate data.

[0066] like Figure 3 As shown, Figure 3 This is an example diagram of a syntax tree involved in the first embodiment of the method for creating a rule file of the present invention. Figure 3 The declaration nodes of the Tree syntax tree include Start declaration, End declaration, and Handler declaration; the child declaration nodes of the Start declaration include Json and request. The child declaration nodes of the End declaration include Json and response. The child declaration nodes of the Handler declaration include =expression (first), global_to_string, and =expression (second). The child expression nodes of =expression (first) include: Integer declaration, *expression, z, .expression, request, x, y, etc. The child expression nodes of global_to_string include: string declaration, z, result. The child expression nodes of =expression (second) include .expression, request, response, and result.

[0067] After the syntax tree is created, the language of the rule file can be translated into the target language by escaping from the root of the syntax tree from top to bottom. In this embodiment, the target language can be C++.

[0068] The translation process specifically includes:

[0069] Conversion of sub-declaration nodes: converting the contents of sub-declaration nodes in the syntax tree into types and variable names in the target language according to the field types defined in the data abstraction paradigm and the type mapping of the target language;

[0070] Converting the sub-expression node into a function call form, a logical operation form, and an assignment form of the target language according to the grammar of the target language defined in the data abstraction paradigm;

[0071] Furthermore, after obtaining the source code file, the source code file is inspected, specifically including:

[0072] The code content in the source code file is checked based on the language constraint specification in the data abstraction paradigm to find out the code content that does not comply with the voice constraint specification; the code content in the source code file is scanned line by line, and based on the language constraint specification in the data abstraction paradigm, it is determined whether each line of code content complies with the language constraint specification, and the code content that does not comply with the voice constraint specification is found.

[0073] For example, system or process-level functions such as exit and sleep should be prohibited, and language constraint specifications are defined through regular expressions.

[0074] In other embodiments, the code content that does not comply with the voice constraint specification may also be corrected according to the language constraint specification to obtain code content that complies with the voice constraint specification.

[0075] The following is a sample source code file obtained by converting the file rule sample according to the above process:

[0076]

[0077] For rule files that use preset functions, their source code will contain global_function.h to reference the preset function. The h in globalfunction (global function) is the custom data processing rule.

[0078] Furthermore, version numbers can be embedded in several source code files for subsequent proofreading. The version number of the source code file example is 1_0_0.

[0079] Step S103, compiling the source code file into a dynamic library through a compilation engine, and pushing the dynamic library to a version library module;

[0080] In this embodiment, the compilation engine calls a compiler of the target language to compile the source code file into a dynamic library. The compiler can be GCC or G++. GCC is a programming language translator developed by GNU (GNU Compiler Collection). GCC was originally designed as a compiler specifically for the GNU operating system. G++ is a C++ compiler under GCC.

[0081] After the compilation is completed and the dynamic library is obtained, the dynamic library is pushed to a preset version library.

[0082] Step S104: maintaining the dynamic library through the version library module.

[0083] In this embodiment, the version library is responsible for maintaining the dynamic library file and its corresponding version information, which includes: file name, processing port, file hash value, creation timestamp, version number, dynamic library ID. This information comes from the execution result of the compilation engine.

[0084] The maintenance includes hash value verification and version verification. Specifically, step S104 includes:

[0085] The version library module calculates a first hash value for the dynamic library, and compares the first hash value with the second hash value calculated by the compilation engine to determine whether the dynamic library has been modified. After receiving the dynamic library, the version library calculates the first hash value for the dynamic library, and after compiling the dynamic library, the compilation engine calculates a second hash value and stores the second hash value in the version information of the dynamic library. The first hash value is compared with the second hash value, and if the two are consistent, it is determined that the dynamic library has not been modified.

[0086] The version library module performs version verification according to the version number pre-embedded in the dynamic library, so as to perform version verification. In this embodiment, the function table of the dynamic library is displayed by the nm tool to verify the dynamic library version.

[0087] The functions in the dynamic library are compared with the preset functions set in the data abstraction paradigm to perform function verification. It is verified whether there are any omissions in the preset functions required by the data abstraction paradigm to ensure that the dynamic library includes the functions required by the data abstraction paradigm.

[0088] If the dynamic library has not been modified and / or the version and function verification are successful, the dynamic library is saved. Otherwise, if the dynamic library has been modified and / or the version and function verification fails, the dynamic library is discarded.

[0089] Based on the above steps, a callable rule file is created. When it needs to be called, the corresponding dynamic library is called to perform data processing based on the rule file.

[0090] Furthermore, the maintenance of the dynamic library by the version library module further includes:

[0091] Traversing the distributed open source service cluster based on the version number through the execution engine, and when a new version dynamic library is found, linking the calling function to the new version dynamic library;

[0092] The new function call format in the new version dynamic library is converted into a preset function call format.

[0093] In this embodiment, the execution engine is responsible for loading the dynamic library and executing function calls to implement data processing.

[0094] Specifically, the execution engine regularly traverses the root path of the zookeeper (distributed open source service) cluster, and calls the getData (retrieval data) function of the zookeeper cluster to monitor the content update events of all sub-paths, that is, monitors the version update events corresponding to the ID of all rule files. When traversing to the new version dynamic library, it is determined that the version update event has been monitored, then the dlopen (opening) function of the calling version library will be linked to the new version dynamic library. If the execution process of the execution engine has linked the dynamic library of different versions of the same ID, then the dlclose (closing) function will be called first to disconnect the dynamic library linked in advance. Wherein dlopen is a computer function, and function is to open the specified dynamic library file in a specified mode, and return a handle to the calling process of dlsym, and use dlclose to unload the opened dynamic library. Dlclose is used to close the dynamic library of the specified handle, and only when the use count of this dynamic library is 0, it will be truly unloaded by the system.

[0095] After linking to the new version of the dynamic library, the dlsym function is used to convert the corresponding new function call format in the dynamic library into the preset function call format according to the same data abstraction paradigm used in the syntax tree parsing module, so that the caller can call the dynamic library. Among them, dlsym is a computer function that operates on the handle and symbol of the dynamic library and returns the address corresponding to the symbol. It can not only obtain the function address, but also the variable address.

[0096] Furthermore, the maintenance of the dynamic library by the version library module further includes:

[0097] When receiving a call request from a caller, obtaining a target port number in the call request to determine a corresponding target dynamic library;

[0098] The function in the target dynamic library is called by the execution engine to process the data in the calling request according to the function to obtain a processing result.

[0099] The execution engine monitors the UDP (User Datagram Protocol) / TCP (Transmission Control Protocol) network port to receive the call request from the caller, and its port is set as the processing port of the rule file. When the execution engine receives the call request, it parses the target port number in the call request and determines the dynamic library with the port number consistent with the target port number as the target dynamic library.

[0100] The data to be processed in the call request is converted into the data format defined in the data abstraction paradigm, and the function in the target dynamic library is called by the execution engine to process the data to be processed by the function, and a return value is output. The return value is determined as the processing result, and the processing result is format-converted and returned to the caller, thereby realizing the application of the rule file.

[0101] Furthermore, this embodiment also performs version rollback, and pulls the old version of the dynamic library in the same steps to load and replace it, so as to process the call request of the caller.

[0102] In addition, an execution framework for executing the creation method of the rule file is pre-built, specifically, referring to Figure 4 , Figure 4 This is a schematic diagram of the execution framework involved in the first embodiment of the method for creating a rule file of the present invention, referring to Figure 4 , the execution framework includes:

[0103] Rule management module, used to obtain file rules;

[0104] A syntax tree parsing module, used for performing syntax parsing on the rule file to obtain a source code file of the rule file;

[0105] A compilation engine, used to compile the source code file into a dynamic library and push the dynamic library to the version library module;

[0106] Version library module, used to maintain the dynamic library through the version library module

[0107] The execution engine calls the function in the dynamic library to process the data in the call request according to the function to obtain a processing result.

[0108] The zookeeper cluster is used to receive the rule information of the rule file issued by the rule management module and issue version update information for the execution engine version to obtain the version update information.

[0109] The modules in the execution framework coordinate and cooperate with each other to complete the creation and execution of the rule file.

[0110] This implementation utilizes the above-mentioned solution to obtain file rules through the rule management module and generate a rule file; perform syntax analysis on the rule file through the syntax tree parsing module to obtain the source code file of the rule file; compile the source code file into a dynamic library through the compilation engine, and push the dynamic library to the version library module; and maintain the dynamic library through the version library module. Thus, the obtained file rules are parsed into a source code file, which is then compiled into a dynamic library. The dynamic library is then maintained by the version library module so that it can be directly called when the caller's data needs to be processed. This improves the flexibility and convenience of calling rule files and saves energy.

[0111] In addition, this embodiment also provides a device for creating a rule file. Figure 5 , Figure 5 This is a functional module diagram of the first embodiment of the device for creating a rule file of the present invention.

[0112] In this embodiment, the creation device of the rule file is a virtual device, which is stored in Figure 1 The memory 1005 of the rule file creation device shown is used to implement all functions of the rule file creation program: used to obtain file rules through the rule management module and generate a rule file; used to perform syntax parsing on the rule file through the syntax tree parsing module to obtain the source code file of the rule file; used to compile the source code file into a dynamic library through the compilation engine and push the dynamic library to the version library module; used to maintain the dynamic library through the version library module.

[0113] Specifically, refer to Figure 5 , the device for creating the rule file includes:

[0114] The acquisition module 10 is used to obtain the file rules through the rule management module and generate a rule file;

[0115] A parsing module 20 is configured to perform syntax parsing on the rule file through a syntax tree parsing module to obtain a source code file of the rule file;

[0116] A compilation module 30 is used to compile the source code file into a dynamic library through a compilation engine, and push the dynamic library to a version library module;

[0117] The maintenance module 40 is used to maintain the dynamic library through the version library module.

[0118] Furthermore, the parsing module is also used to:

[0119] Mapping the rule file into a syntax tree by the syntax tree parsing module, wherein the syntax tree includes a declaration node, a sub-declaration node, and a sub-expression node;

[0120] The declaration node, the sub-declaration node, and the sub-expression node are converted in sequence according to a preset data abstraction paradigm, and the converted content is saved as a source code file.

[0121] Furthermore, the parsing module is further configured to:

[0122] The code content in the source code file is checked based on the language constraint specification in the data abstraction paradigm to find out the code content that does not comply with the language constraint specification.

[0123] Furthermore, the maintenance module is also used to:

[0124] Calculating a first hash value of the dynamic library by the version library module, and comparing the first hash value with a second hash value calculated by the compilation engine to determine whether the dynamic library has been modified; and / or

[0125] Performing version verification according to the version number pre-embedded in the dynamic library through the version library module, and comparing the functions in the dynamic library with the preset functions set in the data abstraction paradigm to perform version and function verification;

[0126] If the dynamic library has not been modified and / or the version and function verification are successful, the dynamic library is saved.

[0127] Furthermore, the acquisition module is further configured to:

[0128] The rule information of the file rule is saved, and the rule information is sent to a distributed open source service cluster.

[0129] Furthermore, the maintenance module is also used to:

[0130] Traversing the distributed open source service cluster based on the version number through the execution engine, and when a new version dynamic library is found, linking the calling function to the new version dynamic library;

[0131] The new function call format in the new version dynamic library is converted into a preset function call format.

[0132] Furthermore, the maintenance module is also used to:

[0133] When receiving a call request from a caller, obtaining a target port number in the call request to determine a corresponding target dynamic library;

[0134] The function in the target dynamic library is called by the execution engine to process the data in the calling request according to the function to obtain a processing result.

[0135] In addition, an embodiment of the present invention further provides a computer-readable storage medium, on which a rule file creation program is stored. When the rule file creation program is executed by a processor, the steps of the rule file creation method described above are implemented, which will not be repeated here.

[0136] Compared to the existing technology, the present invention proposes a rule file calling method, device, equipment, and computer-readable storage medium. The method obtains file rules and generates a rule file through a rule management module; performs syntax parsing on the rule file through a syntax tree parsing module to obtain a source code file for the rule file; compiles the source code file into a dynamic library through a compilation engine, and pushes the dynamic library to a version library module; and maintains the dynamic library through the version library module. Thus, the obtained file rules are parsed into a source code file, which is then compiled into a dynamic library. The dynamic library is then maintained by the version library module so that the dynamic library can be directly called when the caller's data needs to be processed. This improves the flexibility and convenience of calling rule files and saves energy.

[0137] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or system comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or system. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or system comprising the element.

[0138] The serial numbers of the above embodiments of the present invention are for description only and do not represent the advantages or disadvantages of the embodiments.

[0139] Through the description of the above embodiments, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus the necessary general hardware platform, or of course by hardware, but in many cases the former is a better embodiment. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a computer-readable storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes a number of instructions for enabling a terminal device to execute the methods described in various embodiments of the present invention.

[0140] The above description is only a preferred embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent structure or process transformation made by using the contents of the present invention description and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A method for creating a rule file, characterized in that: The method comprises: Obtain file rules through the rule management module and generate rule files; Performing syntax parsing on the rule file through a syntax tree parsing module to obtain a source code file of the rule file; mapping the rule file into a syntax tree through the syntax tree parsing module, wherein the syntax tree includes declaration nodes, sub-declaration nodes, and sub-expression nodes; converting the contents of the sub-declaration nodes in the syntax tree into the types and variable names of the target language according to the field types defined in the data abstraction paradigm and the type mapping of the target language; converting the contents of the sub-expression nodes into the function call form, logical operation form, and assignment form of the target language according to the grammar of the target language defined in the data abstraction paradigm; and saving the converted contents as a source code file; Compile the source code file into a dynamic library through a compilation engine, and push the dynamic library to the version library module; The dynamic library is maintained through the version library module.

2. The method according to claim 1, characterized in that The declaration node, the sub-declaration node, and the sub-expression node are converted in sequence according to a preset data abstraction paradigm, and the converted content is saved as a source code file, and then the following steps are further included: The code content in the source code file is checked based on the language constraint specification in the data abstraction paradigm to find out the code content that does not comply with the language constraint specification.

3. The method according to claim 1, characterized in that Maintaining the dynamic library through the version library module includes: Calculating a first hash value of the dynamic library by the version library module, and comparing the first hash value with a second hash value calculated by the compilation engine to determine whether the dynamic library has been modified; and / or Performing version verification according to the version number pre-embedded in the dynamic library through the version library module, and comparing the functions in the dynamic library with the preset functions set in the data abstraction paradigm to perform version and function verification; If the dynamic library has not been modified and / or the version and function verification are successful, the dynamic library is saved.

4. The method according to claim 1, wherein The method further includes obtaining the waiting file rules through the rule management module and: The rule information of the file rule is saved, and the rule information is sent to a distributed open source service cluster.

5. The method according to claim 4, characterized in that The maintenance of the dynamic library by the version library module further includes: Traversing the distributed open source service cluster based on the version number through the execution engine, and when a new version dynamic library is found, linking the calling function to the new version dynamic library; The new function call format in the new version dynamic library is converted into a preset function call format.

6. The method according to any one of claims 1 to 5, characterized in that The maintenance of the dynamic library by the version library module further includes: When receiving a call request from a caller, obtaining a target port number in the call request to determine a corresponding target dynamic library; The function in the target dynamic library is called by the execution engine to process the data in the calling request according to the function to obtain a processing result.

7. A device for a rule file, characterized in that: The device for the rule file includes: The acquisition module is used to obtain file rules through the rule management module and generate rule files; A parsing module, configured to perform syntax parsing on the rule file through a syntax tree parsing module to obtain a source code file of the rule file; A compilation module, configured to compile the source code file into a dynamic library through a compilation engine, and push the dynamic library to a version library module; A maintenance module, used for maintaining the dynamic library through the version library module; Among them, the parsing module is also used to map the rule file into a syntax tree through the syntax tree parsing module, and the syntax tree includes declaration nodes, sub-declaration nodes, and sub-expression nodes; according to the field type defined in the data abstraction paradigm and the type mapping of the target language, the content of the sub-declaration node in the syntax tree is converted into the type and variable name of the target language; according to the syntax of the target language defined in the data abstraction paradigm, the content of the sub-expression node is converted into the function call form, logical operation form and assignment form of the target language; and the content obtained by the conversion is saved as a source code file.

8. A device for creating a rule file, characterized in that: The rule file creation device includes a processor, a memory, and a rule file creation program stored in the memory. When the rule file creation program is executed by the processor, the steps of the rule file creation method according to any one of claims 1 to 6 are implemented.

9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a program for creating a rule file. When the program for creating a rule file is executed by a processor, the steps of the method for creating a rule file according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Method, device and system for converting a testing and test control notation version 3 (TTCN-3) script into a Java source code

    CN102929680A