CN111124479B - Method and system for analyzing configuration file and electronic equipment - Google Patents

Method and system for analyzing configuration file and electronic equipment Download PDF

Info

Publication number
CN111124479B
CN111124479B CN201911316226.1A CN201911316226A CN111124479B CN 111124479 B CN111124479 B CN 111124479B CN 201911316226 A CN201911316226 A CN 201911316226A CN 111124479 B CN111124479 B CN 111124479B
Authority
CN
China
Prior art keywords
data
configuration file
result
line
reading
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.)
Active
Application number
CN201911316226.1A
Other languages
Chinese (zh)
Other versions
CN111124479A (en
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 Pixel Software Technology Co Ltd
Original Assignee
Beijing Pixel Software 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 Pixel Software Technology Co Ltd filed Critical Beijing Pixel Software Technology Co Ltd
Priority to CN201911316226.1A priority Critical patent/CN111124479B/en
Publication of CN111124479A publication Critical patent/CN111124479A/en
Application granted granted Critical
Publication of CN111124479B publication Critical patent/CN111124479B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management

Abstract

The invention provides a method, a system and electronic equipment for analyzing configuration files, and relates to the field of server configuration. Firstly, reading a configuration file to be analyzed to obtain a reading result of the configuration file; and then, according to the reading result of the configuration file, mapping the object in the configuration file to obtain a mapping result. And analyzing each row of data in the reading result of the configuration file to obtain an analysis result, wherein the analysis result is used for accessing the configuration file through the corresponding mapping result. The method provides a configuration file analysis method which can contain other configuration files and can perform condition judgment at the same time, and each server process can be configured by performing condition judgment on the configuration files provided by the method, so that the debugging efficiency is improved.

Description

Method and system for analyzing configuration file and electronic equipment
Technical Field
The present invention relates to the field of server configuration, and in particular, to a method, a system, and an electronic device for analyzing a configuration file.
Background
In the deployment process of the network game server, in order to enable the server application program to perform convenient and quick setting, a configuration file is generally used to set the server. Thus, if the server setting needs to be modified, only the configuration file needs to be modified. In addition, the same server application program can be set differently according to different requirements, and the configuration file can be used for conveniently carrying out the differentiated setting. The use of configuration files may also make debugging more efficient because of the convenient modification of the configuration files.
In the configuration files in the prior art, JSON and XML format files are generally used, and the configuration files in the JSON format cannot conveniently extract commonly used setting items in a plurality of configuration files as one file; the XML format configuration file is complex to write, poor in readability, large numbers of characters are required to write, the volume of the configuration file is large, and condition judgment cannot be carried out in the two configuration files, so that the efficiency of a server process is low in the debugging process.
Disclosure of Invention
Accordingly, the present invention aims to provide a method, a system and an electronic device for analyzing a configuration file, by which condition judgment is performed on the configuration file, and each server process is configured, so that debugging efficiency is improved.
In a first aspect, an embodiment of the present invention provides a method for parsing a configuration file, where the method includes:
reading the configuration file to be analyzed to obtain a reading result of the configuration file;
mapping the object in the configuration file according to the reading result of the configuration file to obtain a mapping result;
analyzing each row of data in the reading result of the configuration file to obtain an analysis result; and the analysis result is used for accessing the configuration file through the corresponding mapping result.
In some embodiments, the step of parsing each line of data in the read result of the configuration file to obtain a parsed result includes:
traversing the reading result of the configuration file to obtain all line-wrapping symbols in the reading result of the configuration file;
obtaining each row of data in the reading result of the configuration file according to the line feed symbol;
performing primary analysis on each row of data in the reading result of the configuration file;
and carrying out high-level analysis on the data according to the result of the primary analysis.
In some embodiments, the primary parsing includes:
judging whether the data are null data or not;
if yes, returning to the blank line type; if not, judging whether the data are annotation lines;
if yes, returning the annotation line type; if not, the data is subjected to high-level analysis.
In some embodiments, the high-level parsing includes:
judging whether the line data is conditional compiling instruction data or not, and if so, returning to the conditional compiling instruction type; if not, executing macro substitution judgment step on the data;
if the row data can be macro-replaced, performing macro-replacement operation; if the row data cannot be macro-replaced, performing sub-profile operation on the row data;
judging whether the line data contains a # include field, if so, reading a sub-configuration file contained after the # include field; if not, executing a macro definition judging step on the data;
if the row data contains a # definition field, storing data after the # definition field as a macro; if the row data does not contain the # definition field, executing the fast judgment of the object statement;
if the line data is an object statement block, searching an object address in a mapping result; if the line data is not the object statement block, carrying out an assignment statement judging step;
if the row data is an assignment statement, searching for an attribute address according to the corresponding attribute name and assigning; if the row data is not an assignment statement, an error is prompted.
In some embodiments, the configuration file is in any of the C language or the c++ language.
In some embodiments, the step of determining whether the line data is conditional compiling instruction data includes:
it is determined whether any one of #else, # endif, # ifdef, and #ifndef is contained in the line data.
In some embodiments, the step of reading the sub-configuration file included in the #include field includes:
obtaining data of each row of the sub-configuration file;
performing primary analysis on each row of data of the sub configuration file;
and carrying out high-level analysis on each line of data of the sub configuration file according to the result of the primary analysis.
In a second aspect, an embodiment of the present invention provides a system for parsing a configuration file, where the system includes:
the file reading module is used for reading the configuration file to be analyzed to obtain a reading result of the configuration file;
the file mapping module is used for mapping the objects in the configuration file according to the reading result of the configuration file to obtain a mapping result;
the file analysis module is used for analyzing each line of data in the reading result of the configuration file to obtain an analysis result; and the analysis result is used for accessing the configuration file through the corresponding mapping result.
In a third aspect, an embodiment of the present invention provides an electronic device, including: a processor and a storage device; the storage device stores a computer program which, when executed by the processor, performs the steps of the method for parsing a configuration file.
In a fourth aspect, an embodiment of the present invention provides a computer readable storage medium, on which a computer program is stored, which when executed by a processor performs the steps of the above-described method for parsing a configuration file.
The embodiment of the invention has the following beneficial effects: the embodiment of the invention provides a method, a system and electronic equipment for analyzing a configuration file, wherein the method firstly reads the configuration file to be analyzed to obtain a reading result of the configuration file; and then, according to the reading result of the configuration file, mapping the object in the configuration file to obtain a mapping result. And analyzing each row of data in the reading result of the configuration file to obtain an analysis result, wherein the analysis result is used for accessing the configuration file through the corresponding mapping result. The method provides a configuration file analysis method which can contain other configuration files and can perform condition judgment at the same time, and each server process can be configured by performing condition judgment on the configuration files provided by the method, so that the debugging efficiency is improved.
Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. The objectives and other advantages of the invention will be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
In order to make the above objects, features and advantages of the present invention more comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings that are needed in the description of the embodiments or the prior art will be briefly described, and it is obvious that the drawings in the description below are some embodiments of the present invention, and other drawings can be obtained according to the drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a method for parsing a configuration file according to an embodiment of the present invention;
fig. 2 is a flowchart of resolving each line of data in a reading result of a configuration file in the resolving method of the configuration file according to the embodiment of the present invention;
FIG. 3 is a high-level parsing flow chart in a method for parsing a configuration file according to an embodiment of the present invention;
fig. 4 is a flowchart of reading a sub-configuration file included in a #include field in the method for analyzing a configuration file according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of an analysis system for a configuration file according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Icon:
501-a file reading module; 502-a file mapping module; 503-a file parsing module; a 101-processor; 102-memory; 103-bus; 104-communication interface.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
In the deployment process of the network game server, in order to enable the server application program to perform convenient and quick setting, a configuration file is generally used to set the server. If the server setting needs to be modified, only the configuration file needs to be modified. In addition, the same server application program can be set differently according to different requirements, and the configuration file can be used for conveniently carrying out the differentiated setting. The use of configuration files may also make debugging more efficient because of the convenient modification of the configuration files.
In the prior art, the commonly used configuration files include JSON files and XML files, JSON (JavaScript Object Notation ) is a lightweight data exchange format, and is a sequence of markers, where the set of markers includes six constructional characters, a character string, a number and three literal names. The JSON is used as a serialized object or array and is commonly used in a configuration file, but the configuration file in the JSON format cannot conveniently extract commonly used setting items in a plurality of configuration files as a file, if a common part is extracted, the file needs to be manually loaded at each place where the common setting items are needed when the JSON is used, and condition judgment cannot be performed in the configuration file in the JSON format.
XML (Extensible Markup Language ) is a markup language used to mark electronic files to be structured. XML can be used to mark data, define data types, and is a source language that allows users to define their own markup language. The XML can be used for sharing data, and the XML data is stored in a plain text format, so that the XML is easier to read, record and debug, and the data sharing between different systems and different programs is simpler. However, the configuration file in the XML format is complicated to write, the readability is poor, a large number of characters need to be written, the volume of the configuration file is relatively large, and the configuration file in the XML format cannot be subjected to condition judgment in the configuration file.
In view of the above problems in the existing configuration file parsing, the present invention aims to provide a method, a system and an electronic device for parsing a configuration file, where the technology can be applied to a server deployment process and can be implemented by using related software or hardware, and the following description is given by way of embodiments.
For the sake of understanding the present embodiment, first, a method for parsing a configuration file disclosed in the present embodiment is described in detail, and a flowchart of the method is shown in fig. 1, where the method includes:
step S101, reading the configuration file to be analyzed to obtain a reading result of the configuration file.
The configuration file implementation is already deployed in the game server, and the configuration file is typically deployed in a path fixed by the server, and files in the path are configuration files. Specifically, there are folders in the server with file names set or Settings, and the relevant configuration files are stored in these folders.
The process of reading the configuration file may be accomplished by a related tool, such as using a notepad program to open the configuration file and then directly obtain the contents of the configuration file. The obtained reading result of the configuration file can be used as data to be processed and can be stored in the computer content, so that the subsequent analysis operation can be conveniently executed.
Step S102, according to the reading result of the configuration file, mapping the object in the configuration file to obtain a mapping result.
The read result of the configuration file contains the attribute and the attribute value corresponding to the related objects in various server settings, and the attribute names in the objects are analyzed and mapped, so that the server related program can realize the setting and the access of the attribute value in the configuration file through the mapped attribute name character string.
The mapping process can be regarded as a process of providing an interface, and the attribute name corresponding to the object is used as a calling interface, so that the server directly calls the attribute name in the self program to obtain the attribute value of the configuration file.
Step S103, analyzing each row of data in the reading result of the configuration file to obtain an analysis result; and the analysis result is used for accessing the configuration file through the corresponding mapping result.
The result of reading the configuration files is various setting parameters of the server, and in general, the configuration files contain more data, and different attribute parameters are divided by symbols which are convenient to distinguish, such as semicolons, underlines and the like. Line breaks are typically used to distinguish when referring to the properties of different objects.
In this step, therefore, each line of data is parsed, and various sensitive character strings included in each line of data are parsed. For example, if the line data contains an identifier of the annotation line, indicating that the line data is annotated, then the annotation content is not parsed; if the line data contains the condition judgment symbol if or else, overall analysis is needed to be carried out on the context, so that the condition relation is completely characterized.
Specifically, the format of the configuration file can be a file format similar to a C language, a corresponding condition relation can be set in the configuration file, and in the process of analyzing the configuration file data, the data in the configuration file can be analyzed selectively according to the condition relation, so that the analysis efficiency of the configuration file can be improved.
In the analysis process of the configuration files, other configuration files can be combined and read according to the condition relation, so that the analysis efficiency is further improved. And the analysis results are in one-to-one correspondence with the mapping results obtained in the step S102, so that the access to the configuration file is realized.
As can be seen from the method for analyzing the configuration file according to the embodiment of the present invention, the method firstly reads the configuration file to be analyzed to obtain a reading result of the configuration file; and then, according to the reading result of the configuration file, mapping the object in the configuration file to obtain a mapping result. And analyzing each row of data in the reading result of the configuration file to obtain an analysis result, wherein the analysis result is used for accessing the configuration file through the corresponding mapping result. The method provides a configuration file analysis method which can contain other configuration files and can perform condition judgment at the same time, and each server process can be configured by performing condition judgment on the configuration files provided by the method, so that the debugging efficiency is improved.
In some embodiments, the above process of parsing each line of data in the read result of the configuration file, as shown in fig. 2, includes:
step S201, traversing the reading result of the configuration file to obtain all line-wrapping characters in the reading result of the configuration file.
The read result of the configuration file is typically stored in a computer memory, and the process of traversing the line connector in the read result can search the line connector through a related search function. The line-feed symbol is typically "/n" and will also take the form "\n", in particular the actual format of the configuration file.
Step S202, according to the line feed, each line of data in the reading result of the configuration file is obtained.
After the positions of the configuration files of all the line-changing symbols are obtained, the data between two adjacent line-changing symbols are intercepted, and the data of each line are extremely obtained. The first line data of the configuration file is directly obtained through the first line connector; the tail line data of the configuration file is directly obtained through the last line connector.
Step S203, performing primary parsing on each row of data in the read result of the configuration file.
The primary parsing does not involve specific business logic, such as determining whether the line data is an annotation or an empty line. In some embodiments, the primary parsing includes:
judging whether the line data are blank data or not, and if so, returning to the blank line type; if not, it is determined whether the line data is an annotation line.
If the line is the annotation line, returning the annotation line type; if not, the line data is parsed at a high level.
Step S204, data are subjected to advanced analysis according to the primary analysis result.
If the data is returned from the primary parsing result, this indicates that the relevant business logic operation is required in the data, and thus high-level parsing of the data is required.
The high-level analysis is to analyze by using a flow similar to the language C, and the high-level analysis operation is realized by adding a condition judgment logic.
As specifically shown in fig. 3, in some embodiments, the above-mentioned advanced parsing includes:
step S301, judging whether the line data is conditional compiling instruction data, if so, returning to the conditional compiling instruction type; if not, a macro substitution judging step is performed on the data.
The conditional compilation instruction is similar to the form of a common if-else, and in this configuration file, the form of the conditional compilation instruction may be set in advance, for example, in some embodiments, whether the line data is conditional compilation instruction data may be determined by determining whether any of #else, # endif, # ifdef, and #ifndef is included in the line data. If yes, returning to compile instruction type; if not, step S302 is performed.
Step S302, if the row data can be subjected to macro replacement, performing macro replacement operation; if the row data cannot be macro-replaced, a sub-profile operation is performed on the row data.
This step performs a macro replacement decision step for the data, and in some embodiments, the configuration file is in any of the C language or the c++ language. Macro substitution is part of the preprocessing of C/c++, with 4 rules in the c++ standard to define substitution.
Rule 1, substitution of real ginseng.
This rule describes the replacement process of a macro with parameters. For the arguments in the macro definition, in the substitution list, if not as an operand of # or # the corresponding argument is fully expanded (equivalent to evaluating the argument), and then the arguments in the substitution list are replaced. If it is an operand of # or # no replacement is performed.
Rule 2, multiple scans.
After all the shape parameters are replaced by real parameters. The result is scanned again, if an alternative macro is found, the alternative is performed, otherwise the process is stopped.
Rule 3, recursive substitution suppression.
Further, the names of macros that have been replaced are found in the nested replacement process, and no replacement is performed.
Rule 4, recursive preprocessing suppression.
If the replaced result forms a pre-processing instruction, then this pre-processing instruction is not executed.
If the data can be macro-replaced, performing macro-replacement operation; if the data cannot be macro-substituted, step S303 is performed on the data.
Step S303, judging whether the row data contains a # include field, if so, reading a sub-configuration file contained in the # include field; if not, a macro definition judgment step is performed on the data.
The step is sub-profile operation, in which whether the data need to be read from the sub-profile is determined by determining whether the field result of #include is included, if so, the sub-profile included in the #include field is read, and if not, step S304 is executed.
The step of reading the sub-configuration file included in the #include field, as shown in fig. 4, includes:
step S31, each row of data of the sub-configuration file is obtained.
In this step, each line of data obtained from the configuration file is the same as in steps S201 to S202, and the obtaining of the line of data is achieved by the interception of the line feed.
Step S32, carrying out primary analysis on each line of data of the sub configuration file.
Step S33, according to the primary analysis result, carrying out high-level analysis on each line of data of the sub configuration file.
The above procedure is the same as steps S203 and S204, and the sub-profile is read again in a recursive-like manner.
Step S304, if the row data contains a # definition field, storing the data after the # definition field as a macro; if the row data does not contain the # definition field, the judgment of the object statement is performed quickly.
The # definition field is typically used to determine whether it is a macro definition and, if so, stored as a macro. Compared with the traditional configuration file which can only be read and modified, the operation of storing the configuration file as a macro increases the storage process of relevant data in the analysis process of the configuration file, and further increases the flexibility of the analysis of the configuration file. If the #definition field is not included in the line data, step S305 is performed.
Step S305, if the line data is an object statement block, searching an object address in a mapping result; and if the line data is not the object statement block, performing an assignment statement judging step.
The determination of the object statement block is typically determined based on whether it is a set of "{ }" symbols, specifically if "{" is contained in the line data, the discovery result is temporarily marked until "}" is found in the subsequent line data, which is the object statement block. Then, the object name before "{" is obtained based on the previous mark. And obtaining the address of the object according to the mapping result after obtaining the object name. If the data is not the object statement block, step S306 is performed.
Step S306, if the row data is an assignment statement, searching for an attribute address according to the corresponding attribute name and assigning; if the row data is not an assignment statement, an error is prompted.
The judgment of the assignment statement is generally achieved by whether the "=" symbol is included or not, and may also be achieved by whether the "=" symbol is included or not. If the line data is an assignment statement, searching an attribute address according to the corresponding attribute name, and assigning the attribute; if the line data is not a duplicate statement, an error is prompted.
Through the series of processes, each line of data in the reading result of the configuration file is analyzed to obtain an analysis result, and the obtained analysis result is used for accessing the configuration file through the corresponding mapping result. After each line of data is analyzed, the next line of data is automatically executed until all the lines of data in the reading result of the configuration file are analyzed, and the analysis process of the configuration file is completed.
According to the embodiment, the method realizes the configuration file analysis process which comprises other configuration files and can perform condition judgment at the same time, and each server process can be configured by performing condition judgment on the configuration files provided by the method, so that the debugging efficiency is improved.
Corresponding to the embodiment of the method for parsing a configuration file, the present embodiment further provides a system for parsing a configuration file, as shown in fig. 5, where the system includes:
the file reading module 501 is configured to read a configuration file to be analyzed to obtain a reading result of the configuration file;
the file mapping module 502 is configured to map the objects in the configuration file according to the reading result of the configuration file, so as to obtain a mapping result;
a file parsing module 503, configured to parse each line of data in the read result of the configuration file to obtain a parsed result; and the analysis result is used for accessing the configuration file through the corresponding mapping result.
The analysis system of the configuration file provided by the embodiment of the invention has the same implementation principle and technical effects as those of the embodiment of the analysis method of the configuration file, and for the sake of brief description, the corresponding contents in the embodiment of the method can be referred to for the parts of the embodiment which are not mentioned.
The embodiment also provides an electronic device, and a schematic structural diagram of the electronic device is shown in fig. 6, where the device includes a processor 101 and a memory 102; the memory 102 is configured to store one or more computer instructions, where the one or more computer instructions are executed by the processor to implement the method for parsing a configuration file.
The server shown in fig. 6 further comprises a bus 103 and a communication interface 104, the processor 101, the communication interface 104 and the memory 102 being connected by the bus 103.
The memory 102 may include a high-speed random access memory (RAM, random Access Memory), and may further include a non-volatile memory (non-volatile memory), such as at least one magnetic disk memory. Bus 103 may be an ISA bus, a PCI bus, an EISA bus, or the like. The buses may be divided into address buses, data buses, control buses, etc. For ease of illustration, only one bi-directional arrow is shown in FIG. 6, but not only one bus or type of bus.
The communication interface 104 is configured to connect with at least one user terminal and other network units through a network interface, and send the encapsulated IPv4 message or the IPv4 message to the user terminal through the network interface.
The processor 101 may be an integrated circuit chip with signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware in the processor 101 or instructions in the form of software. The processor 101 may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU for short), a network processor (Network Processor, NP for short), etc.; but also digital signal processors (Digital Signal Processor, DSP for short), application specific integrated circuits (Application Specific Integrated Circuit, ASIC for short), field-programmable gate arrays (Field-Programmable Gate Array, FPGA for short) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The various methods, steps and logic blocks of the disclosure in the embodiments of the disclosure may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of a method disclosed in connection with the embodiments of the present disclosure may be embodied directly in hardware, in a decoded processor, or in a combination of hardware and software modules in a decoded processor. The software modules may be located in a random access memory, flash memory, read only memory, programmable read only memory, or electrically erasable programmable memory, registers, etc. as well known in the art. The storage medium is located in the memory 102, and the processor 101 reads information in the memory 102, and in combination with its hardware, performs the steps of the method of the previous embodiment.
The present invention also provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the method of the preceding embodiments.
In the several embodiments provided in this application, it should be understood that the disclosed systems, devices, and methods may be implemented in other ways. The above-described apparatus embodiments are merely illustrative, for example, the division of units is merely a logical function division, and there may be other manners of division in actual implementation, and for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be through some communication interface, indirect coupling or communication connection of devices or units, electrical, mechanical, or other form.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed over a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present invention may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a non-volatile computer readable storage medium executable by a processor. Based on this understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, a network device, etc.) to perform all or part of the steps of the method of the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
Finally, it should be noted that: the above examples are only specific embodiments of the present invention for illustrating the technical solution of the present invention, but not for limiting the scope of the present invention, and although the present invention has been described in detail with reference to the foregoing examples, it will be understood by those skilled in the art that the present invention is not limited thereto: any person skilled in the art may modify or easily conceive of the technical solution described in the foregoing embodiments, or perform equivalent substitution of some of the technical features, while remaining within the technical scope of the present disclosure; such modifications, changes or substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention, and are intended to be included in the scope of the present invention. Therefore, the protection scope of the invention is subject to the protection scope of the claims.

