Query statement display method and device, computer equipment, readable storage medium and program product

By dynamically adjusting the query statement display method based on the lexical parsing mode, the problem of static recommended fields in existing technologies is solved, thereby improving user input efficiency and experience.

CN120929475APending Publication Date: 2025-11-11CHINA TELECOM CORP LTD TECHNOLOGY INNOVATION CENTER +1
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510931414.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-07
Publication Date
2025-11-11

Smart Images

  • Figure CN120929475A_ABST
    Figure CN120929475A_ABST
Patent Text Reader

Abstract

The invention relates to a query statement display method and device, computer equipment, a readable storage medium and a program product. The method comprises the steps that in the process that a user inputs an initial query statement, a current character input by the user is scanned in real time based on a lexical analyzer in a regular matching mode; switching a dynamic lexical analysis mode of a lexical analyzer based on the character type of the current character, and analyzing the current character based on the lexical analyzer after mode switching; based on the analysis result of the current character, generating a structured lexical unit Token stream of the initial query statement, and based on a current Token corresponding to the current character in the structured Token stream, obtaining at least one recommendation value of the current character; and generating a target query statement based on a selection result of the recommended value by the user, and displaying the target query statement in a display interface of the user. According to the method provided by the invention, the actual input requirement of the user can be met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of QL query technology, and in particular to a query statement display method, apparatus, computer equipment, readable storage medium, and program product. Background Technology

[0002] With the rapid development of internet technology, when users input queries about business data, systems can recommend fields that users might need to enter, thereby improving input efficiency. However, in existing technologies, regardless of the user's input, the fields recommended by the system are always the same static fields, which cannot meet the user's actual input needs and result in a poor user experience. Summary of the Invention

[0003] Therefore, it is necessary to provide a query statement display method, apparatus, computer device, readable storage medium, and program product that can meet the actual input needs of users, addressing the aforementioned technical problems.

[0004] Firstly, this application provides a method for displaying query statements, the method comprising:

[0005] During the process of the user inputting the initial query statement, the lexical analyzer, which is in regular expression matching mode, scans the current characters input by the user in real time;

[0006] Based on the character type of the current character, the dynamic lexical parsing mode of the lexical analyzer is switched, and the current character is parsed based on the lexical analyzer after the mode switch; the dynamic lexical parsing mode includes the regular expression matching mode, the state machine mode, and the set parsing mode;

[0007] Based on the parsing result of the current character, a structured lexical unit Token stream of the initial query statement is generated, and based on the current Token corresponding to the current character in the structured Token stream, at least one recommendation value of the current character is obtained;

[0008] Based on the user's selection of the recommended value, a target query statement is generated and displayed on the user's display interface.

[0009] In one embodiment, the step of switching the dynamic lexical parsing mode of the lexical analyzer based on the character type of the current character, and parsing the current character based on the lexical analyzer after the mode switch, includes:

[0010] If the current character is an escape character or is located in a nested syntax structure, the lexical analyzer is switched from the regular expression matching mode to the state machine mode;

[0011] The current character is parsed based on the lexical analyzer in the state machine mode;

[0012] After the parsing of the escape character or all characters within the nested syntax structure is completed, the lexical analyzer is switched from the state machine mode to the regular expression matching mode.

[0013] In one embodiment, the step of switching the dynamic lexical parsing mode of the lexical analyzer based on the character type of the current character, and parsing the current character based on the lexical analyzer after the mode switch, includes:

[0014] If the current character is a set operation keyword, the lexical analyzer is switched from the regular expression matching mode to the set parsing mode;

[0015] Based on the lexical analyzer in the set parsing mode, the sets corresponding to the set operation keywords are parsed;

[0016] After the set parsing is completed, the lexical analyzer is switched from the set parsing mode to the regular expression matching mode.

[0017] In one embodiment, the method further includes:

[0018] If the current character is not the escape character, not a character inside the nested syntax structure, and not located in the set corresponding to the set operation keyword, the current character is parsed based on the lexical analyzer in the regular expression matching mode.

[0019] In one embodiment, obtaining at least one recommendation value for the current character based on the current token corresponding to the current character in the structured token stream includes:

[0020] When the current token represents the current character as a user-defined identifier, at least one recommended identifier that matches the user-defined identifier is selected from a preset identifier list;

