CN114756183A - Data printing method, device, equipment and storage medium - Google Patents

Data printing method, device, equipment and storage medium Download PDF

Info

Publication number
CN114756183A
CN114756183A CN202210678150.2A CN202210678150A CN114756183A CN 114756183 A CN114756183 A CN 114756183A CN 202210678150 A CN202210678150 A CN 202210678150A CN 114756183 A CN114756183 A CN 114756183A
Authority
CN
China
Prior art keywords
code
printing
converted
syntax tree
abstract syntax
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210678150.2A
Other languages
Chinese (zh)
Inventor
廖宏军
张宇翔
冯建设
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Xinrun Fulian Digital Technology Co Ltd
Original Assignee
Shenzhen Xinrun Fulian Digital 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 Shenzhen Xinrun Fulian Digital Technology Co Ltd filed Critical Shenzhen Xinrun Fulian Digital Technology Co Ltd
Priority to CN202210678150.2A priority Critical patent/CN114756183A/en
Publication of CN114756183A publication Critical patent/CN114756183A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/12Digital output to print unit, e.g. line printer, chain printer
    • G06F3/1201Dedicated interfaces to print systems
    • G06F3/1202Dedicated interfaces to print systems specifically adapted to achieve a particular effect
    • G06F3/1203Improving or facilitating administration, e.g. print management
    • G06F3/1206Improving or facilitating administration, e.g. print management resulting in increased flexibility in input data format or job format or job type
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/3624Software debugging by performing operations on the source code, e.g. via a compiler
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/12Digital output to print unit, e.g. line printer, chain printer
    • G06F3/1201Dedicated interfaces to print systems
    • G06F3/1223Dedicated interfaces to print systems specifically adapted to use a particular technique
    • G06F3/1237Print job management
    • G06F3/1253Configuration of print job parameters, e.g. using UI at the client
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis

Abstract

The invention discloses a data printing method, a data printing device, data printing equipment and a storage medium. The method comprises the following steps: acquiring a printing code to be converted in an initial abstract syntax tree of a source code to be processed; printing format conversion is carried out on the printing codes to be converted in the initial abstract syntax tree to obtain a target abstract syntax tree; and generating a target source code according to the target abstract syntax tree, and printing data according to the target source code so as to identify variable data corresponding to the code to be converted and printed. The printing format conversion is carried out on the printing codes to be converted in the initial abstract syntax tree to obtain a target abstract syntax tree; and printing data according to the target source code generated by the target abstract syntax tree. Compared with the existing mode that printing information in the code is displayed on a console when the code is debugged and a tester is relied on to distinguish the printed variable information, the mode provided by the invention can identify the printed variable data, thereby improving the code debugging efficiency.

Description

