Text printing method and device, computer device and storage medium

The text printing result was generated through lexical and syntactic analysis.

CN116301895BActive Publication Date: 2026-04-10SHENZHEN QIANHAI BAIDI NETWORK CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SHENZHEN QIANHAI BAIDI NETWORK CO LTD
Filing Date
2023-03-08
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

The use cases for the C-Lodop printing control are greatly limited by the specific scenarios in which it can be used.

Method used

The target sentence is generated through lexical and syntactic analysis, and resources are loaded into the preset environment to obtain the text printing result.

Benefits of technology

This implementation enables the C-Lodop printing control to operate independently of the browser. Through lexical and syntactic analysis, it generates target sentences, thus creating a text printing control scenario and producing text printing results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116301895B_ABST
    Figure CN116301895B_ABST
Patent Text Reader

Abstract

The application relates to a text printing method and device, computer equipment and a storage medium. The method comprises the following steps: determining a source sentence in a printing instruction, performing lexical analysis on the source sentence, and obtaining a data stream comprising a plurality of word nodes; when the data stream is subjected to syntax analysis, a target syntax tree is obtained, and the target syntax tree is compiled into a target sentence suitable for a preset environment; thus, the text printing result can be obtained according to the target sentence and resource loading on the preset environment. The method can expand the use scene of a C-Lodop printing control.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of cloud printing, and in particular to a text printing method and device, computer equipment and a storage medium. BACKGROUND

[0002] Cloud printing technology integrates printing device resources through a network, and can build a multi-terminal shared printing platform. Therefore, it is crucial to provide high-quality and standardized printing service standards.

[0003] At present, C-Lodop printing controls integrated with a plurality of general instructions are mainly used in cloud printing, and when a printer is connected, the specified text content can be printed out through the instructions. However, since the C-Lodop printing control exists in the form of a browser plug-in, it cannot directly operate system resources and perform interface operations and system calls, which greatly limits the use scenarios of cloud printing. Therefore, how to expand the use scenarios of the C-Lodop printing control is a problem to be solved by the present disclosure. SUMMARY

[0004] Therefore, it is necessary to provide a text printing method, device, computer equipment, computer readable storage medium and computer program product capable of expanding the use scenarios of the C-Lodop printing control.

[0005] In a first aspect, the present application provides a text printing method, comprising:

[0006] When a printing instruction is obtained, a source statement in the printing instruction is determined;

[0007] The source statement is subjected to lexical analysis to obtain a data stream comprising a plurality of word nodes;

[0008] The data stream is subjected to syntax analysis to obtain a target syntax tree, and the target syntax tree is compiled into a target statement suitable for a preset environment;

[0009] According to the target statement, resource loading is performed on the preset environment to obtain a text printing result.

[0010] In one embodiment, before the source statement in the printing instruction is determined, the method further comprises: obtaining a technical document; the technical document comprises a plurality of printing functions; according to the technical document and in response to an editing operation on the printing function, a source statement is obtained; in response to a triggering operation on a printing control, and in combination with the source statement and a printing statement corresponding to the printing control, a printing instruction is generated; the printing control exists in the form of a special plug-in.

[0011] In one of the embodiments, the source sentence is subjected to lexical analysis to obtain a data stream comprising a plurality of word nodes, including: determining a plurality of words in the source sentence, and performing semantic recognition on each of the words by a finite state automaton to obtain a respective word node and a word type corresponding to each of the words; marking the respective word node with a plurality of the word types to obtain a marked word node; and concatenating a plurality of the marked word nodes in the order of arrangement of each of the words to obtain the data stream.

[0012] In one of the embodiments, the data stream is subjected to syntax analysis to obtain a target syntax tree, including: determining a target function corresponding to the data stream from a plurality of the word nodes; the word nodes including a node representing a function; determining a target grammar corresponding to the target function, and constructing the data stream into a target syntax tree from bottom to top according to the target grammar.

[0013] In one of the embodiments, the target grammar comprises a plurality of productions; and constructing the data stream into a target syntax tree from bottom to top according to the target grammar, including: taking an initial node in the data stream as a root node in the target syntax tree, and traversing a plurality of word nodes in the data stream; matching a current word node with a plurality of productions in the target grammar to obtain a matching sub-result, and integrating a plurality of the matching sub-results and the root node to obtain the target syntax tree.