[0021] When the current token represents the current character as an operator, at least one recommended operator that matches the current character is selected from a preset operator list;

[0022] When the input process of the current token representing the current character is in the value input stage, at least one recommended input value is selected from the user's historical input cache record.

[0023] In one embodiment, displaying the target query statement in the user's display interface includes:

[0024] The target query statement is input into the parser, which outputs an abstract syntax tree (AST).

[0025] For any AST node in the AST, the display interface is rendered based on the data type of the fields in the AST node.

[0026] Secondly, this application also provides a query statement display device, the device comprising:

[0027] The scanning module is used to scan the current characters of the user's input in real time, based on the lexical analyzer in regular expression matching mode, during the process of the user inputting the initial query statement.

[0028] The switching module is used to switch the dynamic lexical parsing mode of the lexical analyzer based on the character type of the current character, and to parse the current character based on the lexical analyzer after the mode switch; the dynamic lexical parsing mode includes the regular expression matching mode, the state machine mode, and the set parsing mode;

[0029] The first generation module is used to generate a structured lexical unit Token stream of the initial query statement based on the parsing result of the current character, and to obtain at least one recommendation value of the current character based on the current Token corresponding to the current character in the structured Token stream;

[0030] The second generation module is used to generate a target query statement based on the user's selection of the recommended value, and to display the target query statement in the user's display interface.

[0031] Thirdly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the steps of the methods in any of the above embodiments.

[0032] Fourthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, implements the steps of the methods in any of the above embodiments.

[0033] Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, implements the steps of the methods in any of the above embodiments.

[0034] The aforementioned query statement display method, apparatus, computer device, readable storage medium, and program product, during the process of user inputting an initial query statement, scan the current character input by the user in real time based on a lexical analyzer in regular expression matching mode; based on the character type of the current character, switch the dynamic lexical parsing mode of the lexical analyzer, and parse the current character based on the lexical analyzer after mode switching; the dynamic lexical parsing mode includes regular expression matching mode, state machine mode, and set parsing mode; based on the parsing result of the current character, generate a structured lexical unit token stream of the initial query statement, and obtain at least one recommended value for the current character based on the current token corresponding to the current character in the structured token stream; based on the user's selection of the recommended value, generate the target query statement, and display the target query statement on the user's display interface. The method provided in this application can dynamically recommend recommended values ​​to the user based on the characters currently input by the user, which can improve the user's input efficiency, meet the user's actual input needs, and improve the user experience. Attached Figure Description

[0035] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0036] Figure 1 This is a flowchart illustrating a query statement display method in one embodiment;

[0037] Figure 2 This is a flowchart illustrating a mode switching method in one embodiment;

[0038] Figure 3 This is a schematic diagram illustrating the relationship between different modules in another embodiment;

[0039] Figure 4 This is a structural block diagram of a query statement display device in one embodiment;

[0040] Figure 5 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0041] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0042] It should be noted that the terms "first," "second," etc., used in this application can be used to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish the first element from the second element. The terms "comprising" and "having," and any variations thereof, used in this application, are intended to cover non-exclusive inclusion. The term "multiple" used in this application refers to two or more. The term "and / or" used in this application refers to one of the embodiments, or any combination of multiple embodiments.

[0043] In one embodiment, such as Figure 1 As shown, a method for displaying query statements is provided. This embodiment illustrates the application of this method to a terminal. It is understood that this method can also be applied to a server, and further to a system including both a terminal and a server, and is implemented through interaction between the terminal and the server. In this embodiment, the method includes the following steps:

[0044] S102. During the process of the user inputting the initial query statement, the lexical analyzer, which is in regular expression matching mode, scans the current characters input by the user in real time.

[0045] The lexical analyzer is used to convert the input character sequence into a meaningful lexical unit stream (TokenStream), providing structured input for subsequent syntax analysis. The lexical analyzer has multiple built-in dynamic lexical parsing modes. Based on these dynamic lexical parsing modes, the lexical analyzer can dynamically adjust the Token type according to the input context and dynamically select the optimal parsing strategy according to the real-time input syntax features.