Data printing method, device, equipment and storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a data printing method, apparatus, device, and storage medium.
Background
When developing and debugging, a front-end development engineer often uses a method of printing a log to see the value of a variable in a console. When the console has a plurality of variables to print, it is not easy to tell which variable the printed value corresponds to. Some codes can update and refresh data every second, a large amount of printing information can appear on the console, so that testers can not clearly distinguish variable information printed by the console, the difficulty of code debugging is increased, and the efficiency of code debugging is reduced.
The above is only for the purpose of assisting understanding of the technical solution of the present invention, and does not represent an admission that the above is the prior art.
Disclosure of Invention
The invention mainly aims to provide a data printing method, a data printing device, data printing equipment and a data printing storage medium, and aims to solve the technical problems that in the prior art, when the printing information of a control console is too much, testers cannot easily distinguish the variable information printed by the control console, the difficulty of code debugging is increased, and the code debugging efficiency is reduced.
To achieve the above object, the present invention provides a data printing method, including the steps of:
acquiring a printing code to be converted in an initial abstract syntax tree of a source code to be processed;
Performing printing format conversion on the printing codes to be converted in the initial abstract syntax tree to obtain a target abstract syntax tree;
and generating a target source code according to the target abstract syntax tree, and printing data according to the target source code so as to identify variable data corresponding to the printing code to be converted.
Optionally, the step of obtaining the print code to be converted in the initial abstract syntax tree of the source code to be processed includes:
acquiring an initial abstract syntax tree of a source code to be processed;
identifying the code type of each code in the initial abstract syntax tree;
and when the code type is a preset code type, determining that the code is a printing code to be converted, wherein the preset code type comprises CallExpression or MemberExpression.
Optionally, the step of performing print format conversion on the print code to be converted in the initial abstract syntax tree to obtain a target abstract syntax tree includes:
identifying code attributes corresponding to the printing codes to be converted in the initial abstract syntax tree;
and performing printing format conversion on the printing code to be converted according to the code attribute and a preset printing format conversion strategy to obtain a target abstract syntax tree.
Optionally, after the step of obtaining the print code to be converted in the initial abstract syntax tree of the source code to be processed, the method further includes:
judging whether the printing code to be converted is a preset abbreviated code or not;
when the printing code to be converted is the preset abbreviated code, completing the code of the printing code to be converted;
and updating the initial abstract syntax tree according to the completed printing code to be converted.
Optionally, after the step of identifying the code attribute corresponding to the print code to be converted in the initial abstract syntax tree, the method further includes:
judging whether the code attribute is a preset custom attribute or not;
when the code attribute is the preset custom attribute, acquiring code completion information corresponding to the code attribute;
and performing code completion on the printing code to be converted according to the code completion information.
Optionally, before the step of determining whether the code attribute is a preset custom attribute, the method further includes:
acquiring data printing grammar information set by a user;
and determining preset custom attributes according to the data printing grammar information.
Optionally, before the step of obtaining the print code to be converted in the initial abstract syntax tree of the source code to be processed, the method further includes:
Acquiring an environment variable set by a user;
and when the environment variable is print prohibition data, not converting the printing format of the source code to be processed.
Further, to achieve the above object, the present invention also provides a data printing apparatus comprising:
the acquisition module is used for acquiring the printing codes to be converted in the initial abstract syntax tree of the source codes to be processed;
the conversion module is used for performing printing format conversion on the printing codes to be converted in the initial abstract syntax tree to obtain a target abstract syntax tree;
and the data printing module is used for generating a target source code according to the target abstract syntax tree and printing data according to the target source code so as to identify the variable data corresponding to the printing code to be converted.
Further, to achieve the above object, the present invention also proposes a data printing apparatus comprising: a memory, a processor and a data printing program stored on the memory and executable on the processor, the data printing program being configured to implement the steps of the data printing method as described above.
Furthermore, to achieve the above object, the present invention also proposes a storage medium having stored thereon a data printing program which, when executed by a processor, implements the steps of the data printing method as described above.
The method comprises the steps of obtaining a printing code to be converted in an initial abstract syntax tree of a source code to be processed; performing printing format conversion on the printing codes to be converted in the initial abstract syntax tree to obtain a target abstract syntax tree; and generating a target source code according to the target abstract syntax tree, and printing data according to the target source code so as to identify variable data corresponding to the printing code to be converted. The invention carries out printing format conversion on the printing codes to be converted in the initial abstract syntax tree to obtain a target abstract syntax tree; and generating a target source code according to the target abstract syntax tree, and printing data according to the target source code so as to identify variable data corresponding to the code to be converted and printed. Compared with the existing mode that a large amount of printing information in the code is displayed on a console when the code is debugged and a tester is relied on to distinguish variable information corresponding to the printed variable value, the mode disclosed by the invention can identify the printed variable data and improve the debugging efficiency of the code.
Drawings
FIG. 1 is a schematic diagram of a data printing apparatus in a hardware operating environment according to an embodiment of the present invention;
FIG. 2 is a schematic flow chart of a first embodiment of a data printing method according to the present invention;
FIG. 3 is a schematic flow chart of a data printing method according to a second embodiment of the present invention;
FIG. 4 is a schematic flow chart of a data printing method according to a third embodiment of the present invention;
fig. 5 is a block diagram showing the configuration of the first embodiment of the data printing apparatus of the present invention.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
Referring to fig. 1, fig. 1 is a schematic structural diagram of a data printing apparatus in a hardware operating environment according to an embodiment of the present invention.
As shown in fig. 1, the data printing apparatus may include: a processor 1001, such as a Central Processing Unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Wherein a communication bus 1002 is used to enable connective communication between these components. The user interface 1003 may include a Display screen (Display), an input unit such as a Keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface, a wireless interface. The network interface 1004 may optionally include a standard wired interface, a Wireless interface (e.g., a Wireless-Fidelity (WI-FI) interface). The Memory 1005 may be a Random Access Memory (RAM) or a Non-Volatile Memory (NVM), such as a disk Memory. The memory 1005 may alternatively be a storage device separate from the processor 1001.
Those skilled in the art will appreciate that the configuration shown in fig. 1 does not constitute a limitation of the data printing apparatus and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components.
As shown in fig. 1, a memory 1005, which is a kind of storage medium, may include therein an operating system, a network communication module, a user interface module, and a data printing program.
In the data printing apparatus shown in fig. 1, the network interface 1004 is mainly used for data communication with a network server; the user interface 1003 is mainly used for data interaction with a user; the processor 1001 and the memory 1005 in the data printing apparatus of the present invention may be provided in a data printing apparatus that calls a data printing program stored in the memory 1005 through the processor 1001 and executes a data printing method provided by an embodiment of the present invention.
Based on the data printing device, an embodiment of the present invention provides a data printing method, and referring to fig. 2, fig. 2 is a flowchart illustrating a first embodiment of the data printing method according to the present invention.
In this embodiment, the data printing method includes the steps of:
step S10: and acquiring the printing code to be converted in the initial abstract syntax tree of the source code to be processed.
It should be noted that the execution subject of the embodiment may be a computing service device with data processing, network communication and program running functions, such as a mobile phone, a tablet computer, a personal computer, etc., or an electronic device or a data printing plug-in capable of implementing the above functions. The present embodiment and the following embodiments will be described below by taking the data print plug-in as an example.
It should be noted that the source code to be processed may be a code that needs to be debugged according to variable information printed on the console, for example, when a tester needs to debug the source code a, it may be determined that the source code a is the source code to be processed when the tester needs to run according to the source code a and debugs variable data printed on the console. The initial abstract syntax tree may be a syntax tree corresponding to the source code to be processed. The printing code to be converted can be a code for printing data in an initial abstract syntax tree of the source code to be processed. For example, the source code to be processed includes a code console.log (name), and the console.log (name) outputs a variable value corresponding to the name in the console when the code is executed. Log (name) is a code which needs to be converted into a printing format, namely a printing code to be converted.
It should be understood that an Abstract Syntax Tree (AST), or Syntax Tree for short (Syntax Tree), is an Abstract representation of the Syntax structure of the source code, which represents the Syntax structure of the programming language in the form of a Tree, with each node on the Tree representing a structure in the source code.
Further, when the code debugging is completed or the debugging is not required, it is not required to print the variable value on the console, and at this time, in order to reasonably control the resource overhead of the program operation, the printing format conversion may not be performed on the source code to be processed, so before step S10, the method further includes: acquiring an environment variable set by a user; and when the environment variable is print prohibition data, not converting the printing format of the source code to be processed.
It should be noted that the environment variable may be environment setting information set by the user based on the data printing plug-in, and when the environment variable is print-prohibited data, the data printing plug-in does not perform print format conversion on the source code to be processed. For example, the following code may be set in the data print plug-in: process.env.xxx = = = = = 'levelment'
Figure 431022DEST_PATH_IMAGE001
['babel-plugin-log'] : []And the data printing plug-in does not convert the printing format of the source code to be processed.
Further, in order to improve the development efficiency of the developer, after the step S10, the method further includes determining whether the print code to be converted is a preset abbreviated code; when the printing code to be converted is the preset abbreviated code, completing the code of the printing code to be converted; and updating the initial abstract syntax tree according to the completed printing code to be converted.
It should be noted that the preset abbreviated code may be a preset code that may not need to write its complete name completely in the development process, which may improve the development efficiency of the developer, and the developer may directly adopt the abbreviation when developing the code, for example, for the code console. Because the type of the abbreviated code is the same as that of the code when the code is not abbreviated in the initial abstract syntax tree, when the printing format of the code to be converted and printed is converted by the data printing plug-in of the embodiment, the preset abbreviated code can be identified and can be subjected to code completion according to a preset abbreviated code table; and updating the initial abstract syntax tree according to the completed printing code to be converted. The preset abbreviated code table may be a comparison table storing preset abbreviated codes and corresponding complete codes.
Step S20: and performing printing format conversion on the printing codes to be converted in the initial abstract syntax tree to obtain a target abstract syntax tree.
It should be noted that, the converting the print format of the print code to be converted in the initial abstract syntax tree may be converting the print code to be converted into a code in a preset format, for example, converting log () into console. When the code in the preset format is used for printing the variable, the variable can be subjected to identification printing, for example, the name of the variable is added in front of the variable during variable printing, or the printed variable is subjected to thickening and deepening printing.
Step S30: and generating a target source code according to the target abstract syntax tree, and printing data according to the target source code so as to identify variable data corresponding to the printing code to be converted.
It should be noted that the target source code may be a code generated according to the target abstract syntax tree, and when executed, the target source code may print the variables included in the target abstract syntax tree and printed on the console according to a preset format, for example, color deepening, font enlarging, and the like. The variable data can be variables which need to be printed on a control console when a tester debugs. The identification of the variable data corresponding to the print code to be converted may be to perform thickening printing on the printed variable data, or to add a name of a variable in front when printing the variable.
The embodiment acquires the printing code to be converted in the initial abstract syntax tree of the source code to be processed; performing printing format conversion on the printing codes to be converted in the initial abstract syntax tree to obtain a target abstract syntax tree; and generating a target source code according to the target abstract syntax tree, and printing data according to the target source code so as to identify variable data corresponding to the printing code to be converted. In the embodiment, the printing format of the printing code to be converted in the initial abstract syntax tree is converted to obtain a target abstract syntax tree; and generating a target source code according to the target abstract syntax tree, and printing data according to the target source code so as to identify variable data corresponding to the code to be converted and printed. Compared with the existing mode that a large amount of printing information in the code is displayed on the console when the code is debugged and a tester is relied on to distinguish variable information corresponding to the printed variable value, the method can identify the printed variable data, and improves the code debugging efficiency.
Referring to fig. 3, fig. 3 is a schematic flow chart of a data printing method according to a second embodiment of the present invention.
Based on the first embodiment described above, in the present embodiment, the step S10 includes:
step S101: obtaining an initial abstract syntax tree of a source code to be processed
Step S102: code types of codes in the initial abstract syntax tree are identified.
It should be noted that, as can be seen from the initial abstract syntax tree, the type of container.log () in the initial abstract syntax tree is call expression, and the type of call is MemberExpression. Members of the MemberExpression can include a console and a log, wherein the argument called by the method of the console is an alignment array, so that the effect of enabling a printing result to have identification information when data printing is carried out can be realized only by inserting a preset character string node into the alignment, and the identification information can be obtained by adding the name of a variable when the variable is printed or enabling the variable to be printed according to a preset color, font or font size.
Step S103: and when the code type is a preset code type, determining that the code is a printing code to be converted, wherein the preset code type comprises CallExpression or MemberExpression.
It should be noted that the preset code type may be a code of a variable printed at the console or a code of a method in the initial abstract syntax tree, for example, a code of a method console () of a variable printed at the console in the initial abstract syntax tree is callexpress. When the code type in the initial abstract syntax tree is callexpress or memberexpress, it is known that the corresponding code is the code for printing variables in the console. Accordingly, it may be determined that the code is the print code to be converted when the code type is a preset code type.
The embodiment obtains an initial abstract syntax tree of a source code to be processed; identifying the code type of each code in the initial abstract syntax tree; and when the code type is a preset code type, determining that the code is a printing code to be converted, wherein the preset code type comprises CallExpression or MemberExpression. In the embodiment, the code type in the initial abstract syntax tree is identified to obtain the printing code to be converted, so that the printing format conversion of the printing code to be converted can be further performed, the variable needing to be printed and output on the console can be distinguished by testers more easily, and the debugging efficiency of the prompt code of the testers is improved.
Referring to fig. 4, fig. 4 is a flowchart illustrating a data printing method according to a third embodiment of the present invention.
Based on the foregoing embodiments, in this embodiment, the step S20 includes:
step S201: and identifying the code attribute corresponding to the printing code to be converted in the initial abstract syntax tree.
It should be noted that the code attribute may be an attribute value corresponding to the print code to be converted, for example, when the print code to be converted is console, the corresponding attribute value may be log, info, war, error, debug, or the like.
Further, in order to make the identifier corresponding to the printed variable be the identifier specified by the developer, so as to improve the debugging efficiency, after step S201, the method further includes: judging whether the code attribute is a preset custom attribute or not; when the code attribute is the preset custom attribute, acquiring code completion information corresponding to the code attribute; and performing code completion on the printing code to be converted according to the code completion information.
It should be noted that the preset custom attribute may be a preset attribute value corresponding to a custom code, for example, a preset custom code logRed. The corresponding code completion information may be that the color of the output variable is red when the variable is printed, and then the code completion of the code to be converted according to the code completion information may be that the code logRed is completed to be console.
Further, in order to diversify the identifier of the printed variable, before the step of determining whether the code attribute is a preset custom attribute, the method further includes: acquiring data printing grammar information set by a user; and determining preset custom attributes according to the data printing grammatical information.
It should be noted that the data printing syntax information may include a custom code set by a user, its corresponding code completion information, and corresponding attribute information. The custom attribute of the custom code and the code completion information corresponding to the custom code can be determined according to the data printing grammar information, and the preset custom attribute is generated according to the custom attribute of the custom code.
Step S202: and performing printing format conversion on the printing code to be converted according to the code attribute and a preset printing format conversion strategy to obtain a target abstract syntax tree.
It should be noted that the preset print format conversion policy may be a final print effect corresponding to each code attribute, for example, if the code attribute is war, the preset print format conversion policy may be that a variable printed by a code with the code attribute of war is represented by a red-bold font. If the code attribute is log, the preset print format conversion policy may be that a variable printed by the code having the code attribute log is represented by a gray color, and the name of the printed variable is added in front of the variable. The performing of the print format conversion on the print code to be converted according to the code attribute and the preset print format conversion policy may be searching for a print policy corresponding to the code attribute in the preset print format conversion policy according to the code attribute, and performing the print format conversion on the print code to be converted according to the print policy.
In a specific implementation, in order to make it easier for a tested person to distinguish the variable names corresponding to the variable values printed on the console, the syntax can be used for: the syntax above can convert the code console.log (name) into the code console.log ('name = = = >', name) by adding the corresponding variable name to the variable information printed out by the console, and if the value corresponding to the variable name is 123, the corresponding value output by the console is changed from "123" to "name = = = = = = = = = > 123"
In a specific implementation, the code in the data printing plug-in converting the log () code into the code console. function transform mcustomlogcall (node) ready opening
const callee = types.memberExpression({
object: types.identifier({name: 'console'}),
property: types.identifier({name: 'log'})})
node.callee = callee}
The code that converts logRed () code to console. log () and displays red color may refer to the following code:
function transformCustomLogRedCall(node) {
transformCustomLogCall(node)
node.arguments.push('color: red;')
}
const visitor = {
CallExpression(nodePath, state) {
const { node } = nodePath;
if (types.isMemberExpression(node.callee)) {
v/adding variable names while printing
if (node.callee.object.name === 'console') {
if (['log', 'info', 'warn', 'error', 'debug'].includes(node.callee.property.name)) {
node.arguments = disposeArguments(node.arguments);
}}}
If it is a function call and the function name is log
if(types.isCallExpression(node) && node.callee.name === 'log'){
function transformCustomLogCall(node)
}
If it is a function call and the function name is logRed
if(types.isCallExpression(node) && node.callee.name === 'logRed'){
function transformCustomLogRedCall(node)
}}}
The embodiment identifies the code attribute corresponding to the printing code to be converted in the initial abstract syntax tree; and performing printing format conversion on the printing code to be converted according to the code attribute and a preset printing format conversion strategy to obtain a target abstract syntax tree. In this embodiment, the print format of the print code to be converted is converted according to the code attribute corresponding to the print code to be converted and a preset print format conversion policy, so as to obtain a target abstract syntax tree. The variable finally printed by the printing codes to be converted with different code attributes can display different marking information, and debugging efficiency of testers is improved.
Referring to fig. 5, fig. 5 is a block diagram showing the configuration of the first embodiment of the data printing apparatus according to the present invention.
As shown in fig. 5, a data printing apparatus according to an embodiment of the present invention includes:
an obtaining module 10, configured to obtain a print code to be converted in an initial abstract syntax tree of a source code to be processed;
a conversion module 20, configured to perform print format conversion on the print code to be converted in the initial abstract syntax tree, so as to obtain a target abstract syntax tree;
and the data printing module 30 is configured to generate a target source code according to the target abstract syntax tree, and print data according to the target source code, so as to identify variable data corresponding to the print code to be converted.
The embodiment acquires the printing code to be converted in the initial abstract syntax tree of the source code to be processed; performing printing format conversion on the printing codes to be converted in the initial abstract syntax tree to obtain a target abstract syntax tree; and generating a target source code according to the target abstract syntax tree, and printing data according to the target source code so as to identify variable data corresponding to the printing code to be converted. In the embodiment, the printing format of the printing code to be converted in the initial abstract syntax tree is converted to obtain a target abstract syntax tree; and generating a target source code according to the target abstract syntax tree, and printing data according to the target source code so as to identify variable data corresponding to the code to be converted and printed. Compared with the existing mode that a large amount of printing information in the code is displayed on the console when the code is debugged and a tester is relied on to distinguish variable information corresponding to the printed variable value, the mode can identify the printed variable data, and the code debugging efficiency is improved.
It should be noted that the above-mentioned work flows are only illustrative and do not limit the scope of the present invention, and in practical applications, those skilled in the art may select some or all of them according to actual needs to implement the purpose of the solution of the present embodiment, and the present invention is not limited herein.
In addition, the technical details that are not described in detail in this embodiment can be referred to the data printing method provided in any embodiment of the present invention, and are not described herein again.
A second embodiment of the data printing apparatus of the present invention is proposed based on the above-described first embodiment of the data printing apparatus of the present invention.
In this embodiment, the obtaining module 10 is further configured to obtain an initial abstract syntax tree of a source code to be processed; identifying the code type of each code in the initial abstract syntax tree; and when the code type is a preset code type, determining that the code is a printing code to be converted, wherein the preset code type comprises CallExpression or MemberExpression.
Further, the conversion module 20 is further configured to identify a code attribute corresponding to the print code to be converted in the initial abstract syntax tree; and performing printing format conversion on the printing code to be converted according to the code attribute and a preset printing format conversion strategy to obtain a target abstract syntax tree.
Further, the obtaining module 10 is further configured to determine whether the print code to be converted is a preset abbreviated code; when the printing code to be converted is the preset abbreviated code, completing the code of the printing code to be converted; and updating the initial abstract syntax tree according to the completed printing code to be converted.
Further, the conversion module 20 is further configured to determine whether the code attribute is a preset custom attribute; when the code attribute is the preset custom attribute, acquiring code completion information corresponding to the code attribute; and performing code completion on the printing code to be converted according to the code completion information.
Further, the conversion module 20 is further configured to obtain data printing syntax information set by a user; and determining preset custom attributes according to the data printing grammar information.
Further, the obtaining module 10 is further configured to obtain an environment variable set by a user; and when the environment variable is print prohibition data, not converting the printing format of the source code to be processed.
Other embodiments or specific implementation manners of the data printing apparatus of the present invention may refer to the above method embodiments, and are not described herein again.
Furthermore, an embodiment of the present invention further provides a storage medium, where the storage medium stores a data printing program, and the data printing program, when executed by a processor, implements the steps of the data printing method as described above.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., a rom/ram, a magnetic disk, an optical disk) and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present invention.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