[0014] In one of the embodiments, the production comprises a head; the head is a non-terminal symbol; and matching the current word node with a plurality of productions in the target grammar to obtain a matching sub-result, including: taking the current word node as an edge node in the target syntax tree; determining a target production matched with the edge node from a plurality of the productions, and taking a non-terminal symbol in the head of the target production as a parent node of the edge node; taking the parent node as a new edge node, and returning to the process of determining the target production matched with the edge node from a plurality of the productions to continue until the non-terminal symbol is a root node; and integrating all the edge nodes to obtain a matching sub-result corresponding to the current word node.

[0015] In one of the embodiments, a target statement is obtained according to the target syntax tree, and a preset environment is subjected to resource loading to obtain a text printing result, including: loading a database resource corresponding to the preset environment, and integrating the target statement and the database resource to obtain an installation package file; the installation package file comprises a printer interface; and when the installation package file is triggered, the printer interface is invoked to enable a target printer corresponding to the printer interface to print out the text printing result.

[0016] In a second aspect, the present application provides a text printing device. The device comprises:

[0017] a lexical analysis module configured to, when a printing instruction is obtained, determine a source statement in the printing instruction, perform lexical analysis on the source statement to obtain a data stream comprising a plurality of word nodes;

[0018] a syntax analysis module configured to perform syntax analysis on the data stream to obtain a target syntax tree, and compile the target syntax tree into a target statement suitable for a preset environment;

[0019] a printing result determination module configured to, according to the target statement, load resources of the preset environment to obtain a text printing result.

[0020] In a third aspect, the present application provides a computer device. The computer device comprises a memory and a processor. The memory stores a computer program, and the processor implements the following steps when executing the computer program:

[0021] when a printing instruction is obtained, determining a source statement in the printing instruction;

[0022] performing lexical analysis on the source statement to obtain a data stream comprising a plurality of word nodes;

[0023] performing syntax analysis on the data stream to obtain a target syntax tree, and compiling the target syntax tree into a target statement suitable for a preset environment;

[0024] according to the target statement, loading resources of the preset environment to obtain a text printing result.

[0025] In a fourth aspect, the present application provides a computer readable storage medium. The computer readable storage medium stores a computer program. The computer program is executed by a processor to implement the following steps:

[0026] when a printing instruction is obtained, determining a source statement in the printing instruction;

[0027] performing lexical analysis on the source statement to obtain a data stream comprising a plurality of word nodes;

[0028] performing syntax analysis on the data stream to obtain a target syntax tree, and compiling the target syntax tree into a target statement suitable for a preset environment;

[0029] according to the target statement, loading resources of the preset environment to obtain a text printing result.

[0030] In a fifth aspect, the present application provides a computer program product. The computer program product comprises a computer program. The computer program is executed by a processor to implement the following steps:

[0031] When the print instruction is acquired, a source statement in the print instruction is determined;

[0032] The source statement is subjected to lexical analysis to obtain a data stream comprising a plurality of word nodes;

[0033] The data stream is subjected to syntax analysis to obtain a target syntax tree, and the target syntax tree is compiled into a target statement applicable to a preset environment;

[0034] According to the target statement, resources of the preset environment are loaded to obtain a text printing result.

[0035] The text printing method, device, computer device, storage medium and computer program product, by determining the source statement in the print instruction, and subjecting the source statement to lexical analysis to obtain a data stream comprising a plurality of word nodes; so that when the data stream is subjected to syntax analysis, a target syntax tree is obtained, and the target syntax tree is compiled into a target statement applicable to a preset environment; thus, according to the target statement, resources of the preset environment are loaded to obtain a text printing result. Since the present application sequentially passes through lexical analysis and syntax analysis, the source statement can be parsed, and a target statement applicable to a preset environment is obtained, so that the C-Lodop printing control is separated from the use of the browser, and the use of the C-Lodop printing control in the preset environment is expanded. In addition, during the process of loading resources of the preset environment, a plurality of function interfaces can be obtained, so that system calls such as interface operations can be implemented. BRIEF DESCRIPTION OF DRAWINGS

[0036] Figure 1 An application environment diagram of a text printing method of an embodiment;

[0037] Figure 2 A flowchart of a text printing method of an embodiment;

[0038] Figure 3 A structure diagram of a data stream of an embodiment;

[0039] Figure 4 A flowchart of constructing a target syntax tree of an embodiment;

[0040] Figure 5 A principle diagram of constructing a target syntax tree of an embodiment;

[0041] Figure 6 A structure block diagram of a text printing device of an embodiment;

[0042] Figure 7 An internal structure diagram of a computer device of an embodiment. DETAILED DESCRIPTION

[0043] In order to make the purposes, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and not used to limit the present application.