[0046] The dynamic lexical parsing mode is used to dynamically adjust token rules based on the runtime context. This mode includes regular expression matching, state machine parsing, and set parsing. Regular expression matching uses regular expressions to define token matching rules, segmenting the input stream using greedy matching or longest-matching principles. It can only handle simple and well-defined syntax. State machine parsing uses a finite state automaton (FSM) to transition between different states, determining token boundaries based on the current state and input characters. It can handle complex contexts, such as nested escape characters within a string. Set parsing predefines valid tokens as sets (such as all keywords and operators), quickly determining the token type based on set membership relationships.

[0047] Optionally, the query statement can be, but is not limited to, a QL (Query Language) statement. The lexical analyzer is located in the QL editor. Before the user enters the initial query statement, the QL editor needs to be configured. The specific contents are as follows: (1) Receive configuration in JSON (JavaScript Object Notation) format, which is used to define the behavior of the QL editor in a declarative configuration to avoid hard coding; (2) Mount the root node (selector), which is used to specify the starting parsing rules of the syntax tree; (3) Inject business field metadata fieldList, where fieldList includes Chinese labels, field types and allowed operator sets; (4) Inject custom plugins using the setup callback function. For example, custom plugins can include syntax extension rules and UI (User Interface) theme configuration; (5) Register event listeners through init_instance_callback; (6) Configure the dynamic candidate value interface (setOptions). When setOptions runs, the field optional values ​​can be updated. For example, call setOptions('status group', ['in progress', 'completed']) to dynamically inject the status group list. JSON is a lightweight data exchange format that uses a text-based key-value pair structure, making it easy for humans to read and write, as well as for machines to parse and generate.

[0048] S104. Based on the character type of the current character, switch the dynamic lexical parsing mode of the lexical analyzer, and parse the current character based on the lexical analyzer after the mode switch; the dynamic lexical parsing modes include regular expression matching mode, state machine mode and set parsing mode.

[0049] Optionally, after parsing the current character, the current token corresponding to the current character can be generated.

[0050] Optionally, based on the character type of the current character, a dynamic lexical parsing mode can be selected from regular expression matching mode, state machine mode, and set parsing mode to parse the current character. If the current character is parsed using state machine mode or set parsing mode, the lexical analyzer mode needs to be switched back to regular expression matching mode after the parsing is finished.

[0051] S106. Based on the parsing result of the current character, generate a structured lexical unit Token stream for the initial query statement, and obtain at least one recommendation value for the current character based on the current Token corresponding to the current character in the structured Token stream.

[0052] Among them, the structured Token stream is an ordered and classified symbol sequence generated by the Lexer after parsing the query statement. Each Token contains meta-information such as type, value, and position, providing a standardized input for subsequent syntactic analysis.

[0053] Optionally, by sorting the Tokens of all characters that have been parsed in the initial query statement according to the arrangement order of the corresponding characters in the initial query statement, the structured Token stream can be obtained.

[0054] Optionally, after obtaining the recommended value of the current character, by verifying keywords such as PAREN bracket matching and ORDER BY, it can be ensured that the recommended value strictly matches the syntactic context of the initial query statement, significantly improving the query construction efficiency. Among them, PAREN is the Token type of brackets ( and ), which is used for: verifying nested matching (such as function calls, subqueries), and prompting the closing bracket during completion; ORDER BY is the sorting keyword in the query statement, and the completion module needs to identify the field name or sorting direction after it.

[0055] S108. Generate a target query statement based on the user's selection result of the recommended value, and display the target query statement in the user's display interface.

[0056] Optionally, the target query statement can be displayed by constructing the Abstract Syntax Tree (AST) of the target query statement. In order to display the content of the target query statement more accurately, an AST-UI mapper needs to be constructed to implement the two-way mapping between structured data and the visual interface. Among them, the two-way mapping includes forward mapping and reverse mapping; the forward mapping is used to convert the field names in the AST nodes into Chinese labels and render interactive controls (such as dropdown boxes) according to the type. For example, convert the field name (status) into the Chinese label ("Status"); the reverse mapping is used to capture the Chinese value input by the user (such as "Enabled"), reverse-match the database stored value (waitForProcess), and generate an executable AST node.