Claims (7)

1. A method for parsing a configuration file, the method comprising:
reading the configuration file to be analyzed to obtain a reading result of the configuration file;
according to the reading result of the configuration file, mapping the object in the configuration file to obtain a mapping result;
analyzing each row of data in the reading result of the configuration file to obtain an analysis result; the analysis result is used for accessing the configuration file through the corresponding mapping result;
the step of analyzing each line of data in the reading result of the configuration file to obtain an analysis result comprises the following steps:
traversing the reading result of the configuration file to obtain all line-wrapping symbols in the reading result of the configuration file;
obtaining each row of data in the reading result of the configuration file according to the line feed character;
performing primary analysis on each row of data in the reading result of the configuration file;
performing advanced analysis on the data according to the primary analysis result;
the primary parsing includes:
judging whether the data are null data or not;
if yes, returning to the blank line type; if not, judging whether the line data is an annotation line;
if yes, returning the annotation line type; if not, carrying out high-level analysis on the data;
the advanced parsing includes:
judging whether the data are conditional compiling instruction data or not, and if so, returning to the conditional compiling instruction type; if not, executing a macro substitution judging step on the data;
if the data can be macro-replaced, performing macro-replacement operation; if the data can not be macro-replaced, performing sub-profile operation on the data;
judging whether the line data contains a # include field, if so, reading a sub-configuration file contained in the # include field; if not, executing a macro definition judging step on the data;
if the row data contains a # definition field, storing the data after the # definition field as a macro; if the row data does not contain the # definition field, executing the fast judgment of the object statement;
if the data in the data are object statement blocks, searching an object address in the mapping result; if the line data is not the object statement block, carrying out an assignment statement judging step;
if the row data is an assignment statement, searching for an attribute address according to the corresponding attribute name and assigning the attribute address; if the data is not an assignment statement, an error is prompted.
2. The method of claim 1, wherein the configuration file is in any one of C language or c++ language.
3. The method of claim 1, wherein the step of determining whether the data is conditional compilation instruction data comprises:
it is determined whether any one of #else, # endif, # ifdef, and #ifndef is contained in the line data.
4. The method of claim 1, wherein the step of reading the sub-profile included after the #include field comprises:
obtaining data of each row of the sub-configuration file;
performing primary analysis on each row of data of the sub-configuration file;
and carrying out high-level analysis on each row of data of the sub-configuration file according to the primary analysis result.
5. A system for parsing a configuration file, the system comprising:
the file reading module is used for reading the configuration file to be analyzed to obtain a reading result of the configuration file;
the file mapping module is used for mapping the objects in the configuration file according to the reading result of the configuration file to obtain a mapping result;
the file analysis module is used for analyzing each line of data in the reading result of the configuration file to obtain an analysis result; the analysis result is used for accessing the configuration file through the corresponding mapping result;
the file analysis module is further configured to, in a process of analyzing each line of data in the read result of the configuration file to obtain an analysis result: traversing the reading result of the configuration file to obtain all line-wrapping symbols in the reading result of the configuration file; obtaining each row of data in the reading result of the configuration file according to the line feed character; performing primary analysis on each row of data in the reading result of the configuration file; performing advanced analysis on the data according to the primary analysis result;
the primary parsing in the file parsing module is further configured to: judging whether the data are null data or not; if yes, returning to the blank line type; if not, judging whether the line data is an annotation line; if yes, returning the annotation line type; if not, carrying out high-level analysis on the data;
the high-level parsing in the file parsing module is further configured to: judging whether the data are conditional compiling instruction data or not, and if so, returning to the conditional compiling instruction type; if not, executing a macro substitution judging step on the data; if the data can be macro-replaced, performing macro-replacement operation; if the data can not be macro-replaced, performing sub-profile operation on the data; judging whether the line data contains a # include field, if so, reading a sub-configuration file contained in the # include field; if not, executing a macro definition judging step on the data; if the row data contains a # definition field, storing the data after the # definition field as a macro; if the row data does not contain the # definition field, executing the fast judgment of the object statement; if the data in the data are object statement blocks, searching an object address in the mapping result; if the line data is not the object statement block, carrying out an assignment statement judging step; if the row data is an assignment statement, searching for an attribute address according to the corresponding attribute name and assigning the attribute address; if the data is not an assignment statement, an error is prompted.
6. An electronic device, comprising: a processor and a storage device; the storage means has stored thereon a computer program which, when executed by the processor, performs the method of any of claims 1 to 4.
7. A computer readable storage medium having stored thereon a computer program, characterized in that the computer program when executed by a processor performs the steps of the method of any of the preceding claims 1 to 4.
CN201911316226.1A 2019-12-18 2019-12-18 Method and system for analyzing configuration file and electronic equipment Active CN111124479B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911316226.1A CN111124479B (en) 2019-12-18 2019-12-18 Method and system for analyzing configuration file and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911316226.1A CN111124479B (en) 2019-12-18 2019-12-18 Method and system for analyzing configuration file and electronic equipment