[0044] The text printing method provided by the embodiments of the present application can be applied to an application environment as shown in Figure 1 . Wherein, the terminal 102 communicates with the server 104 through the network, and the printer 106 communicates with the server 104 through the network. The data storage system can store the data required to be processed by the server 104. The data storage system can be integrated on the server 104, or placed on other network servers. The server 104 is used to determine the source statement in the print instruction when the print instruction sent by the terminal 102 is obtained, and perform lexical analysis on the source statement to obtain a data stream including a plurality of word nodes; the server 104 is also used to perform syntax analysis on the data stream, according to the target statement, and load resources on the preset environment, so that the printer 106 prints out the text printing result. Wherein, the terminal 102 can be, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers, Internet of Things devices and portable wearable devices. The Internet of Things device can be a smart speaker, a smart TV, a smart air conditioner, a smart vehicle device, etc. The portable wearable device can be a smart watch, a smart bracelet, a head-mounted device, etc. The server 104 can be a cloud server, or can be implemented by an independent server or a server cluster composed of multiple servers.

[0045] In one of the embodiments, as shown in Figure 2 , a text printing method is provided, which is described by taking the application of the computer device as an example. The computer device can be the terminal or the server in Figure 1 , including the following steps:

[0046] Step 202, when the print instruction is obtained, the source statement in the print instruction is determined.

[0047] Wherein, the source statement can be a kind of source code, such as C-Lodop source code. The source statement can also represent a statement edited by the user according to different printing requirements.

[0048] Specifically, the computer device can determine the print instruction in response to the triggering operation of the user. At this time, the print instruction includes all the codes required to execute the printing task. Since all the codes also include the basic printing statements that do not need to be modified at each printing, the computer device can parse the source statement edited and modified by the user from the print instruction.

[0049] In one of the embodiments, before determining the source statement in the print instruction, further comprising: obtaining a technical document; obtaining the source statement according to the technical document and in response to an editing operation on the print function; and generating the print instruction in response to a triggering operation on the print control and in combination with the source statement and a print statement corresponding to the print control.

[0050] The technical document includes a plurality of print functions; the print functions are embodied by corresponding functions; the technical document can be a technical document of different versions of C-Lodop print control, i.e., the technical document specifies the standard of C-Lodop print control; the print control exists in the form of a special plug-in; the special plug-in can be a browser plug-in, i.e., in the traditional scheme, the user can execute the corresponding print instruction only when the user triggers the computer device that only provides a browser.

[0051] Specifically, since the technical document can be pre-stored in a database, such as a third-party database corresponding to a preset environment, when the technical document is obtained from the database, the user can use it as an editing basis to obtain the corresponding source statement. For example, when there is a function ADD_PRINT_TEXT, the specification of the corresponding source statement is ADD_PRINT_TEXT(intTop, intLeft, intWidth, intHeight, strContent), and the embodied print function is to add a pure text print option, set the position and area size of the print item in the paper, and automatically wrap the text content in the area, i.e., after initialization, a line drawing class function is called to implement printing. When the computer device responds to the triggering operation of the user on the print control, the edited source statement and the basic print statement corresponding to the print control can be combined to generate the print instruction.

[0052] In one of the embodiments, the source statement is not limited to the edited code, but can also refer to all the codes required to execute the print task.

[0053] In step 204, the source statement is subjected to lexical analysis to obtain a data stream including a plurality of word nodes.

[0054] Specifically, the computer device pre-processes the source statement, and then filters out redundant information such as spaces and comments. Then the computer device can scan the source statement as a character sequence from left to right, i.e., scan the word stream constituting the source statement according to the lexical rules of the source code language, and identify the words according to the word formation rules. Since lexical analysis is the process of converting a character sequence into a token sequence, a token is a word, which is the smallest unit constituting the source code, therefore, the process of generating tokens from the input character sequence is called tokenization, i.e., each word in the input character sequence is divided into tokens.

[0055] For example, the character sequence of the source statement is LODOP. ADD_PRINT_TEXT (10, 10, 100, 100, "hello"), and ten lexical units are formed by lexical analysis as follows: <lodop>、<.>、<ADD_PRINT_TEXT> 、<(>、 <10> , <10> , <100> , <100> 、<"hello">、<)>.

[0056] Since each lexical unit corresponds to a word, when a computer device connects multiple lexical units sequentially, a data stream is obtained, and the lexical unit is the corresponding word node in the data stream. This data stream can be a token-formatted data stream.

[0057] In one embodiment, lexical analysis can be performed using a lexical analyzer.