[0057] In the above query statement display method, during the user's initial query statement input, the lexical analyzer, based on regular expression matching mode, scans the current character input by the user in real time; based on the character type of the current character, the dynamic lexical parsing mode of the lexical analyzer is switched, and the current character is parsed based on the lexical analyzer after the mode switch; the dynamic lexical parsing mode includes regular expression matching mode, state machine mode, and set parsing mode; based on the parsing result of the current character, a structured lexical unit Token stream of the initial query statement is generated, and based on the current Token corresponding to the current character in the structured Token stream, at least one recommended value for the current character is obtained; based on the user's selection of the recommended value, the target query statement is generated and displayed on the user's display interface. The method provided in this application can dynamically recommend recommended values ​​to the user based on the characters currently input by the user, which can improve the user's input efficiency, meet the user's actual input needs, and improve the user experience.

[0058] In some embodiments, such as Figure 2 As shown, based on the character type of the current character, the dynamic lexical parsing mode of the lexical analyzer is switched, and the current character is parsed based on the lexical analyzer after the mode switch, including:

[0059] S202. If the current character is an escape character or is located in a nested syntax structure, switch the lexical analyzer from regular expression matching mode to state machine mode.

[0060] S204. Based on the lexical analyzer in state machine mode, the current character is parsed.

[0061] S206. After all characters within escape characters or nested syntax structures have been parsed, switch the lexical analyzer from state machine mode to regular expression matching mode.

[0062] Escape characters are special characters used to represent characters that cannot be directly entered or have special meanings. They usually begin with a backslash \ followed by a specific character, telling the parser to "process the following characters literally". Nested grammatical structures refer to multi-level grammatical units in a language, where one grammatical structure contains another structure of the same or different types.

[0063] Optionally, when the current character is a quotation mark, the system immediately switches from regular expression matching mode to state machine mode to accurately handle escape characters and nested syntax structures. For example, when parsing the string "value\"with\"quote", the state machine continuously tracks the escape state to ensure that the second quotation mark is not misinterpreted as the end of the string.

[0064] In this embodiment, when the current character is an escape character or is located in a nested grammatical structure, the lexical analyzer is switched from regular expression matching mode to state machine mode, which can more accurately parse the current character.

[0065] In some embodiments, the dynamic lexical parsing mode of the lexical analyzer is switched based on the character type of the current character, and the current character is parsed based on the lexical analyzer after the mode switch, including: when the current character is a set operation keyword, the lexical analyzer is switched from regular expression matching mode to set parsing mode; based on the lexical analyzer in set parsing mode, the set corresponding to the set operation keyword is parsed; after the set parsing is completed, the lexical analyzer is switched from set parsing mode to regular expression matching mode.

[0066] Among them, set operation keywords represent the set relationship of values ​​or subqueries, which usually involves parsing the elements within parentheses and requires special handling of commas as separators for set elements.

[0067] Optionally, when the current character is the keyword IN or NOT IN, a special set parsing mode will be activated to adjust the parsing rules for parentheses and commas.

[0068] In this embodiment, when the current character is a set operation keyword, the lexical analyzer is switched from regular expression matching mode to set parsing mode, which can more accurately parse the current character.

[0069] In some embodiments, the method further includes: parsing the current character based on a lexical analyzer in regular expression matching mode, provided that the current character is not an escape character, is not a character within a nested syntax structure, and is not located in the set corresponding to the set operation keyword.

[0070] Optionally, if the current character is not an escape character, not a character within a nested syntax structure, and not located in the set corresponding to the set operation keyword, it indicates that the current character is a simple and well-defined character, and it can be parsed directly using the regular expression matching pattern.

[0071] In this embodiment, when the current character is not an escape character, not a character inside a nested syntax structure, and not located in the set corresponding to the set operation keyword, the current character is parsed based on the lexical analyzer in regular expression matching mode. No mode switching is required, which can accurately and efficiently parse the current character.

[0072] In some embodiments, obtaining at least one recommended value for the current character based on the current token corresponding to the current character in the structured token stream includes: when the current token represents the current character as a user-defined identifier, selecting at least one recommended identifier that matches the user-defined identifier from a preset identifier list; when the current token represents the current character as an operator, selecting at least one recommended operator that matches the current character from a preset operator list; and when the current token represents the current character as being in the value input stage, selecting at least one recommended input value from the user's historical input cache record.

[0073] Optionally, the user-defined identifier can be, but is not limited to, a table name, column name, or alias. A pre-defined identifier list that matches the type of the user-defined identifier can be selected, and at least one of the most matching recommended identifiers can be selected from the list for the user to choose from.