Publications (2)

Publication Number Publication Date
CN111124479A CN111124479A (en) 2020-05-08
CN111124479B true CN111124479B (en) 2024-03-22

Family

ID=70500558

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911316226.1A Active CN111124479B (en) 2019-12-18 2019-12-18 Method and system for analyzing configuration file and electronic equipment

Country Status (1)

Country Link
CN (1) CN111124479B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111651406B (en) * 2020-05-21 2023-07-25 杭州明讯软件技术有限公司 Automatic carrier scheduling system file reading method and device
CN112764831A (en) * 2021-01-19 2021-05-07 中盈优创资讯科技有限公司 Configuration file analysis method and device based on user-defined extensible markup language
CN113190231A (en) * 2021-04-09 2021-07-30 大唐微电子技术有限公司 Attribute configuration file generation method and attribute configuration file analysis method
CN114338854A (en) * 2021-12-31 2022-04-12 中国银行股份有限公司 Message processing method and device

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7568152B1 (en) * 2000-07-14 2009-07-28 International Business Machines Corporation Text file interface support in an object oriented application
CN107992620A (en) * 2017-12-22 2018-05-04 武汉楚鼎信息技术有限公司 A kind of method and system device of json data Fast synchronization and record
CN109413131A (en) * 2018-04-28 2019-03-01 武汉思普崚技术有限公司 A kind of method and device of log parsing
CN109656813A (en) * 2018-11-21 2019-04-19 恒为科技(上海)股份有限公司 A kind of test case operation method and device
CN109670081A (en) * 2018-12-28 2019-04-23 中国银行股份有限公司 The method and device of service request processing
CN109947711A (en) * 2018-08-22 2019-06-28 重庆金康特智能穿戴技术研究院有限公司 A kind of multilingual file automating management method in pair of IOS project development process
WO2019148671A1 (en) * 2018-01-30 2019-08-08 平安科技(深圳)有限公司 Xml file parsing method, device, computer apparatus, and storage medium

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7062551B2 (en) * 2001-05-24 2006-06-13 International Business Machines Corporation Method and apparatus to solve compatibility between heterogeneous web server access logs formats
EP1911029A2 (en) * 2005-07-22 2008-04-16 Koninklijke Philips Electronics N.V. Method and apparatus of controlling playback of an optical disc program
US10176273B2 (en) * 2014-08-27 2019-01-08 Verizon Patent And Licensing Inc. Big data parser

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7568152B1 (en) * 2000-07-14 2009-07-28 International Business Machines Corporation Text file interface support in an object oriented application
CN107992620A (en) * 2017-12-22 2018-05-04 武汉楚鼎信息技术有限公司 A kind of method and system device of json data Fast synchronization and record
WO2019148671A1 (en) * 2018-01-30 2019-08-08 平安科技(深圳)有限公司 Xml file parsing method, device, computer apparatus, and storage medium
CN109413131A (en) * 2018-04-28 2019-03-01 武汉思普崚技术有限公司 A kind of method and device of log parsing
CN109947711A (en) * 2018-08-22 2019-06-28 重庆金康特智能穿戴技术研究院有限公司 A kind of multilingual file automating management method in pair of IOS project development process
CN109656813A (en) * 2018-11-21 2019-04-19 恒为科技(上海)股份有限公司 A kind of test case operation method and device
CN109670081A (en) * 2018-12-28 2019-04-23 中国银行股份有限公司 The method and device of service request processing

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
戴树唯 ; 征容 ; .基于公共信息模型的数据映射工具.通信与信息技术.2016,(02),全文. *
赵文 ; .基于内存映射文件的海量点云数据快速读取方法.铁路计算机应用.2017,(06),全文. *