[0058] Step 206: Perform syntax analysis on the data stream to obtain the target syntax tree, and compile the target syntax tree into a target statement suitable for a preset environment.

[0059] In one embodiment, performing syntactic analysis on the data stream to obtain a target syntax tree includes: determining the target function corresponding to the data stream from multiple word nodes; determining the target grammar corresponding to the target function; and constructing the target syntax tree from the bottom up based on the target grammar.

[0060] Among them, word nodes include nodes that represent functions; the function's functionality corresponds to the printing function in technical documents; the target grammar includes top-and-bottom-free grammars, which are a way of describing programming languages, using simple symbols to describe a set of languages.

[0061] Specifically, because word nodes in a data stream have different word types, computer devices can identify string-type word nodes by parsing the data stream, and then identify the word node representing the function's functionality from among multiple word nodes. For example, referring to the example above, the identified word node is...<ADD_PRINT_TEXT> Since ADD_PRINT_TEXT is a function described in the technical documentation, it is used as the target function corresponding to the data stream. Because the target grammar is used to construct the syntax tree, it is necessary to determine the target grammar corresponding to the target function. This allows for a bottom-up approach to construct the target syntax tree from the data stream.

[0062] Furthermore, the computer device compiles the target syntax tree (AST) to perform code conversion according to pre-defined conversion rules between natural language code and the code of a preset environment, thereby obtaining the final target statement. The target statement is the code that can be executed by the printer to implement C-Lodop functionality. The preset environment can be the environment in which a Java program runs.

[0063] In one of the embodiments, the syntax analysis can be completed by a syntax analyzer. The syntax analyzer can form a plurality of lexical units into an Abstract Syntax Tree (AST) according to the relationship between the plurality of lexical units.

[0064] In one of the embodiments, the target grammar can be obtained by being pre-defined by a user, thereby improving the flexibility of constructing different syntax trees.

[0065] In step 208, the text printing result is obtained by loading resources of the preset environment according to the target sentence.

[0066] In one of the embodiments, the text printing result is obtained by loading resources of the preset environment according to the target sentence, including: loading database resources corresponding to the preset environment, and obtaining an installation package file by integrating the target sentence and the database resources; when the installation package file is triggered, a printer interface is called to make a target printer corresponding to the printer interface print the text printing result.

[0067] The installation package file includes the printer interface. The installation package file integrates a function interface provided by a software development kit and installation package resource information corresponding to the software development kit, etc. The software development kit is, for example, an SDK. The SDK can be regarded as a software delivery form. Through the SDK, the complete content of the software code and resources of an initial application program can be packaged, and the packaged file can be integrated when delivered to another party.

[0068] Specifically, since the target sentence is applicable to the preset environment, when the target sentence with the corresponding printing function is formed, the computer device can also load other database resources corresponding to the preset environment, thereby expanding the ecology of the preset environment, realizing the use of the third-party database, and further forming an installation package file with small memory size and easy to trigger.

[0069] Further, when the computer device adopts a server of a Spring framework, the resources of the corresponding server can be directly used. By introducing the installation package file, when the user triggers the installation package file, the computer device can call the printer interface to make a target printer corresponding to the printer interface print the text printing result. Since the installation package file includes a plurality of function interfaces, the computer device integrated with the C-Lodop printing control expands the function, and further realizes the system call of the interface operation.

[0070] In one of the embodiments, the computer device can also print the trigger by remote JavaScript programming.

[0071] In the text printing method, the source statement in the printing instruction is determined, and the source statement is subjected to lexical analysis to obtain a data stream including a plurality of word nodes; when the data stream is subjected to syntax analysis, a target syntax tree is obtained, and the target syntax tree is compiled into a target statement suitable for a preset environment; in this way, the target statement can be obtained according to the target statement, and resource loading is performed on the preset environment to obtain a text printing result. Since the source statement is analyzed by lexical analysis and syntax analysis in sequence, the target statement suitable for the preset environment can be obtained, and in this way, the C-Lodop printing control is separated from the use of the browser, and the use of the C-Lodop printing control in the preset environment is expanded. In addition, during the resource loading process on the preset environment, a plurality of function interfaces can be obtained, so that system calls such as interface operations can be implemented.

[0072] In one of the embodiments, the source statement is subjected to lexical analysis to obtain a data stream including a plurality of word nodes, including: determining a plurality of words in the source statement, and performing semantic recognition on each word by a finite state automaton to obtain a word node and a word type corresponding to each word respectively; marking the corresponding word node with a plurality of word types to obtain a marked word node; and concatenating a plurality of marked word nodes in the order of arrangement of each word to obtain the data stream.