[0074] Optionally, the operator can be, but is not limited to, an operator or a collection operator. For example, the operator can be =, >, +, AND, and the collection operator can be IN, NOT IN, ANY.

[0075] Optionally, during the value input stage, at least one recommended input value can be determined for the user to choose from based on cached user history input data and the current character.

[0076] In this embodiment, based on the meaning of the current character represented by the current Token, at least one recommended value for the current character is dynamically determined, which can meet the user's input needs and improve the user's input efficiency.

[0077] In some embodiments, displaying the target query statement in the user's display interface includes: inputting the target query statement into a parser and outputting an abstract syntax tree (AST); and rendering the display interface based on the data type of the fields in the AST for any AST node.

[0078] Optionally, the parser, located in the QL editor, is responsible for converting the token stream generated by the lexical analyzer into an abstract syntax tree to verify whether the statement structure conforms to the grammatical rules and to clarify its logical hierarchy.

[0079] Optionally, the input components (such as input boxes / drop-down boxes) can be dynamically rendered through the selector configuration, the onChange (a user interface event) event can be bound to capture user input and drop-down box selection, the QL editor can be called to generate a syntax highlighting token stream and completion suggestions, and the onSubmit (a form-specific event) can be delegated to send the target query statement back to the business system, thus realizing full-link driving from configuration to interaction.

[0080] In this embodiment, by generating an abstract syntax tree and rendering the display interface based on AST nodes, the content of the target query statement can be displayed more accurately.

[0081] In one embodiment, another method for displaying query statements is provided. The corresponding system includes a core syntax engine module, a configuration interface module, a parsing and generation module, and a queryer instance module. The relationship between these modules is shown in the diagram below. Figure 3 As shown, the specific contents of each module are as follows:

[0082] (1) Core Syntax Engine Module

[0083] 1) Dynamic Lexical Parsing Module (qlParse): This module primarily parses user-inputted QL statements into a structured token stream and constructs an Abstract Syntax Tree (AST), providing foundational data support for subsequent modules. This part includes the specific implementation of dynamic lexical analysis, which can be summarized as follows:

[0084] The lexical analyzer (tokenize method) is not entirely static; instead, it dynamically adjusts the token type based on the context. This analyzer incorporates a dual engine of regular expressions and a finite state machine, dynamically selecting the optimal parsing strategy based on the syntactic features of the real-time input. When a quotation mark is detected, it immediately switches from regular expression matching mode to state machine mode to precisely handle escape characters and nested syntactic structures. For example, when parsing the string "value\"with\"quote", the state machine continuously tracks escape states to ensure that the second quotation mark is not misinterpreted as the end of the string. Similarly, when encountering the IN or NOT IN keywords, a dedicated set parsing mode is activated, adjusting the parsing rules for parentheses and commas.

[0085] 2) Context-Aware Suggestion Generation Module (qlCompleter): Based on cursor position, current token stream, field type, and user history, it generates a context-sensitive completion suggestion list in real time. It can identify the user's input stage based on currentToken and prevToken: when an IDENTIFIER type token is detected, it recommends matching field names from the fieldList; when an OPERATOR or COLLECTION_OPERATOR is encountered, it returns the set of operators (e.g., =, IN) from the field configuration; during value input, it filters selected options (parts) based on cachedOptVals and recommends valid values. By validating PAREN bracket matching and keywords such as ORDER BY (KEYWORD type), it ensures that suggestions strictly match the syntactic context, significantly improving query construction efficiency. Specifically, currentToken is the token currently being entered or just completed at the current cursor position, used to determine the user's current operation intent; prevToken is the preceding, already determined token adjacent to currentToken, used to infer the context; IDENTIFIER represents the user-defined name.

[0086] 3) QL statement generation and update module (QLSuggest Engine): Responds to user completion selections or manual input, generates new QL statements that conform to the syntax rules, and intelligently adjusts the cursor position.

[0087] (2) Configure the interface module

[0088] 1) The editor constructor receives standardized configuration parameters: it receives configuration in JSON format, mounts the root node selector, injects business field metadata fieldList (including Chinese tags, field types and allowed operator sets), injects custom plugins (such as syntax extension rules and UI theme configurations) using the setup callback function, and registers event listeners through init_instance_callback.