Claims (10)

1. A data printing method, characterized by comprising the steps of:
acquiring a printing code to be converted in an initial abstract syntax tree of a source code to be processed;
performing printing format conversion on the printing codes to be converted in the initial abstract syntax tree to obtain a target abstract syntax tree;
and generating a target source code according to the target abstract syntax tree, and printing data according to the target source code so as to identify variable data corresponding to the printing code to be converted.
2. The data printing method according to claim 1, wherein the step of obtaining the print code to be converted in the initial abstract syntax tree of the source code to be processed comprises:
acquiring an initial abstract syntax tree of a source code to be processed;
identifying the code type of each code in the initial abstract syntax tree;
And when the code type is a preset code type, determining that the code is a printing code to be converted, wherein the preset code type comprises CallExpression or MemberExpression.
3. The data printing method according to claim 2, wherein the step of performing print format conversion on the print code to be converted in the initial abstract syntax tree to obtain a target abstract syntax tree comprises:
identifying code attributes corresponding to the printing codes to be converted in the initial abstract syntax tree;
and performing printing format conversion on the printing code to be converted according to the code attribute and a preset printing format conversion strategy to obtain a target abstract syntax tree.
4. The data printing method according to claim 3, wherein after the step of obtaining the print code to be converted in the initial abstract syntax tree of the source code to be processed, further comprising:
judging whether the printing code to be converted is a preset abbreviated code or not;
when the printing code to be converted is the preset abbreviated code, performing code completion on the printing code to be converted;
and updating the initial abstract syntax tree according to the completed printing code to be converted.
5. The data printing method according to claim 3, wherein after the step of identifying the code attributes corresponding to the print code to be converted in the initial abstract syntax tree, further comprising:
judging whether the code attribute is a preset custom attribute or not;
when the code attribute is the preset custom attribute, acquiring code completion information corresponding to the code attribute;
and performing code completion on the printing code to be converted according to the code completion information.
6. The data printing method of claim 5, wherein the step of determining whether the code attribute is a preset custom attribute further comprises, before the step of determining whether the code attribute is a preset custom attribute:
acquiring data printing grammar information set by a user;
and determining preset custom attributes according to the data printing grammar information.
7. A method for printing data as claimed in any one of claims 1 to 6 wherein, prior to said step of obtaining the print code to be translated in the initial abstract syntax tree of the source code to be processed, it further comprises:
acquiring an environment variable set by a user;
and when the environment variable is print prohibition data, not converting the printing format of the source code to be processed.
8. A data printing apparatus, characterized in that the data printing apparatus comprises:
the acquisition module is used for acquiring the printing code to be converted in the initial abstract syntax tree of the source code to be processed;
the conversion module is used for performing printing format conversion on the printing codes to be converted in the initial abstract syntax tree to obtain a target abstract syntax tree;
and the data printing module is used for generating a target source code according to the target abstract syntax tree and printing data according to the target source code so as to identify the variable data corresponding to the printing code to be converted.
9. A data printing apparatus, characterized in that the apparatus comprises: memory, a processor and a data printing program stored on the memory and executable on the processor, the data printing program being configured to implement the steps of the data printing method as claimed in any one of claims 1 to 7.
10. A storage medium having stored thereon a data printing program which, when executed by a processor, implements the steps of the data printing method according to any one of claims 1 to 7.
CN202210678150.2A 2022-06-16 2022-06-16 Data printing method, device, equipment and storage medium Pending CN114756183A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210678150.2A CN114756183A (en) 2022-06-16 2022-06-16 Data printing method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210678150.2A CN114756183A (en) 2022-06-16 2022-06-16 Data printing method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114756183A true CN114756183A (en) 2022-07-15