[0073] Specifically, the computer device performs semantic recognition on each word in the source statement by a finite state automaton (DFA) to obtain a word node and a word type corresponding to each word respectively. The DFA is a five-tuple M = Σ (S, S0, f, Z), where Σ represents each character, i.e., each word; S represents the state of each character; S0 represents the initial state; f represents the transformation function; and Z represents the final state set. The word type can include a string, an integer, a floating-point number, and a punctuation mark, etc. When the five-tuple M is represented in the form of a node set of a graph, an initial structure of the data stream can be obtained. Since each word node corresponds to a word type, when the corresponding word node is marked by the word type, a marked word node can be obtained, and then a plurality of marked word nodes are concatenated in the order of arrangement of each word to form a data stream corresponding to the source statement, i.e., a data stream in the Token format with states.

[0074] For example, when the source statement is LODOP.ADD_PRINT_TEXT(10, 10, 100, 100, "hello"), the DFA graph obtained by recognition is as shown in Figure 3 Figure 3 which is a structural schematic diagram of the data stream in one of the embodiments.

[0075] ​In one embodiment, when the source statement is INT:'-'? [0-9]+, it represents the recognition of positive and negative integers, numbers such as 10, -10, etc.; when the source statement is FLOAT:([0-9]+'.'[0-9]+), it represents the recognition of numbers with decimal points, such as 0.12, etc.

[0076] In this embodiment, by using a finite state automaton to perform lexical analysis on the source statement, the lexical units of the source statement can be accurately analyzed, so that the corresponding syntax tree can be accurately obtained when constructing the syntax tree in the subsequent process, thereby improving the accuracy of printing the text.

[0077] In one embodiment, such as Figure 4 As shown, Figure 4 This is a flowchart illustrating the process of constructing the target syntax tree. Based on the target grammar, the data flow is constructed into the target syntax tree from the bottom up, which also includes the following steps:

[0078] Step S402: Take the initial node in the data stream as the root node in the target syntax tree, and traverse the multiple word nodes in the data stream.

[0079] Specifically, the computer device identifies the initial node in the data stream and uses it as the root node in the target syntax tree. (See reference) Figure 3 The initial node in is <lodop>The computer device starts from the root node and traverses multiple word nodes in the data stream. Since the matching process of each word node is the same, the current word node is taken as an example for illustration. For example, the current word node is <ADD_PRINT_TEXT>.

[0080] In step S404, the current word node is matched with multiple productions in the target grammar to obtain matching sub-results, and the multiple matching sub-results and the root node are integrated to obtain the target syntax tree.

[0081] In one embodiment, matching the current word node with multiple productions in the target grammar to obtain matching sub-results includes: taking the current word node as an edge node in the target syntax tree; determining a target production matched with the edge node from the multiple productions, and taking a non-terminal symbol in the head of the target production as a parent node of the edge node; taking the parent node as a new edge node, and returning to the process of determining a target production matched with the edge node from the multiple productions, until the non-terminal symbol is the root node; and integrating all edge nodes to obtain the matching sub-result corresponding to the current word node.

[0082] The target grammar includes multiple productions; a production includes a head; and the head is a non-terminal symbol. For example, the production 1 corresponding to an integer in the target grammar is D->0|1|...|10, the production 2 corresponding to a letter is L->a|b|c|d...|z, and the production 3 corresponding to the integration of a digit and a letter is P->L|D, i.e., P can be derived as L or D. The left P in the production 3 is the head, and the right L|D is the body. For another example, the target grammar includes the production 4 LODOP.ADD_PRINT_TEXT”('(ARG(','ARG)*)?')' and the production 5 ARG->INT|FLOAT|STRING, where LODOP.ADD_PRINT_TEXT is the current word node to be matched; '('(ARG(','ARG)*)?')' is the target parameter to be matched; (','ARG)*)?' indicates that the target parameter can be 0 or more; and the production 5 indicates that the target parameter ARG can be derived as an integer, a string, or a floating-point type.

[0083] Specifically, the computer device takes the current word node as an edge node in the target syntax tree, the edge node being a node farthest from the root node and at the end when matching from bottom to top. The computer device searches the body corresponding to each of the plurality of productions for a production identical to the edge node, i.e., a target production matching the edge node, and takes the non-terminal in the head of the target production as the parent node of the edge node. For example, when the integer 10 is the edge node, the computer device determines production 1 as the target production, and D in production 1 as the parent node of 10.

