Method, device and server for determining corresponding original text column position after macro replacement
By inserting column instructions in the preprocessing stage and modifying the counting results of the column counter in the parsing stage, the coupling problems of preprocessing and parsing stages caused by Verilog macro replacement are solved, and efficient column position determination is achieved.
Patent Information
- Application Number
- CN202411681518.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-22
- Publication Date
- 2025-03-11
- Estimated Expiration
- 2044-11-22
AI Technical Summary
After processing Verilog macro replacement, the prior art causes the independence of the preprocessing stage and the parsing stage to be destroyed, resulting in unnecessary coupling, and takes up a lot of time and takes up a lot of memory space.
In the preprocessing stage, the original text is replaced according to the macro instruction, and column instructions are inserted at the replacement position to obtain the preprocessed text. During the parsing phase, the column instructions are parsed row by row and the counting result of the column counter is modified to determine the column position of the keywords in the original text.
The purpose of determining the corresponding original text column position after macro replacement is achieved, reducing processing time and space resource consumption, and maintaining the independence of the preprocessing and parsing stages.
Smart Images

Figure CN119166836B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of digital computer systems, and in particular to a method, device and server for determining the position of a corresponding original text column after macro replacement. Background Art
[0002] In computer science, a macro is an abstraction that replaces certain text patterns according to a set of predefined rules. The compiler automatically performs this pattern replacement when encountering a macro. Macros in the hardware description language (Verilog) are a mechanism for text replacement during the compilation preprocessing phase. It allows developers to define some commonly used code snippets or identifiers and reuse these macros in multiple locations in the code to improve the readability and maintainability of the code. Macros in Verilog are defined using the define directive, and its basic syntax is as follows: `define macro name replaces text.
[0003] In FPGA development work, the debugging tool logic analyzer is often used. In the logic analyzer, you need to select the capture signal keyword in the Verilog source code on the interface, and then obtain the column position information of the keyword based on the source code string. However, the macro in Verilog is a mechanism for text replacement in the compilation preprocessing stage. In the preprocessing stage, the string of the source code will be changed to generate a processed string, and it will be sent to the subsequent parsing stage. In the syntax analysis stage of the parsing stage, the column position information of the keyword based on the processed string can be obtained. Due to the existence of macros, the same keyword may have inconsistent column position information before and after processing, which hinders the process of mapping the information obtained in the parsing stage back to the interface source code. Based on this, a method is needed to determine the corresponding original text column position after macro replacement.
[0004] The solution of the prior art: First, a mapping table needs to be established to record the position of the keywords that have changed positions before and after the change. In the preprocessing stage, when performing macro replacement, the length of the macro name and the length of the replacement text are obtained, the difference between the two is calculated, and it is included in the total offset of the line. In this way, when traversing a line, if the use of a macro is encountered, if the difference between the length of the macro name and the replacement text is not 0, then the position of the elements after the macro is used will change, and they need to be added to the mapping table. In this way, the position information of all keywords that have changed positions before and after the change can be obtained. Then, the lexical and grammatical analysis of the normal processing flow is performed. After the grammatical analysis is completed, a step is added to replace the position information. This requires traversing all keywords to check whether the keyword is in the mapping table. If it exists in the mapping table, it is also necessary to determine whether the position after the position change in the mapping table is consistent with the position information obtained by the grammatical analysis. If it is consistent, the position information of the keyword in the normal processing flow can be replaced with the position information based on the original file.
[0005] However, the method provided by the prior art requires storing a large amount of location information, which occupies a large amount of memory space. Secondly, matching keywords and comparing location information also takes a lot of time. On the other hand, the existence of this mapping table also destroys the independence of the preprocessing stage and the parsing stage, causing unnecessary coupling. Summary of the invention
[0006] The present invention solves the problems in the prior art that the introduction of a mapping table destroys the independence of the preprocessing stage and the parsing stage, causes unnecessary coupling between the preprocessing stage and the parsing stage, and consumes a long time by providing a method, device and server for determining the position of the corresponding original text column after macro replacement. The present invention reduces the running time and running space of the search, and can also maintain the independence of the preprocessing stage and the parsing stage.
[0007] In a first aspect, the present invention provides a method for determining the position of a corresponding original text column after macro replacement, the method comprising:
[0008] In the preprocessing stage, the original text is replaced according to the macro instruction, and the column instruction is inserted at the replacement position to obtain the preprocessed text; wherein the column position in the column instruction is the counting result of the column counter in the preprocessing stage;
[0009] In the parsing stage, the column instructions existing in the preprocessed text are parsed line by line, and the counting result of the column counter in the parsing stage is modified, and the column position of the keyword in the original text is determined using the modified counting result.
[0010] In combination with the first aspect, in a possible implementation, performing replacement processing on the original text according to the macro instruction in the preprocessing stage, and inserting a column instruction at the replacement position to obtain the preprocessed text includes:
[0011] The original text is loaded line by line, and the following operations are performed for each line of the original text:
[0012] If the current line of the original text is a macro definition text, determining a macro name and a replacement text in the macro definition text, and storing the macro name and the replacement text as a key-value pair in a database;
[0013] If the current line of the original text is a macro usage text, the write-back replacement text is constructed using the key-value pairs in the database, the macro name in the macro usage text is replaced with the write-back replacement text, and the text is loaded into the output buffer;
[0014] When the original text is loaded line by line, a preprocessed text is obtained.
[0015] In combination with the first aspect, in a possible implementation, the step of constructing a write-back replacement text using the key-value pairs in the database, replacing the macro name in the macro usage text with the write-back replacement text, and loading the text into the output cache includes:
[0016] Obtaining the macro name in the current line of the original text, and searching the database according to the macro name to obtain a replacement text corresponding to the macro name;
[0017] Constructing a write-back replacement text according to the replacement text and the counting result of the column counter in the preprocessing stage; wherein the format of the write-back replacement text is: replacement text+`column+column position; `column is a predefined character;
[0018] The write-back replacement text is replaced with the macro name in the current line of the original text, the replacement text is inserted into the replacement position, and loaded into the output buffer.
[0019] In combination with the first aspect, in a possible implementation manner, parsing the column instructions in the preprocessed text line by line in the parsing stage and modifying the counting result of the column counter in the parsing stage includes:
[0020] The preprocessed text is loaded into the cache line by line, and the following operations are performed for each line of the preprocessed text:
[0021] If the current line of the preprocessed text does not include a column instruction, the current line of the preprocessed text is analyzed according to the grammar rules;
[0022] If the current line of the preprocessed text includes a column instruction, the count result of the column counter in the parsing phase is modified to be the column position in the column instruction.
[0023] In combination with the first aspect, in a possible implementation manner, the method further includes:
[0024] In the preprocessing stage, before the original text is replaced according to the macro instruction, if the original text contains a column instruction, the counting result of the column counter in the preprocessing stage is modified to the column position in the column instruction, and the step of replacing the original text according to the macro instruction and subsequent steps are continued.
[0025] In combination with the first aspect, in a possible implementation manner, determining the column position of the keyword in the original text by using the modified counting result includes:
[0026] Obtaining the keyword, and determining the line where the keyword is located in the preprocessed text;
[0027] Determine whether there is a modified column instruction in the row where the keyword is located; if not, determine the column position of the keyword as the counting result of the column counter in the parsing stage; if so, determine the positional relationship between the keyword and the modified column instruction;
[0028] If the keyword is before the modified column instruction, determining the column position of the keyword is the counting result of the column counter in the parsing stage;
[0029] If the keyword is after the modified column instruction, then the counting result of the column counter in the parsing stage is determined to be the column position in the modified column instruction.
[0030] In a second aspect, the present invention provides a device for determining the position of a corresponding original text column after macro replacement, the device comprising:
[0031] A preprocessing module, used for performing replacement processing on the original text according to the macro instruction in the preprocessing stage, and inserting a column instruction at the replacement position to obtain a preprocessed text; wherein the column position in the column instruction is the counting result of the column counter in the preprocessing stage;
[0032] The parsing module is used to parse the column instructions existing in the preprocessed text line by line in the parsing stage, and modify the counting result of the column counter in the parsing stage, and use the modified counting result to determine the column position of the keyword in the original text.
[0033] In a third aspect, the present invention provides a server for determining the position of a corresponding original text column after macro replacement, comprising a memory and a processor;
[0034] The memory is used to store computer executable instructions;
[0035] The processor is used to execute the computer executable instructions to implement a method for determining the position of a corresponding original text column after macro replacement.
[0036] In a fourth aspect, the present invention provides a computer-readable storage medium having executable instructions, and when a computer executes the executable instructions, a method for determining the position of a corresponding original text column after macro replacement can be implemented.
[0037] One or more technical solutions provided in the present invention have at least the following technical effects or advantages:
[0038] (1) The present invention achieves the purpose of determining the corresponding original text column position after macro replacement by adopting the method of inserting column instructions; in the preprocessing stage and the parsing stage, the required processing time and space resource consumption can be greatly reduced, bringing a smoother and more efficient experience to users;
[0039] (2) While ensuring efficient operation, the present invention also takes into account the flexibility and maintainability of the system architecture; it ensures the independence of the preprocessing stage and the formal processing stage at the architectural level. This design ingenuity allows the two stages to develop independently without interfering with each other, leaving sufficient space for system expansion and upgrading. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 A flowchart of the method steps for determining the position of the corresponding original text column after macro replacement provided by an embodiment of the present invention;
[0041] Figure 2 A processing flow chart of the preprocessing stage provided by an embodiment of the present invention;
[0042] Figure 3 A processing flow chart of the parsing stage provided by an embodiment of the present invention;
[0043] Figure 4 A processing flow chart of the preprocessing stage of adding a judgment column instruction provided by an embodiment of the present invention;
[0044] Figure 5 A schematic diagram of the original Verilog code provided by an embodiment of the present invention;
[0045] Figure 6 A schematic diagram of a Verilog code after macro replacement provided by an embodiment of the present invention;
[0046] Figure 7 A schematic diagram of output codes in the preprocessing stage provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0047] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0048] The present invention provides a method for determining the position of the corresponding original text column after macro replacement, such as Figure 1 As shown, the method includes the following steps S101 to S102.
[0049] S101, in the preprocessing stage, the original text is replaced according to the macro instruction, and the column instruction is inserted at the replacement position to obtain the preprocessed text; wherein the column position in the column instruction is the counting result of the column counter in the preprocessing stage.
[0050] Here, the column directive is expressed as: `column column position, where the column position refers to the column position of the macro name in the macro usage text in the preprocessed text.
[0051] Specifically, in step S101, the original text is replaced according to the macro instruction, and a column instruction is inserted at the replacement position to obtain the preprocessed text, including the following steps S1011 to S1013.
[0052] S1011, load the original text line by line, for each line of the original text:
[0053] S1012: If the current line of the original text is a macro definition text, determine the macro name and replacement text in the macro definition text, and store the macro name and replacement text as a key-value pair in a database.
[0054] S1013, if the current line of the original text is a macro usage text, then use the key-value pairs in the database to construct a write-back replacement text, replace the macro name in the macro usage text with the write-back replacement text, and load it into the output cache.
[0055] Here, the key-value pairs in the database are used to construct the write-back replacement text, the macro name in the macro usage text is replaced with the write-back replacement text, and loaded into the output cache, including:
[0056] (1) Obtain the macro name in the current line of the original text, and search the database according to the macro name to obtain the replacement text corresponding to the macro name;
[0057] (2) constructing a write-back replacement text according to the replacement text and the counting result of the column counter in the preprocessing stage; wherein the format of the write-back replacement text is: replacement text+`column+column position; `column is a predefined character;
[0058] (3) Replace the write-back replacement text with the macro name in the current line of the original text and load it into the output buffer.
[0059] S1014, when the original text is loaded line by line, the preprocessed text is obtained in the output buffer.
[0060] Exemplarily, by creating a built-in custom column instruction in the syntax analysis stage, when macro replacement occurs, the column instruction is added to the end of the replacement text, and the current column information is modified immediately when parsing the column instruction, thereby ensuring that the column information of subsequent keywords corresponds to the information of the original text.
[0061] The format of the column directive is: `column column position;
[0062] The meaning of this column instruction is: when this instruction is encountered during syntax analysis, the current column position will be changed to the column position in the column instruction.
[0063] During the preprocessing phase, macro text replacement is performed. The preprocessor reads the original text line by line into the cache. If it finds a macro name, the preprocessor will generate a column instruction. At this time, the column position in the column instruction is the count result of the column counter in the current preprocessor. The column instruction is inserted into the head of the cache, and then the replacement text is inserted into the head of the cache again, thus completing the increase of the column instruction.
[0064] When the preprocessor encounters a column instruction, it changes the current column position to the column position in the column instruction, and then continues to read the remaining contents in the cache line by line.
[0065] When the preprocessing phase is finished, you have a text file that contains the column directive at the end where the macro substitution took place.
[0066] like Figure 2 As shown, it is a processing flow chart of the present invention in the pre-processing stage, according to Figure 2 The flowchart makes a judgment on each line of text in the original text.
[0067] S1, the preprocessor reads the original text into the cache and reads the data line by line from the cache.
[0068] S2, the preprocessor parses the current text.
[0069] S3, determine whether the current text is a macro definition text; if the current text is a macro definition text, store the macro name and the replacement text as a key-value pair in the database. Specifically, it includes: respectively parse and extract the macro name and the replacement text in the macro definition text, and store them as a key-value pair for query. Enter S6. If the current text is not a macro definition, execute S4.
[0070] S4, determine whether the current text is a macro-using text; if the current text is a macro-using text, construct a write-back replacement text, specifically including: parsing to obtain the macro name in the macro-using text, and querying from the storage whether there is a key-value pair with the macro name as the key, if not, return an error; if it exists, you can get the replacement text corresponding to the macro name. At this time, first get the column position of the current processing text from the preprocessor, then construct the write-back replacement text, and write the write-back replacement text back to the cache header. Enter S2. If the current text is not a macro-using text, enter S5.
[0071] S5, write the current text to the output.
[0072] S6, judging whether the termination condition is met; if so, ending the preprocessing stage; if not, returning to S1. Here, the termination condition includes: completing the entire text parsing or encountering an error during the process.
[0073] In an optional implementation of the present invention, the method for determining the corresponding original text column position after macro replacement provided by the present invention also includes: in the preprocessing stage, before the original text is replaced according to the macro instruction, if the original text contains a column instruction, then the counting result of the column counter in the preprocessing stage is modified to the column position in the column instruction, and the step of replacing the original text according to the macro instruction and subsequent steps are continued.
[0074] For example, Figure 4 The process flow chart of the present invention in the pre-processing stage is shown as follows. Figure 4 The flowchart makes a judgment on each line of text in the original text.
[0075] S1.1, the preprocessor reads the original text into a cache and reads data line by line from the cache.
[0076] S2.1, the preprocessor parses the current text.
[0077] S3.1, determine whether the current text is a macro definition text; if the current text is a macro definition text, store the macro name and the replacement text as a key-value pair in the database. Specifically, it includes: respectively parse and extract the macro name and replacement text in the macro definition text, and store them as a key-value pair for query. Enter S7.1. If the current text is not a macro definition, execute S4.1.
[0078] S4.1, determine whether the current text is a macro-using text; if the current text is a macro-using text, construct a write-back replacement text, specifically including: parsing to obtain the macro name in the macro-using text, and querying from the storage whether there is a key-value pair with the macro name as the key, if not, return an error; if it exists, you can get the replacement text corresponding to the macro name. At this time, first get the column position of the current processing text from the preprocessor, then construct the write-back replacement text, and write the write-back replacement text back to the cache header. Go to S2.1. If the current text is not a macro-using text, go to S5.1.
[0079] S5.1 determines whether the current text includes a column instruction; if so, the count result of the column counter of the current processing text in the preprocessor is modified to the column position in the column instruction. Enter S6.1. If not, enter S6.1.
[0080] S6.1, write the current text to the output.
[0081] S7.1, determine whether the termination condition is met, if so, end the preprocessing stage; if not, return to S1.1. The termination condition includes: completing the entire text parsing or encountering an error during the process.
[0082] S102, in the parsing stage, the column instructions existing in the preprocessed text are parsed line by line, and the counting result of the column counter in the parsing stage is modified, and the column position of the keyword in the original text is determined by using the modified counting result.
[0083] Specifically, in step S102, the column instructions in the preprocessed text are parsed line by line, and the counting result of the column counter in the parsing stage is modified, including:
[0084] S1021, loading the preprocessed text into the cache line by line, for each line of the preprocessed text:
[0085] S1022: If the current line of the preprocessed text does not include a column instruction, the current line of the preprocessed text is analyzed according to grammatical rules.
[0086] S1023: If the current line of the preprocessed text includes a column instruction, modify the count result of the column counter in the parsing stage to be the column position in the column instruction.
[0087] Here, no new column directives are added during the parsing phase, only column directives are processed.
[0088] When a column instruction is encountered, the count result of the column counter is modified to the column position in the column instruction, and then the remaining contents in the cache are read row by row.
[0089] like Figure 3As shown, it is a processing flow chart of the present invention in the parsing stage, according to Figure 3 The flowchart of is judged for each line of text in the preprocessed text.
[0090] S8, the parser reads the output text of the preprocessor into a cache, and reads data line by line from the cache.
[0091] S9, the parser parses the current text.
[0092] S10, determining whether the current text includes a column instruction. If the column instruction is included, modifying the count result of the column counter of the current text being processed in the syntax analyzer to be the column position in the column instruction. If the column instruction is not included, executing S11.
[0093] S11, performing grammatical analysis according to the provided grammatical rules.
[0094] S12, judging whether the termination condition is met; if so, ending the parsing phase; if not, executing S8. Here, the termination condition includes: completing the parsing of the entire text or encountering an error during the process.
[0095] Specifically, in step S102, the column position of the keyword in the original text is determined using the modified counting result, including:
[0096] (1) Obtain keywords and determine the lines where the keywords are located in the preprocessed text;
[0097] (2) determining whether there is a modified column instruction in the row where the keyword is located; if not, determining the column position of the keyword as the counting result of the column counter in the parsing stage; if so, determining the positional relationship between the keyword and the modified column instruction;
[0098] (3) If the keyword is before the modified column instruction, the column position of the keyword is determined as the count result of the column counter in the parsing stage;
[0099] (4) If the keyword is after the modified column instruction, the counting result of the column counter in the parsing phase is determined to be the column position in the modified column instruction.
[0100] In a specific embodiment provided by the present invention, for example Figure 5 In the Verilog code shown, you can see that macro A is defined in the code, representing a 16-bit binary number, and is used once later.
[0101] For the above code, after macro replacement, it becomes Figure 6The code shown in FIG. 10 shows that the content of the tenth line has changed, where the column position of the out_1 keyword has changed from 29 to 44. The parsing stage will read the text after macro replacement, and the method of the present invention will set the count result of the column counter of the out_1 keyword to 29, that is, the actual column position in the original text, after the normal process grammar analysis is completed.
[0102] For example Figure 5 The Verilog code shown in the figure judges each line of code according to steps S1.1 to S7.1 to obtain the key-value pair<A,16'b0000000000001> ; and query the key-value pair corresponding to the macro name A according to the tenth line of the code, generate the column instruction <`column; 20>, write back the replacement text "16'b0000000000001`column 20"; insert the write-back replacement text into the macro name to get the output of the preprocessor. Here the output of the preprocessor is as follows Figure 7 shown.
[0103] right Figure 7 Each line of code executes operations from S8 to S12. There is a difference of 9 characters between the beginning of the out_1 keyword and the end of the column instruction. Therefore, we can know that the final starting column position of the out_1 keyword is 29. Until the code execution ends, all text parsing is completed and exit is completed.
[0104] The invention provides a device for determining the position of a corresponding original text column after macro replacement, and the device comprises: a preprocessing module and a parsing module.
[0105] The preprocessing module is used to replace the original text according to the macro instruction in the preprocessing stage, and insert the column instruction at the replacement position to obtain the preprocessed text; wherein the column position in the column instruction is the counting result of the column counter in the preprocessing stage.
[0106] The parsing module is used to parse the column instructions existing in the preprocessed text line by line in the parsing stage, and modify the counting result of the column counter in the parsing stage, and use the modified counting result to determine the column position of the keyword in the original text.
[0107] Some modules in the apparatus of the present invention may be described in the general context of computer executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, classes, etc. that perform specific tasks or implement specific abstract data types. The present invention may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.
[0108] The present invention provides a server for determining the position of a corresponding original text column after macro replacement, comprising a memory and a processor; the memory is used to store computer executable instructions; the processor is used to execute the computer executable instructions to implement a method for determining the position of a corresponding original text column after macro replacement.
[0109] The present invention provides a computer-readable storage medium having executable instructions. When a computer executes the executable instructions, a method for determining the position of a corresponding original text column after macro replacement can be implemented.
[0110] The computer-readable storage medium includes, but is not limited to, random access memory (RAM), read-only memory (ROM), cache, hard disk (HDD), or memory card. The memory can be used to store computer program instructions.
[0111] The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. All or part of the present invention can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld devices or portable devices, tablet devices, mobile communication terminals, multi-processor systems, microprocessor-based systems, programmable electronic devices, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc.
[0112] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some or all of the technical features thereof may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the present invention.
Claims
1. A method for determining the position of a corresponding original text column after macro replacement, characterized in that: include: In the preprocessing stage, the original text is replaced according to the macro instruction, and the column instruction is inserted at the replacement position to obtain the preprocessed text; wherein the column position in the column instruction is the counting result of the column counter in the preprocessing stage; In the parsing stage, the column instructions in the preprocessed text are parsed line by line, and the counting result of the column counter in the parsing stage is modified, and the column position of the keyword in the original text is determined by using the modified counting result; wherein, determining the column position of the keyword in the original text by using the modified counting result includes: Obtaining the keyword, and determining the line where the keyword is located in the preprocessed text; Determine whether there is a modified column instruction in the row where the keyword is located; if not, determine the column position of the keyword as the counting result of the column counter in the parsing stage; if so, determine the position relationship between the keyword and the modified column instruction; If the keyword is before the modified column instruction, determining the column position of the keyword is the counting result of the column counter in the parsing stage; If the keyword is after the modified column instruction, then the counting result of the column counter in the parsing stage is determined to be the column position in the modified column instruction.
2. The method for determining the position of the corresponding original text column after macro replacement according to claim 1, characterized in that: The preprocessing stage replaces the original text according to the macro instruction and inserts the column instruction at the replacement position to obtain the preprocessed text, including: The original text is loaded line by line, and the following operations are performed for each line of the original text: If the current line of the original text is a macro definition text, determining a macro name and a replacement text in the macro definition text, and storing the macro name and the replacement text as a key-value pair in a database; If the current line of the original text is a macro usage text, the write-back replacement text is constructed using the key-value pairs in the database, the macro name in the macro usage text is replaced with the write-back replacement text, and the text is loaded into the output buffer; When the original text is loaded line by line, the preprocessed text is obtained in the output buffer.
3. The method for determining the position of the corresponding original text column after macro replacement according to claim 2, characterized in that: The step of constructing a write-back replacement text by using the key-value pairs in the database, replacing the macro name in the macro usage text with the write-back replacement text, and loading the text into the output cache includes: Obtaining the macro name in the current line of the original text, and searching the database according to the macro name to obtain a replacement text corresponding to the macro name; Constructing a write-back replacement text according to the replacement text and the counting result of the column counter in the preprocessing stage; wherein the format of the write-back replacement text is: replacement text+`column+column position; `column is a predefined character; The write-back replacement text is replaced with the macro name in the current line of the original text and loaded into the output buffer.
4. The method for determining the position of the corresponding original text column after macro replacement according to claim 1, characterized in that: The step of parsing the column instructions in the preprocessed text line by line in the parsing stage and modifying the counting result of the column counter in the parsing stage includes: The preprocessed text is loaded into the cache line by line, and the following operations are performed for each line of the preprocessed text: If the current line of the preprocessed text does not include a column instruction, the current line of the preprocessed text is analyzed according to the grammar rules; If the current line of the preprocessed text includes a column instruction, the count result of the column counter in the parsing phase is modified to be the column position in the column instruction.
5. The method for determining the position of the corresponding original text column after macro replacement according to claim 1, characterized in that: Also includes: In the preprocessing stage, before the original text is replaced according to the macro instruction, if the original text contains a column instruction, the counting result of the column counter in the preprocessing stage is modified to the column position in the column instruction, and the step of replacing the original text according to the macro instruction and subsequent steps are continued.
6. A device for determining the position of a corresponding original text column after macro replacement, characterized in that: include: A preprocessing module, used for performing replacement processing on the original text according to the macro instruction in the preprocessing stage, and inserting a column instruction at the replacement position to obtain a preprocessed text; wherein the column position in the column instruction is the counting result of the column counter in the preprocessing stage; A parsing module is used to parse the column instructions existing in the preprocessed text line by line in the parsing stage, and modify the counting result of the column counter in the parsing stage, and determine the column position of the keyword in the original text using the modified counting result; wherein, determining the column position of the keyword in the original text using the modified counting result includes: Obtaining the keyword, and determining the line where the keyword is located in the preprocessed text; Determine whether there is a modified column instruction in the row where the keyword is located; if not, determine the column position of the keyword as the counting result of the column counter in the parsing stage; if so, determine the position relationship between the keyword and the modified column instruction; If the keyword is before the modified column instruction, determining the column position of the keyword is the counting result of the column counter in the parsing stage; If the keyword is after the modified column instruction, then the counting result of the column counter in the parsing stage is determined to be the column position in the modified column instruction.
7. A server for determining the position of a corresponding original text column after macro replacement, characterized in that: including memory and processor; The memory is used to store computer executable instructions; The processor is used to execute the computer executable instructions to implement the method for determining the position of the corresponding original text column after macro replacement as described in any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium has executable instructions, and when a computer executes the executable instructions, it can implement the method for determining the position of the corresponding original text column after macro replacement as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Treatment method and device for performing geometric transformation on digital image
CN106355545A
Reconfigurable processing unit
US11113058B1