Family

ID=82336221

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210678150.2A Pending CN114756183A (en) 2022-06-16 2022-06-16 Data printing method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114756183A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115509514A (en) * 2022-11-23 2022-12-23 济南浪潮数据技术有限公司 Front-end data simulation method, device, equipment and medium

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140282373A1 (en) * 2013-03-15 2014-09-18 Trinity Millennium Group, Inc. Automated business rule harvesting with abstract syntax tree transformation
US20170139690A1 (en) * 2015-11-16 2017-05-18 Sap Se Universal transcompiling framework
CN108959199A (en) * 2018-06-28 2018-12-07 武汉斗鱼网络科技有限公司 A kind of log highlights method, apparatus, storage medium and android terminal
CN111249736A (en) * 2020-01-16 2020-06-09 网易(杭州)网络有限公司 Code processing method and device
CN112685308A (en) * 2020-12-30 2021-04-20 平安普惠企业管理有限公司 Front-end code debugging method and device, computer equipment and computer storage medium
CN113076167A (en) * 2021-04-21 2021-07-06 杭州涂鸦信息技术有限公司 Code processing method and related equipment
CN113760291A (en) * 2020-09-16 2021-12-07 北京沃东天骏信息技术有限公司 Log output method and device
CN114327614A (en) * 2021-12-29 2022-04-12 苏州盛科通信股份有限公司 Method and application for recording and analyzing data flow of reference model
CN114356257A (en) * 2022-03-04 2022-04-15 平安商业保理有限公司 Log printing method, apparatus, computer device, storage medium, and program product
CN114579136A (en) * 2022-03-03 2022-06-03 网易(杭州)网络有限公司 Code processing method and device, computer equipment and storage medium

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140282373A1 (en) * 2013-03-15 2014-09-18 Trinity Millennium Group, Inc. Automated business rule harvesting with abstract syntax tree transformation
US20170139690A1 (en) * 2015-11-16 2017-05-18 Sap Se Universal transcompiling framework
CN108959199A (en) * 2018-06-28 2018-12-07 武汉斗鱼网络科技有限公司 A kind of log highlights method, apparatus, storage medium and android terminal
CN111249736A (en) * 2020-01-16 2020-06-09 网易(杭州)网络有限公司 Code processing method and device
CN113760291A (en) * 2020-09-16 2021-12-07 北京沃东天骏信息技术有限公司 Log output method and device
CN112685308A (en) * 2020-12-30 2021-04-20 平安普惠企业管理有限公司 Front-end code debugging method and device, computer equipment and computer storage medium
CN113076167A (en) * 2021-04-21 2021-07-06 杭州涂鸦信息技术有限公司 Code processing method and related equipment
CN114327614A (en) * 2021-12-29 2022-04-12 苏州盛科通信股份有限公司 Method and application for recording and analyzing data flow of reference model
CN114579136A (en) * 2022-03-03 2022-06-03 网易(杭州)网络有限公司 Code processing method and device, computer equipment and storage medium
CN114356257A (en) * 2022-03-04 2022-04-15 平安商业保理有限公司 Log printing method, apparatus, computer device, storage medium, and program product

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
刘羽冲: "AST抽象语法树——最基础的javascript重点知识,99%的人根本不了解", 《HTTPS://SEGMENTFAULT.COM/A/1190000016231512》 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115509514A (en) * 2022-11-23 2022-12-23 济南浪潮数据技术有限公司 Front-end data simulation method, device, equipment and medium
CN115509514B (en) * 2022-11-23 2023-03-10 济南浪潮数据技术有限公司 Front-end data simulation method, device, equipment and medium