[0084] Since the target syntax tree is composed of nodes at multiple levels, for each round of construction, the process of taking the parent node as a new edge node and returning to determining the target production matching the edge node from the plurality of productions is performed. For example, when D is the new edge node, the computer device determines production 3 as the target production, and P in production 3 as the parent node of D.

[0085] When the non-terminal is the root node, the round ends, at which time there is no matching production, and the computer device synthesizes all edge nodes to obtain a matching sub-result corresponding to the current word node, the matching sub-result representing a sub-structure tree constructed by the current word node. As shown in Figure 5 Figure 5 is a schematic diagram of the principle of constructing the target syntax tree. For example, the specification of the source statement ADD_PRINT_TEXT(intTop, intLeft, intWidth, intHeight, strContent) can obtain five parameters, and when the source statement edited by the user is LODOP.ADD_PRINT_TEXT(10, 10, 100, 100, "hello"), the computer device can determine the word type corresponding to each parameter and assign values to the corresponding parameters.

[0086] In this embodiment, the target grammar is used to construct the data stream into the target syntax tree from bottom to top, so that the source statement can be quickly recognized, and since the source statement only needs to edit a small number of parameters, the corresponding target syntax tree can be quickly constructed when the different printing functions are triggered multiple times, ensuring the efficiency of text printing. In addition, since the target grammar can be obtained by being predefined by the user, the flexibility of constructing different syntax trees is also improved.

[0087] ​In one of the embodiments, the computer device can encrypt the target syntax tree according to a preset encryption algorithm to obtain an encrypted syntax tree. The preset encryption algorithm can be, for example, an MD5 (Message-Digest Algorithm 5) encryption algorithm, a base64 encryption algorithm, or the like. The computer device can encrypt each node in the target syntax tree respectively to generate the encrypted syntax tree, or encrypt part of the nodes in the target syntax tree and combine the encrypted part of the nodes with the unencrypted nodes to form the encrypted target syntax tree. In this way, the security of compiling the target syntax tree can be ensured.

[0088] It should be understood that, although each step in the flowchart involved in the above embodiments is shown in sequence according to the arrow, these steps are not necessarily executed in the order indicated by the arrow. Unless otherwise specified herein, the execution of these steps is not strictly limited in sequence, and these steps can be executed in other orders. Moreover, at least part of the steps in the flowchart involved in the above embodiments can include multiple steps or stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily sequential, but can be executed alternately or alternately with at least part of other steps or steps or stages in other steps.

[0089] Based on the same inventive concept, the embodiments of the present application also provide a text printing device for implementing the above-mentioned text printing method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme described in the above method, so the specific limitations in one or more text printing device embodiments provided below can refer to the limitations of the text printing method in the above text, which will not be repeated here.

[0090] In one of the embodiments, as shown in Figure 6 A text printing device 600 is provided, which includes a lexical analysis module 602, a syntax analysis module 604, and a printing result determination module 606, wherein:

[0091] The lexical analysis module 602 is configured to determine a source statement in the printing instruction when the printing instruction is acquired, and perform lexical analysis on the source statement to obtain a data stream including a plurality of word nodes.

[0092] The syntax analysis module 604 is configured to perform syntax analysis on the data stream to obtain a target syntax tree, and compile the target syntax tree into a target statement suitable for a preset environment.

[0093] The printing result determination module 606 is configured to load resources on the preset environment according to the target statement to obtain a text printing result.

[0094] In one of the embodiments, the text printing apparatus 600 further comprises an instruction generation module 608 configured to acquire a technical document; the technical document comprises a plurality of printing functions; obtain a source sentence according to the technical document and in response to an editing operation on the printing functions; generate a printing instruction in response to a triggering operation on a printing control and in combination with the source sentence and a printing sentence corresponding to the printing control; and the printing control exists in the form of a special plug-in.

[0095] In one of the embodiments, the lexical analysis module 602 is further configured to determine a plurality of words in the source sentence, and perform semantic recognition on each word by using a finite state automaton to obtain a word node and a word type corresponding to each word respectively; mark the corresponding word node with a plurality of word types to obtain a marked word node; and take the created initial node as a starting point, and concatenate a plurality of marked word nodes in the arrangement order of each word to obtain a data stream.

[0096] In one of the embodiments, the syntax analysis module 604 is further configured to determine a target function corresponding to the data stream from the plurality of word nodes; the word node comprises a node representing a function; determine a target grammar corresponding to the target function, and construct the data stream into a target syntax tree from bottom to top according to the target grammar.