[0089] 2) Dynamic candidate value interface (setOptions): Updates optional values ​​for fields at runtime (e.g., dynamically injects the list of status groups by calling setOptions('status group', ['in progress', 'completed'])).

[0090] (3) Parsing and generation module

[0091] AST-UI Mapper: Enables bidirectional mapping between structured data and visual interfaces.

[0092] 1) Forward mapping: Convert the field name (status) in the AST node to a Chinese label ("Status"), and render an interactive control (such as a dropdown box) according to the type.

[0093] 2) Reverse mapping: Capture the Chinese value entered by the user (such as "Enabled"), reverse-match the value stored in the database (waitForProcess), and generate an executable AST node.

[0094] (4) Query instance module

[0095] Generate a final business-available intelligent editor instance through configuration-driven:

[0096] This module dynamically renders input components (such as input boxes / dropdown boxes) through selector configuration, binds the onChange event to capture user input and dropdown selections, calls the parser to generate a syntax-highlighted Token stream and completion suggestions, and proxies the onSubmit to send the standard QL back to the business system, realizing the full-link drive from configuration to interaction.

[0097] It should be understood that although the steps in the flowcharts involved in the above-described embodiments are shown in sequence according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless there is a clear indication in this article, the execution of these steps has no strict order limit, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-described embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be executed alternately or alternately with at least a part of other steps or steps in other steps. It can be understood that the steps in different embodiments can be freely combined as needed, and all non-contradictory solutions formed by the combination belong to the scope protected by this application.

[0098] Based on the same inventive concept, the embodiments of this application also provide a query statement display device for implementing the above-mentioned query statement display method. The solution provided by this device to solve the problem is similar to the solution described in the above method. Therefore, the specific limitations in one or more embodiments of the query statement display device provided below can be referred to the limitations on the query statement display method in the above text, and will not be repeated here.

[0099] In an exemplary embodiment, as Figure 4 shown, a query statement display device 400 is provided, including: a scanning module 401, a switching module 402, a first generation module 403, and a second generation module 404, where:

[0100] The scanning module 401 is used to scan the current characters input by the user in real time based on the lexical analyzer in regular expression matching mode during the process of the user inputting the initial query statement.

[0101] The switching module 402 is used to switch the dynamic lexical parsing mode of the lexical analyzer based on the character type of the current character, and to parse the current character based on the lexical analyzer after the mode switch; the dynamic lexical parsing mode includes the regular expression matching mode, the state machine mode, and the set parsing mode.

[0102] The first generation module 403 is used to generate a structured lexical unit Token stream of the initial query statement based on the parsing result of the current character, and to obtain at least one recommendation value of the current character based on the current Token corresponding to the current character in the structured Token stream.

[0103] The second generation module 404 is used to generate a target query statement based on the user's selection result of the recommended value, and display the target query statement in the user's display interface.

[0104] In some embodiments, the switching module 402 is further configured to switch the lexical analyzer from the regular expression matching mode to the state machine mode when the current character is an escape character or is located in a nested syntax structure; parse the current character based on the lexical analyzer in the state machine mode; and switch the lexical analyzer from the state machine mode to the regular expression matching mode after the parsing of the escape character or all characters in the nested syntax structure is completed.

[0105] In some embodiments, the switching module 402 is further configured to, when the current character is a set operation keyword, switch the lexical analyzer from the regular expression matching mode to the set parsing mode; parse the set corresponding to the set operation keyword based on the lexical analyzer in the set parsing mode; and after the set parsing is completed, switch the lexical analyzer from the set parsing mode to the regular expression matching mode.

[0106] In some embodiments, the switching module 402 is further configured to parse the current character based on the lexical analyzer in the regular expression matching mode when the current character is not the escape character, not a character inside the nested syntax structure, and not located in the set corresponding to the set operation keyword.

[0107] In some embodiments, the first generation module 403 is further configured to: when the current token represents the current character as a user-defined identifier, select at least one recommended identifier that matches the user-defined identifier from a preset identifier list; when the current token represents the current character as an operator, select at least one recommended operator that matches the current character from a preset operator list; and when the current token represents the current character as an input process in the value input stage, select at least one recommended input value from the user's historical input cache record.