Similar Documents

Publication Publication Date Title
CN110008113B (en) Test method and device and electronic equipment
CN111178512B (en) Device operation neural network test method and device
CN107145784B (en) Vulnerability scanning method and device and computer readable medium
CN110955409B (en) Method and device for creating resources on cloud platform
CN111475390A (en) Log collection system deployment method, device, equipment and storage medium
CN111427583A (en) Component compiling method and device, electronic equipment and computer readable storage medium
CN113741898B (en) Form generation method, device and equipment
CN111597110A (en) Page testing method and device, electronic equipment and storage medium
CN110990008B (en) Page updating method and device, storage medium and electronic equipment
CN112433940A (en) Software development kit SDK testing method and related equipment
CN114756183A (en) Data printing method, device, equipment and storage medium
CN107341106A (en) Application compatibility detection method, exploitation terminal and storage medium
CN112527286A (en) Service code generation method and device, computer equipment and storage medium
CN113900922A (en) Method, device, equipment and medium for testing application program interface of multi-platform application
CN115543324B (en) Method, device, equipment and medium for generating interactive interface
CN116996601A (en) Message format conversion method and device, electronic equipment and storage medium
CN109284097B (en) Method, device, system and storage medium for realizing complex data analysis
CN111045943B (en) Mock data generation method, test system and readable storage medium
CN112162776B (en) Dependency relationship acquisition method and device
CN113467860B (en) Service logic execution method and device of program source code
CN113656036B (en) Compiling method, device, terminal and medium based on Mybatis
CN111045657B (en) Program code operation method and device, and compiling method and device
CN113343659A (en) Analysis report generation method, device, equipment and storage medium
CN113778394A (en) SDK adaptation method, device, electronic equipment and storage medium
CN114817793A (en) Page generation method, device, equipment and storage medium

Legal Events

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

Application publication date: 20220715