[0097] In one of the embodiments, the syntax analysis module 604 is further configured to take the initial node in the data stream as a root node in the target syntax tree, and traverse a plurality of word nodes in the data stream; match the current word node with a plurality of productions in the target grammar to obtain a matching sub-result, and combine the plurality of matching sub-results and the root node to obtain the target syntax tree.

[0098] In one of the embodiments, the syntax analysis module 604 is further configured to take the current word node as an edge node in the target syntax tree; determine a target production matched with the edge node from the plurality of productions, and take a non-terminal symbol in the head of the target production as a parent node of the edge node; take the parent node as a new edge node, and return to the process of determining the target production matched with the edge node from the plurality of productions to continue until the non-terminal symbol is the root node; and combine all the edge nodes to obtain a matching sub-result corresponding to the current word node.

[0099] In one of the embodiments, the printing result determination module 606 is further configured to load a database resource corresponding to a preset environment, and combine the target sentence and the database resource to obtain an installation package file; the installation package file comprises a printer interface; and when the installation package file is triggered, the printer interface is called to enable a target printer corresponding to the printer interface to print the text printing result.

[0100] In one of the embodiments, a computer device is provided, which can be a server, and an internal structure diagram of the computer device can be as shown in FIG. 1. Figure 7 The computer device includes a processor, a memory, an input / output interface (I / O), and a communication interface. The processor, the memory, and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for running the operating system and the computer program in the non-volatile storage medium. The database of the computer device is configured to store text printing data. The input / output interface of the computer device is configured to exchange information between the processor and external devices. The communication interface of the computer device is configured to communicate with terminals outside through a network connection. The computer program is executed by the processor to implement a text printing method.

[0101] Those skilled in the art can understand that Figure 7 The structure shown in FIG. 1 is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device can include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0102] In one of the embodiments, a computer device is provided, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the steps in the above-mentioned method embodiments.

[0103] In one of the embodiments, a computer readable storage medium is provided, which stores a computer program. The computer program is executed by a processor to implement the steps in the above-mentioned method embodiments.

[0104] In one of the embodiments, a computer program product or a computer program is provided, which includes computer instructions stored in a computer readable storage medium. A processor of a computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions to make the computer device execute the steps in the above-mentioned method embodiments.

[0105] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium, and when the computer program is executed, the processes of the above-mentioned embodiments of the methods can be included. In the embodiments provided in the present application, any application of the memory, database or other medium can include at least one of the non-volatile and volatile memories. The non-volatile memory can include read-only memory (Read-Only Memory, ROM), magnetic tape, floppy disk, flash memory, optical storage, high-density embedded non-volatile memory, resistive memory (ReRAM), magnetoresistive random access memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric memory (Ferroelectric Random Access Memory, FRAM), phase change memory (Phase Change Memory, PCM), graphene memory, etc. The volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, etc. As an illustration but not limitation, the RAM can be in various forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), etc. The database involved in the embodiments provided in the present application can include at least one of the relational database and the non-relational database. The non-relational database can include a distributed database based on a block chain, etc., and is not limited thereto. The processor involved in the embodiments provided in the present application can be a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., and is not limited thereto.

[0106] Any combination of the technical features of the above embodiments can be made. In order to make the description simple, all possible combinations of the technical features in the above embodiments are not described, however, as long as the combination of the technical features does not exist contradictory, it should be considered as the scope of the present application.

[0107] The above embodiments only express several implementation manners of the present application, and the description is more specific and detailed, but it should not be understood as a limitation on the patent scope of the present application. It should be pointed out that for those skilled in the art, without departing from the concept of the present application, a number of modifications and improvements can be made, which are all within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the appended claims.< / lodop> < / lodop>

Claims

1. A method of printing text, characterized by, The method comprises: When the print instruction is acquired, the source statement in the print instruction is determined; wherein the print instruction is generated by comprehensively editing the source statement and the basic print statement corresponding to the print control; the source statement is obtained according to the technical document and in response to the editing operation of the print function; the technical document is the technical document of different versions of the C-Lodop print control, which is used to standardize the description of the standard of the C-Lodop print control; the source statement is the C-Lodop source code, and the C-Lodop print control exists in the form of a browser plug-in; The source statement is subjected to lexical analysis to obtain a data stream comprising a plurality of word nodes; The data stream is subjected to syntax analysis to obtain a target syntax tree; The target syntax tree is compiled into a target statement suitable for a preset environment, comprising: code conversion of the target syntax tree according to the conversion rule between the pre-set natural language code and the code of the preset environment, to obtain the target statement; According to the target statement, the resources of the preset environment are loaded to obtain a text printing result, comprising: loading the database resources or other database resources corresponding to the preset environment, and comprehensively analyzing the target statement, the database resources or the other database resources to obtain an installation package file; the installation package file comprises a printer interface; when the installation package file is triggered, the printer interface is called to enable the target printer corresponding to the printer interface to print out the text printing result; the target statement is the code executed by the printer to realize the C-Lodop function; wherein the preset environment is the environment of the Java program.