[0108] The second generation module 404 is further configured to input the target query statement into the syntax analyzer and output an abstract syntax tree (AST); and to render the display interface based on the data type of the fields in the AST for any AST node.

[0109] The various modules in the query statement display device described above can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.

[0110] In one exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 5 As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, Near Field Communication (NFC), or other technologies. When executed by the processor, the computer program implements a query statement display method.

[0111] Those skilled in the art will understand that Figure 5The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0112] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.

[0113] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.

[0114] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.

[0115] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.

[0116] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.

[0117] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0118] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A method for displaying query statements, characterized in that, The method includes: During the process of the user entering the initial query statement, the lexical analyzer, which is in regular expression matching mode, scans the current characters entered by the user in real time; Based on the character type of the current character, the dynamic lexical parsing mode of the lexical analyzer is switched, and the current character is parsed based on the lexical analyzer after the mode switch; the dynamic lexical parsing mode includes the regular expression matching mode, the state machine mode, and the set parsing mode; Based on the parsing result of the current character, a structured lexical unit Token stream of the initial query statement is generated, and based on the current Token corresponding to the current character in the structured Token stream, at least one recommendation value of the current character is obtained; Based on the user's selection of the recommended value, a target query statement is generated and displayed on the user's display interface.

2. The method according to claim 1, characterized in that, The step of switching the dynamic lexical parsing mode of the lexical analyzer based on the character type of the current character, and parsing the current character based on the lexical analyzer after the mode switch, includes: If the current character is an escape character or is located in a nested syntax structure, the lexical analyzer is switched from the regular expression matching mode to the state machine mode; The current character is parsed based on the lexical analyzer in the state machine mode; After the parsing of the escape character or all characters within the nested syntax structure is completed, the lexical analyzer is switched from the state machine mode to the regular expression matching mode.

3. The method according to claim 1, characterized in that, The step of switching the dynamic lexical parsing mode of the lexical analyzer based on the character type of the current character, and parsing the current character based on the lexical analyzer after the mode switch, includes: If the current character is a set operation keyword, the lexical analyzer is switched from the regular expression matching mode to the set parsing mode; Based on the lexical analyzer in the set parsing mode, the sets corresponding to the set operation keywords are parsed; After the set parsing is completed, the lexical analyzer is switched from the set parsing mode to the regular expression matching mode.

4. The method according to any one of claims 1 to 3, characterized in that, The method further includes: If the current character is not the escape character, not a character inside the nested syntax structure, and not located in the set corresponding to the set operation keyword, the current character is parsed based on the lexical analyzer in the regular expression matching mode.

5. The method according to claim 1, characterized in that, The step of obtaining at least one recommendation value for the current character based on the current token corresponding to the current character in the structured token stream includes: When the current token represents the current character as a user-defined identifier, at least one recommended identifier that matches the user-defined identifier is selected from a preset identifier list; When the current token represents the current character as an operator, at least one recommended operator that matches the current character is selected from a preset operator list; When the input process of the current token representing the current character is in the value input stage, at least one recommended input value is selected from the user's historical input cache record.

6. The method according to claim 1, characterized in that, Displaying the target query statement in the user's display interface includes: The target query statement is input into the parser, which outputs an abstract syntax tree (AST). For any AST node in the AST, the display interface is rendered based on the data type of the fields in the AST node.

7. A query statement display device, characterized in that, The device includes: The scanning module is used to scan the current characters of the user's input in real time, based on the lexical analyzer in regular expression matching mode, during the process of the user inputting the initial query statement. The switching module is used to switch the dynamic lexical parsing mode of the lexical analyzer based on the character type of the current character, and to parse the current character based on the lexical analyzer after the mode switch; the dynamic lexical parsing mode includes the regular expression matching mode, the state machine mode, and the set parsing mode; The first generation module is used to generate a structured lexical unit Token stream of the initial query statement based on the parsing result of the current character, and to obtain at least one recommendation value of the current character based on the current Token corresponding to the current character in the structured Token stream; The second generation module is used to generate a target query statement based on the user's selection of the recommended value, and to display the target query statement in the user's display interface.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.

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

10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.

Citation Information

Cited By

  • SQL (Structured Query Language) statement extraction method and device, electronic equipment and storage medium

    CN121350065A