Also Published As

Publication number Publication date
CN111124479A (en) 2020-05-08

Similar Documents

Publication Publication Date Title
CN111124479B (en) Method and system for analyzing configuration file and electronic equipment
US11048798B2 (en) Method for detecting libraries in program binaries
CN108427731B (en) Page code processing method and device, terminal equipment and medium
CN103853650A (en) Test case generating method and device for fuzz testing
CN103294598A (en) Method and device for source code inspection
EP3682324A1 (en) Method and apparatus for finding long methods in code
CN110096264A (en) A kind of code operation method and device
CN108664471A (en) Text region error correction method, device, equipment and computer readable storage medium
US20230315416A1 (en) Code translation method and apparatus, and device
CN110069736A (en) Page loading method and equipment
US10823782B2 (en) Ensuring completeness of interface signal checking in functional verification
CN108427580A (en) Configure detection method, storage medium and the smart machine repeated to name
CN110716866A (en) Code quality scanning method and device, computer equipment and storage medium
CN113805861B (en) Code generation method based on machine learning, code editing system and storage medium
CN112069052A (en) Abnormal object detection method, device, equipment and storage medium
CN111444456B (en) Style editing method and device and electronic equipment
EP3692456A1 (en) Binary image stack cookie protection
CN109783134B (en) Front-end page configuration method and device and electronic equipment
CN113760291A (en) Log output method and device
CN110737431B (en) Software development method, development platform, terminal device and storage medium
CN113760249A (en) Program file processing method, device and equipment
CN113408250B (en) Project file processing method and device
CN110244954A (en) A kind of Compilation Method and equipment of application program
CN116069633B (en) Code checking method and device, electronic equipment and storage medium
CN113946347A (en) Function call detection method and device, electronic equipment and readable 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
GR01 Patent grant
GR01 Patent grant