2. The method of claim 1, wherein, Before the source statement in the print instruction is determined, the method further comprises: Acquiring a technical document; the technical document comprises a plurality of print functions; According to the technical document, the source statement is obtained in response to the editing operation of the print function; In response to the triggering operation of the print control, the print instruction is generated by comprehensively analyzing the source statement and the print statement corresponding to the print control; the print control exists in the form of a special plug-in.

3. The method of claim 1, wherein, The source statement is subjected to lexical analysis to obtain a data stream comprising a plurality of word nodes, comprising: A plurality of words in the source statement are determined, and each word is subjected to semantic recognition by a finite state automaton to obtain a word node and a word type corresponding to each word; The corresponding word nodes are marked with a plurality of word types to obtain marked word nodes; According to the arrangement order of each word, a plurality of marked word nodes are concatenated to obtain a data stream.

4. The method of claim 1, wherein, The data stream is subjected to syntax analysis to obtain a target syntax tree, comprising: A target function corresponding to the data stream is determined from a plurality of word nodes; the word nodes comprise nodes representing functions; The target function corresponding to the target function is determined, and the data stream is constructed into a target syntax tree from bottom to top according to the target grammar.

5. The method of claim 4, wherein, The target grammar comprises a plurality of productions; and the bottom-up construction of the data stream into a target syntax tree according to the target grammar comprises: taking an initial node in the data stream as a root node in the target syntax tree, and traversing a plurality of word nodes in the data stream; matching the current word node with a plurality of productions in the target grammar to obtain matching sub-results, and synthesizing the matching sub-results and the root node to obtain a target syntax tree.

6. The method of claim 5, wherein, The production comprises a head; the head is a non-terminal symbol; and the matching of the current word node with a plurality of productions in the target grammar to obtain matching sub-results comprises: taking the current word node as an edge node in the target syntax tree; determining a target production matched with the edge node from the plurality of productions, and taking a non-terminal symbol in the head of the target production as a parent node of the edge node; taking the parent node as a new edge node, and returning to the process of determining a target production matched with the edge node from the plurality of productions until the non-terminal symbol is a root node; synthesizing all edge nodes to obtain a matching sub-result corresponding to the current word node.

7. A text printing apparatus characterized by comprising: The apparatus comprises: a lexical analysis module configured to determine a source statement in a print instruction when the print instruction is acquired, wherein the print instruction is generated by synthesizing a source statement and a basic print statement corresponding to a print control, the source statement is obtained according to a technical document and in response to an editing operation on a print function, the technical document is a technical document of different versions of a C-Lodop print control, and is used to standardize a specification of the C-Lodop print control, the source statement is C-Lodop source code, and the C-Lodop print control exists in the form of a browser plug-in; the source statement is subjected to lexical analysis to obtain a data stream comprising a plurality of word nodes; a syntax analysis module configured to perform syntax analysis on the data stream to obtain a target syntax tree, and compile the target syntax tree into a target statement suitable for a preset environment, comprising: performing code conversion on the target syntax tree according to a preset conversion rule between a natural language code and a code of the preset environment, to obtain the target statement; a print result determination module configured to load resources of the preset environment according to the target statement to obtain a text print result, comprising: loading database resources or other database resources corresponding to the preset environment, and synthesizing the target statement, the database resources or the other database resources to obtain an installation package file; the installation package file comprises a printer interface; when the installation package file is triggered, the printer interface is invoked to enable a target printer corresponding to the printer interface to print the text print result; the target statement is a code executed by a printer to implement a C-Lodop function; and the preset environment is an environment in which a Java program runs.

8. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that, The processor executes the computer program to implement the steps of the method in any one of claims 1 to 6.

9. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program, which when executed by a processor, implements the steps of the method of any one of claims 1 to 6.

10. A computer program product comprising a computer program, characterized in that, The computer program, which when executed by a processor, implements the steps of the method of any one of claims 1 to 6.

Citation Information

Patent Citations

  • Safety compiling method and device based on HiWing SylixOS operating system

    CN111459500A