WO2021129074A1 - Method and system for processing reference of variable in program code - Google Patents

Method and system for processing reference of variable in program code Download PDF

Info

Publication number
WO2021129074A1
WO2021129074A1 PCT/CN2020/121830 CN2020121830W WO2021129074A1 WO 2021129074 A1 WO2021129074 A1 WO 2021129074A1 CN 2020121830 W CN2020121830 W CN 2020121830W WO 2021129074 A1 WO2021129074 A1 WO 2021129074A1
Authority
WO
WIPO (PCT)
Prior art keywords
variable
variable symbol
symbol
program code
user
Prior art date
Application number
PCT/CN2020/121830
Other languages
French (fr)
Chinese (zh)
Inventor
丛明舒
瞿中明
曲嘉宝
曾凯
唐来朋
何毅良
Original Assignee
深圳逻辑汇科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳逻辑汇科技有限公司 filed Critical 深圳逻辑汇科技有限公司
Publication of WO2021129074A1 publication Critical patent/WO2021129074A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/34Graphical or visual programming
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/43Checking; Contextual analysis
    • G06F8/433Dependency analysis; Data or control flow analysis

Definitions

  • the present invention generally relates to the field of processing computer programming, and specifically, to a method and system for processing undeclared, undefined, or uninitialized variable references in programming language codes.
  • Computer programs generally involve the processing of variables.
  • a variable is a placeholder corresponding to a piece of computer memory space; in an object-oriented programming language, a variable can also be represented as an object as an instance of a certain class.
  • Operations on variables in a programming language may include, for example, declare, define, initialize, assign, access, destruct, and so on. Usually these operations on variables follow strict dependencies. For example, an uninitialized variable cannot be accessed, and an undefined variable cannot be destroyed.
  • the dependent operation is referred to as the "definition” of the variable
  • the variable operation that depends on the “definition” is referred to as A “reference” to the variable. That is to say, the “define” in the present invention is not limited to a narrow definition operation, but may include various operations on which the "quoting” operation may depend.
  • the "definition” operation it relies on includes the “declaration” operation in addition to the narrow “definition” operation.
  • a method for handling references of variables in program code includes sequentially receiving a stream of characters contained in user input.
  • the character stream is part of the program code.
  • the method also includes identifying the first variable symbol from the received character stream and storing information related to the first variable symbol.
  • the first variable symbol represents the first variable.
  • the method also includes matching the first variable symbol with at least one variable symbol previously identified from the program code to determine whether there is a second variable symbol representing the first variable in the at least one variable symbol.
  • the method further includes, in response to determining that there is at least one second variable symbol, determining whether the first variable symbol involves an undefined reference based on an operation related to the first variable symbol and an operation related to the one or more second variable symbols .
  • the method also includes in response to determining that the first variable symbol relates to an undefined reference, providing visual assistance to the user to process the undefined reference.
  • a computer system includes one or more processors and a memory coupled to the one or more processors.
  • the memory stores computer instructions that, when executed by the one or more processors, cause the one or more processors to perform the operations of the above-mentioned method.
  • a computer-readable storage medium stores computer instructions that, when run by a processor, cause the processor to perform the above-mentioned method.
  • Figure 1 shows a block diagram of an exemplary computer system/server 12 suitable for implementing embodiments of the present invention.
  • Fig. 2 shows a flowchart of a method for handling references of variables in program code according to an embodiment of the present disclosure.
  • Fig. 3 shows an example of the operation of a graphical user interface editor using SMALL language.
  • Fig. 4 shows an example of inputting code by a graphical user interface editor using SMALL language according to an embodiment of the present disclosure.
  • Fig. 5 shows an example of a variable symbol table according to an embodiment of the present disclosure.
  • Fig. 6 shows an example of the relationship between the program code, the variable symbol table, and the variable table according to an embodiment of the disclosure.
  • FIG. 7 shows an example of a process of establishing a variable table according to an embodiment of the present disclosure.
  • FIG. 8 shows an example of establishing a relationship between a variable symbol table and a variable table according to an embodiment of the present disclosure.
  • FIG. 9 shows an example of updating the variable symbol table and the variable table according to an embodiment of the present disclosure.
  • FIG. 10 shows another example of updating the variable table according to the variable symbol table according to an embodiment of the present disclosure.
  • FIG. 11 shows an example of providing visual assistance according to an embodiment of the present disclosure.
  • Fig. 12 shows an example of a strict matching prompt according to an embodiment of the present disclosure.
  • FIG. 13 shows an example of a prompt for rule-based matching according to an embodiment of the present disclosure.
  • Fig. 14 shows a hint example of fuzzy matching according to an embodiment of the present disclosure.
  • FIG. 15 shows an example in which a user selects a fuzzy matching result according to an embodiment of the present disclosure.
  • FIG. 16 shows an example of changing the name of a variable symbol according to a matching result according to an embodiment of the present disclosure.
  • FIG. 17 shows an example of an undefined reference table according to an embodiment of the present disclosure.
  • FIG. 18 shows a display example of an undefined reference table according to an embodiment of the present disclosure.
  • FIG. 19 shows a display example of an undefined reference table according to an embodiment of the present disclosure.
  • FIG. 20 shows an example of deleting a defined variable symbol from an undefined reference table according to an embodiment of the present disclosure.
  • FIG. 21 shows an example of performing a prior access using a subsequent definition according to an embodiment of the present disclosure.
  • FIG. 22 shows a display example of a variable symbol table and a variable table according to an embodiment of the present disclosure.
  • FIG. 23 shows a display example of a variable symbol table according to an embodiment of the present disclosure.
  • FIG. 24 shows an example of error correction according to an embodiment of the present disclosure.
  • FIG. 25 shows an example of displaying the adjusted program code to the user according to an embodiment of the present disclosure.
  • FIG. 26 shows an example of the correspondence between source program codes and adjusted program codes according to an embodiment of the present disclosure.
  • FIG. 27 shows an example in which a user manually adjusts the order of program statements according to an embodiment of the present disclosure.
  • the inventor of the present invention proposes a system and method for handling undefined references in program code.
  • the system and method can relax the limitation of the traditional programming language on the position sequence or input sequence of the code.
  • the present invention allows the user to first input a code that references an undefined variable, and then input the code that defines this variable at any position.
  • the present invention also allows the program to be parsed and executed locally when not all variables have been defined.
  • the present invention also allows assisting users to adjust the sequence of variable definition operation codes and variable reference operation codes so as to correctly complete program compilation and execution.
  • the system will automatically match the definition and reference to the same variable.
  • the "definition” operation of the variable mentioned here also uses the broad meaning described above, that is, it includes various operations on which the "reference” operation depends, and is not limited to the narrow definition operation, depending on the type of the reference operation, for example, Including declaration, definition, assignment, etc.
  • the "access” operation (referred to as reference) to the integer variable x depends on the "declaration”, “definition” and “assignment” operations (referred to as definition for simplicity) of the variable x .
  • the "definition” and “reference” of a variable are relative terms. They are two operations on the same variable in the program code.
  • the “reference” operation of a variable depends on the variable.
  • "Define” operation The definition and reference of a variable can be the following operations on the variable: declaration (declare), definition (define), initialization (initialize), assignment (assignment), access (access), destruction (destruct) and so on.
  • the declaration of a variable is the program code telling the compiler the variable name and type of the variable and the variable will be defined.
  • the definition of a variable means that the program code tells the compiler to create a variable and allocate a memory space for the variable.
  • the initialization of a variable means that the program code tells the compiler to assign an initial value to the variable.
  • Variable assignment refers to assigning a specified value to this variable as the value of this variable.
  • Variable access refers to reading or using this variable, including assigning the value of the variable to other variables.
  • the destruction of a variable refers to the release of the memory space occupied by the variable.
  • the same code statement can complete one or more variable operations.
  • int a completes the declaration and definition of the variable "a” at the same time;
  • the variable “a” is only declared in one file, and “a” needs to be defined in another file;
  • the operation of adding a row named "Revenue" to a table simultaneously completes the declaration, definition and initialization of this row.
  • accessing a variable refers to reading the address or value of the variable and using it to perform certain operations.
  • the sequence of performing the variable reference operation first and then performing the variable definition operation may be more in line with the thinking logic of the program writer, making it more readable.
  • the present invention can be implemented as a system, a method or a computer program product. Therefore, the present disclosure can be specifically implemented in the following forms, namely: it can be complete hardware, complete software (including firmware, resident software, microcode, etc.), or a combination of hardware and software. This article generally Called “circuit", “module” or “system”.
  • the present invention may also be implemented in the form of a computer program product in one or more computer-readable media, the computer-readable medium containing computer-readable program code.
  • each block of the flowchart and/or block diagram and the combination of each block in the flowchart and/or block diagram can be implemented by computer program instructions.
  • These computer program instructions can be provided to the processors of general-purpose computers, special-purpose computers, or other programmable data processing devices, thereby producing a machine.
  • These computer program instructions are executed by the computer or other programmable data processing devices to generate an implementation flow chart. And/or the function/operation device specified in the block in the block diagram.
  • Figure 1 shows a block diagram of an exemplary computer system/server 12 suitable for implementing embodiments of the present invention.
  • the computer system/server 12 shown in FIG. 1 is only an example, and should not bring any limitation to the function and application scope of the embodiment of the present invention.
  • the computer system/server 12 is represented in the form of a general-purpose computing device.
  • the components of the computer system/server 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 connecting different system components (including the system memory 28 and the processing unit 16).
  • the bus 18 represents one or more of several types of bus structures, including a memory bus or a memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any bus structure among multiple bus structures.
  • these architectures include, but are not limited to, industry standard architecture (ISA) bus, microchannel architecture (MAC) bus, enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and peripheral component interconnection ( PCI) bus.
  • ISA industry standard architecture
  • MAC microchannel architecture
  • VESA Video Electronics Standards Association
  • PCI peripheral component interconnection
  • the computer system/server 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the computer system/server 12, including volatile and nonvolatile media, removable and non-removable media.
  • the system memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and/or cache memory 32.
  • the computer system/server 12 may further include other removable/non-removable, volatile/nonvolatile computer system storage media.
  • the storage system 34 may be used to read and write non-removable, non-volatile magnetic media (not shown in FIG. 1 and generally referred to as a "hard drive").
  • a disk drive for reading and writing to a removable non-volatile disk such as a "floppy disk”
  • a removable non-volatile disk such as CD-ROM, DVD-ROM
  • other optical media read and write optical disc drives.
  • each drive can be connected to the bus 18 through one or more data media interfaces.
  • the memory 28 may include at least one program product, the program product having a set of (for example, at least one) program modules, and these program modules are configured to perform the functions of the embodiments of the present invention.
  • a program/utility tool 40 having a set of (at least one) program module 42 may be stored in, for example, the memory 28.
  • Such program module 42 includes, but is not limited to, an operating system, one or more application programs, and other programs Modules and program data, each of these examples or some combination may include the realization of a network environment.
  • the program module 42 generally executes the functions and/or methods in the described embodiments of the present invention.
  • the computer system/server 12 can also communicate with one or more external devices 14 (such as keyboards, pointing devices, displays 24, etc.), and can also communicate with one or more devices that enable users to interact with the computer system/server 12. And/or communicate with any device (such as a network card, modem, etc.) that enables the computer system/server 12 to communicate with one or more other computing devices. This communication can be performed through an input/output (I/O) interface 22.
  • the computer system/server 12 may also communicate with one or more networks (for example, a local area network (LAN), a wide area network (WAN), and/or a public network, such as the Internet) through the network adapter 20.
  • LAN local area network
  • WAN wide area network
  • public network such as the Internet
  • the network adapter 20 communicates with other modules of the computer system/server 12 through the bus 18. It should be understood that although not shown in the figure, other hardware and/or software modules can be used in conjunction with the computer system/server 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, Tape drives and data backup storage systems, etc.
  • Fig. 2 shows a flowchart of a method for handling references of variables in program code according to an embodiment of the present disclosure.
  • the method shown in FIG. 2 may be executed by, for example, the computer system or the server 12 shown in FIG. 1.
  • the method shown in FIG. 2 includes steps 210 to 250, but this is only illustrative, and the method may also include more or fewer steps.
  • step 210 the character stream contained in the user input may be received sequentially.
  • the character stream is a part of the program code, and the program code is written in a compiled language, an interpreted language, or a language used to build a spreadsheet model.
  • the user can input all or part of the program code through a text editor or a graphical user interface editor, or directly read all or part of the program code stored in the storage device.
  • the "program code" in the present disclosure can be composed of plain text code, or can be composed of a set of operations of the user in the graphical user interface.
  • traditional programming languages such as C++ and Python only receive codes in plain text, but programs in SMALL language can either be codes in plain text or a set of user operations in a graphical user interface.
  • the user input may include at least a part of program code generated by a user input action monitored by a text editor.
  • step 220 can perform corresponding operations by reading the character string and the cursor position saved by the text editor.
  • the user input may include at least a part of program code generated by a user's operation in a graphical user interface editor.
  • a graphical user interface editor to input program code
  • the editor monitors user operations in the graphical user interface For use in subsequent steps.
  • Fig. 3 shows an example of the operation of a graphical user interface editor using SMALL language.
  • the graphical user interface editor using SMALL language contains different components. The user can add the component "+row" 301 by clicking the row of the graphical user interface with the mouse.
  • the component 302 the component 302 represents a row in the spreadsheet. If the row name "Revenue” 303 is entered in the component 302, the newly added row will be named "Revenue”.
  • the system saves the user's operation of adding a row (for example, clicking on the component 301) and the character string input in the component 302 for use in subsequent steps.
  • the user input may include at least a part of the program code edited and stored by the user.
  • the system can directly read all or part of the programs previously edited by the user and saved in the storage device.
  • step 210 is implemented as the system reads all or part of the program codes saved by the user into the memory, and starts to read the program codes in the memory sequentially to form a character stream.
  • step 220 the first variable symbol is identified from the received character stream and information related to the first variable symbol is stored.
  • the first variable symbol represents the first variable.
  • identifying the first variable symbol from the received character stream may include using one or more of a lexical analyzer or a machine learning classifier to identify the first variable symbol from the received character stream .
  • a lexer Lexer
  • the lexical analyzer is implemented by a finite state machine.
  • a machine learning classifier may be used to identify variable symbols.
  • recognizing the first variable symbol from the received character stream may include recognizing the character stream received from a specific component of the graphical user interface editor as the first variable symbol.
  • the process of identifying variable symbols may only partially use or not use lexical analysis.
  • the content entered by the user in a specific graphical user interface component can be recognized as a variable symbol.
  • Fig. 4 shows an example of inputting code by a graphical user interface editor using SMALL language according to an embodiment of the present disclosure. As shown in FIG. 4, when the user enters "Revenue" in the column 402 in a row component 401, "Revenue" will be recognized as a variable symbol of the type "row".
  • a lexical analyzer or machine learning classifier to identify variable symbols. For example, if you enter " ⁇ US Revenue ⁇ + ⁇ China Revenue ⁇ " (403,404) in the formula input field to the right of the equal sign in the line component 401 shown in Figure 4, the lexical analyzer can convert the content in the braces Recognized as variable symbols; and if you enter "US Revenue+China Revenue” in the formula input column, the machine learning classifier can recognize "US Revenue” and "China Revenue” as variable symbols.
  • the information related to the variable symbol may include one or more of the following information: the name of the variable symbol, the position of the variable symbol in the program code, the namespace of the variable symbol, and the role of the variable symbol Domains, types of variables represented by variable symbols, variables represented by variable symbols, and operations related to variable symbols.
  • the name of the variable symbol refers to the string representing the variable symbol. For example, in the above example, “x”, “aa”, “b”, “Revenue”, “US Revenue”, and “China Revenue” are all variable symbols The name. When the variable symbol is recognized, the name of the variable symbol is obtained.
  • the position of the variable symbol in the program code refers to the information that can locate the variable symbol in the program code.
  • the position of a variable symbol in the program code can be represented by a tuple that represents the position of the variable symbol in the program code. For example, (8, 10, 3) represents that the variable symbol is the first in the program code. 3 characters from the 10th character on the 8th line.
  • the position of the variable symbol in the program code can be obtained by the position of the component to which the variable symbol is input.
  • variable symbols in a program can be grouped, and each group belongs to a namespace or a scope.
  • Two variable symbols with the same name in different namespaces or different scopes actually The above represents different variables.
  • namespace is similar to scope, and it is also a way to refer to the grouping of variable symbols.
  • namespaces can be used to further distinguish variable symbols with the same name in the same scope.
  • the variable names referred to by the two variable symbols “namespaceA::a” and “namespaceB::a” are all "a", but because they belong In different namespaces, it represents two different variables.
  • the program code of SMALL language if a row “Revenue” is added to a table named “Revenue Breakup”, and a row “Revenue” is added to a table named “Income Statement”, then The two variable symbols whose names are both "Revenue” belong to different namespaces. That is, the former belongs to the namespace in the table "Revenue Breakup”, and the latter belongs to the namespace in the table "Income Statement”.
  • the namespace can be obtained by grammatically analyzing the context of the variable symbol.
  • the syntax analysis is to construct the token sequence (Tokens) obtained from the lexical analysis into at least one of a parse tree (Parse Tree) or an abstract syntax tree (Abstract Syntax Tree) or other hierarchical data structures according to grammatical rules.
  • the data structure records the affiliation and dependency relationship between the variable symbols, as well as the name space and other information.
  • the scope of the variable symbol and the type of the variable represented by the variable symbol can also be obtained by grammatically analyzing the context of the variable symbol.
  • the namespace can be obtained by the information of the graphical user interface component when the variable is created.
  • the name space of a variable symbol can be obtained according to the structural relationship between the component to which the variable symbol is input and other components.
  • the namespace of the variable symbol can be obtained according to the path of the variable symbol specified by the user.
  • the scope of the variable symbol can be obtained by the structural relationship between the component inputting the variable symbol and other components.
  • operations related to variable symbols include at least one of the following: declaration, definition, initialization, assignment, access, and destruction.
  • Operations related to variable symbols refer to operations on variables represented by variable symbols.
  • the variable represented by the variable symbol "x" has been declared, defined and initialized.
  • the operations related to the variable symbols can be obtained through the user's corresponding operations in the graphical user interface editor.
  • Figure 3 for example, by clicking on the row add component 301 and inputting "Revenue” 303 to add a row (namely variable) named "Revenue", this series of operations represents the declaration and definition of this row.
  • Figure 4 the operation of entering "US Revenue” 403 and "China Revenue” 404 in the formula input box on the right side of the equal sign in row 401 represents the access to these two variables.
  • the type of the variable represented by the variable symbol can be obtained from the information of the component when the variable is created. For example, as shown in Figure 3, when the row "Revenue” is created, since the row addition component 301 is clicked, the type of the variable "Revenue” is row.
  • the first variable symbol refers to the variable symbol being recognized by the method at this time.
  • other variable symbols located before the first variable symbol in the program code may have been identified.
  • the information related to the first variable symbol is stored in a data structure.
  • the data structure may be a table, which will be referred to as a variable symbol table in the following for ease of description.
  • the variable symbol table stores information related to each recognized variable symbol in the program code.
  • the variable symbol table is used to store the variable symbols identified in step 220 and their related information. After identifying a variable symbol, the system stores the identified variable symbol and its related information in the variable symbol table. If the variable symbol table does not exist, first establish the variable symbol table, and then save the recognized variable symbol and its related information into the variable symbol table.
  • the process of creating a variable symbol table is: request storage space from the operating system and establish a variable symbol table data structure in the storage space. During the operation of the variable symbol table, if the storage space of the variable symbol table is insufficient, more storage space is dynamically applied to the operating system to store the newly added content. According to an embodiment of the present disclosure, an index can be established in the variable symbol table through the hash value of the name of the variable symbol.
  • variable symbol table corresponds to a hash value, and a tree index is established according to the hash value and stored in the variable symbol table.
  • Fig. 5 shows an example of a variable symbol table according to an embodiment of the present disclosure.
  • the variable symbols representing the same variable appear multiple times in the program code, they correspond to multiple entries in the variable symbol table. For example, as shown in Figure 5, taking the program code on the left side of Figure 5 as input, the variable symbols "a”, “a”, “b”, “a”, and “c” can be sequentially identified and stored in Figure 5.
  • the variable symbol table shown on the right For example, the variable symbol "a” in Figure 5 appears three times in the program code, and it is correspondingly recorded three times in the variable symbol table.
  • variable symbol table in FIG. 5 is only illustrative, and it may also include other columns, such as the position of the variable symbol in the program code, the namespace of the variable symbol, the scope of the variable symbol, and the variable symbol table.
  • the type of the variable represented by the symbol, the variable represented by the variable symbol, and the operations related to the variable symbol is also true for the other illustrative variable symbol tables that appear below.
  • FIG. 5 shows a variable symbol table in the form of a table
  • the present invention should not be limited to this.
  • the variable symbol table can also adopt other data structures, such as linked lists, databases, and so on.
  • step 230 the first variable symbol is matched with at least one variable symbol previously identified from the program code to determine whether there is a first variable representing the first variable in the at least one variable symbol.
  • Two variable symbol. The purpose of step 230 is to compare the currently recognized variable symbol with each previously recognized variable symbol to determine which previously recognized variable symbol or symbols represent the same variable as the currently recognized variable symbol.
  • the second variable symbol refers to one of the variable symbols that has been previously identified and recorded in the variable symbol table and also represents the first variable.
  • the variable symbol in response to the information related to the variable symbol being stored in the variable symbol table, the variable symbol can be matched with the previously stored variable symbol through the index. For example, when the index is established by the hash value of the variable symbol name, the hash value of the currently recognized variable symbol name can be calculated, and the variable symbol name in the variable symbol table that is similar to the currently recognized variable symbol name can be searched through the index, and Make a match.
  • step 230 in response to the information related to the variable symbol being stored in the variable symbol table, the variable symbol is matched with the previously stored variable symbol one by one. That is, for the newly recognized first variable symbol, compare it with each entry in the variable symbol table to determine whether they represent the same variable.
  • Such matching may be strict matching, rule matching, or fuzzy matching, for example.
  • matching the first variable symbol with at least one variable symbol previously identified from the program code may include: when the stored first variable symbol and the second one of the at least one variable symbol When the names, namespaces, scopes, and types of variables represented by the variable symbols are all the same, it is determined that the first variable symbol and the second variable symbol represent the same variable.
  • strict matching can be used. If and only if the namespace, scope, name, and type of the two variable symbols are the same, it is determined that the two variable symbols match.
  • matching the first variable symbol with at least one variable symbol previously identified from the program code may include: when the first variable symbol and a plurality of second ones of the at least one variable symbol When the names of the variable symbols are the same, the first variable symbol and which second variable symbol represents the same variable are determined according to a predefined rule.
  • rule-based matching can be used.
  • matching the first variable symbol with at least one variable symbol previously identified from the program code may include: when the information related to the first variable symbol is related to the at least one variable symbol When the similarity between the information related to the second variable symbol is higher than the threshold, the user is prompted to confirm whether the first variable symbol and the second variable symbol represent the same variable.
  • fuzzy matching can be used, so that even variable symbols with different names can be matched.
  • variable symbol matches the variable symbol "Sales”, and the user is prompted for confirmation.
  • fuzzy matching is to calculate the corresponding word vector for any variable symbol, and calculate the similarity between the two variable symbols according to the distance between the word vectors of the two variable symbols, and the similarity is higher than a threshold. The two variable symbols are determined to match.
  • Another implementation is to calculate the similarity based on the edit distance between two variable symbols.
  • variable symbol "Revenue” and the variable symbol "revenue” only the first letter is different, and the difference between the first letter is only the difference between upper and lower case, then the variable can be obtained by comparing the ratio of the same characters in the two variable symbols The edit distance between the symbols to calculate the similarity. Therefore, the similarity between the above two variable symbols is relatively high, and the user can be prompted to confirm whether they match.
  • the similarity is calculated based on the edit distance of the name of the variable symbol or the word vector distance.
  • the similarity can be obtained by one or more of the following: edit distance between variable symbol names, semantic similarity between variable symbol names, and variable symbol namespaces The degree of similarity, the inclusion relationship between the scopes of variable symbols, and the distance between the positions of variable symbols in the program code.
  • step 240 in response to determining that there is at least one second variable symbol, according to an operation related to the first variable symbol and related to the one or more second variable symbols The operation of determining whether the first variable symbol involves an undefined reference.
  • variable table in order to identify which variables are in the program code, a variable table can also be established and the relationship between the variable symbol table and the variable table can be established.
  • there is no need to establish a separate variable table but the same data structure can be used to store the variable symbols and variables, for example, a table, a linked list, etc. can be used.
  • the variable table is used to store the variables referred to by the variable symbols. If the variable table does not exist after step 220 is completed, the variable table is created first, and then the variable referred to by the variable symbol is stored in the variable table. Variable symbols and variables are different.
  • every variable is referred to by at least one variable symbol, but in this disclosure, not every variable symbol points to a variable.
  • the memory address of the variable can be used to represent the variable; for the SMALL language, since each variable corresponds to a certain level in the hierarchy of the spreadsheet, the unique ID of this level can be used to represent the variable.
  • Fig. 6 shows an example of the relationship between the program code, the variable symbol table, and the variable table according to an embodiment of the disclosure. As shown in Figure 6, the present invention sets a special variable type in the variable table, which is called an empty variable.
  • variable represented by the variable symbol has not yet been defined, add a null variable in the variable table.
  • the variable "c" is not defined, then the variable c 602 with an empty type is added to the variable table.
  • the id of the variable can be an automatically assigned serial number or the address of the variable.
  • the variable table stores the state of the identified variable, and the state of the variable includes one or more of the following: the variable symbol representing the variable, the address of the variable in the memory, the operation performed by the variable, the variable Whether it is defined and whether the variable is referenced.
  • variable table in Figure 6 is only illustrative, and it can also include other columns, such as the variable symbol representing the variable, the address of the variable in the memory, the operation performed by the variable, and whether the variable is defined , And whether the variable is referenced, etc. The same is true for the other illustrative variable tables that appear below.
  • the operation performed by one variable in the variable table is equal to the union of operations related to each of the at least one variable symbol representing the variable. That is, taking Fig. 7 as an example, the operation 707 in the entry 703 of the variable table is equal to the union of the operations related to each variable symbol representing the variable. That is, the operation 707 "declare, define, assign, access" in entry 703 is the union of the operation "access" of entry 705 and the operation "declare, define, assign” of entry 706.
  • FIG. 10 shows another example of updating the variable table according to the variable symbol table according to an embodiment of the present disclosure. The operation of the variables in the variable table is determined by the operation of all variable symbols related to it.
  • variable "a” 1007 corresponds to the variable symbols 1001, 1002, 1003 with ids 1, 2, and 4 in the variable symbol table, and the operations they perform are "declare, define” 1004, and "assign” respectively "1006, "Access” 1005, the operations performed by the variable "a” are "declaration, definition, assignment, access”.
  • the variable is defined according to the operations included in the union. Since “definition” and “reference” are relative terms, the two states of "whether the variable is defined” and “whether the variable is referenced” need to correspond to a specific scenario. These two states are flag bits set according to the present invention and can be represented by Boolean values. In an embodiment, the following judgment methods for these two flags adapted to different scenarios may be specified.
  • the operations in Table 1 refer to the operations of variables in the variable table.
  • the flag bit variable is quoted as “true”; at this time, if the variable x is missing "declaration” in the operation of the variable table Any one of "”, “definition” and “assignment” means that the variable is not ready (hereinafter referred to as undefined), then the flag bit "variable is defined” is "false”. In the case where "variable is defined” is false and “variable is referenced” is true, it is determined that the variable x involves an undefined reference.
  • step 240 it is assumed that at least one second variable symbol that represents the same variable as the first variable symbol is matched.
  • the first variable symbol involves an undefined reference according to an operation related to the first variable symbol.
  • the first variable symbol is the first variable symbol identified to represent the first variable, and other variable symbols representing the first variable have not been identified before.
  • the variable symbol "US Revenue" 702 in FIG. 7 belongs to this case, because only the variable symbol "Revenue" with an id of 1 is recognized before the variable symbol.
  • variable "US Revenue” 703 in the variable table is the same as the operation of the variable symbol "US Revenue” 702 in the variable symbol table, both of which are access.
  • Table 1 in the case of SMALL language, since the operation of the variable "US Revenue” 703 does not include definition but includes access, the flag bit “variable is defined” is false and the flag bit “variable is referenced” "Is true, thereby confirming that the newly recognized variable symbol "US Revenue" 702 involves an undefined reference.
  • variable symbol table when the relationship between the variable symbol table and the variable table is established, for each variable symbol in the variable symbol table, the variable in the variable table represented by it is stored; for each variable symbol in the variable table Variables store the variable symbols in the variable symbol table that can represent it.
  • variable symbol A if the variable referred to by a variable symbol A is empty, an empty variable B is established in the variable table, and the relationship between the variable symbol A and the empty variable B is established.
  • variable B in the variable table is stored in the "variable symbol represented by variable symbol” field of the entry of variable symbol A in the variable symbol table, and the entry of variable B in the variable table indicates the variable
  • the "variable symbol” field stores the position or ID of the variable symbol A in the variable symbol table.
  • the variable symbol "x" points to an empty variable in the variable table.
  • FIG. 8 shows an example of establishing a relationship between a variable symbol table and a variable table according to an embodiment of the present disclosure.
  • variable symbol "US Revenue” also points to An empty variable in the variable table.
  • the characteristic of an empty variable is that the type of the variable in the variable table is empty, and all other attributes are the same as normal variables.
  • step 250 in response to determining that the first variable symbol relates to an undefined reference, visual assistance is provided to the user to process the undefined reference.
  • providing visual assistance to the user includes one or more of the following: in a text editor or a graphical user interface editor, displaying a prompt box near the first variable symbol, or highlighting the first variable symbol A variable symbol.
  • the system Prompt the user.
  • the system can have different prompts.
  • the system pops up a prompt box near the variable to prompt the user that the variable involves an undefined reference.
  • the prompt box can disappear automatically within a certain period of time.
  • the name of the variable symbol involved in the undefined reference can be displayed in a special way. For example, at least one of the color, font, size, and background of the variable symbol name is different from the name of the normal variable to distinguish normal Variable symbols and variable symbols involving undefined references.
  • the system pops up a prompt box in the upper right corner of the variable symbol "aa", prompting "undefined” 1101.
  • the prompt box disappears after three seconds, and the background color of the name "aa” of the variable symbol changes to light gray 1103, which is different from the normal variable symbol.
  • the program code input by the user is sequentially recognized, so the method shown in FIG. 2 is executed cyclically to sequentially recognize each variable identifier in the program code.
  • the method in FIG. 2 may further include continuing to identify the third variable symbol from the received character stream and storing information related to the third variable symbol Information, where the third variable symbol represents the first variable.
  • the third variable symbol represents the first variable.
  • the method also includes matching a third variable symbol with at least one variable symbol previously identified from the program code to determine whether there is a variable symbol representing the first variable in the at least one variable symbol.
  • the matching process includes matching the third variable symbol with each previously identified variable symbol to determine whether there is a previously identified variable symbol representing the same variable. This is the same as the process of matching the first variable symbol, for example, it may be a strict match. , Rule matching, or fuzzy matching.
  • the variable symbol represents the same variable
  • the variable represented by the newly recognized variable symbol is stored in the variable symbol table as the same variable represented by the matched variable symbol.
  • the names and namespaces of the two variable symbols are changed to be the same.
  • the method further includes finding at least a first variable symbol that both represents the first variable with the third variable symbol through the matching.
  • the variable symbol "US Revenue” 702 corresponding to the variable symbol "US Revenue” 704 is found through the above-mentioned matching.
  • the entry 703 in the variable table is updated to modify its type from “null” to "row” and the operation 707 of this entry 703 is modified to the union of the operations of the two matched variable symbols 702 and 704.
  • the method further includes performing the operation related to the first variable symbol using at least the operation related to the third variable symbol in a case where it is determined that the operation related to the first variable symbol depends on the operation related to the third variable symbol.
  • the operations related to the first variable symbol depend on the operations related to the third variable symbol including at least one of the following: access to the first variable symbol depends on the definition of the third variable symbol, The access of the first variable symbol depends on the declaration, definition or assignment of the third variable symbol, the assignment of the first variable symbol depends on the declaration or definition of the third variable symbol, and the destruction of the first variable symbol depends on The declaration or definition of the third variable symbol.
  • the recognition of the third variable symbol causes the state of the variable represented by the third variable symbol to change from false to true, so that the variable no longer involves undefined references. Therefore, it can be determined based on this that the operation related to the first variable symbol depends on the operation related to the third variable symbol.
  • FIG. 21 shows an example of performing a prior access using a subsequent definition according to an embodiment of the present disclosure.
  • the variable represented by the variable symbol in the variable symbol table can be updated according to the matching of the new variable symbol.
  • FIG. 9 shows an example of updating the variable symbol table and the variable table according to an embodiment of the present disclosure.
  • variable symbol "c" 902 of the variable symbol table is a newly input variable symbol.
  • the variable symbol "c" 902 can be directly made to point to the variable
  • the empty variable "c” 903 in the table and the empty variable “c” 903 point to the variable symbol "c” 902 in addition, the type of the empty variable "c” 903 is modified from “null" to "int”. This embodiment does not need to create or delete any empty variables.
  • processing undefined references includes generating a second program code, and the second program code is adjusted relative to the original program code to include the first variable
  • the position of one or more variable symbol statements in the program code is such that the sequence of operations on the variables in the adjusted second program code conforms to the sequence required by the programming language.
  • the method in FIG. 2 may further include continuing to identify the third variable symbol from the received character stream and storing information related to the third variable symbol, wherein The third variable symbol represents the first variable.
  • the method further includes matching a third variable symbol with at least one variable symbol previously identified from the program code to determine whether there is a variable symbol representing the first variable in the at least one variable symbol.
  • the execution of the above steps is the same as the corresponding steps described above.
  • the method further includes finding at least the first variable symbol that represents the first variable with the third variable symbol through the matching, and in response to determining that the operation related to the first variable symbol depends on the operation related to the third variable symbol, adjusting The position of at least one of the statement containing the first variable symbol and the statement containing the third variable symbol in the program code is to eliminate the undefined reference.
  • the following C language program code A is taken as an example for description.
  • the adjusted program code can be compiled and executed or interpreted and executed. As shown in the above example, the sequence of operations on the variable c in the two adjusted program codes B and C conforms to the sequence required by the C language, so that they can be compiled and executed. According to an embodiment of the present disclosure, there is a one-to-one correspondence between the statements in the adjusted program code and the statements in the program code.
  • the adjusted program code can also be displayed to the user through a graphical user interface. In one embodiment, on the graphical user interface, the first program code and the second program code can be displayed at the same time.
  • FIG. 25 shows an example of displaying the adjusted program code to the user according to an embodiment of the present disclosure. As shown in FIG.
  • the original program code 2701 is adjusted to generate a second program code 2702, and each line in the second program code 2702 corresponds to a line with the same content in the original program code 2701 in a one-to-one correspondence.
  • the adjustment is automatically performed according to a predefined rule or according to a prediction result of a machine learning model.
  • a machine learning model that predicts the position of the undefined reference in the second program code can be constructed.
  • the machine learning model can be a recurrent neural network, which inputs each line of the original program code in order, extracts the variable symbol in each line of the sentence, the variable represented by the variable symbol, and the operation performed on the variable symbol , The location of the variable symbol, the location of the statement in the program code, whether the statement contains undefined references and other features, based on these features, predict the location of each line of the original program code in the second program code, and according to the machine The prediction result of the learning model generates a second program code.
  • the sequence of the displayed statements in the adjusted program code can be manually adjusted by the user. If the user is not satisfied with the automatic adjustment of the sequence of program statements by the system, the user can manually change the position in the second program code of the statements with undefined references on the interactive interface. Specifically, the original program code and the second program code can be displayed at the same time in the graphical user interface, and the original program code contains the statements that involve undefined reference variable symbols, and the user can manually Adjust the position of these highlighted sentences.
  • FIG. 27 shows an example in which a user manually adjusts the order of program statements according to an embodiment of the present disclosure.
  • the multiple symbols when there are multiple previous variable symbols whose similarity with the name of the newly recognized variable symbol is higher than a threshold, the multiple symbols are displayed to the user in the list in descending order of similarity. A preceding variable symbol.
  • This process is the same for fuzzy matching of the first variable symbol with the second variable symbol and fuzzy matching of the third variable symbol with the first variable symbol.
  • fuzzy matching is used when matching variable symbols, the user needs to be prompted. For example, when matching "Revenue" and "Sales", a prompt box needs to be shown to the user.
  • a prompt box may be displayed for the user to select.
  • a temporary table can be created, and multiple variable symbols with a high degree of similarity (for example, similarity of names) to a variable symbol are added to the temporary table.
  • a similarity threshold can be set, and when the similarity between the names of the variable symbols exceeds the threshold, the matched variable symbols are added to the temporary table.
  • the system sorts all variable symbols in the temporary table. One way of sorting is to sort from high to low based on similarity. Then, some or all of the variable symbols of the ordered temporary table are shown to the user.
  • variable symbols that are highly similar to the variable symbol "Revenue” are “Total Revenue”, “Revenue per User”, “revenue”, “Revenue”, “Sales”, “Cost of Revenue”
  • the sorted results in this temporary table are “Revenue”, “Total Revenue”, “revenue”, “Revenue per User”, “Sales”, and “Cost of Revenue”. If you choose to display only a part of the sorted temporary table to the user, the displayed part can be “Revenue”, “Total Revenue”, and "revenue”.
  • the user can manually confirm or modify the variable symbol matching result.
  • the user can select a fuzzy matching result in the prompt box of the fuzzy matching result to confirm that it matches the currently entered variable symbol.
  • FIG. 15 shows an example in which a user selects a fuzzy matching result according to an embodiment of the present disclosure.
  • the variable symbols in the displayed fuzzy matching result 1501 include "Total Revenue”, “revenue”, “Revenue per User”, “Sales”, “Cost of Revenue” ".
  • the user can move the cursor 1502 and press the "Enter” key to select a variable symbol, or use the mouse 1504 to click the variable symbol 1503 in the prompt box.
  • the system will match "revenue” with the currently input variable symbol "Revenue”.
  • the name of the currently input variable symbol in the program code is modified to the selected matching variable The name of the symbol.
  • the system will prompt the user to modify the name of the variable symbol so that it can be strictly matched.
  • FIG. 16 shows an example of changing the name of a variable symbol according to a matching result according to an embodiment of the present disclosure.
  • variable symbol entered by the user matches other variable symbols in the variable table successfully
  • the system prompts the user.
  • the system prompts differently.
  • the matching result is a strict match
  • the system automatically points these two variable symbols to the same variable in the variable table, and prompts the user that the system has automatically matched the two variable symbols.
  • Fig. 12 shows an example of a strict matching prompt according to an embodiment of the present disclosure.
  • the system automatically points the two variable symbols in the variable symbol table to the same variable in the variable table.
  • the “aa” in the message box can be highlighted, for example, the message box can fade out and disappear after three seconds.
  • FIG. 13 shows an example of a prompt for rule-based matching according to an embodiment of the present disclosure.
  • Fig. 14 shows a hint example of fuzzy matching according to an embodiment of the present disclosure.
  • the fuzzy matching result of the variable symbol "Revenue” input by the user includes the variable symbols "Total Revenue”, “revenue”, “Revenue per User”, “Sales”, “Cost of Revenue” ".
  • the system pops up a display box 1401 below the variable symbol "Revenue”, and displays the result of fuzzy matching in the prompt box.
  • the cursor can move between the variable symbols in the prompt box. When the cursor moves to a variable symbol, the variable symbol is displayed 1402 in a specific way to distinguish it from other variable symbols.
  • providing visual assistance to the user may include displaying a list on a graphical user interface, the list showing the user all variable symbols related to undefined references in the program code and including the first variable symbol.
  • the graphical user interface can provide the user with a visual variable symbol table and some key information in the variable table, so that the user can understand the dynamic change process of these key information.
  • An undefined reference variable is a variable whose status is "undefined reference” in the variable table.
  • the variable symbol corresponding to the undefined reference variable can be displayed in a table called "undefined reference table" in the graphical user interface.
  • the undefined reference table displayed in the graphical user interface also changes accordingly.
  • FIG. 17 shows an example of an undefined reference table according to an embodiment of the present disclosure.
  • the undefined reference table can be hidden at the edge of the editor, and the undefined reference table is displayed when the mouse moves to the edge of the editor.
  • the user can also press the button to make the undefined reference list always displayed.
  • FIG. 18 shows a display example of an undefined reference table according to an embodiment of the present disclosure.
  • the content shown in the undefined reference table 1801 is the variable symbol and its input location related to the undefined reference.
  • the mouse or cursor moves to the area 1802 where the variable symbol "Cash" in the undefined reference table is located, the area where the variable symbol is located is highlighted.
  • FIG. 19 shows a display example of an undefined reference table according to an embodiment of the present disclosure.
  • a list including the variable symbol involving an undefined reference Highlight the first variable symbol that matches successfully.
  • the undefined reference list 1901 will pop up.
  • the previously entered variable symbol "aa” 1902 (corresponding to code 1904) is highlighted, prompting to match the variable symbol "aa” 1903 (corresponding to code 1905) entered later.
  • the first variable in response to detecting from the variable table that the first variable represented by the first variable symbol becomes defined, the first variable is deleted from the list showing all variable symbols involved in undefined references in the program code.
  • a variable symbol In other words, when the displayed undefined reference variable is defined later, the system deletes the variable symbol from the undefined reference list of the graphical user interface.
  • the variable symbol in the input content includes the definition operation and is strictly matched to the previous variable symbol involving undefined reference, the undefined reference list pops up. The system deletes the variable symbol (which is defined at this time) involving undefined reference from the undefined reference table.
  • FIG. 20 shows an example of deleting a defined variable symbol from an undefined reference table according to an embodiment of the present disclosure.
  • variable symbol "aa” here strictly matches the two variable symbols "aa” involved in undefined references, and the system pops up the undefined reference table 2001 And the relevant "aa” variable symbol in the table is highlighted 2002, prompting it to match. Then, the system deletes 2004 both of the two "aa” variable symbols in the undefined reference table.
  • providing visual assistance to the user may include displaying the variable table and the variable symbol table and the relationship between them on a graphical user interface.
  • the variable symbols and variables in the variable symbol table and the variable table and their related information can be displayed in the graphical user interface, and the user can interact with the above two tables through the graphical user interface.
  • FIG. 22 shows a display example of a variable symbol table and a variable table according to an embodiment of the present disclosure. Shown in Figure 22 is the input program code and the relationship between the variable symbol table, the variable table, and these two tables.
  • providing visual assistance to the user may include displaying all the successfully matched variable symbols in the program code on a graphical user interface, and the displayed variable symbols that have been successfully matched can be modified by the user Its matching relationship.
  • the system automatically points "US Revenue[1]” on line 32 and "US Revenue[2]” on line 18 to the same variable in the variable table according to rule-based matching.
  • the user can manually modify the variable symbol matched by "US Revenue[1]” to "US Revenue[3]” on the 6th line.
  • the system can point the variable symbol "USRevenue[1]” to the same variable pointed to by "USRevenue[3]” in the variable table, and cancel USRevenue[2]" in the variable table pointed to by "USRevenue[1]” The variable pointed to.
  • providing visual assistance to the user may include displaying the variable symbol table on a graphical user interface, and in response to the user selecting a variable symbol in the variable symbol table, the corresponding variable symbol in the program code is highlight.
  • FIG. 23 shows a display example of a variable symbol table according to an embodiment of the present disclosure. As shown in Fig. 23, the graphical user interface 2301 displaying the variable symbol table displays information such as the names and positions of all variable symbols.
  • variable symbol 2302 in the variable symbol table in the graphical user interface When using the mouse or other selection methods to select a variable symbol 2302 in the variable symbol table in the graphical user interface, you can directly jump to the line where the variable symbol is entered in the program code, and change the corresponding variable symbol in the variable symbol table Entries are displayed 2302 in a special way (for example, using a different background color). At the same time, the area where the variable symbol is located in the input area can also be displayed 2304 in a special way.
  • the system when the user inputs a wrong variable symbol name during input, can provide the user with an error correction function.
  • the fuzzy matching function can still match the user with a variable symbol similar to the input variable symbol.
  • the user can select a variable symbol in the fuzzy matching result and choose to correct the entered variable symbol name .
  • the system automatically corrects the wrong variable symbol name to the name of the variable symbol selected by the user according to the user's selection.
  • FIG. 24 shows an example of error correction according to an embodiment of the present disclosure.
  • the system detects that there may be an error in the user input, and highlights the "a” in "Ravenue” to prompt the input error.
  • the result returned by fuzzy matching may be, for example, "Revenue”, “Total Revenue”, “revenue”, “Revenue per User”, and "Cost of Revenue” 2402. If the user selects "Revenue” 2403 in the fuzzy matching result, the system automatically corrects the wrong "Ravenue” variable symbol entered by the user to the "Revenue” 2404 selected by the user.
  • the system can also provide variable naming specifications, and automatically correct variable symbol names according to the variable naming specifications.
  • variable names are mostly accounting professional vocabulary, and the professional vocabulary has industry standards.
  • the system and method of the present disclosure can provide users with specific naming conventions in accordance with relevant standards and specifications.
  • the system can give a prompt and recommend a variable name that conforms to the specification. If the user selects the recommended variable name, the system automatically replaces the variable name entered by the user with the selected variable name. For example, suppose a specification has the following rule: variable names should start with a capital letter.
  • variable symbol "revenue” If the user enters the variable symbol "revenue”, the system will prompt the user that the variable symbol does not conform to the naming convention, and recommend a variable symbol name that conforms to the naming convention, such as "Revenue”. If the user selects the recommended "Revenue”, the system replaces the previously entered "revenue” with "Revenue”.
  • the system does not perform real-time variable symbol matching when the user is inputting, and then batches matching variable symbols when the user completes the input.
  • This method is also suitable for user input including loading all or part of the program from the storage device as user input. Users can modify the matching results in batches. For example, in the SMALL language, the user can save the entered program to a storage device such as a hard disk, and can later load the saved program from the storage device. When the program is loaded, the system batches match all variable symbols in the program, automatically recognize the variable symbols that meet strict matching and rule-based matching, and make them point to the same variable in the variable table. The system prompts the user with the result of the fuzzy matching, and assists the user to manually confirm whether it represents the same variable.
  • the method according to an embodiment of the present invention further includes parsing or executing a part of the program code, which does not include program statements that involve undefined references.
  • the embodiments of the present disclosure support limiting the influence of undefined references on programs within a certain range, so that partial analysis of programs containing undefined references can be performed, and parts of programs not affected by undefined references can be processed normally. For example, in the SMALL language, if a row’s formula contains undefined references (for example, undefined access), in the generated spreadsheet, only the row’s formula is empty and the value is empty, but it does not affect the row’s The drawing in the spreadsheet and the format of the row do not affect the remaining rows in the spreadsheet. FIG.
  • FIG. 21 shows an example of a partially executed program code according to an embodiment of the present disclosure.
  • 2101 refers to the undefined variable "China Revenue” 2102 in the row defined by the variable "Revenue”, so in the generated spreadsheet 2103, except for the variable "Revenue” row 2104 and China Revenue" Except that the value of the row 2105 is empty, the rows of all other variables can be parsed and drawn normally.
  • the present invention can solve the problem that undefined variables cannot be referenced in the traditional technology. Using the method and system of the present invention to reference undefined variables is efficient and convenient for users. The reason for the efficiency is that the present invention can automatically record the undefined variable symbols referenced by the user, and automatically match the newly declared or defined variable symbols and their corresponding undefined references after the user's subsequent declarations or definitions of the variable symbols appear. Variable symbol. The reason for the convenience is that the present invention provides users with various input aids, undefined citation prompts, variable matching prompts, and other functions. In addition, with the present invention, when a part of the program code involves an undefined reference, the rest of the program code that does not involve an undefined reference can be interpreted and executed. In addition, with the present invention, in the case of undefined references in the program code, the user can be prompted to adjust the order of the statements in the code to make it conform to the compilation rules and thus can be successfully compiled and executed.
  • the present invention may be a system, a method and/or a computer program product.
  • the computer program product may include a computer-readable storage medium loaded with computer-readable program instructions for enabling a processor to implement various aspects of the present invention.
  • a computer system includes one or more processors and a memory coupled to the one or more processors.
  • the memory stores computer instructions that, when executed by the one or more processors, cause the one or more processors to perform operations of the method in any of the above embodiments.
  • a computer-readable storage medium stores computer instructions that, when executed by a processor, cause the processor to perform the method in any of the above embodiments.
  • the computer-readable storage medium may be a tangible device that can hold and store instructions used by the instruction execution device.
  • the computer-readable storage medium may be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing.
  • Non-exhaustive list of computer-readable storage media include: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM) Or flash memory), static random access memory (SRAM), portable compact disk read-only memory (CD-ROM), digital versatile disk (DVD), memory stick, floppy disk, mechanical encoding device, such as a printer with instructions stored thereon
  • RAM random access memory
  • ROM read-only memory
  • EPROM erasable programmable read-only memory
  • flash memory flash memory
  • SRAM static random access memory
  • CD-ROM compact disk read-only memory
  • DVD digital versatile disk
  • memory stick floppy disk
  • mechanical encoding device such as a printer with instructions stored thereon
  • the computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to various computing/processing devices, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and/or a wireless network.
  • the network may include copper transmission cables, optical fiber transmission, wireless transmission, routers, firewalls, switches, gateway computers, and/or edge servers.
  • the network adapter card or network interface in each computing/processing device receives computer-readable program instructions from the network, and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing/processing device .
  • the computer program instructions used to perform the operations of the present invention may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, status setting data, or in one or more programming languages.
  • Source code or object code written in any combination, the programming language includes object-oriented programming languages such as Smalltalk, C++, etc., and conventional procedural programming languages such as "C" language or similar programming languages.
  • Computer-readable program instructions can be executed entirely on the user's computer, partly on the user's computer, executed as a stand-alone software package, partly on the user's computer and partly executed on a remote computer, or entirely on the remote computer or server carried out.
  • the remote computer can be connected to the user's computer through any kind of network-including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (for example, using an Internet service provider to connect to the user's computer) connection).
  • LAN local area network
  • WAN wide area network
  • an electronic circuit such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), can be customized by using the status information of the computer-readable program instructions.
  • the computer-readable program instructions are executed to implement various aspects of the present invention.
  • These computer-readable program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine that makes these instructions when executed by the processor of the computer or other programmable data processing device , A device that implements the functions/actions specified in one or more blocks in the flowcharts and/or block diagrams is produced.

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Stored Programmes (AREA)

Abstract

A method and system for processing a reference of a variable in a program code. The method comprises: sequentially receiving a character stream included in a user input, wherein the character stream is part of a program code; identifying a first variable symbol from the received character stream, and storing information related to the first variable symbol, wherein the first variable symbol represents a first variable; matching the first variable symbol with at least one variable symbol previously identified from the program code, so as to determine whether a second variable symbol representing the first variable is present in the at least one variable symbol; in response to determining that there is at least one second variable symbol present, determining, according to an operation related to the first variable symbol and an operation related to the one or more second variable symbols, whether the first variable symbol involves an undefined reference; and in response to determining that the first variable symbol involves an undefined reference, providing visible assistance to a user to process the undefined reference.

Description

用于处理程序代码中的变量的引用的方法和系统Method and system for processing variable reference in program code 技术领域Technical field
本发明一般地涉及处理计算机编程领域,具体地说,涉及处理编程语言代码中的未声明、未定义、或未初始化的变量的引用的方法和系统。The present invention generally relates to the field of processing computer programming, and specifically, to a method and system for processing undeclared, undefined, or uninitialized variable references in programming language codes.
背景技术Background technique
计算机程序一般都涉及对变量的处理。在一些编程语言中,变量是对应于计算机的一块内存空间的占位符;在面向对象的编程语言中,变量也可以表现为作为某个类的实例的对象。编程语言中对变量的操作例如可以包括声明(declare)、定义(define)、初始化(initialize)、赋值(assignment)、访问(access)、析构(destruct)等。通常这些对于变量的操作之间遵从严格的依赖关系。例如,无法访问一个未被初始化的变量,也无法析构一个未被定义的变量。为了便于说明,在本申请中将对于同一个变量的存在依赖关系的两个变量操作之中,被依赖的操作简称为对该变量的“定义”,而依赖于“定义”的变量操作称为对该变量的“引用”。也就是说,本发明中的“定义”并不限于狭义的定义(define)操作,而是可以包括“引用”操作可能依赖的各种操作。例如,对于C语言程序中的一个变量的引用操作“赋值”而言,其所依赖的“定义”操作除了包括狭义的“定义”操作以外还包括“声明”操作。Computer programs generally involve the processing of variables. In some programming languages, a variable is a placeholder corresponding to a piece of computer memory space; in an object-oriented programming language, a variable can also be represented as an object as an instance of a certain class. Operations on variables in a programming language may include, for example, declare, define, initialize, assign, access, destruct, and so on. Usually these operations on variables follow strict dependencies. For example, an uninitialized variable cannot be accessed, and an undefined variable cannot be destroyed. For ease of description, in this application, among the two variable operations that have a dependency on the same variable, the dependent operation is referred to as the "definition" of the variable, and the variable operation that depends on the "definition" is referred to as A "reference" to the variable. That is to say, the "define" in the present invention is not limited to a narrow definition operation, but may include various operations on which the "quoting" operation may depend. For example, for the reference operation "assignment" of a variable in a C language program, the "definition" operation it relies on includes the "declaration" operation in addition to the narrow "definition" operation.
由于这种依赖关系的存在,大部分编程语言都要求在进行变量定义的代码和进行变量引用的代码之间遵从严格的位置顺序或输入顺序。这种顺序关系对于C++等编译型语言而言,要求对变量进行定义的代码在源文件中的位置在对变量进行引用的代码之前;而对于Python等解释型语言而言,要求对变量进行定义的代码在输入顺序上需要比对变量进行引用的代码先输入。在现有技术中,如果违反了上述位置顺序或输入顺序,则编译或解释执行时会报告错误。Due to the existence of this dependency, most programming languages require strict positional order or input order between the code for variable definition and the code for variable reference. For compiled languages such as C++, the position of the code that requires the variable definition in the source file is before the code that refers to the variable; for interpreted languages such as Python, the variable is required to be defined. The code in the input sequence needs to be input before the code that references the variable. In the prior art, if the above-mentioned position order or input order is violated, an error will be reported during compilation or interpretation.
然而,对于某些领域特定编程语言而言,这种严格的顺序要求可能会给编程人员造成困难。例如在本申请的申请人深圳逻辑汇科技有限公司提出的用以构建电子表格模型的领域特定语言“SMALL”中,可以通过输入代码来构建电子表格的行,并指定不同的行之间的计算关系。此时,最直观且有利的是按照这些行在电子表格中的位置顺序来输入与这些行对应的代码,但这种代码输入顺序无法保证对一个行(变量)进行定义的代码出现在对这个行进行引用(例如,该变量作为等式的右值)的代码之前。在现实应用中, 还经常出现SMALL语言中出现在等式右边的变量尚没有全部被定义就需要解析SMALL语言的情形。However, for certain domain-specific programming languages, such strict order requirements may cause difficulties for programmers. For example, in the domain-specific language "SMALL" proposed by Shenzhen Logic Technology Co., Ltd., the applicant of this application, to build a spreadsheet model, you can enter the code to build the rows of the spreadsheet and specify the calculations between different rows relationship. At this time, it is most intuitive and advantageous to enter the codes corresponding to these rows in the order of their positions in the spreadsheet, but this code input sequence cannot guarantee that the code that defines a row (variable) appears in this Line before the code that is referenced (for example, the variable is used as the rvalue of the equation). In real applications, there are often situations in the SMALL language where the variables that appear on the right side of the equation need to be parsed before all the variables are defined.
发明内容Summary of the invention
根据本公开的一个实施例,提供了一种用于处理程序代码中的变量的引用的方法。该方法包括顺序地接收用户输入中包含的字符流。所述字符流是所述程序代码的一部分。该方法还包括从所接收的字符流中识别第一变量符号并且存储与第一变量符号相关的信息。第一变量符号表示第一变量。该方法还包括把第一变量符号与从所述程序代码中先前识别的至少一个变量符号进行匹配以确定所述至少一个变量符号中是否存在表示第一变量的第二变量符号。该方法还包括响应于确定存在至少一个第二变量符号,根据与第一变量符号相关的操作以及与所述一个或多个第二变量符号相关的操作,确定第一变量符号是否涉及未定义引用。该方法还包括响应于确定第一变量符号涉及未定义引用,向用户提供可视辅助来处理该未定义引用。According to an embodiment of the present disclosure, a method for handling references of variables in program code is provided. The method includes sequentially receiving a stream of characters contained in user input. The character stream is part of the program code. The method also includes identifying the first variable symbol from the received character stream and storing information related to the first variable symbol. The first variable symbol represents the first variable. The method also includes matching the first variable symbol with at least one variable symbol previously identified from the program code to determine whether there is a second variable symbol representing the first variable in the at least one variable symbol. The method further includes, in response to determining that there is at least one second variable symbol, determining whether the first variable symbol involves an undefined reference based on an operation related to the first variable symbol and an operation related to the one or more second variable symbols . The method also includes in response to determining that the first variable symbol relates to an undefined reference, providing visual assistance to the user to process the undefined reference.
根据本公开的另一个实施例,提供了一种计算机系统。该计算机系统包括一个或多个处理器和耦接到所述一个或多个处理器的存储器。所述存储器存储有计算机指令,所述计算机指令当由所述一个或多个处理器执行时使所述一个或多个处理器执行上述的方法的操作。According to another embodiment of the present disclosure, a computer system is provided. The computer system includes one or more processors and a memory coupled to the one or more processors. The memory stores computer instructions that, when executed by the one or more processors, cause the one or more processors to perform the operations of the above-mentioned method.
根据本公开的又一实施例,提供了一种计算机可读存储介质。该计算机可读存储介质存储有计算机指令,所述计算机指令当由处理器运行时使所述处理器执行上述的方法。According to yet another embodiment of the present disclosure, a computer-readable storage medium is provided. The computer-readable storage medium stores computer instructions that, when run by a processor, cause the processor to perform the above-mentioned method.
附图说明Description of the drawings
通过结合附图对本公开示例性实施方式进行更详细的描述,本公开的上述以及其它目的、特征和优势将变得更加明显,其中,在本公开示例性实施方式中,相同的参考标号通常代表相同部件。Through a more detailed description of the exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, the above and other objectives, features and advantages of the present disclosure will become more apparent. Among them, in the exemplary embodiments of the present disclosure, the same reference numerals generally represent The same parts.
图1示出了适于用来实现本发明实施方式的示例性计算机系统/服务器12的框图。Figure 1 shows a block diagram of an exemplary computer system/server 12 suitable for implementing embodiments of the present invention.
图2示出了根据本公开的一个实施例的用于处理程序代码中的变量的引用的方法的流程图。Fig. 2 shows a flowchart of a method for handling references of variables in program code according to an embodiment of the present disclosure.
图3示出了使用SMALL语言的图形用户界面编辑器的操作的示例。Fig. 3 shows an example of the operation of a graphical user interface editor using SMALL language.
图4示出了根据本公开的一个实施例的使用SMALL语言的图形用户界面编辑器输入代码的示例。Fig. 4 shows an example of inputting code by a graphical user interface editor using SMALL language according to an embodiment of the present disclosure.
图5示出了根据本公开的一个实施例的变量符号表的示例。Fig. 5 shows an example of a variable symbol table according to an embodiment of the present disclosure.
图6示出了根据公开的一个实施例的程序代码、变量符号表和变量表的关系示例。Fig. 6 shows an example of the relationship between the program code, the variable symbol table, and the variable table according to an embodiment of the disclosure.
图7示出了根据本公开的一个实施例的建立变量表的过程的示例。FIG. 7 shows an example of a process of establishing a variable table according to an embodiment of the present disclosure.
图8示出了根据本公开的一个实施例的建立变量符号表和变量表之间的关系的示例。FIG. 8 shows an example of establishing a relationship between a variable symbol table and a variable table according to an embodiment of the present disclosure.
图9示出了根据本公开的实施例的更新变量符号表和变量表的示例。FIG. 9 shows an example of updating the variable symbol table and the variable table according to an embodiment of the present disclosure.
图10给出了根据本公开的一个实施例的根据变量符号表来更新变量表的另一个例子。FIG. 10 shows another example of updating the variable table according to the variable symbol table according to an embodiment of the present disclosure.
图11示出了根据本公开的一个实施例的提供可视辅助的示例。FIG. 11 shows an example of providing visual assistance according to an embodiment of the present disclosure.
图12示出了根据本公开的一个实施例的严格匹配的提示示例。Fig. 12 shows an example of a strict matching prompt according to an embodiment of the present disclosure.
图13示出了根据本公开的一个实施例的基于规则的匹配的提示示例。FIG. 13 shows an example of a prompt for rule-based matching according to an embodiment of the present disclosure.
图14示出了根据本公开的一个实施例的模糊匹配的提示示例。Fig. 14 shows a hint example of fuzzy matching according to an embodiment of the present disclosure.
图15示出了根据本公开的一个实施例的用户选择模糊匹配结果的示例。FIG. 15 shows an example in which a user selects a fuzzy matching result according to an embodiment of the present disclosure.
图16示出了根据本公开的一个实施例的根据匹配结果来改变变量符号的名称的示例。FIG. 16 shows an example of changing the name of a variable symbol according to a matching result according to an embodiment of the present disclosure.
图17示出了根据本公开的一个实施例的未定义引用表的示例。FIG. 17 shows an example of an undefined reference table according to an embodiment of the present disclosure.
图18示出了根据本公开的一个实施例的未定义引用表的显示示例。FIG. 18 shows a display example of an undefined reference table according to an embodiment of the present disclosure.
图19示出了根据本公开的一个实施例的未定义引用表的显示示例。FIG. 19 shows a display example of an undefined reference table according to an embodiment of the present disclosure.
图20示出了根据本公开的一个实施例的从未定义引用表删除已定义变量符号的示例。FIG. 20 shows an example of deleting a defined variable symbol from an undefined reference table according to an embodiment of the present disclosure.
图21示出了根据本公开的一个实施例的利用在后的定义来执行在先的访问的示例。FIG. 21 shows an example of performing a prior access using a subsequent definition according to an embodiment of the present disclosure.
图22示出了根据本公开的一个实施例的变量符号表和变量表的显示示例。FIG. 22 shows a display example of a variable symbol table and a variable table according to an embodiment of the present disclosure.
图23示出了根据本公开的一个实施例的变量符号表的显示示例。FIG. 23 shows a display example of a variable symbol table according to an embodiment of the present disclosure.
图24示出了根据本公开的一个实施例的错误更正的示例。FIG. 24 shows an example of error correction according to an embodiment of the present disclosure.
图25示出了根据本公开的一个实施例的向用户显示经调整后的程序代码的示例。FIG. 25 shows an example of displaying the adjusted program code to the user according to an embodiment of the present disclosure.
图26示出了根据本公开的一个实施例的源程序代码与经调整后的程序代码的对应关系的示例。FIG. 26 shows an example of the correspondence between source program codes and adjusted program codes according to an embodiment of the present disclosure.
图27示出了根据本公开的一个实施例的用户手动调整程序语句的顺序的示例。FIG. 27 shows an example in which a user manually adjusts the order of program statements according to an embodiment of the present disclosure.
具体实施方式Detailed ways
本发明的发明人提出了一种在处理程序代码中的未定义的引用的系统和方法。该系统和方法可以放松传统编程语言对代码的位置顺序或输入顺序的限制。本发明例如允许用户先输入对一个未定义的变量进行引用的代码,然后之后在任意位置输入对这个变量进行定义的代码。本发明还允许在并非所有变量都已定义的情况下局部地解析并执行程序。本发明还允许辅助用户调整变量定义操作代码和变量引用操作代码的顺序从而能够正确地完成程序的编译和执行。此外,采用本公开的技术方案,系统会自动匹配对同一个变量的定义和引用。The inventor of the present invention proposes a system and method for handling undefined references in program code. The system and method can relax the limitation of the traditional programming language on the position sequence or input sequence of the code. For example, the present invention allows the user to first input a code that references an undefined variable, and then input the code that defines this variable at any position. The present invention also allows the program to be parsed and executed locally when not all variables have been defined. The present invention also allows assisting users to adjust the sequence of variable definition operation codes and variable reference operation codes so as to correctly complete program compilation and execution. In addition, with the technical solution of the present disclosure, the system will automatically match the definition and reference to the same variable.
这里提及的变量的“定义”操作同样使用上文所述的广义含义,即,包括“引用”操作所依赖的各种操作,不局限于狭义的定义操作,取决于引用操作的类型例如可以包括声明、定义、赋值等。在一个C语言的例子中,对整型变量x的“访问”操作(称为引用)依赖于对该变量x的“声明”、“定义”和“赋值”操作(为了简便均称为定义)。The "definition" operation of the variable mentioned here also uses the broad meaning described above, that is, it includes various operations on which the "reference" operation depends, and is not limited to the narrow definition operation, depending on the type of the reference operation, for example, Including declaration, definition, assignment, etc. In a C language example, the "access" operation (referred to as reference) to the integer variable x depends on the "declaration", "definition" and "assignment" operations (referred to as definition for simplicity) of the variable x .
在本公开中,对变量的“定义”和“引用”是相对而言的,它们是对程序代码中的同一变量的两个操作,其中,对一个变量的“引用”操作依赖于对该变量的“定义”操作。变量的定义和引用可以是对变量的以下操作:声明(declare)、定义(define)、初始化(initialize)、赋值(assignment)、访问(access)、析构(destruct)等。变量的声明是程序代码告诉编译器该变量的变量名和类型以及该变量将会被定义。变量的定义是指程序代码告诉编译器创建一个变量,并为该变量分配一块内存空间。变量的初始化是指程序代码告诉编译器为该变量赋予一个初始值。变量的赋值是指将一个指定值赋值给这个变量作为这个变量的值。变量的访问是指读取或使用这个变量,包括将该变量的值赋给其他变量等。变量的析构是指释放该变量占用的内存空间。In the present disclosure, the "definition" and "reference" of a variable are relative terms. They are two operations on the same variable in the program code. The "reference" operation of a variable depends on the variable. "Define" operation. The definition and reference of a variable can be the following operations on the variable: declaration (declare), definition (define), initialization (initialize), assignment (assignment), access (access), destruction (destruct) and so on. The declaration of a variable is the program code telling the compiler the variable name and type of the variable and the variable will be defined. The definition of a variable means that the program code tells the compiler to create a variable and allocate a memory space for the variable. The initialization of a variable means that the program code tells the compiler to assign an initial value to the variable. Variable assignment refers to assigning a specified value to this variable as the value of this variable. Variable access refers to reading or using this variable, including assigning the value of the variable to other variables. The destruction of a variable refers to the release of the memory space occupied by the variable.
在一些编程语言中,同一代码语句可以完成一个或多个变量操作。例如,在C语言中,“int a”同时完成了变量“a”的声明和定义;“int a=1”同时完成了对变量“a”的声明、定义和初始化;而“extern int a”则仅仅在一个文件中对变量“a”进行了声明,需要在另一个文件中对“a”进行定义;“a=1”仅仅对变量“a”进行了初始化。例如,在Python语言中,“a=1”同时完成了对变量“a”的声明、定义和初始化。例如,在SMALL语言中,在一个表格中添加一个名为“Revenue”的行的操作同时完成了对这个行的声明、定义和初始化。In some programming languages, the same code statement can complete one or more variable operations. For example, in the C language, "int a" completes the declaration and definition of the variable "a" at the same time; "int a = 1" completes the declaration, definition and initialization of the variable "a" at the same time; and "extern int a" Then the variable “a” is only declared in one file, and “a” needs to be defined in another file; “a=1” only initializes the variable “a”. For example, in the Python language, "a=1" simultaneously completes the declaration, definition and initialization of the variable "a". For example, in the SMALL language, the operation of adding a row named "Revenue" to a table simultaneously completes the declaration, definition and initialization of this row.
此外,访问一个变量是指读取该变量的地址或者值,并利用其进行某操作。例如,在C++语言中,“b=a”代表变量“a”被访问。例如,在SMALL语言中,为名为“Revenue”的变量输入公式“Revenue={US Revenue}+{China Revenue}”,则变量“US Revenue”和“China Revenue”被访问,并且可以被用来进行计算“Revenue”的操作。In addition, accessing a variable refers to reading the address or value of the variable and using it to perform certain operations. For example, in the C++ language, "b=a" means that the variable "a" is accessed. For example, in SMALL language, enter the formula "Revenue={USRevenue}+{ChinaRevenue}" for a variable named "Revenue", then the variables "USRevenue" and "ChinaRevenue" are accessed and can be used Perform the operation of calculating "Revenue".
在本公开中,由于“定义”和“引用”是相对而言的,所以当参照对象不同时,同一个变量操作可以是“定义”,也可以是“引用”。例如,在C++语言中,变量的初始化操作“a=1”相对于变量的声明和定义操作“int a”而言是引用,而相对于“b=a+1”而言则是定义。In the present disclosure, since "definition" and "reference" are relative terms, when the reference objects are different, the same variable operation can be "definition" or "reference". For example, in the C++ language, the variable initialization operation "a=1" is a reference relative to the variable declaration and definition operation "int a", but it is a definition relative to "b=a+1".
在一些领域特定语言中,有时无法满足在对一个变量进行“引用”之前已经完成了对该变量进行“定义”的要求。例如,在SMALL语言中,按照在拟生成的电子表格中的行的顺序输入定义不同行的代码,其中每个变量表示一个行。此时,如果希望为名为“Revenue”的行输入了公式“Revenue={US Revenue}+{China Revenue}”,并且名为“US Revenue”和“China Revenue”的行需要在之后才能定义,那么会出现在表示这两个行的变量被定义之前这两个变量就被引用的情况。In some domain-specific languages, sometimes it is not possible to satisfy the requirement of “defining” a variable before “quoting” the variable. For example, in the SMALL language, enter codes that define different rows in the order of rows in the spreadsheet to be generated, where each variable represents a row. At this time, if you want to enter the formula "Revenue={USRevenue}+{ChinaRevenue}" for the row named "Revenue", and the rows named "USRevenue" and "ChinaRevenue" need to be defined later, Then there will be cases where these two variables are referenced before the variables representing these two lines are defined.
这个问题在C++和Python等语言中以另一种形式表现。在一些特殊的应用场景下,在编写例如C++语言的程序时,为了代码可读性,对变量的定义有可能会出现在对变量的引用之后,现有技术在此时会报告编译错误。例如在Python解释器中,当先输入“b=a+1”,再输入“a=1”并执行时,现有技术同样会报告错误。This problem is expressed in another form in languages such as C++ and Python. In some special application scenarios, when writing a program in C++ language, for code readability, the definition of a variable may appear after the reference to the variable, and the prior art will report a compilation error at this time. For example, in the Python interpreter, when “b=a+1” is input first, and then “a=1” is input and executed, the prior art will also report an error.
此外,在一些科学计算程序中,由于与数学公式的顺序一致,先执行变量的引用操作后执行该变量的定义操作的顺序可能会更符合程序编写者的思考逻辑,使得可读性更强。In addition, in some scientific calculation programs, because the sequence of the mathematical formula is consistent, the sequence of performing the variable reference operation first and then performing the variable definition operation may be more in line with the thinking logic of the program writer, making it more readable.
下面将参照附图更详细地描述本公开的优选实施方式。虽然附图中显示了本公开的优选实施方式,然而应该理解,可以以各种形式实现本公开而不应被这里阐述的实施方式所限制。相反,提供这些实施方式是为了使本公开更加透彻和完整,并且能够将本公开的范围完整地传达给本领域的技术人员。Hereinafter, preferred embodiments of the present disclosure will be described in more detail with reference to the accompanying drawings. Although the drawings show preferred embodiments of the present disclosure, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to make the present disclosure more thorough and complete, and to fully convey the scope of the present disclosure to those skilled in the art.
所属技术领域的技术人员知道,本发明可以实现为系统、方法或计算机程序产品。因此,本公开可以具体实现为以下形式,即:可以是完全的硬件、也可以是完全的软件(包括固件、驻留软件、微代码等),还可以是硬件和软件结合的形式,本文一般称为“电路”、“模块”或“系统”。此外,在一些实施例中,本发明还可以实现为在一个或多个计算机可读介质中的计算机程序产品的形式,该计算机可读介质中包含计算机可读的程序代码。Those skilled in the art know that the present invention can be implemented as a system, a method or a computer program product. Therefore, the present disclosure can be specifically implemented in the following forms, namely: it can be complete hardware, complete software (including firmware, resident software, microcode, etc.), or a combination of hardware and software. This article generally Called "circuit", "module" or "system". In addition, in some embodiments, the present invention may also be implemented in the form of a computer program product in one or more computer-readable media, the computer-readable medium containing computer-readable program code.
下面将参照本发明实施例的方法、装置(系统)和计算机程序产品的流程图和/或框图描述本发明。应当理解,流程图和/或框图的每个方框以及流程图和/或框图中各方框的组合,都可以由计算机程序指令实现。这些计算机程序指令可以提供给通用计算机、专用计算机或其它可编程数据处理装置的处理器,从而生产出一种机器,这些计算机程序 指令通过计算机或其它可编程数据处理装置执行,产生了实现流程图和/或框图中的方框中规定的功能/操作的装置。Hereinafter, the present invention will be described with reference to flowcharts and/or block diagrams of methods, devices (systems) and computer program products of embodiments of the present invention. It should be understood that each block of the flowchart and/or block diagram and the combination of each block in the flowchart and/or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to the processors of general-purpose computers, special-purpose computers, or other programmable data processing devices, thereby producing a machine. These computer program instructions are executed by the computer or other programmable data processing devices to generate an implementation flow chart. And/or the function/operation device specified in the block in the block diagram.
图1示出了适于用来实现本发明实施方式的示例性计算机系统/服务器12的框图。图1显示的计算机系统/服务器12仅仅是一个示例,不应对本发明实施例的功能和使用范围带来任何限制。Figure 1 shows a block diagram of an exemplary computer system/server 12 suitable for implementing embodiments of the present invention. The computer system/server 12 shown in FIG. 1 is only an example, and should not bring any limitation to the function and application scope of the embodiment of the present invention.
如图1所示,计算机系统/服务器12以通用计算设备的形式表现。计算机系统/服务器12的组件可以包括但不限于:一个或者多个处理器或者处理单元16,系统存储器28,连接不同系统组件(包括系统存储器28和处理单元16)的总线18。As shown in FIG. 1, the computer system/server 12 is represented in the form of a general-purpose computing device. The components of the computer system/server 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 connecting different system components (including the system memory 28 and the processing unit 16).
总线18表示几类总线结构中的一种或多种,包括存储器总线或者存储器控制器,外围总线,图形加速端口,处理器或者使用多种总线结构中的任意总线结构的局域总线。举例来说,这些体系结构包括但不限于工业标准体系结构(ISA)总线,微通道体系结构(MAC)总线,增强型ISA总线、视频电子标准协会(VESA)局域总线以及外围组件互连(PCI)总线。The bus 18 represents one or more of several types of bus structures, including a memory bus or a memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any bus structure among multiple bus structures. For example, these architectures include, but are not limited to, industry standard architecture (ISA) bus, microchannel architecture (MAC) bus, enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and peripheral component interconnection ( PCI) bus.
计算机系统/服务器12典型地包括多种计算机系统可读介质。这些介质可以是任何能够被计算机系统/服务器12访问的可用介质,包括易失性和非易失性介质,可移动的和不可移动的介质。The computer system/server 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the computer system/server 12, including volatile and nonvolatile media, removable and non-removable media.
系统存储器28可以包括易失性存储器形式的计算机系统可读介质,例如随机存取存储器(RAM)30和/或高速缓存存储器32。计算机系统/服务器12可以进一步包括其它可移动/不可移动的、易失性/非易失性计算机系统存储介质。仅作为举例,存储系统34可以用于读写不可移动的、非易失性磁介质(图1未显示,通常称为“硬盘驱动器”)。尽管图1中未示出,可以提供用于对可移动非易失性磁盘(例如“软盘”)读写的磁盘驱动器,以及对可移动非易失性光盘(例如CD-ROM,DVD-ROM或者其它光介质)读写的光盘驱动器。在这些情况下,每个驱动器可以通过一个或者多个数据介质接口与总线18相连。存储器28可以包括至少一个程序产品,该程序产品具有一组(例如至少一个)程序模块,这些程序模块被配置以执行本发明各实施例的功能。The system memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and/or cache memory 32. The computer system/server 12 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. For example only, the storage system 34 may be used to read and write non-removable, non-volatile magnetic media (not shown in FIG. 1 and generally referred to as a "hard drive"). Although not shown in FIG. 1, a disk drive for reading and writing to a removable non-volatile disk (such as a "floppy disk") and a removable non-volatile disk (such as CD-ROM, DVD-ROM) can be provided. Or other optical media) read and write optical disc drives. In these cases, each drive can be connected to the bus 18 through one or more data media interfaces. The memory 28 may include at least one program product, the program product having a set of (for example, at least one) program modules, and these program modules are configured to perform the functions of the embodiments of the present invention.
具有一组(至少一个)程序模块42的程序/实用工具40,可以存储在例如存储器28中,这样的程序模块42包括——但不限于——操作系统、一个或者多个应用程序、其它程序模块以及程序数据,这些示例中的每一个或某种组合中可能包括网络环境的实现。程序模块42通常执行本发明所描述的实施例中的功能和/或方法。A program/utility tool 40 having a set of (at least one) program module 42 may be stored in, for example, the memory 28. Such program module 42 includes, but is not limited to, an operating system, one or more application programs, and other programs Modules and program data, each of these examples or some combination may include the realization of a network environment. The program module 42 generally executes the functions and/or methods in the described embodiments of the present invention.
计算机系统/服务器12也可以与一个或多个外部设备14(例如键盘、指向设备、显 示器24等)通信,还可与一个或者多个使得用户能与该计算机系统/服务器12交互的设备通信,和/或与使得该计算机系统/服务器12能与一个或多个其它计算设备进行通信的任何设备(例如网卡,调制解调器等等)通信。这种通信可以通过输入/输出(I/O)接口22进行。并且,计算机系统/服务器12还可以通过网络适配器20与一个或者多个网络(例如局域网(LAN),广域网(WAN)和/或公共网络,例如因特网)通信。如图所示,网络适配器20通过总线18与计算机系统/服务器12的其它模块通信。应当明白,尽管图中未示出,可以结合计算机系统/服务器12使用其它硬件和/或软件模块,包括但不限于:微代码、设备驱动器、冗余处理单元、外部磁盘驱动阵列、RAID系统、磁带驱动器以及数据备份存储系统等。The computer system/server 12 can also communicate with one or more external devices 14 (such as keyboards, pointing devices, displays 24, etc.), and can also communicate with one or more devices that enable users to interact with the computer system/server 12. And/or communicate with any device (such as a network card, modem, etc.) that enables the computer system/server 12 to communicate with one or more other computing devices. This communication can be performed through an input/output (I/O) interface 22. In addition, the computer system/server 12 may also communicate with one or more networks (for example, a local area network (LAN), a wide area network (WAN), and/or a public network, such as the Internet) through the network adapter 20. As shown in the figure, the network adapter 20 communicates with other modules of the computer system/server 12 through the bus 18. It should be understood that although not shown in the figure, other hardware and/or software modules can be used in conjunction with the computer system/server 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, Tape drives and data backup storage systems, etc.
图2示出了根据本公开的一个实施例的用于处理程序代码中的变量的引用的方法的流程图。图2中所示的方法例如可以由图1中所示的计算机系统或服务器12来执行。图2中所示的方法包括步骤210至250,但是这仅仅是示意性的,该方法还可以包括更多或更少的步骤。Fig. 2 shows a flowchart of a method for handling references of variables in program code according to an embodiment of the present disclosure. The method shown in FIG. 2 may be executed by, for example, the computer system or the server 12 shown in FIG. 1. The method shown in FIG. 2 includes steps 210 to 250, but this is only illustrative, and the method may also include more or fewer steps.
图2中所示的方法开始于步骤210,在步骤210中,用户输入中包含的字符流可以被顺序地接收。所述字符流是程序代码的一部分,并且所述程序代码是以编译型语言、解释型语言、或者用于构建电子表格模型的语言编写的。The method shown in FIG. 2 starts at step 210. In step 210, the character stream contained in the user input may be received sequentially. The character stream is a part of the program code, and the program code is written in a compiled language, an interpreted language, or a language used to build a spreadsheet model.
用户可以通过文本编辑器或图形用户界面编辑器输入全部或者部分程序代码,也可以直接读取存储在存储设备中的全部或部分程序代码。本公开中的“程序代码”可以由纯文本代码构成,也可以由图形用户界面中用户的一组操作构成。例如,C++、Python等传统编程语言仅接收纯文本的代码,但是SMALL语言的程序既可以是纯文本的代码,也可以是图形用户界面中用户的一组操作。The user can input all or part of the program code through a text editor or a graphical user interface editor, or directly read all or part of the program code stored in the storage device. The "program code" in the present disclosure can be composed of plain text code, or can be composed of a set of operations of the user in the graphical user interface. For example, traditional programming languages such as C++ and Python only receive codes in plain text, but programs in SMALL language can either be codes in plain text or a set of user operations in a graphical user interface.
根据本公开的另一个实施例,所述用户输入可以包括由文本编辑器监听的用户输入动作产生的程序代码的至少一部分。在该实施例中,如果用户通过文本编辑器输入纯文本代码,步骤210被实现为由文本编辑器监听输入设备的输入操作,将已经输入的所有字符、光标所在的位置、和上一步操作存储在内存中,供后续步骤使用。例如当用户依次输入以下字符“i”、“n”、“t”、“”、“x”、“=”、“aa”、“+”,文本编辑器接收这些字符并将它们连接成字符串“int x=aa+”保存,并将光标的位置也保存。如果用户继续输入“b”、“*”、“2”,则文本编辑器把增加的字符串“b*2”保存并且保存更新的光标位置。如果用户从后向前删除了“2”、“*2”,则文本编辑器将删除了“*2”的字符串保存并且保存更新的光标位置。当用户手动保存(例如通过用户按下“Ctrl+S”快捷键或用鼠标点击文本编辑器 的保存按钮)时,文本编辑器将存储于内存中的内容转存至硬盘。后续步骤(例如步骤220)可以通过读取文本编辑器保存的字符串和光标位置来执行相应的操作。According to another embodiment of the present disclosure, the user input may include at least a part of program code generated by a user input action monitored by a text editor. In this embodiment, if the user inputs a plain text code through a text editor, step 210 is implemented as the text editor monitors the input operation of the input device, and stores all the characters that have been input, the position of the cursor, and the previous operation. In memory, for use in subsequent steps. For example, when the user sequentially inputs the following characters "i", "n", "t", "", "x", "=", "aa", "+", the text editor receives these characters and connects them into characters The string "int x=aa+" is saved, and the position of the cursor is also saved. If the user continues to input "b", "*", "2", the text editor saves the added character string "b*2" and saves the updated cursor position. If the user deletes "2" and "*2" from back to front, the text editor will save the string with "*2" deleted and save the updated cursor position. When the user manually saves (for example, by pressing the "Ctrl+S" shortcut key or clicking the save button of the text editor with the mouse), the text editor will dump the content stored in the memory to the hard disk. The subsequent steps (for example, step 220) can perform corresponding operations by reading the character string and the cursor position saved by the text editor.
在根据本公开的又一个实施例中,所述用户输入可以包括通过用户在图形用户界面编辑器中的操作产生的程序代码的至少一部分。在该实施例中,如果用户使用图形用户界面编辑器输入程序代码,例如使用图3所示的用以构建电子表格模型的图形用户界面编辑器,则该编辑器监听图形用户界面中的用户操作,以供后续步骤使用。图3示出了使用SMALL语言的图形用户界面编辑器的操作的示例。如图3中所示,作为本发明的一个应用场景,使用SMALL语言的图形用户界面编辑器中包含不同的组件,用户可以通过用鼠标点击图形用户界面的行添加组件“+row”301来添加组件302,组件302代表电子表格中的一个行。如果在组件302中输入行的名称“Revenue”303,则该新添加的行将被命名为“Revenue”。在根据本公开的一个实施例中,系统将用户添加行的操作(例如点击组件301)以及在组件302内输入的字符串保存以供后续步骤使用。In yet another embodiment according to the present disclosure, the user input may include at least a part of program code generated by a user's operation in a graphical user interface editor. In this embodiment, if the user uses a graphical user interface editor to input program code, for example, the graphical user interface editor for building a spreadsheet model as shown in FIG. 3, the editor monitors user operations in the graphical user interface For use in subsequent steps. Fig. 3 shows an example of the operation of a graphical user interface editor using SMALL language. As shown in Figure 3, as an application scenario of the present invention, the graphical user interface editor using SMALL language contains different components. The user can add the component "+row" 301 by clicking the row of the graphical user interface with the mouse. The component 302, the component 302 represents a row in the spreadsheet. If the row name "Revenue" 303 is entered in the component 302, the newly added row will be named "Revenue". In an embodiment according to the present disclosure, the system saves the user's operation of adding a row (for example, clicking on the component 301) and the character string input in the component 302 for use in subsequent steps.
根据本公开的一个实施例,所述用户输入可以包括用户编辑完成并存储的程序代码的至少一部分。在该实施例中,系统可以直接读取由用户之前编辑并保存在存储设备中的全部或部分程序。此时步骤210被实现为由系统将用户保存的全部或部分程序代码读入内存,并且开始顺序地读取内存中的所述程序代码以形成字符流。According to an embodiment of the present disclosure, the user input may include at least a part of the program code edited and stored by the user. In this embodiment, the system can directly read all or part of the programs previously edited by the user and saved in the storage device. At this time, step 210 is implemented as the system reads all or part of the program codes saved by the user into the memory, and starts to read the program codes in the memory sequentially to form a character stream.
再次参考图2,该方法进行到步骤220。在步骤220中,从所接收的字符流中识别第一变量符号并且存储与第一变量符号相关的信息。这里,第一变量符号表示第一变量。Referring again to FIG. 2, the method proceeds to step 220. In step 220, the first variable symbol is identified from the received character stream and information related to the first variable symbol is stored. Here, the first variable symbol represents the first variable.
根据本公开的一个实施例,从所接收的字符流中识别第一变量符号可以包括利用词法分析器或者机器学习分类器中的一者或多者从所接收的字符流中识别第一变量符号。在该实施例中,如果输入的程序代码是文本代码,则可以使用词法分析器(Lexer)逐字符扫描文本代码,将文本字符流分解为单个字符组成的序列,然后根据词法规则识别出其中代表变量符号的字符串。词法分析器通过有限状态机实现。例如,在扫描一个C语言代码语句“int x=aa+b*2”时,当扫描完“int”,“x”、“=”、“aa”、“+”、“b”、“*”、“2”,有限状态机会分别返回“keyword”(关键字)、“identifier”(标识符)、“operator”(运算符)、“identifier”、“operator”、“identifier”、“operator”、“constant”(常量)的状态。其中,与“identifier”对应的字符串“x”、“aa”、“b”就是变量符号。According to an embodiment of the present disclosure, identifying the first variable symbol from the received character stream may include using one or more of a lexical analyzer or a machine learning classifier to identify the first variable symbol from the received character stream . In this embodiment, if the input program code is a text code, a lexer (Lexer) can be used to scan the text code character by character, and the text character stream can be decomposed into a sequence of individual characters, and then the representative can be identified according to the lexical rules The character string of the variable symbol. The lexical analyzer is implemented by a finite state machine. For example, when scanning a C language code sentence "int x=aa+b*2", after scanning "int", "x", "=", "aa", "+", "b", "* ", "2", the limited state opportunity returns "keyword", "identifier", "operator", "identifier", "operator", "identifier", "operator" respectively , "Constant" (constant) status. Among them, the character strings "x", "aa", and "b" corresponding to "identifier" are variable symbols.
在该实施例中,替代地或者附加地,可以利用机器学习分类器来识别变量符号。在一个实施例中,可以使用机器学习分类器来给文本代码中的子字符串打分。如果分数大于预定阈值,则认为该子字符串是一个变量符号。例如,在SMALL语言的代码中,如果 以文本方式输入“Revenue=US Revenue+China Revenue”,则分类器会给“Revenue”、“US Revenue”、“China Revenue”这些子字符串打出较高的分数并且将它们识别为变量符号。In this embodiment, alternatively or in addition, a machine learning classifier may be used to identify variable symbols. In one embodiment, a machine learning classifier can be used to score substrings in the text code. If the score is greater than the predetermined threshold, the substring is considered to be a variable symbol. For example, in the SMALL language code, if you enter "Revenue=USRevenue+ChinaRevenue" in text mode, the classifier will give the substrings "Revenue", "USRevenue", and "ChinaRevenue" higher Score and recognize them as variable symbols.
根据本公开的一个实施例,从所接收的字符流中识别第一变量符号可以包括把从图形用户界面编辑器的特定组件中接收的字符流识别为第一变量符号。在该实施例中,如果用户通过图形用户界面输入程序代码,则识别变量符号的过程可以只部分地使用或者不使用词法分析。例如,可以将用户在特定图形用户界面组件中输入的内容识别为变量符号。图4示出了根据本公开的一个实施例的使用SMALL语言的图形用户界面编辑器输入代码的示例。如图4中所示,当用户在一个行组件401中的栏402中输入“Revenue”时,“Revenue”将被识别为一个类型为“行”的变量符号。在图形用户界面编辑器中同样也可以使用词法分析器或机器学习分类器来识别变量符号。例如,如果在图4所示的行组件401中的等号右侧的公式输入栏中输入“{US Revenue}+{China Revenue}”(403,404),则词法分析器可以将大括号内的内容识别为变量符号;而如果在公式输入栏中输入“US Revenue+China Revenue”,则机器学习分类器可以将“US Revenue”和“China Revenue”识别为变量符号。According to an embodiment of the present disclosure, recognizing the first variable symbol from the received character stream may include recognizing the character stream received from a specific component of the graphical user interface editor as the first variable symbol. In this embodiment, if the user enters the program code through the graphical user interface, the process of identifying variable symbols may only partially use or not use lexical analysis. For example, the content entered by the user in a specific graphical user interface component can be recognized as a variable symbol. Fig. 4 shows an example of inputting code by a graphical user interface editor using SMALL language according to an embodiment of the present disclosure. As shown in FIG. 4, when the user enters "Revenue" in the column 402 in a row component 401, "Revenue" will be recognized as a variable symbol of the type "row". In the graphical user interface editor, you can also use a lexical analyzer or machine learning classifier to identify variable symbols. For example, if you enter "{US Revenue}+{China Revenue}" (403,404) in the formula input field to the right of the equal sign in the line component 401 shown in Figure 4, the lexical analyzer can convert the content in the braces Recognized as variable symbols; and if you enter "US Revenue+China Revenue" in the formula input column, the machine learning classifier can recognize "US Revenue" and "China Revenue" as variable symbols.
根据本公开的一个实施例,与变量符号相关的信息可以包括以下信息中的一者或多者:变量符号的名称、变量符号在程序代码中的位置、变量符号的命名空间、变量符号的作用域、变量符号表示的变量的类型、变量符号表示的变量、以及与变量符号相关的操作。According to an embodiment of the present disclosure, the information related to the variable symbol may include one or more of the following information: the name of the variable symbol, the position of the variable symbol in the program code, the namespace of the variable symbol, and the role of the variable symbol Domains, types of variables represented by variable symbols, variables represented by variable symbols, and operations related to variable symbols.
变量符号的名称是指代表这个变量符号的字符串,例如在上面的例子中,“x”、“aa”、“b”、“Revenue”、“US Revenue”、“China Revenue”都是变量符号的名称。在识别出变量符号的同时,得到了变量符号的名称。The name of the variable symbol refers to the string representing the variable symbol. For example, in the above example, "x", "aa", "b", "Revenue", "US Revenue", and "China Revenue" are all variable symbols The name. When the variable symbol is recognized, the name of the variable symbol is obtained.
变量符号在程序代码中的位置是指能够在程序代码中定位到该变量符号的信息。对于文本形式的程序代码,变量符号在程序代码中的位置可以使用表示该变量符号在程序代码中的位置的元组来表示,例如(8,10,3)代表该变量符号是程序代码中第8行第10个字符起的3个字符。对于图形用户界面的程序代码,变量符号在程序代码中的位置可以通过输入了该变量符号的组件的位置获得。The position of the variable symbol in the program code refers to the information that can locate the variable symbol in the program code. For program code in text form, the position of a variable symbol in the program code can be represented by a tuple that represents the position of the variable symbol in the program code. For example, (8, 10, 3) represents that the variable symbol is the first in the program code. 3 characters from the 10th character on the 8th line. For the program code of the graphical user interface, the position of the variable symbol in the program code can be obtained by the position of the component to which the variable symbol is input.
根据本公开的一个实施例,一个程序中的所有变量符号可以被分组,每一个组归属于一个命名空间或一个作用域,在不同命名空间或不同作用域中拥有同样名称的两个变量符号实际上代表不同的变量。例如,对于C程序代码,如果输入“int a=1;”,之后又 输入“int f(){int a=2}”,则程序代码中有两个名称为“a”的变量符号,但前者归属于文件作用域,后者归属于“f()”函数内的作用域,所以它们代表两个不同的变量。命名空间的概念类似于作用域,也是指代变量符号归属的分组的一种方式。例如,在C语言中,可以用命名空间进一步区分相同作用域的相同名称的变量符号。例如对于C语言中的两个命名空间“namespaceA”和“namespaceB”,两个变量符号“namespaceA::a”和“namespaceB::a”指代的变量名称都为“a”,但是由于它们归属于不同的命名空间,所以代表两个不同的变量。例如,在SMALL语言的程序代码中,如果在一个名为“Revenue Breakup”的表中添加了一个行“Revenue”,又在一个名为“Income Statement”的表中添加一个行“Revenue”,那么这两个名称都是“Revenue”的变量符号归属于不同的命名空间。即,前者归属于表“Revenue Breakup”内的命名空间,而后者归属于表“Income Statement”内的命名空间。According to an embodiment of the present disclosure, all variable symbols in a program can be grouped, and each group belongs to a namespace or a scope. Two variable symbols with the same name in different namespaces or different scopes actually The above represents different variables. For example, for C program code, if you enter "int a=1;" and then enter "int f(){int a=2}", there are two variable symbols named "a" in the program code, but The former belongs to the file scope, and the latter belongs to the scope of the "f()" function, so they represent two different variables. The concept of namespace is similar to scope, and it is also a way to refer to the grouping of variable symbols. For example, in the C language, namespaces can be used to further distinguish variable symbols with the same name in the same scope. For example, for the two namespaces "namespaceA" and "namespaceB" in the C language, the variable names referred to by the two variable symbols "namespaceA::a" and "namespaceB::a" are all "a", but because they belong In different namespaces, it represents two different variables. For example, in the program code of SMALL language, if a row “Revenue” is added to a table named “Revenue Breakup”, and a row “Revenue” is added to a table named “Income Statement”, then The two variable symbols whose names are both "Revenue" belong to different namespaces. That is, the former belongs to the namespace in the table "Revenue Breakup", and the latter belongs to the namespace in the table "Income Statement".
根据本公开的一个实施例,对于文本形式的程序代码,命名空间可以通过对该变量符号的上下文进行语法分析而获得。所述语法分析是根据语法规则,将词法分析得到的标记序列(Tokens)构建为解析树(Parse Tree)或抽象语法树(Abstract Syntax Tree)或其他层级数据结构中的至少一种。该数据结构中记录了变量符号之间的从属和依赖关系以及命名空间等信息。此外,变量符号的作用域、变量符号表示的变量的类型也可以通过对该变量符号的上下文进行语法分析而获得。According to an embodiment of the present disclosure, for the program code in text form, the namespace can be obtained by grammatically analyzing the context of the variable symbol. The syntax analysis is to construct the token sequence (Tokens) obtained from the lexical analysis into at least one of a parse tree (Parse Tree) or an abstract syntax tree (Abstract Syntax Tree) or other hierarchical data structures according to grammatical rules. The data structure records the affiliation and dependency relationship between the variable symbols, as well as the name space and other information. In addition, the scope of the variable symbol and the type of the variable represented by the variable symbol can also be obtained by grammatically analyzing the context of the variable symbol.
根据本公开的一个实施例,对于图形用户界面的程序代码,命名空间可以通过建立该变量时的图形用户界面组件的信息获得。例如,变量符号的命名空间可以根据输入了该变量符号的组件与其它组件的结构关系获得。或者变量符号的命名空间可以根据用户指定的该变量符号的路径获得。与变量符号的命名空间类似,变量符号的作用域可以通过输入了该变量符号的组件与其它组件的结构关系获得。According to an embodiment of the present disclosure, for the program code of the graphical user interface, the namespace can be obtained by the information of the graphical user interface component when the variable is created. For example, the name space of a variable symbol can be obtained according to the structural relationship between the component to which the variable symbol is input and other components. Or the namespace of the variable symbol can be obtained according to the path of the variable symbol specified by the user. Similar to the namespace of the variable symbol, the scope of the variable symbol can be obtained by the structural relationship between the component inputting the variable symbol and other components.
根据本公开的一个实施例,与变量符号相关的操作包括以下的至少一者:声明、定义、初始化、赋值、访问、以及析构。与变量符号相关的操作指的是对变量符号代表的变量的操作。对于文本形式的程序代码,与变量符号相关的操作可以通过对该变量符号的上下文进行语法分析而获得。例如,在C语言中,“int x=aa+b*2”中的“x”由于前面有关键词“int”,后面跟着一个表达式“=aa+b*2”,所以这行代码对变量符号“x”所代表的变量进行了声明、定义和初始化。例如,对于图形用户界面的程序代码,与变量符号相关的操作可以通过用户在图形用户界面编辑器中的相应操作获得。如图3所示,例如通过点击行添加组件301并输入“Revenue”303从而添加一个名称为“Revenue”的行(即变 量),这一系列操作代表对这个行进行了声明和定义。如图4所示,在行401的等号右侧的公式输入框中输入“US Revenue”403和“China Revenue”404的操作则代表了对这两个变量的访问。According to an embodiment of the present disclosure, operations related to variable symbols include at least one of the following: declaration, definition, initialization, assignment, access, and destruction. Operations related to variable symbols refer to operations on variables represented by variable symbols. For the program code in text form, the operations related to the variable symbol can be obtained by grammatically analyzing the context of the variable symbol. For example, in the C language, the "x" in "int x=aa+b*2" is preceded by the keyword "int", followed by an expression "=aa+b*2", so this line of code is right The variable represented by the variable symbol "x" has been declared, defined and initialized. For example, for the program code of the graphical user interface, the operations related to the variable symbols can be obtained through the user's corresponding operations in the graphical user interface editor. As shown in Figure 3, for example, by clicking on the row add component 301 and inputting "Revenue" 303 to add a row (namely variable) named "Revenue", this series of operations represents the declaration and definition of this row. As shown in Figure 4, the operation of entering "US Revenue" 403 and "China Revenue" 404 in the formula input box on the right side of the equal sign in row 401 represents the access to these two variables.
此外,对于图形用户界面的程序代码,变量符号表示的变量的类型可以通过创建该变量时的组件的信息获得。例如,如图3所示,在创建行“Revenue”时,由于点击了行添加组件301,所以变量“Revenue”的类型为行。In addition, for the program code of the graphical user interface, the type of the variable represented by the variable symbol can be obtained from the information of the component when the variable is created. For example, as shown in Figure 3, when the row "Revenue" is created, since the row addition component 301 is clicked, the type of the variable "Revenue" is row.
这里,第一变量符号是指方法此时正在识别的变量符号。在第一变量符号之前可能已经识别了在程序代码中位于第一变量符号之前的其他变量符号。在步骤220中存储与第一变量符号相关的信息时,与第一变量符号相关的信息被存储到一个数据结构中。在一个实施例中,该数据结构可以是一个表格,在下文中为了便于描述该表格将被称为变量符号表。该变量符号表存储有与程序代码中的每个识别的变量符号相关的信息。Here, the first variable symbol refers to the variable symbol being recognized by the method at this time. Before the first variable symbol, other variable symbols located before the first variable symbol in the program code may have been identified. When storing the information related to the first variable symbol in step 220, the information related to the first variable symbol is stored in a data structure. In one embodiment, the data structure may be a table, which will be referred to as a variable symbol table in the following for ease of description. The variable symbol table stores information related to each recognized variable symbol in the program code.
变量符号表用于存储在步骤220中识别的变量符号及其相关信息。在识别了一个变量符号后,系统将该识别的变量符号及其相关信息存储至变量符号表。如果变量符号表不存在,则先建立变量符号表,再将识别的变量符号及其相关信息存入变量符号表。在一个实现中,创建变量符号表的过程为:向操作系统申请存储空间并在该存储空间中建立变量符号表数据结构。在对变量符号表的操作过程中,如果变量符号表的存储空间不足,则动态地向操作系统申请更多的存储空间以存储新增的内容。根据本公开的一个实施例,可以通过变量符号的名称的哈希值在变量符号表中建立索引。变量符号表中的每一个变量符号都对应于一个哈希值,根据哈希值建立树状索引,并存储在变量符号表中。图5示出了根据本公开的一个实施例的变量符号表的示例。在变量符号表中,如果代表同一个变量的变量符号在程序代码中出现多次,则它们在变量符号表中对应多个条目。例如,如图5所示,以图5左侧的程序代码作为输入,可以依次识别出变量符号“a”、“a”、“b”、“a”、“c”,并存储在图5右侧示出的变量符号表中。例如,图5中的变量符号“a”在程序代码中出现了三次,它在变量符号表中也被对应地记录了三次,参见id为1、2和4的条目。本领域技术人员可以理解,图5中的变量符号表仅仅是示意性的,它还可以包括其他列,例如变量符号在程序代码中的位置、变量符号的命名空间、变量符号的作用域、变量符号表示的变量的类型、变量符号表示的变量、以及与变量符号相关的操作等。对于下文中出现的其他示意性变量符号表也是如此。The variable symbol table is used to store the variable symbols identified in step 220 and their related information. After identifying a variable symbol, the system stores the identified variable symbol and its related information in the variable symbol table. If the variable symbol table does not exist, first establish the variable symbol table, and then save the recognized variable symbol and its related information into the variable symbol table. In one implementation, the process of creating a variable symbol table is: request storage space from the operating system and establish a variable symbol table data structure in the storage space. During the operation of the variable symbol table, if the storage space of the variable symbol table is insufficient, more storage space is dynamically applied to the operating system to store the newly added content. According to an embodiment of the present disclosure, an index can be established in the variable symbol table through the hash value of the name of the variable symbol. Each variable symbol in the variable symbol table corresponds to a hash value, and a tree index is established according to the hash value and stored in the variable symbol table. Fig. 5 shows an example of a variable symbol table according to an embodiment of the present disclosure. In the variable symbol table, if the variable symbols representing the same variable appear multiple times in the program code, they correspond to multiple entries in the variable symbol table. For example, as shown in Figure 5, taking the program code on the left side of Figure 5 as input, the variable symbols "a", "a", "b", "a", and "c" can be sequentially identified and stored in Figure 5. The variable symbol table shown on the right. For example, the variable symbol "a" in Figure 5 appears three times in the program code, and it is correspondingly recorded three times in the variable symbol table. See the entries with id 1, 2, and 4. Those skilled in the art can understand that the variable symbol table in FIG. 5 is only illustrative, and it may also include other columns, such as the position of the variable symbol in the program code, the namespace of the variable symbol, the scope of the variable symbol, and the variable symbol table. The type of the variable represented by the symbol, the variable represented by the variable symbol, and the operations related to the variable symbol. The same is true for the other illustrative variable symbol tables that appear below.
尽管图5示出了表格形式的变量符号表,但是本发明不应局限于此。例如,变量符号表也可以采用其他数据结构,例如链表、数据库等。Although FIG. 5 shows a variable symbol table in the form of a table, the present invention should not be limited to this. For example, the variable symbol table can also adopt other data structures, such as linked lists, databases, and so on.
现在返回参照图2,在步骤230中,第一变量符号与从所述程序代码中先前识别的至少一个变量符号被进行匹配,以确定所述至少一个变量符号中是否存在表示第一变量的第二变量符号。步骤230的目的是把当前识别的变量符号与先前识别的各个变量符号进行比较,以确定哪个或哪些先前识别的变量符号与当前识别的变量符号表示同样的变量。这里,第二变量符号是指先前已识别的并记录在变量符号表中的也表示第一变量的变量符号之一。Now referring back to FIG. 2, in step 230, the first variable symbol is matched with at least one variable symbol previously identified from the program code to determine whether there is a first variable representing the first variable in the at least one variable symbol. Two variable symbol. The purpose of step 230 is to compare the currently recognized variable symbol with each previously recognized variable symbol to determine which previously recognized variable symbol or symbols represent the same variable as the currently recognized variable symbol. Here, the second variable symbol refers to one of the variable symbols that has been previously identified and recorded in the variable symbol table and also represents the first variable.
根据本公开的一个实施例,响应于与变量符号相关的信息被存储到变量符号表中,可以通过所述索引把该变量符号与先前存储的变量符号进行匹配。例如,当通过变量符号名称的哈希值建立索引时,可以计算当前识别的变量符号名称的哈希值,并通过索引搜索变量符号表中与当前识别的变量符号名称类似的变量符号名称,并进行匹配。According to an embodiment of the present disclosure, in response to the information related to the variable symbol being stored in the variable symbol table, the variable symbol can be matched with the previously stored variable symbol through the index. For example, when the index is established by the hash value of the variable symbol name, the hash value of the currently recognized variable symbol name can be calculated, and the variable symbol name in the variable symbol table that is similar to the currently recognized variable symbol name can be searched through the index, and Make a match.
根据本公开的一个实施例,在步骤230中,响应于与变量符号相关的信息被存储到变量符号表中,把该变量符号与先前存储的变量符号逐个进行匹配。也就是说,针对新识别的第一变量符号,将它与变量符号表中的每一条目进行比较,确定它们是否表示同一个变量。这种匹配例如可以是严格匹配、规则匹配、或者模糊匹配。According to an embodiment of the present disclosure, in step 230, in response to the information related to the variable symbol being stored in the variable symbol table, the variable symbol is matched with the previously stored variable symbol one by one. That is, for the newly recognized first variable symbol, compare it with each entry in the variable symbol table to determine whether they represent the same variable. Such matching may be strict matching, rule matching, or fuzzy matching, for example.
根据本公开的一个实施例,把第一变量符号与从所述程序代码中先前识别的至少一个变量符号进行匹配可以包括:当所存储的第一变量符号和所述至少一个变量符号中的第二变量符号的名称、命名空间、作用域、以及表示的变量的类型都相同时,确定第一变量符号和第二变量符号表示同一变量。在该实施例中,可以采用严格匹配。当且仅当两个变量符号的命名空间、作用域、名称、类型都相同时,确定这两个变量符号匹配。例如,在C语言的代码中,如果同时输入“int a=1;”和“void f(){int global a=2};”,则这两个名称为“a”的变量符号都属于默认命名空间以及文件作用域,所以它们可以被严格匹配。例如,在SMALL语言中,在同一个表格下先分别建立“Revenue”、“US Revenue”、“China Revenue”三个行,并输入公式“Revenue={US Revenue}+{China Revenue}”,则两个名为“US Revenue”的变量符号属于同一命名空间,所以它们可以被严格匹配。According to an embodiment of the present disclosure, matching the first variable symbol with at least one variable symbol previously identified from the program code may include: when the stored first variable symbol and the second one of the at least one variable symbol When the names, namespaces, scopes, and types of variables represented by the variable symbols are all the same, it is determined that the first variable symbol and the second variable symbol represent the same variable. In this embodiment, strict matching can be used. If and only if the namespace, scope, name, and type of the two variable symbols are the same, it is determined that the two variable symbols match. For example, in the code of C language, if you enter "int a=1;" and "void f(){int global a=2};" at the same time, then the two variable symbols named "a" belong to the default Namespace and file scope, so they can be strictly matched. For example, in the SMALL language, first create three rows of "Revenue", "US Revenue", and "China Revenue" in the same form, and enter the formula "Revenue={USRevenue}+{ChinaRevenue}", then Two variable symbols named "US Revenue" belong to the same namespace, so they can be strictly matched.
根据本公开的一个实施例,把第一变量符号与从所述程序代码中先前识别的至少一个变量符号进行匹配可以包括:当第一变量符号和所述至少一个变量符号中的多个第二变量符号的名称相同时,根据预定义的规则确定第一变量符号和哪个第二变量符号表示同一变量。在该实施例中,可以采用基于规则的匹配。该预定义的规则可以包括将第一变量符号和距离其最近的相同名称的第二变量符号匹配为表示同一变量。例如,在SMALL语言中,如果在“Revenue”行中输入公式“={US Revenue}+{China Revenue}”, 但是在同一命名空间中建立过两个名为“US Revenue”的行。这里,把这三个变量符号分别称为“US Revenue[1]”、“US Revenue[2]”、“US Revenue[3]”。那么可以确定“US Revenue[2]”和“US Revenue[3]”代表的行哪一个距离“Revenue”这一行更近,将更近的行确定为与“US Revenue[1]”匹配。上述规则示例基于行之间的距离,但是本发明不限于此,还可以规定其他的规则,例如基于行建立时间先后的规则、基于空值较少的规则等等。According to an embodiment of the present disclosure, matching the first variable symbol with at least one variable symbol previously identified from the program code may include: when the first variable symbol and a plurality of second ones of the at least one variable symbol When the names of the variable symbols are the same, the first variable symbol and which second variable symbol represents the same variable are determined according to a predefined rule. In this embodiment, rule-based matching can be used. The predefined rule may include matching the first variable symbol and the nearest second variable symbol of the same name to represent the same variable. For example, in the SMALL language, if you enter the formula "={US Revenue}+{China Revenue}" in the "Revenue" row, but two rows named "US Revenue" have been created in the same namespace. Here, these three variable symbols are called "US Revenue[1]", "US Revenue[2]", and "US Revenue[3]" respectively. Then you can determine which of the rows represented by "US Revenue[2]" and "US Revenue[3]" is closer to the "Revenue" row, and determine the closer row as matching "US Revenue[1]". The foregoing rule example is based on the distance between rows, but the present invention is not limited to this, and other rules may also be specified, such as a rule based on the time sequence of row establishment, a rule based on fewer empty values, and so on.
根据本公开的一个实施例,把第一变量符号与从所述程序代码中先前识别的至少一个变量符号进行匹配可以包括:当与第一变量符号相关的信息和与所述至少一个变量符号中的第二变量符号相关的信息之间的相似度高于阈值时,提示用户确认第一变量符号和第二变量符号是否表示同一变量。在该实施例中,可以采用模糊匹配,从而即使不同名称的变量符号之间也可以被匹配。例如,在SMALL语言中,如果用户建立了一个名为“Sales”的行,又在其他行的公式栏中输入“={Revenue}”,则基于自然语言识别的匹配,建议将“Revenue”这一变量符号和“Sales”这一变量符号匹配,并提示用户确认。模糊匹配的一种实现是对任何一个变量符号计算其对应的词向量,根据两个变量符号的词向量之间的距离计算两个变量符号之间的相似度,将相似度高于一阈值的两个变量符号确定为匹配。另一种实现是根据两个变量符号之间的编辑距离来计算相似度。例如,对于变量符号“Revenue”和变量符号“revenue”,只是首字母不同,且首字母之间的区别仅是大小写区别,那么可以通过对比两个变量符号中相同字符的比例,得出变量符号之间的编辑距离从而计算相似度。因此,上述两个变量符号之间的相似度较高,可以向用户发出提示进行确认是否匹配。According to an embodiment of the present disclosure, matching the first variable symbol with at least one variable symbol previously identified from the program code may include: when the information related to the first variable symbol is related to the at least one variable symbol When the similarity between the information related to the second variable symbol is higher than the threshold, the user is prompted to confirm whether the first variable symbol and the second variable symbol represent the same variable. In this embodiment, fuzzy matching can be used, so that even variable symbols with different names can be matched. For example, in the SMALL language, if the user creates a row named "Sales" and enters "={Revenue}" in the formula bar of other rows, based on the matching of natural language recognition, it is recommended to change the "Revenue" A variable symbol matches the variable symbol "Sales", and the user is prompted for confirmation. One implementation of fuzzy matching is to calculate the corresponding word vector for any variable symbol, and calculate the similarity between the two variable symbols according to the distance between the word vectors of the two variable symbols, and the similarity is higher than a threshold. The two variable symbols are determined to match. Another implementation is to calculate the similarity based on the edit distance between two variable symbols. For example, for the variable symbol "Revenue" and the variable symbol "revenue", only the first letter is different, and the difference between the first letter is only the difference between upper and lower case, then the variable can be obtained by comparing the ratio of the same characters in the two variable symbols The edit distance between the symbols to calculate the similarity. Therefore, the similarity between the above two variable symbols is relatively high, and the user can be prompted to confirm whether they match.
在以上的例子中,相似度是基于变量符号的名称的编辑距离或词向量距离计算。在根据公开的另一实施例中,所述相似度可以通过以下的一者或多者得到:变量符号名称之间的编辑距离、变量符号名称之间的语义相似度、变量符号命名空间之间的相似度、变量符号作用域之间的包含关系、以及变量符号在所述程序代码中的位置之间的距离。In the above example, the similarity is calculated based on the edit distance of the name of the variable symbol or the word vector distance. In another embodiment according to the disclosure, the similarity can be obtained by one or more of the following: edit distance between variable symbol names, semantic similarity between variable symbol names, and variable symbol namespaces The degree of similarity, the inclusion relationship between the scopes of variable symbols, and the distance between the positions of variable symbols in the program code.
返回参照图2,方法继续进行到步骤240,在步骤240中,响应于确定存在至少一个第二变量符号,根据与第一变量符号相关的操作以及与所述一个或多个第二变量符号相关的操作,确定第一变量符号是否涉及未定义引用。Referring back to FIG. 2, the method continues to step 240. In step 240, in response to determining that there is at least one second variable symbol, according to an operation related to the first variable symbol and related to the one or more second variable symbols The operation of determining whether the first variable symbol involves an undefined reference.
根据本公开的一个实施例,为了识别程序代码中有哪些变量,还可以建立变量表并且建立变量符号表和变量表之间的关系。在另一个实施例中,不需要建立单独的变量表,而可以使用同一个数据结构来保存变量符号和变量,例如可以使用表格、链表等。为了便于说明,以下基于分别维护变量表和变量符号表的实施例进行描述。变量表用于 存储变量符号所指代的变量。在步骤220完成后如果变量表不存在,则先建立变量表,再将变量符号指代的变量存入变量表。变量符号和变量是不同的,在程序代码中,每一个变量都至少被一个变量符号指代,但是在本公开中,并非每个变量符号都指向一个变量。例如,在C语言中,如果仅写“x=1”却没有声明过“x”,则“x”这个变量符号并未指向一个变量。对于C语言代码,可以用变量的内存地址表示变量;对于SMALL语言,由于每个变量都对应于电子表格的层级结构中的某个层级,可以用这个层级的唯一ID表示该变量。图6示出了根据公开的一个实施例的程序代码、变量符号表和变量表的关系示例。如图6所示,本发明在变量表中设定了一种特殊的变量类型,称为空变量。如果变量符号代表的变量尚未定义,则在变量表中添加一个类型为空(null)的变量。例如,在图6中的语句“int b=a+c;”601中,变量“c”未定义,那么在变量表中添加类型为空的变量c 602。变量表中可以有多个类型为空的变量,它们具有不同的id。变量的id可以是自动分配的序号,也可以是变量的地址。According to an embodiment of the present disclosure, in order to identify which variables are in the program code, a variable table can also be established and the relationship between the variable symbol table and the variable table can be established. In another embodiment, there is no need to establish a separate variable table, but the same data structure can be used to store the variable symbols and variables, for example, a table, a linked list, etc. can be used. For ease of description, the following description is based on the embodiment of maintaining the variable table and the variable symbol table separately. The variable table is used to store the variables referred to by the variable symbols. If the variable table does not exist after step 220 is completed, the variable table is created first, and then the variable referred to by the variable symbol is stored in the variable table. Variable symbols and variables are different. In the program code, every variable is referred to by at least one variable symbol, but in this disclosure, not every variable symbol points to a variable. For example, in the C language, if only "x=1" is written but "x" is not declared, then the variable symbol "x" does not point to a variable. For the C language code, the memory address of the variable can be used to represent the variable; for the SMALL language, since each variable corresponds to a certain level in the hierarchy of the spreadsheet, the unique ID of this level can be used to represent the variable. Fig. 6 shows an example of the relationship between the program code, the variable symbol table, and the variable table according to an embodiment of the disclosure. As shown in Figure 6, the present invention sets a special variable type in the variable table, which is called an empty variable. If the variable represented by the variable symbol has not yet been defined, add a null variable in the variable table. For example, in the sentence "int b=a+c;" 601 in Fig. 6, the variable "c" is not defined, then the variable c 602 with an empty type is added to the variable table. There can be multiple empty variables in the variable table, and they have different ids. The id of the variable can be an automatically assigned serial number or the address of the variable.
根据本公开的一个实施例,变量表存储所识别的变量的状态,并且变量的状态包括以下一者或多者:表示该变量的变量符号、变量在内存中的地址、变量进行的操作、变量是否被定义、以及变量是否被引用。According to an embodiment of the present disclosure, the variable table stores the state of the identified variable, and the state of the variable includes one or more of the following: the variable symbol representing the variable, the address of the variable in the memory, the operation performed by the variable, the variable Whether it is defined and whether the variable is referenced.
本领域技术人员可以理解,图6中的变量表仅仅是示意性的,它还可以包括其他列,例如表示该变量的变量符号、变量在内存中的地址、变量进行的操作、变量是否被定义、以及变量是否被引用等。对于下文中出现的其他示意性变量表也是如此。Those skilled in the art can understand that the variable table in Figure 6 is only illustrative, and it can also include other columns, such as the variable symbol representing the variable, the address of the variable in the memory, the operation performed by the variable, and whether the variable is defined , And whether the variable is referenced, etc. The same is true for the other illustrative variable tables that appear below.
变量进行的操作可以是声明、定义、初始化、赋值、访问、析构中的一者或多者。由于在程序代码中同一个变量可能被多个变量符号指代,这些变量符号在程序代码中的不同位置可能进行了不同的操作,所以“变量进行的操作”可能与“与变量符号相关的操作”不同。图7示出了根据本公开的一个实施例的建立变量表的过程的示例。如图7所示,例如,在SMALL语言中,参见图7的上部,先输入“Revenue={US Revenue}+{China Revenue}”701,此时对于变量符号表中的“US Revenue”条目702和变量表中的“US Revenue”条目703,“操作”都是“访问”。但是,参见图7的下部,在建立了“US Revenue”704这一行后,变量符号表中有两个名称为“US Revenue”的变量符号705和706,对应的“操作”分别是“访问”和“声明,定义,赋值”,这两个变量符号对应的变量相同,都是变量表中的“US Revenue”703。这个变量的“操作”是“声明,定义,赋值,访问”707。The operation performed by the variable can be one or more of declaration, definition, initialization, assignment, access, and destruction. Since the same variable in the program code may be referred to by multiple variable symbols, these variable symbols may perform different operations in different positions in the program code, so "operation performed by variables" may be related to "operations related to variable symbols" "different. FIG. 7 shows an example of a process of establishing a variable table according to an embodiment of the present disclosure. As shown in Figure 7, for example, in the SMALL language, referring to the upper part of Figure 7, first enter "Revenue={USRevenue}+{ChinaRevenue}" 701, then for the "USRevenue" entry 702 in the variable symbol table And the "US Revenue" entry 703 in the variable table, "Operation" is "Access". However, referring to the lower part of Figure 7, after the line "US Revenue" 704 is created, there are two variable symbols 705 and 706 named "US Revenue" in the variable symbol table, and the corresponding "operations" are "Access". As with "declaration, definition, assignment", the variables corresponding to these two variable symbols are the same, and they are both "US Revenue" 703 in the variable table. The "operation" of this variable is "declaration, definition, assignment, access" 707.
根据本公开的一个实施例,所述变量表中的一个变量进行的操作等于与表示该变量的至少一个变量符号中的每个变量符号相关的操作的并集。也就是说,以图7为例,变 量表的条目703中的操作707等于与表示该变量的每个变量符号相关的操作的并集。也就是说,条目703中的操作707“声明,定义,赋值,访问”是条目705的操作“访问”和条目706的操作“声明,定义,赋值”的并集。图10给出了根据本公开的一个实施例的根据变量符号表来更新变量表的另一个例子。变量表中的变量的操作由与之相关的所有变量符号的操作决定。如图10所示,如果变量“a”1007对应变量符号表中的id为1、2、4的变量符号1001、1002、1003,并且它们进行的操作分别是“声明、定义”1004、“赋值”1006、“访问”1005,则变量“a”进行的操作为“声明、定义、赋值、访问”。According to an embodiment of the present disclosure, the operation performed by one variable in the variable table is equal to the union of operations related to each of the at least one variable symbol representing the variable. That is, taking Fig. 7 as an example, the operation 707 in the entry 703 of the variable table is equal to the union of the operations related to each variable symbol representing the variable. That is, the operation 707 "declare, define, assign, access" in entry 703 is the union of the operation "access" of entry 705 and the operation "declare, define, assign" of entry 706. FIG. 10 shows another example of updating the variable table according to the variable symbol table according to an embodiment of the present disclosure. The operation of the variables in the variable table is determined by the operation of all variable symbols related to it. As shown in Figure 10, if the variable "a" 1007 corresponds to the variable symbols 1001, 1002, 1003 with ids 1, 2, and 4 in the variable symbol table, and the operations they perform are "declare, define" 1004, and "assign" respectively "1006, "Access" 1005, the operations performed by the variable "a" are "declaration, definition, assignment, access".
根据本公开的一个实施例,可以根据所述并集中包括的操作来判断该变量是否被定义。由于“定义”和“引用”是相对而言的,“变量是否被定义”和“变量是否被引用”这两个状态需要对应于一个特定的场景。这两个状态是根据本发明设置的标志位,可以由布尔值表示。在一个实施例中,可以规定如下的适应不用场景的这两个标志的判断方式。According to an embodiment of the present disclosure, it is possible to determine whether the variable is defined according to the operations included in the union. Since "definition" and "reference" are relative terms, the two states of "whether the variable is defined" and "whether the variable is referenced" need to correspond to a specific scenario. These two states are flag bits set according to the present invention and can be represented by Boolean values. In an embodiment, the following judgment methods for these two flags adapted to different scenarios may be specified.
表1Table 1
Figure PCTCN2020121830-appb-000001
Figure PCTCN2020121830-appb-000001
表1中的操作指的是变量表中的变量的操作。例如,对于C语言的程序代码,如果变量x在变量表的操作中包含了“访问”,则标志位变量被引用为“真”;此时如果变量x在变量表的操作中缺少了“声明”、“定义”和“赋值”中的任一个,则说明该变量未准备好(以下称为未定义),那么标志位“变量被定义”为“假”。在“变量被定义”为假且“变量被引用”为真的情况下,确定了该变量x涉及未定义引用。The operations in Table 1 refer to the operations of variables in the variable table. For example, for the C language program code, if the variable x contains "access" in the operation of the variable table, the flag bit variable is quoted as "true"; at this time, if the variable x is missing "declaration" in the operation of the variable table Any one of "", "definition" and "assignment" means that the variable is not ready (hereinafter referred to as undefined), then the flag bit "variable is defined" is "false". In the case where "variable is defined" is false and "variable is referenced" is true, it is determined that the variable x involves an undefined reference.
在步骤240中假定匹配到与第一变量符号表示同一变量的至少一个第二变量符号。 在根据本公开的另一个实施例中,当确定不存在第二变量符号时,根据与第一变量符号相关的操作,确定第一变量符号是否涉及未定义引用。在此情况下,第一变量符号是首个识别的表示第一变量的变量符号,之前没有识别出表示第一变量的其他变量符号。例如,图7中的变量符号“US Revenue”702就属于这种情况,因为在该变量符号之前仅识别了id为1的变量符号“Revenue”。此时,变量表中的变量“US Revenue”703的操作与变量符号表中的变量符号“US Revenue”702的操作相同,都是访问(access)。而从以上的表1中可知,在SMALL语言的情况下,由于变量“US Revenue”703的操作不包括定义,却包括访问,所以标志位“变量被定义”为假且标志位“变量被引用”为真,从而确定了新识别的变量符号“US Revenue”702涉及未定义引用。In step 240, it is assumed that at least one second variable symbol that represents the same variable as the first variable symbol is matched. In another embodiment according to the present disclosure, when it is determined that there is no second variable symbol, it is determined whether the first variable symbol involves an undefined reference according to an operation related to the first variable symbol. In this case, the first variable symbol is the first variable symbol identified to represent the first variable, and other variable symbols representing the first variable have not been identified before. For example, the variable symbol "US Revenue" 702 in FIG. 7 belongs to this case, because only the variable symbol "Revenue" with an id of 1 is recognized before the variable symbol. At this time, the operation of the variable "US Revenue" 703 in the variable table is the same as the operation of the variable symbol "US Revenue" 702 in the variable symbol table, both of which are access. As can be seen from Table 1 above, in the case of SMALL language, since the operation of the variable "US Revenue" 703 does not include definition but includes access, the flag bit "variable is defined" is false and the flag bit "variable is referenced" "Is true, thereby confirming that the newly recognized variable symbol "US Revenue" 702 involves an undefined reference.
根据本公开的一个实施例,在建立变量符号表和变量表之间的关系时,对于变量符号表中的每个变量符号,存储其表示的变量表中的变量;对于变量表中的每个变量,存储能表示它的变量符号表中的变量符号。在一个实现中,如果一个变量符号A指代的变量为空,则在变量表中建立一个空变量B,并建立变量符号A和空变量B之间的关系。例如,在变量符号表中的变量符号A的条目的“变量符号表示的变量”字段中存储变量B在变量表中的位置或ID,并且在变量表中的变量B的条目的“表示该变量的变量符号”字段中存储变量符号A在变量符号表中的位置或ID。例如,在C语言的程序代码中,如果没有声明“x”而直接输入“x=1”,则“x”这一变量符号就指向变量表中的一个类型为空的变量。图8示出了根据本公开的一个实施例的建立变量符号表和变量表之间的关系的示例。如图8所示,在SMALL语言中,如果之前没有构建“US Revenue”这一行,而直接输入“Revenue={US Revenue}+{China Revenue}”,则“US Revenue”这一变量符号也指向变量表中的一个类型为空的变量。在根据本公开的一个实施例中,空变量的特征是,该变量在变量表中的类型为空,其他所有属性与正常变量相同。According to an embodiment of the present disclosure, when the relationship between the variable symbol table and the variable table is established, for each variable symbol in the variable symbol table, the variable in the variable table represented by it is stored; for each variable symbol in the variable table Variables store the variable symbols in the variable symbol table that can represent it. In an implementation, if the variable referred to by a variable symbol A is empty, an empty variable B is established in the variable table, and the relationship between the variable symbol A and the empty variable B is established. For example, the position or ID of variable B in the variable table is stored in the "variable symbol represented by variable symbol" field of the entry of variable symbol A in the variable symbol table, and the entry of variable B in the variable table indicates the variable The "variable symbol" field stores the position or ID of the variable symbol A in the variable symbol table. For example, in the program code of C language, if "x" is not declared and "x=1" is directly input, then the variable symbol "x" points to an empty variable in the variable table. FIG. 8 shows an example of establishing a relationship between a variable symbol table and a variable table according to an embodiment of the present disclosure. As shown in Figure 8, in the SMALL language, if the line "US Revenue" is not constructed before, and "Revenue={US Revenue}+{China Revenue}" is directly entered, the variable symbol "US Revenue" also points to An empty variable in the variable table. In an embodiment according to the present disclosure, the characteristic of an empty variable is that the type of the variable in the variable table is empty, and all other attributes are the same as normal variables.
返回参照图2,在步骤250中,响应于确定第一变量符号涉及未定义引用,向用户提供可视辅助来处理该未定义引用。Referring back to FIG. 2, in step 250, in response to determining that the first variable symbol relates to an undefined reference, visual assistance is provided to the user to process the undefined reference.
根据本公开的一个实施例,向用户提供可视辅助包括以下的一者或多者:在文本编辑器或图形用户界面编辑器中,在第一变量符号的附近显示提示框、或者突出显示第一变量符号。当用户输入的被引用的变量符号在变量表中对应的变量的状态为“未定义引用”(即,“变量被定义”标志位为假且“变量被引用”标志位为真)时,系统向用户进行提示。在不同的实现中,系统可以有不同的提示方式。在一个实现中,当输入光标离开当前输入行,而该输入行的内容中的某被引用变量未被定义时,系统在该变量附近弹出提 示框提示用户该变量涉及未定义引用。该提示框可以在一定时间内自动消失。提示框消失后,涉及未定义引用的变量符号的名称可以以特殊方式显示,例如,该变量符号名称的颜色、字体、大小、背景中的至少一项与正常变量的名称不同,以此区分正常变量符号与涉及未定义引用的变量符号。图11示出了根据本公开的一个实施例的提供可视辅助的示例。如图11所示,例如用户在某行输入了“int x=aa+b*2;”1102,然后输入光标移动至下一行,而变量符号“aa”在变量表中对应的变量尚未被定义。此时系统在变量符号“aa”右上角弹出提示框,提示“未定义”1101。例如在三秒后该提示框消失,变量符号的名称“aa”的背景颜色变为了浅灰色1103,区别于正常变量符号。According to an embodiment of the present disclosure, providing visual assistance to the user includes one or more of the following: in a text editor or a graphical user interface editor, displaying a prompt box near the first variable symbol, or highlighting the first variable symbol A variable symbol. When the state of the variable corresponding to the referenced variable symbol input by the user in the variable table is "undefined reference" (that is, the "variable is defined" flag is false and the "variable is referenced" flag is true), the system Prompt the user. In different implementations, the system can have different prompts. In one implementation, when the input cursor leaves the current input line and a referenced variable in the content of the input line is not defined, the system pops up a prompt box near the variable to prompt the user that the variable involves an undefined reference. The prompt box can disappear automatically within a certain period of time. After the prompt box disappears, the name of the variable symbol involved in the undefined reference can be displayed in a special way. For example, at least one of the color, font, size, and background of the variable symbol name is different from the name of the normal variable to distinguish normal Variable symbols and variable symbols involving undefined references. FIG. 11 shows an example of providing visual assistance according to an embodiment of the present disclosure. As shown in Figure 11, for example, the user enters "int x=aa+b*2;" 1102 in a certain line, and then the cursor moves to the next line, and the variable symbol "aa" in the variable table has not yet been defined. . At this time, the system pops up a prompt box in the upper right corner of the variable symbol "aa", prompting "undefined" 1101. For example, the prompt box disappears after three seconds, and the background color of the name "aa" of the variable symbol changes to light gray 1103, which is different from the normal variable symbol.
根据本公开,用户输入的程序代码被顺序的识别,所以图2所示的方法被循环地执行从而顺序地识别程序代码中的各个变量标识符。According to the present disclosure, the program code input by the user is sequentially recognized, so the method shown in FIG. 2 is executed cyclically to sequentially recognize each variable identifier in the program code.
根据本公开的一个实施例,在确定第一变量符号涉及未定义引用之后,图2中的方法可以进一步包括从所接收的字符流中继续识别第三变量符号并且存储与第三变量符号相关的信息,其中第三变量符号表示第一变量。以图7为例进行说明,例如,在识别了涉及未定义引用的变量符号“US Revenue”702之后,用户继续输入了“US Revenue=$567,890”704,其中“US Revenue”702对应于第一变量符号,“US Revenue”704对应于第三变量符号。According to an embodiment of the present disclosure, after determining that the first variable symbol relates to an undefined reference, the method in FIG. 2 may further include continuing to identify the third variable symbol from the received character stream and storing information related to the third variable symbol Information, where the third variable symbol represents the first variable. Take Figure 7 as an example for illustration. For example, after identifying the variable symbol "US Revenue" 702 that involves an undefined reference, the user continues to input "US Revenue=$567,890" 704, where "US Revenue" 702 corresponds to the first variable The symbol, "US Revenue" 704 corresponds to the third variable symbol.
该方法还包括把第三变量符号与从所述程序代码中先前识别的至少一个变量符号进行匹配以确定所述至少一个变量符号中是否存在表示第一变量的变量符号。该匹配过程包括把第三变量符号与先前识别的各变量符号进行匹配以确定是否有表示同一变量的先前识别的变量符号,这与对第一变量符号进行匹配的过程相同,例如可以是严格匹配、规则匹配、或者模糊匹配。The method also includes matching a third variable symbol with at least one variable symbol previously identified from the program code to determine whether there is a variable symbol representing the first variable in the at least one variable symbol. The matching process includes matching the third variable symbol with each previously identified variable symbol to determine whether there is a previously identified variable symbol representing the same variable. This is the same as the process of matching the first variable symbol, for example, it may be a strict match. , Rule matching, or fuzzy matching.
根据本公开的一个实施例,在进行模糊匹配时,无论是用第一变量符号来匹配第二变量符号的过程,还是用第三变量符号来匹配第一变量的过程,当提示用户确认两个变量符号是否表示同一变量时,如果用户确认表示同一变量时,则在变量符号表中把新识别的变量符号表示的变量存储为与所匹配的变量符号表示的相同的变量。根据本公开的另一个实施例,当用户确认表示同一变量时,将这两个变量符号的名称和命名空间改成相同。According to an embodiment of the present disclosure, when performing fuzzy matching, whether it is the process of matching the second variable symbol with the first variable symbol, or the process of matching the first variable symbol with the third variable symbol, when the user is prompted to confirm the two When the variable symbol represents the same variable, if the user confirms that it represents the same variable, the variable represented by the newly recognized variable symbol is stored in the variable symbol table as the same variable represented by the matched variable symbol. According to another embodiment of the present disclosure, when the user confirms that the same variable is represented, the names and namespaces of the two variable symbols are changed to be the same.
该方法还包括通过所述匹配至少找到与第三变量符号均表示第一变量的第一变量符号。以图7为例进行说明,例如,通过上述的匹配找到了与变量符号“US Revenue”704对应的变量符号“US Revenue”702。此时,更新变量表中的条目703以把其类型从“null” 修改为“row”并且把该条目703的操作707修改为所匹配的两个变量符号702和704的操作的并集。The method further includes finding at least a first variable symbol that both represents the first variable with the third variable symbol through the matching. Taking FIG. 7 as an example for description, for example, the variable symbol "US Revenue" 702 corresponding to the variable symbol "US Revenue" 704 is found through the above-mentioned matching. At this time, the entry 703 in the variable table is updated to modify its type from "null" to "row" and the operation 707 of this entry 703 is modified to the union of the operations of the two matched variable symbols 702 and 704.
该方法还包括在确定与第一变量符号相关的操作依赖于与第三变量符号相关的操作的情况下,至少利用与第三变量符号相关的操作来执行与第一变量符号相关的操作。从表1中可以得到,与第一变量符号相关的操作依赖于与第三变量符号相关的操作包括以下的至少一者:对第一变量符号的访问依赖于对第三变量符号的定义,对第一变量符号的访问依赖于对第三变量符号的声明、定义或赋值、对第一变量符号的赋值依赖于对第三变量符号的声明或定义、以及对第一变量符号的析构依赖于对第三变量符号的声明或定义。根据本公开的一个实施例,由于第三变量符号的识别导致了第三变量符号所表示的变量的状态“变量被定义”从假变为真,从而该变量不再涉及未定义引用。所以可以基于此来确定与第一变量符号相关的操作依赖于与第三变量符号相关的操作。以图7为例进行说明,例如,由于在后输入的“US Revenue=$567,890”给出了变量“US Revenue”的定义,所以变量“US Revenue”不再涉及未定义引用。图21示出了根据本公开的一个实施例的利用在后的定义来执行在先的访问的示例。如图21所示,在输入行“Product Sales={iPhone Sales}+{iPad Sales}+{Mac Sales}”时,由于等式右侧的变量符号“iPhone Sales”、“iPad Sales”、“Mac Sales”都未被定义,所以它们都涉及未定义引用。在继续输入了三个行“iPhone Sales=$23,456”、“iPad Sales=$23,456”、“Mac Sales=$23,456”后,完成了对这三个变量符号表示的变量的定义。这里,变量的在后的定义操作被利用以执行在前的访问操作,从而使得“Product Sales”可以通过这些访问操作而取得值“$70,368”(参见图21中右侧的表格)。The method further includes performing the operation related to the first variable symbol using at least the operation related to the third variable symbol in a case where it is determined that the operation related to the first variable symbol depends on the operation related to the third variable symbol. It can be obtained from Table 1 that the operations related to the first variable symbol depend on the operations related to the third variable symbol including at least one of the following: access to the first variable symbol depends on the definition of the third variable symbol, The access of the first variable symbol depends on the declaration, definition or assignment of the third variable symbol, the assignment of the first variable symbol depends on the declaration or definition of the third variable symbol, and the destruction of the first variable symbol depends on The declaration or definition of the third variable symbol. According to an embodiment of the present disclosure, the recognition of the third variable symbol causes the state of the variable represented by the third variable symbol to change from false to true, so that the variable no longer involves undefined references. Therefore, it can be determined based on this that the operation related to the first variable symbol depends on the operation related to the third variable symbol. Take Figure 7 as an example for illustration. For example, since the "US Revenue=$567,890" input later gives the definition of the variable "US Revenue", the variable "US Revenue" no longer involves undefined references. FIG. 21 shows an example of performing a prior access using a subsequent definition according to an embodiment of the present disclosure. As shown in Figure 21, when the input line "Product Sales={iPhoneSales}+{iPadSales}+{Mac Sales}", due to the variable symbols "iPhone Sales", "iPad Sales", "Mac Sales" on the right side of the equation Sales" are not defined, so they all involve undefined references. After continuing to input the three lines "iPhoneSales=$23,456", "iPadSales=$23,456", and "MacSales=$23,456", the definition of the variables represented by the three variable symbols is completed. Here, the subsequent definition operation of the variable is used to perform the previous access operation, so that "Product Sales" can obtain the value "$70,368" through these access operations (see the table on the right in Figure 21).
根据本公开的一个实施例,变量符号表中变量符号表示的变量可以根据新变量符号的匹配而被更新。图9示出了根据本公开的实施例的更新变量符号表和变量表的示例。如图9所示,如果变量符号表中的变量符号“c”902成功匹配至变量符号“c”901,并且变量符号“c”902指向变量表中的变量“c”904,变量符号“c”901指向变量表中的一个空变量“c”903,则可以将变量表中的空变量“c”903删除,并且使变量符号表中的变量符号“c”901指向变量表中的变量“c”904,并且使变量表中的变量“c”904指向变量符号表中的变量符号“c”901。根据本公开的另一个实施例,变量符号表的变量符号“c”902是新输入的变量符号,当它成功匹配至变量符号“c”901后,可以直接使变量符号“c”902指向变量表中的空变量“c”903并且使空变量“c”903指向变量符号“c”902,此外,将空变量“c”903的类型从“null”修改为“int”。此实施例不需要建立或删除任何空变量。According to an embodiment of the present disclosure, the variable represented by the variable symbol in the variable symbol table can be updated according to the matching of the new variable symbol. FIG. 9 shows an example of updating the variable symbol table and the variable table according to an embodiment of the present disclosure. As shown in Figure 9, if the variable symbol "c" 902 in the variable symbol table is successfully matched to the variable symbol "c" 901, and the variable symbol "c" 902 points to the variable "c" 904 in the variable table, the variable symbol "c" "901 points to an empty variable "c" 903 in the variable table, you can delete the empty variable "c" 903 in the variable table, and make the variable symbol "c" 901 in the variable symbol table point to the variable " c" 904, and make the variable "c" 904 in the variable table point to the variable symbol "c" 901 in the variable symbol table. According to another embodiment of the present disclosure, the variable symbol "c" 902 of the variable symbol table is a newly input variable symbol. When it is successfully matched to the variable symbol "c" 901, the variable symbol "c" 902 can be directly made to point to the variable The empty variable "c" 903 in the table and the empty variable "c" 903 point to the variable symbol "c" 902, in addition, the type of the empty variable "c" 903 is modified from "null" to "int". This embodiment does not need to create or delete any empty variables.
根据本公开的一个实施例,对于Python和C++等对执行顺序有强要求的语言,处理未定义引用包括生成第二程序代码,第二程序代码相对于原程序代码调整了包含表示第一变量的一个或多个变量符号的语句在程序代码中的位置,以使得调整后的第二程序代码中对变量的操作顺序符合程序设计语言所要求的顺序。根据该实施例,在确定第一变量符号涉及未定义引用之后,图2中的方法可以进一步包括从所接收的字符流中继续识别第三变量符号并且存储与第三变量符号相关的信息,其中第三变量符号表示第一变量。该方法还包括把第三变量符号与从所述程序代码中先前识别的至少一个变量符号进行匹配从而确定所述至少一个变量符号中是否存在表示第一变量的变量符号。以上步骤与上文所述的对应步骤的执行是相同的。该方法还包括通过所述匹配至少找到与第三变量符号均表示第一变量的第一变量符号,以及响应于确定与第一变量符号相关的操作依赖于与第三变量符号相关的操作,调整包含第一变量符号的语句和包含第三变量符号的语句中的至少一个语句在所述程序代码中的位置以消除所述未定义引用。以下面的C语言的程序代码A为例进行说明。According to an embodiment of the present disclosure, for languages such as Python and C++ that have strong requirements on the order of execution, processing undefined references includes generating a second program code, and the second program code is adjusted relative to the original program code to include the first variable The position of one or more variable symbol statements in the program code is such that the sequence of operations on the variables in the adjusted second program code conforms to the sequence required by the programming language. According to this embodiment, after determining that the first variable symbol relates to an undefined reference, the method in FIG. 2 may further include continuing to identify the third variable symbol from the received character stream and storing information related to the third variable symbol, wherein The third variable symbol represents the first variable. The method further includes matching a third variable symbol with at least one variable symbol previously identified from the program code to determine whether there is a variable symbol representing the first variable in the at least one variable symbol. The execution of the above steps is the same as the corresponding steps described above. The method further includes finding at least the first variable symbol that represents the first variable with the third variable symbol through the matching, and in response to determining that the operation related to the first variable symbol depends on the operation related to the third variable symbol, adjusting The position of at least one of the statement containing the first variable symbol and the statement containing the third variable symbol in the program code is to eliminate the undefined reference. The following C language program code A is taken as an example for description.
int a;int a;
a=1;a=1;
c++;c++;
int b=a+c;int b=a+c;
int c=0;int c=0;
c=2;c=2;
对于上述的原程序代码A,根据本公开的方法,首先会确定“c++”中的“c”和“int b=a+c”中的“c”(第一变量符号)涉及未定义引用,然后会确定“int c=2”中的“c”以及“c=2”中的“c”(第三变量符号)与上述的涉及未定义引用的变量符号匹配,在此情况下,可以利用与第三变量符号相关的操作“声明、定义、赋值”来执行与第一变量符号相关的操作“c++”和“int b=a+c”,即“访问”。For the above-mentioned original program code A, according to the method of the present disclosure, it is first determined that the "c" in "c++" and the "c" (first variable symbol) in "int b=a+c" involve undefined references, Then it will be determined that the "c" in "int c=2" and the "c" (the third variable symbol) in "c=2" match the above-mentioned variable symbols involving undefined references. In this case, you can use The operations "declaration, definition, assignment" related to the third variable symbol execute the operations "c++" and "int b=a+c" related to the first variable symbol, that is, "access".
此时,需要将包含表示第一变量的变量符号的语句“c++”、“int b=a+c”、“int c=0”、“c=2”在程序代码中的位置进行调整,以生成如下的第二程序代码B或C:At this time, it is necessary to adjust the positions of the statements "c++", "int b=a+c", "int c=0", and "c=2" in the program code that contain the variable symbol representing the first variable to Generate the following second program code B or C:
表2Table 2
Figure PCTCN2020121830-appb-000002
Figure PCTCN2020121830-appb-000002
Figure PCTCN2020121830-appb-000003
Figure PCTCN2020121830-appb-000003
根据本公开的一个实施例,所述经调整后的程序代码能够被编译执行或者被解释执行。如上面的例子所示,经调整后的两种程序代码B和C中对变量c的操作顺序都符合C语言所要求的顺序,从而可以被编译并执行。根据本公开的一个实施例,所述经调整后的程序代码中的语句与所述程序代码中的语句存在一一对应的关系。此外,还可以通过图形用户界面向用户显示经调整后的程序代码。在一个实施例中,在图形用户界面上,可以同时显示第一程序代码和第二程序代码。图25示出了根据本公开的一个实施例的向用户显示经调整后的程序代码的示例。如图25所示,原程序代码2701经调整后生成第二程序代码2702,第二程序代码2702中的每一行与原程序代码2701中内容相同的行一一对应。例如,第二程序代码2701中的“int c=0;”行2704对应于原程序代码2701中“int c=0;”行2703。According to an embodiment of the present disclosure, the adjusted program code can be compiled and executed or interpreted and executed. As shown in the above example, the sequence of operations on the variable c in the two adjusted program codes B and C conforms to the sequence required by the C language, so that they can be compiled and executed. According to an embodiment of the present disclosure, there is a one-to-one correspondence between the statements in the adjusted program code and the statements in the program code. In addition, the adjusted program code can also be displayed to the user through a graphical user interface. In one embodiment, on the graphical user interface, the first program code and the second program code can be displayed at the same time. FIG. 25 shows an example of displaying the adjusted program code to the user according to an embodiment of the present disclosure. As shown in FIG. 25, the original program code 2701 is adjusted to generate a second program code 2702, and each line in the second program code 2702 corresponds to a line with the same content in the original program code 2701 in a one-to-one correspondence. For example, the “int c=0;” row 2704 in the second program code 2701 corresponds to the “int c=0;” row 2703 in the original program code 2701.
根据本公开的一个实施例,当用户选择原程序代码中的一个语句时,第二程序代码中的相应的语句被高亮显示;并且当用户选择第二程序代码中的一个语句时,原程序代码中的相应的语句被高亮显示。图26示出了根据本公开的一个实施例的源程序代码与经调整后的程序代码的对应关系的示例。如图26所示,当用户点击第二程序代码中的“int c=0;”行2802时,原程序代码中相应的”int c=0;”行2801被高亮显示。According to an embodiment of the present disclosure, when the user selects a statement in the original program code, the corresponding statement in the second program code is highlighted; and when the user selects a statement in the second program code, the original program The corresponding statement in the code is highlighted. FIG. 26 shows an example of the correspondence between source program codes and adjusted program codes according to an embodiment of the present disclosure. As shown in Figure 26, when the user clicks the "int c=0;" line 2802 in the second program code, the corresponding "int c=0;" line 2801 in the original program code is highlighted.
根据本公开的一个实施例,所述调整是按照预定义的规则或者根据机器学习模型的预测结果而自动执行的。在按照预定义的规则调整程序代码行的位置的实施例中,例如可以将包含对变量的声明的操作的语句(例如“int c=0”)调整至所有包含表示该变量的变量符号的语句之前,即,调整到“c=2;”、“c++;”、“int b=a+c;”的前一行。在根据机器学习模型的预测结果来调整程序代码行的位置的实施例中,可以构建预测未定义引用在第二程序代码中的位置的机器学习模型。例如,该机器学习模型可以是一个循环神经网络,该循环神经网络按照顺序输入原程序代码的每一行语句,提取每一行语句中的变量符号、变量符号表示的变量、对该变量符号进行的操作、变量符号对应的位置、该 语句在程序代码中的位置、该语句是否包含未定义引用等特征,根据这些特征预测原程序代码中的每一行语句在第二程序代码中的位置,并根据机器学习模型的预测结果生成第二程序代码。例如,在上面的例子中,由于“int c=0;”语句在声明变量的同时对变量进行了定义与赋值,根据机器学习的结果,此时紧接着出现对这个变量重新赋值的操作“c=2”的概率要小于访问这个变量的操作“c++”的概率。基于该预测,应生成上述的程序代码C。According to an embodiment of the present disclosure, the adjustment is automatically performed according to a predefined rule or according to a prediction result of a machine learning model. In the embodiment of adjusting the position of the program code line according to the predefined rules, for example, the statement containing the operation of the declaration of the variable (for example, "int c=0") can be adjusted to all the statements containing the variable symbol representing the variable Before, that is, adjust to the previous line of "c=2;", "c++;", and "int b=a+c;". In the embodiment in which the position of the program code line is adjusted according to the prediction result of the machine learning model, a machine learning model that predicts the position of the undefined reference in the second program code can be constructed. For example, the machine learning model can be a recurrent neural network, which inputs each line of the original program code in order, extracts the variable symbol in each line of the sentence, the variable represented by the variable symbol, and the operation performed on the variable symbol , The location of the variable symbol, the location of the statement in the program code, whether the statement contains undefined references and other features, based on these features, predict the location of each line of the original program code in the second program code, and according to the machine The prediction result of the learning model generates a second program code. For example, in the above example, since the statement "int c=0;" defines and assigns the variable while declaring the variable, according to the results of machine learning, the operation of reassigning the variable "c" The probability of ="2" is smaller than the probability of the operation "c++" that accesses this variable. Based on this prediction, the above-mentioned program code C should be generated.
根据本公开的一个实施例,所显示的经调整后的程序代码中的语句的顺序能够被用户手动地调整。如果用户对于系统自动对程序语句的顺序的调整不满意,那么用户可以在交互界面上手动地更改存在未定义引用的语句在第二程序代码中的位置。具体而言,在图形用户界面中可以同时显示原程序代码和第二程序代码,并将原程序代码中包含涉及未定义引用的变量符号的语句高亮显示,用户可以在第二程序代码中手动地调整这些高亮显示的语句的位置。According to an embodiment of the present disclosure, the sequence of the displayed statements in the adjusted program code can be manually adjusted by the user. If the user is not satisfied with the automatic adjustment of the sequence of program statements by the system, the user can manually change the position in the second program code of the statements with undefined references on the interactive interface. Specifically, the original program code and the second program code can be displayed at the same time in the graphical user interface, and the original program code contains the statements that involve undefined reference variable symbols, and the user can manually Adjust the position of these highlighted sentences.
根据本公开的一个实施例,在用户手动地调整所述经调整后的程序代码中的语句的顺序时选中了一语句时,向用户提示该语句可以被移动至的程序代码中的至少一个位置。图27示出了根据本公开的一个实施例的用户手动调整程序语句的顺序的示例。如图27所示,假定图27的右上角为系统自动生成的第二程序代码B,但是用户对该调整结果不满意。此时,用户选择程序语句“c=2”2902,则“c=2”在原程序代码中对应的语句2901被高亮显示。根据本公开的一个实施例,当用户选择了第二程序代码中的一程序语句时,向用户提示该程序语句可以被移动至的可能位置。例如,在图27中,当选择了第二程序代码中的“c=2”2902时,其可以被移动至的多个位置2903被显示。此时,用户可以拖拽语句“c=0”将其手动调整至目标位置2904。从而,系统自动生成的程序代码B,被用户手动地调整为程序代码C。According to an embodiment of the present disclosure, when a sentence is selected when the user manually adjusts the sequence of the sentences in the adjusted program code, the user is prompted to at least one position in the program code to which the sentence can be moved . FIG. 27 shows an example in which a user manually adjusts the order of program statements according to an embodiment of the present disclosure. As shown in Fig. 27, suppose that the upper right corner of Fig. 27 is the second program code B automatically generated by the system, but the user is not satisfied with the adjustment result. At this time, the user selects the program sentence "c=2" 2902, and the sentence 2901 corresponding to "c=2" in the original program code is highlighted. According to an embodiment of the present disclosure, when the user selects a program statement in the second program code, the user is prompted to a possible position to which the program statement can be moved. For example, in FIG. 27, when "c=2" 2902 in the second program code is selected, multiple positions 2903 to which it can be moved are displayed. At this time, the user can drag the sentence "c=0" to manually adjust it to the target position 2904. Therefore, the program code B automatically generated by the system is manually adjusted to the program code C by the user.
根据本公开的一个实施例,当存在与新识别的变量符号的名称之间的相似度高于阈值的多个在先的变量符号时,按照相似度的降序在列表中向用户显示所述多个在先的变量符号。该过程对于把第一变量符号与第二变量符号进行模糊匹配以及把第三变量符号与第一变量符号进行模糊匹配而言是相同的。如上所述,如果在匹配变量符号时采用模糊匹配,需要给用户以提示。例如,当将“Revenue”和“Sales”进行匹配时,需要向用户展示提示框。在一些实现中,当有多个模糊匹配的备选项时,可以显示提示框供用户选择。此时,可以建立一个临时表,把与一个变量符号的相似度(例如,名称的相似度)较高的多个变量符号至该临时表中。在一些实现中,可以设定一个相似度的阈值,当变 量符号的名称之间的相似度超过该阈值时,将匹配的变量符号添加至该临时表。系统对临时表中的所有变量符号排序,排序的一种方式是依据相似度,由高至低进行排序。然后,将该有序临时表的部分或全部变量符号展示给用户。例如,在一个应用场景中,与变量符号“Revenue”相似度较高的变量符号有“Total Revenue”,“Revenue per User”,“revenue”,“Revenue”,“Sales”,“Cost of Revenue”,该临时表中排序后的结果是“Revenue”,“Total Revenue”,“revenue”,“Revenue per User”,“Sales”,“Cost of Revenue”。如果选择只将排序后的临时表中的一部分展示给用户,则展示的部分可以是“Revenue”,“Total Revenue”,“revenue”。According to an embodiment of the present disclosure, when there are multiple previous variable symbols whose similarity with the name of the newly recognized variable symbol is higher than a threshold, the multiple symbols are displayed to the user in the list in descending order of similarity. A preceding variable symbol. This process is the same for fuzzy matching of the first variable symbol with the second variable symbol and fuzzy matching of the third variable symbol with the first variable symbol. As mentioned above, if fuzzy matching is used when matching variable symbols, the user needs to be prompted. For example, when matching "Revenue" and "Sales", a prompt box needs to be shown to the user. In some implementations, when there are multiple fuzzy matching options, a prompt box may be displayed for the user to select. At this time, a temporary table can be created, and multiple variable symbols with a high degree of similarity (for example, similarity of names) to a variable symbol are added to the temporary table. In some implementations, a similarity threshold can be set, and when the similarity between the names of the variable symbols exceeds the threshold, the matched variable symbols are added to the temporary table. The system sorts all variable symbols in the temporary table. One way of sorting is to sort from high to low based on similarity. Then, some or all of the variable symbols of the ordered temporary table are shown to the user. For example, in an application scenario, the variable symbols that are highly similar to the variable symbol "Revenue" are "Total Revenue", "Revenue per User", "revenue", "Revenue", "Sales", "Cost of Revenue" , The sorted results in this temporary table are "Revenue", "Total Revenue", "revenue", "Revenue per User", "Sales", and "Cost of Revenue". If you choose to display only a part of the sorted temporary table to the user, the displayed part can be "Revenue", "Total Revenue", and "revenue".
在一些实现中,用户可以手动确认或修改变量符号匹配结果。对于模糊匹配的变量符号,用户可以在模糊匹配结果的提示框中选定一个模糊匹配结果,确认与当前输入的变量符号匹配。图15示出了根据本公开的一个实施例的用户选择模糊匹配结果的示例。如图15所示,例如,用户输入了变量“Revenue”,展示的模糊匹配结果1501中的变量符号包括“Total Revenue”,“revenue”,“Revenue per User”,“Sales”,“Cost of Revenue”。用户可移动光标1502,并按“Enter”键选择一个变量符号,也可使用鼠标1504点击提示框中的变量符号1503。当用户选择了变量符号“revenue”1503后,系统将“revenue”与当前输入的变量符号“Revenue”匹配。In some implementations, the user can manually confirm or modify the variable symbol matching result. For fuzzy matching variable symbols, the user can select a fuzzy matching result in the prompt box of the fuzzy matching result to confirm that it matches the currently entered variable symbol. FIG. 15 shows an example in which a user selects a fuzzy matching result according to an embodiment of the present disclosure. As shown in Figure 15, for example, if the user enters the variable "Revenue", the variable symbols in the displayed fuzzy matching result 1501 include "Total Revenue", "revenue", "Revenue per User", "Sales", "Cost of Revenue" ". The user can move the cursor 1502 and press the "Enter" key to select a variable symbol, or use the mouse 1504 to click the variable symbol 1503 in the prompt box. When the user selects the variable symbol "revenue" 1503, the system will match "revenue" with the currently input variable symbol "Revenue".
根据本公开的一个实施例,响应于用户选择了列表中的所述多个匹配的变量符号中的一个,所述程序代码中的当前输入的变量符号的名称被修改为所选择的匹配的变量符号的名称。根据本公开的另一个实施例,响应于用户选择了列表中的所述多个匹配的变量符号中的一个,确认当前输入的变量符号与所选择的变量符号表示同一变量,并且提示用户统一当前输入的变量符号与所选择的变量符号的名称。在一些实现中,系统会提示用户修改变量符号的名称使得能够严格匹配。图16示出了根据本公开的一个实施例的根据匹配结果来改变变量符号的名称的示例。例如,在图16中,如果用户选择了提示框中的变量符号“revenue”1603,“revenue”中的“r”被高亮显示1602。当前输入的变量符号“Revenue”中的“R”也被高亮显示1601。此时,如果用户按下“Tab”键,则当前输入的变量符号被修改为“revenue”1604;而如果用户按下“Shift+Tab”键,则所选择的变量符号“revenue”会被修改为当前输入的变量符号“Revenue”1605。According to an embodiment of the present disclosure, in response to the user selecting one of the plurality of matching variable symbols in the list, the name of the currently input variable symbol in the program code is modified to the selected matching variable The name of the symbol. According to another embodiment of the present disclosure, in response to the user selecting one of the plurality of matching variable symbols in the list, it is confirmed that the currently input variable symbol and the selected variable symbol represent the same variable, and the user is prompted to unify the current The input variable symbol and the name of the selected variable symbol. In some implementations, the system will prompt the user to modify the name of the variable symbol so that it can be strictly matched. FIG. 16 shows an example of changing the name of a variable symbol according to a matching result according to an embodiment of the present disclosure. For example, in Figure 16, if the user selects the variable symbol "revenue" 1603 in the prompt box, the "r" in "revenue" is highlighted 1602. The "R" in the currently entered variable symbol "Revenue" is also highlighted 1601. At this time, if the user presses the "Tab" key, the currently entered variable symbol is modified to "revenue" 1604; and if the user presses the "Shift+Tab" key, the selected variable symbol "revenue" will be modified This is the variable symbol "Revenue" 1605 currently entered.
当用户输入的变量符号与变量表中的其他变量符号匹配成功时,系统对用户进行提示。根据匹配方式不同,系统提示方式不同。根据本公开的一个实施例,当确定当前输入的变量符号与先前识别的变量符号表示同一变量时,向用户进行提示。当匹配结果 是严格匹配的结果时,系统自动将这两个变量符号指向变量表中的同一个变量,并提示用户系统已自动匹配这两个变量符号。图12示出了根据本公开的一个实施例的严格匹配的提示示例。如图12所示,例如当前输入的程序代码为“int x=aa+b*2;”1202中的变量符号“aa”和之前输入的“int aa=3;”中的变量符号“aa”严格匹配时,系统自动将变量符号表中的这两个变量符号指向变量表中的同一个变量。然后,在当前输入的变量符号“aa”附近弹出提示框,提示框中的内容为“匹配int aa=3;”1201。消息框中的“aa”可以被高亮显示,例如在三秒后消息框可以淡出消失。当进行基于规则的匹配时,系统仍然可以自动将这两个变量符号指向变量表中的同一个变量,并提示用户系统已自动依据规则匹配了这两个变量符号。图13示出了根据本公开的一个实施例的基于规则的匹配的提示示例。如图13所示,例如,在SMALL语言中,如果在第32行“Revenue”行中输入公式“={US Revenue}+{China Revenue}”1301,但是同一命名空间中建立过两个名为“US Revenue”的行(上述三个变量符号分别称为第32行的“US Revenue[1]”、第18行的“US Revenue[2]”、第6行的“US Revenue[3]”),则判断“US Revenue[2]”和“US Revenue[3]”代表的行中的哪一个距离“US Revenue[1]”1302这一行更近。将最近的行与“US Revenue[1]”匹配。例如,当“US Revenue[2]”与“US Revenue[1]”距离更近时,将这两个变量符号指向变量表中同一个变量。然后,在变量符号“US Revenue[1]”附近弹出提示框,提示框中的内容可以为“匹配US Revenue,第18行”1303,例如在三秒后消息框可以淡出消失。When the variable symbol entered by the user matches other variable symbols in the variable table successfully, the system prompts the user. Depending on the matching method, the system prompts differently. According to an embodiment of the present disclosure, when it is determined that the currently input variable symbol and the previously recognized variable symbol represent the same variable, the user is prompted. When the matching result is a strict match, the system automatically points these two variable symbols to the same variable in the variable table, and prompts the user that the system has automatically matched the two variable symbols. Fig. 12 shows an example of a strict matching prompt according to an embodiment of the present disclosure. As shown in Figure 12, for example, the currently entered program code is "int x=aa+b*2;" the variable symbol "aa" in 1202 and the variable symbol "aa" in the previously entered "int aa=3;" When strictly matching, the system automatically points the two variable symbols in the variable symbol table to the same variable in the variable table. Then, a prompt box pops up near the currently entered variable symbol "aa", and the content in the prompt box is "match int aa=3;" 1201. The "aa" in the message box can be highlighted, for example, the message box can fade out and disappear after three seconds. When performing rule-based matching, the system can still automatically point these two variable symbols to the same variable in the variable table, and prompt the user that the system has automatically matched the two variable symbols according to the rules. FIG. 13 shows an example of a prompt for rule-based matching according to an embodiment of the present disclosure. As shown in Figure 13, for example, in the SMALL language, if you enter the formula "={US Revenue}+{China Revenue}" 1301 in the "Revenue" line on line 32, but two names have been created in the same namespace The line of "US Revenue" (the above three variable symbols are respectively called "US Revenue[1]" on line 32, "US Revenue[2]" on line 18, and "US Revenue[3]" on line 6 ), then determine which of the rows represented by "US Revenue[2]" and "US Revenue[3]" is closer to the row "US Revenue[1]" 1302. Match the most recent row with "US Revenue[1]". For example, when "US Revenue[2]" and "US Revenue[1]" are closer, point these two variable symbols to the same variable in the variable table. Then, a prompt box pops up near the variable symbol "US Revenue[1]", the content of the prompt box can be "Match US Revenue, line 18" 1303, for example, the message box can fade out and disappear after three seconds.
当进行模糊匹配时,系统不会自动将匹配的两个变量符号指向变量表中的同一个变量,而是将模糊匹配的结果向用户提示,提醒用户当前输入的变量符号可能与变量符号表中的一些项匹配。图14示出了根据本公开的一个实施例的模糊匹配的提示示例。如图14所示,例如在SMALL语言中,用户输入的变量符号“Revenue”的模糊匹配结果包括变量符号“Total Revenue”,“revenue”,“Revenue per User”,“Sales”,“Cost of Revenue”。系统在变量符号“Revenue”的下方弹出展示框1401,将模糊匹配的结果展示在提示框内。光标可在提示框中的变量符号之间移动,当光标移动到一个变量符号上时,该变量符号以特定方式显示1402,以区别于其他变量符号。When performing fuzzy matching, the system will not automatically point the two matched variable symbols to the same variable in the variable table, but will prompt the user with the result of the fuzzy matching, reminding the user that the variable symbol currently entered may be in the variable symbol table. Some of the items match. Fig. 14 shows a hint example of fuzzy matching according to an embodiment of the present disclosure. As shown in Figure 14, for example, in the SMALL language, the fuzzy matching result of the variable symbol "Revenue" input by the user includes the variable symbols "Total Revenue", "revenue", "Revenue per User", "Sales", "Cost of Revenue" ". The system pops up a display box 1401 below the variable symbol "Revenue", and displays the result of fuzzy matching in the prompt box. The cursor can move between the variable symbols in the prompt box. When the cursor moves to a variable symbol, the variable symbol is displayed 1402 in a specific way to distinguish it from other variable symbols.
根据本公开的一个实施例,向用户提供可视辅助可以包括在图形用户界面上展示一列表,该列表向用户展示所述程序代码中涉及未定义引用的所有变量符号并且包括第一变量符号。可以在图形用户界面中向用户提供可视化的变量符号表和变量表中的一些关键信息,从而使用户了解这些关键信息的动态变化过程。未定义引用变量是变量表中状态为“未定义引用”的变量。可以将与未定义引用变量对应的变量符号展示在图形用户 界面中的称为“未定义引用表”的表格中。当变量符号表和变量表变化时,图形用户界面中展示的未定义引用表也相应变化。在一些实现中,“未定义引用”有多种类型。例如在C++中,有“未声明变量赋值”、“未初始化变量访问”等,不同类型的未定义变量可以用不同的格式显示。例如,当相继输入“a=1;”、“int c;”和“int b=d+c;”时,系统判断“a=1;”中的变量符号“a”为“未声明变量赋值”,“int b=d+c;”中变量符号“d”为“未声明变量访问”,变量符号“c”为“未初始化变量访问”。在未定义引用表中这三类未定义引用可以以不同的方式显示。图17示出了根据本公开的一个实施例的未定义引用表的示例。如图17所示,在未定义引用表1701中,“未声明变量赋值”以浅灰色展示1702,“未声明变量访问”以白色展示1703,“未初始化变量访问”以深灰色展示1704。According to an embodiment of the present disclosure, providing visual assistance to the user may include displaying a list on a graphical user interface, the list showing the user all variable symbols related to undefined references in the program code and including the first variable symbol. The graphical user interface can provide the user with a visual variable symbol table and some key information in the variable table, so that the user can understand the dynamic change process of these key information. An undefined reference variable is a variable whose status is "undefined reference" in the variable table. The variable symbol corresponding to the undefined reference variable can be displayed in a table called "undefined reference table" in the graphical user interface. When the variable symbol table and the variable table change, the undefined reference table displayed in the graphical user interface also changes accordingly. In some implementations, there are multiple types of "undefined references". For example, in C++, there are "undeclared variable assignment", "uninitialized variable access", etc., and different types of undefined variables can be displayed in different formats. For example, when successively inputting "a=1;", "int c;" and "int b=d+c;", the system judges that the variable symbol "a" in "a=1;" is "undeclared variable assignment" ", "int b=d+c;" in the variable symbol "d" is "undeclared variable access", and the variable symbol "c" is "uninitialized variable access". These three types of undefined references can be displayed in different ways in the undefined reference table. FIG. 17 shows an example of an undefined reference table according to an embodiment of the present disclosure. As shown in FIG. 17, in the undefined reference table 1701, "undeclared variable assignment" is displayed 1702 in light gray, "undeclared variable access" is displayed 1703 in white, and "uninitialized variable access" is displayed 1704 in dark gray.
在本发明的一些实现中,未定义引用表可以隐藏于编辑器边缘,当鼠标移至编辑器边缘时才展示未定义引用表。用户也可以按下按键使得未定义引用表始终展示。图18示出了根据本公开的一个实施例的未定义引用表的显示示例。如图18所示,未定义引用表1801中展示的内容为涉及未定义引用的变量符号和其输入位置。当鼠标或光标移动至未定义引用表中的变量符号“Cash”所在的区域1802时,该变量符号所在的区域被高亮显示。当点击或选取未定义引用表中的变量符号“Cash”1802时,输入区域中的编辑光标会跳至该变量符号被输入的位置1803,并且该变量符号在输入区域中会以特定的方式显示,以区别于其他变量符号。当输入内容涉及未定义引用变量时,未定义引用表会弹出,系统将该被引用的未定义变量符号和其位置等信息添加至未定义引用表。添加完毕后未定义引用表可以自动隐藏。图19示出了根据本公开的一个实施例的未定义引用表的显示示例。根据本公开的一个实施例,响应于通过所述匹配确定第三变量符号与第一变量符号都表示第一变量,在图形用户界面上的包括涉及未定义引用的所述变量符号的列表上中突出显示匹配成功的第一变量符号。如图19所示,当输入内容中再次引用该未定义变量符号时,例如当输入“int x=aa”1904后又输入“int y=aa+c;”1905,并且“aa”未被定义时,在第二次输入“aa”时,会弹出未定义引用表1901。之前输入的变量符号“aa”1902(对应于代码1904)被高亮显示,提示与之后输入的变量符号“aa”1903(对应于代码1905)匹配。In some implementations of the present invention, the undefined reference table can be hidden at the edge of the editor, and the undefined reference table is displayed when the mouse moves to the edge of the editor. The user can also press the button to make the undefined reference list always displayed. FIG. 18 shows a display example of an undefined reference table according to an embodiment of the present disclosure. As shown in FIG. 18, the content shown in the undefined reference table 1801 is the variable symbol and its input location related to the undefined reference. When the mouse or cursor moves to the area 1802 where the variable symbol "Cash" in the undefined reference table is located, the area where the variable symbol is located is highlighted. When you click or select the variable symbol "Cash" 1802 in the undefined reference table, the edit cursor in the input area will jump to the position 1803 where the variable symbol is entered, and the variable symbol will be displayed in a specific way in the input area , To distinguish it from other variable symbols. When the input content involves an undefined reference variable, the undefined reference list will pop up, and the system will add the referenced undefined variable symbol and its location to the undefined reference list. After adding, the undefined reference table can be automatically hidden. FIG. 19 shows a display example of an undefined reference table according to an embodiment of the present disclosure. According to an embodiment of the present disclosure, in response to determining through the matching that both the third variable symbol and the first variable symbol represent the first variable, in the graphical user interface a list including the variable symbol involving an undefined reference Highlight the first variable symbol that matches successfully. As shown in Figure 19, when the undefined variable symbol is quoted again in the input content, for example, when "int x=aa" 1904 is input and then "int y=aa+c;" 1905 is input, and "aa" is not defined When entering "aa" for the second time, the undefined reference list 1901 will pop up. The previously entered variable symbol "aa" 1902 (corresponding to code 1904) is highlighted, prompting to match the variable symbol "aa" 1903 (corresponding to code 1905) entered later.
根据本公开的一个实施例,响应于从变量表中检测到第一变量符号表示的第一变量变为被定义,从展示所述程序代码中涉及未定义引用的所有变量符号的列表中删除第一变量符号。也就是说,当展示的未定义引用变量之后被定义时,系统将该变量符号从图形用户界面的未定义引用表中删除。当输入内容中的变量符号包括定义操作且被严格 匹配至在先的涉及未定义引用的变量符号时,未定义引用表弹出。系统将该涉及未定义引用的变量符号(此时已定义)从未定义引用表中删除。图20示出了根据本公开的一个实施例的从未定义引用表删除已定义变量符号的示例。如图20所示,当输入“int aa=3;”2003后,此处的变量符号“aa”与之前涉及未定义引用的两个变量符号“aa”严格匹配,系统弹出未定义引用表2001并将表中的相关“aa”变量符号高亮显示2002,提示与之匹配。然后,系统将未定义引用表中的两个“aa”变量符号都删除2004。According to an embodiment of the present disclosure, in response to detecting from the variable table that the first variable represented by the first variable symbol becomes defined, the first variable is deleted from the list showing all variable symbols involved in undefined references in the program code. A variable symbol. In other words, when the displayed undefined reference variable is defined later, the system deletes the variable symbol from the undefined reference list of the graphical user interface. When the variable symbol in the input content includes the definition operation and is strictly matched to the previous variable symbol involving undefined reference, the undefined reference list pops up. The system deletes the variable symbol (which is defined at this time) involving undefined reference from the undefined reference table. FIG. 20 shows an example of deleting a defined variable symbol from an undefined reference table according to an embodiment of the present disclosure. As shown in Figure 20, after entering "int aa=3;" 2003, the variable symbol "aa" here strictly matches the two variable symbols "aa" involved in undefined references, and the system pops up the undefined reference table 2001 And the relevant "aa" variable symbol in the table is highlighted 2002, prompting it to match. Then, the system deletes 2004 both of the two "aa" variable symbols in the undefined reference table.
根据本公开的一个实施例,向用户提供可视辅助可以包括在图形用户界面上显示所述变量表和变量符号表以及它们之间的关系。变量符号表和变量表中的变量符号和变量以及它们的相关信息可以在图形用户界面中展示,并且用户可以通过图形用户界面与上述两个表进行交互。图22示出了根据本公开的一个实施例的变量符号表和变量表的显示示例。图22中显示是输入的程序代码与变量符号表、变量表、以及这两个表之间的关系。According to an embodiment of the present disclosure, providing visual assistance to the user may include displaying the variable table and the variable symbol table and the relationship between them on a graphical user interface. The variable symbols and variables in the variable symbol table and the variable table and their related information can be displayed in the graphical user interface, and the user can interact with the above two tables through the graphical user interface. FIG. 22 shows a display example of a variable symbol table and a variable table according to an embodiment of the present disclosure. Shown in Figure 22 is the input program code and the relationship between the variable symbol table, the variable table, and these two tables.
根据本公开的一个实施例,向用户提供可视辅助可以包括在图形用户界面上显示所述程序代码中的已经匹配成功的所有变量符号,并且所显示的已经匹配成功的变量符号能够被用户修改其匹配关系。对于严格匹配和基于规则的匹配,系统允许用户修改自动匹配的结果,将当前输入的变量符号匹配至其他变量符号。例如,如果在第32行“Revenue”行中输入公式“={US Revenue}+{China Revenue}”,但是同一命名空间中建立过两个名为“US Revenue”的行(上述三个变量符号分别称为第32行的“US Revenue[1]”、第18行的“US Revenue[2]”、第6行的“US Revenue[3]”)。系统按照基于规则的匹配自动将第32行的“US Revenue[1]”与第18行的“US Revenue[2]”指向变量表中同一个变量。用户可手动将“US Revenue[1]”匹配的变量符号修改为第6行的“US Revenue[3]”。系统可以将变量符号“US Revenue[1]”指向变量表中“US Revenue[3]”指向的同一个变量,而取消原来“US Revenue[1]”指向的变量表中US Revenue[2]”指向的变量。According to an embodiment of the present disclosure, providing visual assistance to the user may include displaying all the successfully matched variable symbols in the program code on a graphical user interface, and the displayed variable symbols that have been successfully matched can be modified by the user Its matching relationship. For strict matching and rule-based matching, the system allows users to modify the results of automatic matching, and match the currently entered variable symbol to other variable symbols. For example, if you enter the formula "={USRevenue}+{ChinaRevenue}" in the "Revenue" line on line 32, but two lines named "USRevenue" have been created in the same namespace (the above three variable symbols They are called "US Revenue[1]" on line 32, "US Revenue[2]" on line 18, and "US Revenue[3]" on line 6). The system automatically points "US Revenue[1]" on line 32 and "US Revenue[2]" on line 18 to the same variable in the variable table according to rule-based matching. The user can manually modify the variable symbol matched by "US Revenue[1]" to "US Revenue[3]" on the 6th line. The system can point the variable symbol "USRevenue[1]" to the same variable pointed to by "USRevenue[3]" in the variable table, and cancel USRevenue[2]" in the variable table pointed to by "USRevenue[1]" The variable pointed to.
根据本公开的一个实施例,向用户提供可视辅助可以包括在图形用户界面上显示所述变量符号表,并且响应于用户选择了变量符号表中的变量符号,程序代码中的对应变量符号被突出显示。图23示出了根据本公开的一个实施例的变量符号表的显示示例。如图23所示,展示变量符号表的图形用户界面2301展示了所有变量符号的名称和位置等信息。当使用鼠标或其他选择方式选择了图形用户界面中变量符号表中的某一个变量符号2302时,可直接跳至程序代码中该变量符号被输入的行,并将变量符号表中的对应变量符号条目以特殊方式显示2302(例如使用不同的背景色)。同时,输入区域中该变量 符号所在的区域也可以以特殊方式显示2304。According to an embodiment of the present disclosure, providing visual assistance to the user may include displaying the variable symbol table on a graphical user interface, and in response to the user selecting a variable symbol in the variable symbol table, the corresponding variable symbol in the program code is highlight. FIG. 23 shows a display example of a variable symbol table according to an embodiment of the present disclosure. As shown in Fig. 23, the graphical user interface 2301 displaying the variable symbol table displays information such as the names and positions of all variable symbols. When using the mouse or other selection methods to select a variable symbol 2302 in the variable symbol table in the graphical user interface, you can directly jump to the line where the variable symbol is entered in the program code, and change the corresponding variable symbol in the variable symbol table Entries are displayed 2302 in a special way (for example, using a different background color). At the same time, the area where the variable symbol is located in the input area can also be displayed 2304 in a special way.
根据本公开的一个实施例,当用户在输入时输入了错误的变量符号名称时,系统可以为用户提供错误更正功能。当用户输入了错误的变量符号名称时,模糊匹配功能依然可以为用户匹配与输入的变量符号相似的变量符号,用户可以选择模糊匹配结果中的某一变量符号并选择更正已输入的变量符号名称。系统根据用户的选择,自动将该错误的变量符号名称更正为用户选择的变量符号的名称。图24示出了根据本公开的一个实施例的错误更正的示例。如图24所示,例如当用户输入变量符号名称“Ravenue”2401时,系统检测到用户输入中可能有错误,将“Ravenue”中的“a”高亮显示,以提示输入错误。模糊匹配返回的结果例如可以是“Revenue”,“Total Revenue”,“revenue”,“Revenue per User”,“Cost of Revenue”2402。如果用户选择了模糊匹配结果中的“Revenue”2403,则系统自动将用户输入的错误的“Ravenue”变量符号更正为用户选择的“Revenue”2404。According to an embodiment of the present disclosure, when the user inputs a wrong variable symbol name during input, the system can provide the user with an error correction function. When the user enters the wrong variable symbol name, the fuzzy matching function can still match the user with a variable symbol similar to the input variable symbol. The user can select a variable symbol in the fuzzy matching result and choose to correct the entered variable symbol name . The system automatically corrects the wrong variable symbol name to the name of the variable symbol selected by the user according to the user's selection. FIG. 24 shows an example of error correction according to an embodiment of the present disclosure. As shown in Figure 24, for example, when the user inputs the variable symbol name "Ravenue" 2401, the system detects that there may be an error in the user input, and highlights the "a" in "Ravenue" to prompt the input error. The result returned by fuzzy matching may be, for example, "Revenue", "Total Revenue", "revenue", "Revenue per User", and "Cost of Revenue" 2402. If the user selects "Revenue" 2403 in the fuzzy matching result, the system automatically corrects the wrong "Ravenue" variable symbol entered by the user to the "Revenue" 2404 selected by the user.
根据本公开的一个实施例,系统还可以提供变量命名规范,并根据变量命名规范来自动更正变量符号名称。例如在SMALL语言中,由于用该语言编写的程序多用于金融建模领域,所以使用的变量名多为会计专业词汇,而专业词汇是有行业标准的。本公开的系统和方法可按照相关的标准与规范为用户提供特定的命名规范。当用户输入的变量名不符合规范时,系统可以给出提示并推荐符合规范的变量名。如果用户选择了推荐的变量名,则系统自动将用户输入的变量名替换为选择的变量名。例如,假定某规范有如下的规则:变量名应以大写字母开头。如果用户输入了变量符号“revenue”,则系统会提示用户该变量符号不符合命名规范,并为用户推荐符合命名规范的变量符号名称,例如“Revenue”。如果用户选择了推荐的“Revenue”,则系统将原来输入的“revenue”替换为“Revenue”。According to an embodiment of the present disclosure, the system can also provide variable naming specifications, and automatically correct variable symbol names according to the variable naming specifications. For example, in the SMALL language, because the programs written in this language are mostly used in the field of financial modeling, the variable names used are mostly accounting professional vocabulary, and the professional vocabulary has industry standards. The system and method of the present disclosure can provide users with specific naming conventions in accordance with relevant standards and specifications. When the variable name entered by the user does not conform to the specification, the system can give a prompt and recommend a variable name that conforms to the specification. If the user selects the recommended variable name, the system automatically replaces the variable name entered by the user with the selected variable name. For example, suppose a specification has the following rule: variable names should start with a capital letter. If the user enters the variable symbol "revenue", the system will prompt the user that the variable symbol does not conform to the naming convention, and recommend a variable symbol name that conforms to the naming convention, such as "Revenue". If the user selects the recommended "Revenue", the system replaces the previously entered "revenue" with "Revenue".
根据本公开的一个实施例,根据用户的选择,系统在用户输入的时候不进行实时的变量符号匹配,而在用户完成输入时再批量匹配变量符号。这种方式也适用于对用户输入包括从存储设备加载全部或部分程序作为用户输入的情况。用户可以批量修改匹配结果。例如,在SMALL语言中,用户可将已输入的程序保存到硬盘等存储设备中,并且可以之后从存储设备加载被保存的程序。当程序被加载时,系统批量匹配程序中所有的变量符号,将符合严格匹配和基于规则的匹配的变量符号自动识别,并令它们指向变量表中的同一变量。系统将模糊匹配的结果提示给用户,辅助用户手动确认是否表示同一变量。According to an embodiment of the present disclosure, according to the user's selection, the system does not perform real-time variable symbol matching when the user is inputting, and then batches matching variable symbols when the user completes the input. This method is also suitable for user input including loading all or part of the program from the storage device as user input. Users can modify the matching results in batches. For example, in the SMALL language, the user can save the entered program to a storage device such as a hard disk, and can later load the saved program from the storage device. When the program is loaded, the system batches match all variable symbols in the program, automatically recognize the variable symbols that meet strict matching and rule-based matching, and make them point to the same variable in the variable table. The system prompts the user with the result of the fuzzy matching, and assists the user to manually confirm whether it represents the same variable.
根据本发明的一个实施例的方法还包括解析或执行所述程序代码的一部分,该部 分不包括包含涉及未定义引用的程序语句。本公开的实施例支持将未定义引用对程序的影响限定在一定范围内,使得可以对包含有未定义引用的程序进行部分解析,并且使得不受未定义引用影响的程序部分能够被正常处理。例如,在SMALL语言中,如果一个行的公式中包含未定义引用(例如,未定义访问),则在生成的电子表格中只是该行的公式为空从而值为空,但不影响该行在电子表格中的绘制以及该行的格式,也不影响电子表格中的其余行。图21示出了根据本公开的一个实施例的部分执行程序代码的示例。如图21所示,由于在变量“Revenue”定义的行中2101引用了未定义的变量“China Revenue”2102,从而在生成的电子表格中2103,除了变量“Revenue”所在行2104和China Revenue”所在的行2105的值为空之外,其余所有变量所在的行都可以被正常解析和绘制。The method according to an embodiment of the present invention further includes parsing or executing a part of the program code, which does not include program statements that involve undefined references. The embodiments of the present disclosure support limiting the influence of undefined references on programs within a certain range, so that partial analysis of programs containing undefined references can be performed, and parts of programs not affected by undefined references can be processed normally. For example, in the SMALL language, if a row’s formula contains undefined references (for example, undefined access), in the generated spreadsheet, only the row’s formula is empty and the value is empty, but it does not affect the row’s The drawing in the spreadsheet and the format of the row do not affect the remaining rows in the spreadsheet. FIG. 21 shows an example of a partially executed program code according to an embodiment of the present disclosure. As shown in Figure 21, because 2101 refers to the undefined variable "China Revenue" 2102 in the row defined by the variable "Revenue", so in the generated spreadsheet 2103, except for the variable "Revenue" row 2104 and China Revenue" Except that the value of the row 2105 is empty, the rows of all other variables can be parsed and drawn normally.
本发明可以解决传统技术的不能引用未定义的变量的问题。使用本发明的方法和系统引用未定义的变量对于用户高效且方便。高效的原因在于,本发明可以自动记录用户引用的未定义的变量符号,并在用户该变量符号在之后的声明或定义出现后自动匹配该新声明或定义的变量符号和其对应涉及未定义引用的变量符号。方便的原因在于本发明为用户提供了各种输入辅助、未定义引用提示和变量匹配提式等功能。此外,采用本发明,可以在程序代码的一部分涉及未定义引用的情况下,解释执行程序代码的不涉及未定义引用的其余部分。此外,采用本发明,在程序代码中出现未定义引用的情况下,可以提示用户调整代码中的语句的顺序以使其符合编译规则从而可以成功地被编译执行。The present invention can solve the problem that undefined variables cannot be referenced in the traditional technology. Using the method and system of the present invention to reference undefined variables is efficient and convenient for users. The reason for the efficiency is that the present invention can automatically record the undefined variable symbols referenced by the user, and automatically match the newly declared or defined variable symbols and their corresponding undefined references after the user's subsequent declarations or definitions of the variable symbols appear. Variable symbol. The reason for the convenience is that the present invention provides users with various input aids, undefined citation prompts, variable matching prompts, and other functions. In addition, with the present invention, when a part of the program code involves an undefined reference, the rest of the program code that does not involve an undefined reference can be interpreted and executed. In addition, with the present invention, in the case of undefined references in the program code, the user can be prompted to adjust the order of the statements in the code to make it conform to the compilation rules and thus can be successfully compiled and executed.
本发明可以是系统、方法和/或计算机程序产品。计算机程序产品可以包括计算机可读存储介质,其上载有用于使处理器实现本发明的各个方面的计算机可读程序指令。The present invention may be a system, a method and/or a computer program product. The computer program product may include a computer-readable storage medium loaded with computer-readable program instructions for enabling a processor to implement various aspects of the present invention.
根据本公开的一个实施例,提供了一种计算机系统。该计算机系统包括一个或多个处理器以及耦接到所述一个或多个处理器的存储器。所述存储器存储有计算机指令,所述计算机指令当由所述一个或多个处理器执行时使所述一个或多个处理器执行以上任意实施例中的方法的操作。According to an embodiment of the present disclosure, a computer system is provided. The computer system includes one or more processors and a memory coupled to the one or more processors. The memory stores computer instructions that, when executed by the one or more processors, cause the one or more processors to perform operations of the method in any of the above embodiments.
根据本公开的一个实施例,提供了一种计算机可读存储介质。计算机可读存储介质存储有计算机指令,所述计算机指令当由处理器运行时使所述处理器执行以上任意实施例中的方法。According to an embodiment of the present disclosure, a computer-readable storage medium is provided. The computer-readable storage medium stores computer instructions that, when executed by a processor, cause the processor to perform the method in any of the above embodiments.
计算机可读存储介质可以是可以保持和存储由指令执行设备使用的指令的有形设备。计算机可读存储介质例如可以是――但不限于――电存储设备、磁存储设备、光存储设备、电磁存储设备、半导体存储设备或者上述的任意合适的组合。计算机可读存储介质 的更具体的例子(非穷举的列表)包括:便携式计算机盘、硬盘、随机存取存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、静态随机存取存储器(SRAM)、便携式压缩盘只读存储器(CD-ROM)、数字多功能盘(DVD)、记忆棒、软盘、机械编码设备、例如其上存储有指令的打孔卡或凹槽内凸起结构、以及上述的任意合适的组合。The computer-readable storage medium may be a tangible device that can hold and store instructions used by the instruction execution device. The computer-readable storage medium may be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples (non-exhaustive list) of computer-readable storage media include: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM) Or flash memory), static random access memory (SRAM), portable compact disk read-only memory (CD-ROM), digital versatile disk (DVD), memory stick, floppy disk, mechanical encoding device, such as a printer with instructions stored thereon The protruding structure in the hole card or the groove, and any suitable combination of the above.
这里所描述的计算机可读程序指令可以从计算机可读存储介质下载到各个计算/处理设备,或者通过网络、例如因特网、局域网、广域网和/或无线网下载到外部计算机或外部存储设备。网络可以包括铜传输电缆、光纤传输、无线传输、路由器、防火墙、交换机、网关计算机和/或边缘服务器。每个计算/处理设备中的网络适配卡或者网络接口从网络接收计算机可读程序指令,并转发该计算机可读程序指令,以供存储在各个计算/处理设备中的计算机可读存储介质中。The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to various computing/processing devices, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and/or a wireless network. The network may include copper transmission cables, optical fiber transmission, wireless transmission, routers, firewalls, switches, gateway computers, and/or edge servers. The network adapter card or network interface in each computing/processing device receives computer-readable program instructions from the network, and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing/processing device .
用于执行本发明操作的计算机程序指令可以是汇编指令、指令集架构(ISA)指令、机器指令、机器相关指令、微代码、固件指令、状态设置数据、或者以一种或多种编程语言的任意组合编写的源代码或目标代码,所述编程语言包括面向对象的编程语言—诸如Smalltalk、C++等,以及常规的过程式编程语言—诸如“C”语言或类似的编程语言。计算机可读程序指令可以完全地在用户计算机上执行、部分地在用户计算机上执行、作为一个独立的软件包执行、部分在用户计算机上部分在远程计算机上执行、或者完全在远程计算机或服务器上执行。在涉及远程计算机的情形中,远程计算机可以通过任意种类的网络—包括局域网(LAN)或广域网(WAN)—连接到用户计算机,或者,可以连接到外部计算机(例如利用因特网服务提供商来通过因特网连接)。在一些实施例中,通过利用计算机可读程序指令的状态信息来个性化定制电子电路,例如可编程逻辑电路、现场可编程门阵列(FPGA)或可编程逻辑阵列(PLA),该电子电路可以执行计算机可读程序指令,从而实现本发明的各个方面。The computer program instructions used to perform the operations of the present invention may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, status setting data, or in one or more programming languages. Source code or object code written in any combination, the programming language includes object-oriented programming languages such as Smalltalk, C++, etc., and conventional procedural programming languages such as "C" language or similar programming languages. Computer-readable program instructions can be executed entirely on the user's computer, partly on the user's computer, executed as a stand-alone software package, partly on the user's computer and partly executed on a remote computer, or entirely on the remote computer or server carried out. In the case of a remote computer, the remote computer can be connected to the user's computer through any kind of network-including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (for example, using an Internet service provider to connect to the user's computer) connection). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), can be customized by using the status information of the computer-readable program instructions. The computer-readable program instructions are executed to implement various aspects of the present invention.
这里参照根据本发明实施例的方法、装置(系统)和计算机程序产品的流程图和/或框图描述了本发明的各个方面。应当理解,流程图和/或框图的每个方框以及流程图和/或框图中各方框的组合,都可以由计算机可读程序指令实现。Here, various aspects of the present invention are described with reference to flowcharts and/or block diagrams of methods, devices (systems) and computer program products according to embodiments of the present invention. It should be understood that each block of the flowcharts and/or block diagrams, and combinations of blocks in the flowcharts and/or block diagrams, can be implemented by computer-readable program instructions.
这些计算机可读程序指令可以提供给通用计算机、专用计算机或其它可编程数据处理装置的处理器,从而生产出一种机器,使得这些指令在通过计算机或其它可编程数据处理装置的处理器执行时,产生了实现流程图和/或框图中的一个或多个方框中规定的功能/动作的装置。These computer-readable program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine that makes these instructions when executed by the processor of the computer or other programmable data processing device , A device that implements the functions/actions specified in one or more blocks in the flowcharts and/or block diagrams is produced.
以上已经描述了本发明的各实施例,上述说明是示例性的,并非穷尽性的,并且也不限于所披露的各实施例。在不偏离所说明的各实施例的范围和精神的情况下,对于本技术领域的普通技术人员来说许多修改和变更都是显而易见的。本文中所用术语的选择,旨在最好地解释各实施例的原理、实际应用或对市场中的技术的技术改进,或者使本技术领域的其它普通技术人员能理解本文披露的各实施例。The embodiments of the present invention have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Without departing from the scope and spirit of the illustrated embodiments, many modifications and changes are obvious to those of ordinary skill in the art. The choice of terms used herein is intended to best explain the principles, practical applications, or technical improvements of the technologies in the market, or to enable other ordinary skilled in the art to understand the embodiments disclosed herein.

Claims (58)

  1. 一种用于处理程序代码中的变量的引用的方法,包括:A method for handling references to variables in program code, including:
    顺序地接收用户输入中包含的字符流,其中所述字符流是所述程序代码的一部分;Sequentially receiving the character stream contained in the user input, wherein the character stream is a part of the program code;
    从所接收的字符流中识别第一变量符号并且存储与第一变量符号相关的信息,其中第一变量符号表示第一变量;Identifying the first variable symbol from the received character stream and storing information related to the first variable symbol, where the first variable symbol represents the first variable;
    把第一变量符号与从所述程序代码中先前识别的至少一个变量符号进行匹配以确定所述至少一个变量符号中是否存在表示第一变量的第二变量符号;Matching the first variable symbol with at least one variable symbol previously identified from the program code to determine whether there is a second variable symbol representing the first variable in the at least one variable symbol;
    响应于确定存在至少一个第二变量符号,根据与第一变量符号相关的操作以及与所述一个或多个第二变量符号相关的操作,确定第一变量符号是否涉及未定义引用;以及In response to determining that there is at least one second variable symbol, determining whether the first variable symbol involves an undefined reference according to operations related to the first variable symbol and operations related to the one or more second variable symbols; and
    响应于确定第一变量符号涉及未定义引用,向用户提供可视辅助来处理该未定义引用。In response to determining that the first variable symbol relates to an undefined reference, visual assistance is provided to the user to process the undefined reference.
  2. 根据权利要求1所述的方法,还包括:响应于确定不存在第二变量符号,根据与第一变量符号相关的操作,确定第一变量符号是否涉及未定义引用。The method according to claim 1, further comprising: in response to determining that the second variable symbol does not exist, determining whether the first variable symbol involves an undefined reference according to an operation related to the first variable symbol.
  3. 根据权利要求1所述的方法,还包括:The method according to claim 1, further comprising:
    从所接收的字符流中继续识别第三变量符号并且存储与第三变量符号相关的信息,其中第三变量符号表示第一变量;Continue to identify the third variable symbol from the received character stream and store information related to the third variable symbol, where the third variable symbol represents the first variable;
    把第三变量符号与从所述程序代码中先前识别的至少一个变量符号进行匹配以确定所述至少一个变量符号中是否存在表示第一变量的变量符号;Matching the third variable symbol with at least one variable symbol previously identified from the program code to determine whether there is a variable symbol representing the first variable in the at least one variable symbol;
    通过所述匹配至少找到与第三变量符号均表示第一变量的第一变量符号;以及At least find the first variable symbol that represents the first variable with the third variable symbol through the matching; and
    在确定与第一变量符号相关的操作依赖于与第三变量符号相关的操作的情况下,至少利用与第三变量符号相关的操作来执行与第一变量符号相关的操作。In the case where it is determined that the operation related to the first variable symbol depends on the operation related to the third variable symbol, at least the operation related to the third variable symbol is used to perform the operation related to the first variable symbol.
  4. 根据权利要求1所述的方法,还包括解析或执行所述程序代码的一部分,该部分不包括包含第一变量符号的程序语句。The method according to claim 1, further comprising parsing or executing a part of the program code that does not include the program statement including the first variable symbol.
  5. 根据权利要求1所述的方法,其中,所述用户输入包括以下输入中的一者:用户编辑完成并存储的程序代码的至少一部分,由文本编辑器监听的用户输入动作产生的程序代码的至少一部分,以及通过用户在图形用户界面编辑器中的操作产生 的程序代码的至少一部分。The method according to claim 1, wherein the user input comprises one of the following inputs: at least a part of the program code edited and stored by the user, and at least a part of the program code generated by the user input action monitored by a text editor A part, and at least a part of the program code generated by the user's operation in the graphical user interface editor.
  6. 根据权利要求5所述的方法,其中向用户提供可视辅助包括以下的一者或多者:在文本编辑器或图形用户界面编辑器中,在第一变量符号的附近显示提示框、或者突出显示第一变量符号。The method of claim 5, wherein providing visual assistance to the user includes one or more of the following: in a text editor or a graphical user interface editor, displaying a prompt box or highlighting near the first variable symbol The first variable symbol is displayed.
  7. 根据权利要求1所述的方法,其中从所接收的字符流中识别第一变量符号包括利用词法分析器或者机器学习分类器中的一者或多者从所接收的字符流中识别第一变量符号。The method of claim 1, wherein identifying the first variable symbol from the received character stream comprises using one or more of a lexical analyzer or a machine learning classifier to identify the first variable from the received character stream symbol.
  8. 根据权利要求1所述的方法,其中从所接收的字符流中识别第一变量符号包括把从图形用户界面编辑器的特定组件中接收的字符流识别为第一变量符号。The method of claim 1, wherein identifying the first variable symbol from the received character stream comprises recognizing the character stream received from a specific component of the graphical user interface editor as the first variable symbol.
  9. 根据权利要求1或3所述的方法,其中与变量符号相关的信息包括以下信息中的一者或多者:变量符号的名称、变量符号在程序代码中的位置、变量符号的命名空间、变量符号的作用域、变量符号表示的变量的类型、变量符号表示的变量、以及与变量符号相关的操作。The method according to claim 1 or 3, wherein the information related to the variable symbol includes one or more of the following information: the name of the variable symbol, the position of the variable symbol in the program code, the namespace of the variable symbol, the variable The scope of the symbol, the type of the variable represented by the variable symbol, the variable represented by the variable symbol, and the operations related to the variable symbol.
  10. 根据权利要求9所述的方法,其中与变量符号相关的信息被存储到变量符号表中,并且其中所述变量符号表存储有与所述程序代码中的每个识别的变量符号相关的信息。The method according to claim 9, wherein information related to variable symbols is stored in a variable symbol table, and wherein the variable symbol table stores information related to each identified variable symbol in the program code.
  11. 根据权利要求10所述的方法,还包括建立变量表以及建立变量符号表和变量表之间的关系。The method according to claim 10, further comprising establishing a variable table and establishing a relationship between the variable symbol table and the variable table.
  12. 根据权利要求11所述的方法,其中,所述变量表存储所识别的变量的状态,并且变量的状态包括以下一者或多者:表示该变量的变量符号、变量在内存中的地址、变量进行的操作、变量是否被定义、以及变量是否被引用。The method according to claim 11, wherein the variable table stores the state of the identified variable, and the state of the variable includes one or more of the following: a variable symbol representing the variable, the address of the variable in the memory, and the variable The operation performed, whether the variable is defined, and whether the variable is referenced.
  13. 根据权利要求11所述的方法,其中,建立变量符号表和变量表之间的关系包括:对于变量符号表中的每个变量符号,存储其表示的变量表中的变量;对于变量表中的每个变量,存储能表示它的变量符号表中的变量符号。The method according to claim 11, wherein establishing the relationship between the variable symbol table and the variable table comprises: for each variable symbol in the variable symbol table, storing the variable in the variable table it represents; for each variable symbol in the variable table Each variable stores the variable symbols in the variable symbol table that can represent it.
  14. 根据权利要求9所述的方法,其中,在图形用户界面编辑器环境中,变量符号在程序代码中的位置通过输入了该变量符号的组件的位置获得,变量符号的命名空间根据输入了该变量符号的组件与其它组件的结构关系或用户指定的该变量符号的路径获得,变量符号的作用域通过输入了该变量符号的组件与其它组件的结构关系获得,变量符号表示的变量的类型通过创建该变量时的组件的信息获得,与变量符号相关的操作通过用户在图形用户界面编辑器中的相应操作获得。The method according to claim 9, wherein, in a graphical user interface editor environment, the position of the variable symbol in the program code is obtained by the position of the component where the variable symbol is input, and the namespace of the variable symbol is based on the input of the variable The structural relationship between the component of the symbol and other components or the path of the variable symbol specified by the user is obtained. The scope of the variable symbol is obtained by the structural relationship between the component of the variable symbol and other components. The type of the variable represented by the variable symbol is created by creating The information of the component when the variable is obtained, and the operation related to the variable symbol is obtained through the user's corresponding operation in the graphical user interface editor.
  15. 根据权利要求9所述的方法,其中,变量符号在程序代码中的位置使用表示该变量符号在程序代码中的位置的元组来表示,并且变量符号的命名空间、变量符号的作用域、变量符号表示的变量的类型、以及与变量符号相关的操作通过对该变量符号的上下文进行语法分析而获得。The method according to claim 9, wherein the position of the variable symbol in the program code is represented by a tuple representing the position of the variable symbol in the program code, and the namespace of the variable symbol, the scope of the variable symbol, and the variable symbol The type of the variable represented by the symbol and the operations related to the variable symbol are obtained by grammatically analyzing the context of the variable symbol.
  16. 根据权利要求9所述的方法,其中,把第一变量符号与从所述程序代码中先前识别的至少一个变量符号进行匹配包括:当所存储的第一变量符号和所述至少一个变量符号中的第二变量符号的名称、命名空间、作用域、以及表示的变量的类型都相同时,确定第一变量符号和第二变量符号表示同一变量。The method according to claim 9, wherein matching the first variable symbol with at least one variable symbol previously identified from the program code comprises: when the stored first variable symbol and the at least one variable symbol When the name, namespace, scope, and type of the variable represented by the second variable symbol are all the same, it is determined that the first variable symbol and the second variable symbol represent the same variable.
  17. 根据权利要求9所述的方法,其中,把第一变量符号与从所述程序代码中先前识别的至少一个变量符号进行匹配包括:当第一变量符号和所述至少一个变量符号中的多个第二变量符号的名称相同时,根据预定义的规则确定第一变量符号和哪个第二变量符号表示同一变量。The method according to claim 9, wherein matching the first variable symbol with at least one variable symbol previously identified from the program code comprises: when the first variable symbol and a plurality of the at least one variable symbol When the names of the second variable symbols are the same, the first variable symbol and which second variable symbol represents the same variable are determined according to a predefined rule.
  18. 根据权利要求17所述方法,其中所述预定义的规则包括将第一变量符号和距离其最近的相同名称的第二变量符号匹配为表示同一变量。The method according to claim 17, wherein the predefined rule comprises matching the first variable symbol and the nearest second variable symbol of the same name to represent the same variable.
  19. 根据权利要求9所述的方法,其中,把第三变量符号与从所述程序代码中先前识别的至少一个变量符号进行匹配包括:当所存储的第三变量符号和第一变量符号的名称、命名空间、作用域、以及表示的变量的类型都相同时,确定第三变量符号和第一变量符号表示同一变量。The method according to claim 9, wherein matching the third variable symbol with at least one variable symbol previously identified from the program code comprises: when the stored third variable symbol and the name, naming of the first variable symbol When the space, scope, and types of the variables represented are the same, it is determined that the third variable symbol and the first variable symbol represent the same variable.
  20. 根据权利要求9所述的方法,其中,把第三变量符号与从所述程序代码中先前识别的至少一个变量符号进行匹配包括:当第三变量符号和所述至少一个变量符号中的多个变量符号的名称相同时,根据预定义的规则确定第三变量符号和哪个变量符号表示同一变量。The method according to claim 9, wherein matching a third variable symbol with at least one variable symbol previously identified from the program code comprises: when the third variable symbol and a plurality of the at least one variable symbol When the names of the variable symbols are the same, the third variable symbol and which variable symbol represents the same variable are determined according to predefined rules.
  21. 根据权利要求18所述方法,其中所述预定义的规则包括将第三变量符号和距离其最近的相同名称的第一变量符号匹配为表示同一变量。The method according to claim 18, wherein the predefined rule comprises matching the third variable symbol with the nearest first variable symbol of the same name to represent the same variable.
  22. 根据权利要求9所述的方法,其中,把第一变量符号与从所述程序代码中先前识别的至少一个变量符号进行匹配包括:当与第一变量符号相关的信息和与所述至少一个变量符号中的第二变量符号相关的信息之间的相似度高于阈值时,提示用户确认第一变量符号和第二变量符号是否表示同一变量。The method according to claim 9, wherein matching the first variable symbol with at least one variable symbol previously identified from the program code comprises: when the information related to the first variable symbol is related to the at least one variable symbol When the similarity between the information related to the second variable symbol in the symbol is higher than the threshold, the user is prompted to confirm whether the first variable symbol and the second variable symbol represent the same variable.
  23. 根据权利要求9所述的方法,其中,把第三变量符号与从所述程序代码中先前识别的至少一个变量符号进行匹配包括:当与第三变量符号相关的信息和与第一变 量符号相关的信息之间的相似度高于阈值时,提示用户确认第三变量符号和第一变量符号是否表示同一变量。The method of claim 9, wherein matching the third variable symbol with at least one variable symbol previously identified from the program code comprises: when the information related to the third variable symbol is related to the first variable symbol When the similarity between the information is higher than the threshold, the user is prompted to confirm whether the third variable symbol and the first variable symbol represent the same variable.
  24. 根据权利要求22或23所述的方法,其中,所述相似度可以通过以下的一者或多者得到:变量符号名称之间的编辑距离、变量符号名称之间的语义相似度、变量符号命名空间之间的相似度、变量符号作用域之间的包含关系、以及变量符号在所述程序代码中的位置之间的距离。The method according to claim 22 or 23, wherein the similarity can be obtained by one or more of the following: edit distance between variable symbol names, semantic similarity between variable symbol names, variable symbol naming The similarity between the spaces, the containment relationship between the scopes of the variable symbols, and the distance between the positions of the variable symbols in the program code.
  25. 根据权利要求22所述的方法,其中,当用户确认表示同一变量时,在变量符号表中把第一变量符号表示的变量存储为与第二变量符号表示的相同的变量。22. The method according to claim 22, wherein when the user confirms that the same variable is represented, the variable represented by the first variable symbol is stored as the same variable represented by the second variable symbol in the variable symbol table.
  26. 根据权利要求23所述的方法,其中,当用户确认表示同一变量时,在变量符号表中把第三变量符号表示的变量存储为与第一变量符号表示的相同的变量。23. The method according to claim 23, wherein when the user confirms that the same variable is represented, the variable represented by the third variable symbol is stored as the same variable represented by the first variable symbol in the variable symbol table.
  27. 根据权利要求22所述的方法,其中,当用户确认表示同一变量时,将第一变量符号和第二变量符号的名称和命名空间改成相同。The method according to claim 22, wherein when the user confirms that the same variable is represented, the name and namespace of the first variable symbol and the second variable symbol are changed to be the same.
  28. 根据权利要求23所述的方法,其中,当用户确认表示同一变量时,将第三变量符号和第一变量符号的名称和命名空间改成相同。The method according to claim 23, wherein when the user confirms that the same variable is represented, the names and namespaces of the third variable symbol and the first variable symbol are changed to be the same.
  29. 根据权利要求13所述的方法,其中,响应于与变量符号相关的信息被存储到变量符号表中,把该变量符号与先前存储的变量符号逐个进行匹配。The method of claim 13, wherein, in response to the information related to the variable symbols being stored in the variable symbol table, the variable symbols are matched with previously stored variable symbols one by one.
  30. 根据权利要求13所述的方法,其中,通过变量符号的名称的哈希值在变量符号表中建立索引,并且其中,响应于与变量符号相关的信息被存储到变量符号表中,通过所述索引把该变量符号与先前存储的变量符号进行匹配。The method according to claim 13, wherein the index is established in the variable symbol table by the hash value of the name of the variable symbol, and wherein, in response to the information related to the variable symbol being stored in the variable symbol table, the The index matches the variable symbol with the previously stored variable symbol.
  31. 根据权利要求3所述的方法,其中,与第一变量符号相关的操作、与第二变量符号相关的操作、以及与第三变量符号相关的操作中的每一个包括以下的至少一者:声明、定义、初始化、赋值、访问、以及析构。The method according to claim 3, wherein each of the operation related to the first variable symbol, the operation related to the second variable symbol, and the operation related to the third variable symbol includes at least one of the following: declaration , Definition, initialization, assignment, access, and destruction.
  32. 根据权利要求31所述的方法,其中,与第一变量符号相关的操作依赖于与第三变量符号相关的操作包括以下的至少一者:对第一变量符号的访问依赖于对第三变量符号的定义,对第一变量符号的访问依赖于对第三变量符号的声明、定义或赋值、对第一变量符号的赋值依赖于对第三变量符号的声明或定义、以及对第一变量符号的析构依赖于对第三变量符号的声明或定义。The method according to claim 31, wherein the operation related to the first variable symbol depends on the operation related to the third variable symbol comprises at least one of the following: access to the first variable symbol depends on the third variable symbol The definition of the first variable symbol depends on the declaration, definition or assignment of the third variable symbol, the assignment of the first variable symbol depends on the declaration or definition of the third variable symbol, and the access to the first variable symbol The destruction depends on the declaration or definition of the third variable symbol.
  33. 根据权利要求1所述的方法,其中所述程序代码是以编译型语言、解释型语言、或者用于构建电子表格模型的语言编写的。The method according to claim 1, wherein the program code is written in a compiled language, an interpreted language, or a language used to build a spreadsheet model.
  34. 根据权利要求22所述的方法,其中,当存在与第一变量符号的名称之间的相似度 高于阈值的多个第二变量符号时,按照相似度的降序在列表中向用户显示所述多个第二变量符号。22. The method according to claim 22, wherein when there are a plurality of second variable symbols whose similarity with the name of the first variable symbol is higher than a threshold, the user is displayed in the list in descending order of the similarity. Multiple second variable symbols.
  35. 根据权利要求34所述的方法,其中,响应于用户选择了列表中的所述多个第二变量符号中的一个,所述程序代码中的第一变量符号的名称被修改为所选择的第二变量符号的名称。The method according to claim 34, wherein, in response to the user selecting one of the plurality of second variable symbols in the list, the name of the first variable symbol in the program code is modified to the selected first variable symbol The name of the two variable symbol.
  36. 根据权利要求34所述的方法,其中,响应于用户选择了列表中的所述多个第二变量符号中的一个,确认第一变量符号与所选择的第二变量符号表示同一变量,并且提示用户统一第一变量符号与所选择的第二变量符号的名称。The method of claim 34, wherein, in response to the user selecting one of the plurality of second variable symbols in the list, confirming that the first variable symbol and the selected second variable symbol represent the same variable, and prompting The user unifies the names of the first variable symbol and the selected second variable symbol.
  37. 根据权利要求23所述的方法,其中,当存在与第三变量符号的名称之间的相似度高于阈值的包含第一变量符号的多个变量符号时,按照相似度的降序在列表中向用户显示所述多个变量符号。23. The method according to claim 23, wherein when there are a plurality of variable symbols containing the first variable symbol whose similarity with the name of the third variable symbol is higher than a threshold value, they are listed in descending order of the similarity. The user displays the plurality of variable symbols.
  38. 根据权利要求37所述的方法,其中,响应于用户选择了列表中的第一变量符号,所述程序代码中的第三变量符号的名称被修改为所选择的第一变量符号的名称,或者所述程序代码中的第一变量符号的名称被修改为第三变量符号的名称。The method of claim 37, wherein, in response to the user selecting the first variable symbol in the list, the name of the third variable symbol in the program code is modified to the name of the selected first variable symbol, or The name of the first variable symbol in the program code is modified to the name of the third variable symbol.
  39. 根据权利要求37所述的方法,其中,响应于用户选择了列表中的第一变量符号,确认第三变量符号与所选择的第一变量符号表示同一变量,并且提示用户统一第三变量符号与所选择的第一变量符号的名称。The method according to claim 37, wherein, in response to the user selecting the first variable symbol in the list, confirming that the third variable symbol and the selected first variable symbol represent the same variable, and prompting the user to unify the third variable symbol and The name of the selected first variable symbol.
  40. 根据权利要求3所述的方法,其中,向用户提供可视辅助包括在图形用户界面上展示一列表,该列表向用户展示所述程序代码中涉及未定义引用的所有变量符号并且包括第一变量符号。The method of claim 3, wherein providing visual assistance to the user includes displaying a list on the graphical user interface, the list showing the user all variable symbols in the program code that involve undefined references and include the first variable symbol.
  41. 根据权利要求40所述的方法,还包括:响应于通过所述匹配确定第三变量符号与第一变量符号都表示第一变量,在图形用户界面上的所述列表上中突出显示匹配成功的第一变量符号。40. The method according to claim 40, further comprising: in response to determining through the matching that the third variable symbol and the first variable symbol both represent the first variable, highlighting the successful matching in the list on the graphical user interface The first variable symbol.
  42. 根据权利要求11所述的方法,其中,向用户提供可视辅助包括在图形用户界面上显示所述变量表和变量符号表以及它们之间的关系。The method of claim 11, wherein providing visual assistance to the user comprises displaying the variable table and the variable symbol table and the relationship between them on a graphical user interface.
  43. 根据权利要求1所述的方法,其中,向用户提供可视辅助包括在图形用户界面上显示所述程序代码中的已经匹配成功的所有变量符号。The method according to claim 1, wherein providing visual assistance to the user comprises displaying all variable symbols in the program code that have been successfully matched on a graphical user interface.
  44. 根据权利要求43所述的方法,其中,所显示的已经匹配成功的变量符号能够被用户修改其匹配关系。The method according to claim 43, wherein the displayed variable symbols that have been successfully matched can be modified by the user.
  45. 根据权利要求16或17所述的方法,还包括:当确定第一变量符号和第二变量符 号表示同一变量时,向用户进行提示。The method according to claim 16 or 17, further comprising: prompting the user when it is determined that the first variable symbol and the second variable symbol represent the same variable.
  46. 根据权利要求19或20所述的方法,还包括:当确定第三变量符号和第一变量符号表示同一变量时,向用户进行提示。The method according to claim 19 or 20, further comprising: prompting the user when it is determined that the third variable symbol and the first variable symbol represent the same variable.
  47. 根据权利要求12所述的方法,其中,所述变量表中的一个变量进行的操作等于与表示该变量的至少一个变量符号中的每个变量符号相关的操作的并集。The method according to claim 12, wherein the operation performed by one variable in the variable table is equal to a union of operations related to each of the at least one variable symbol representing the variable.
  48. 根据权利要求47所述的方法,还包括:根据所述并集中包括的操作来判断该变量是否被定义。The method according to claim 47, further comprising: judging whether the variable is defined according to the operations included in the union.
  49. 根据权利要求48所述的方法,还包括:响应于从变量表中检测到第一变量符号表示的第一变量变为被定义,从展示所述程序代码中涉及未定义引用的所有变量符号的列表中删除第一变量符号。The method according to claim 48, further comprising: in response to detecting from the variable table that the first variable represented by the first variable symbol becomes defined, displaying all variable symbols in the program code involving undefined references Delete the first variable symbol from the list.
  50. 根据权利要求1或2所述的方法,还包括:The method according to claim 1 or 2, further comprising:
    从所接收的字符流中继续识别第三变量符号并且存储与第三变量符号相关的信息,其中第三变量符号表示第一变量;Continue to identify the third variable symbol from the received character stream and store information related to the third variable symbol, where the third variable symbol represents the first variable;
    把第三变量符号与从所述程序代码中先前识别的至少一个变量符号进行匹配从而确定所述至少一个变量符号中是否存在表示第一变量的变量符号;Matching the third variable symbol with at least one variable symbol previously identified from the program code to determine whether there is a variable symbol representing the first variable in the at least one variable symbol;
    通过所述匹配至少找到与第三变量符号均表示第一变量的第一变量符号;以及At least find the first variable symbol that represents the first variable with the third variable symbol through the matching; and
    响应于确定与第一变量符号相关的操作依赖于与第三变量符号相关的操作,调整包含第一变量符号的语句和包含第三变量符号的语句中的至少一个语句在所述程序代码中的位置以消除所述未定义引用。In response to determining that the operation related to the first variable symbol depends on the operation related to the third variable symbol, adjusting at least one of the statement containing the first variable symbol and the statement containing the third variable symbol in the program code Position to eliminate the undefined reference.
  51. 根据权利要求50所述的方法,其中,所述调整是按照预定义的规则或者根据机器学习模型的预测结果而自动执行的。The method according to claim 50, wherein the adjustment is performed automatically according to a predefined rule or according to a prediction result of a machine learning model.
  52. 根据权利要求50所述的方法,还包括显示经调整后的程序代码,其中所述经调整后的程序代码中的语句与所述程序代码中的语句存在一一对应的关系。The method according to claim 50, further comprising displaying the adjusted program code, wherein there is a one-to-one correspondence between the statements in the adjusted program code and the statements in the program code.
  53. 根据权利要求52所述的方法,其中所显示的经调整后的程序代码中的语句的顺序能够被用户手动地调整。The method according to claim 52, wherein the sequence of the displayed sentences in the adjusted program code can be manually adjusted by the user.
  54. 根据权利要求53所述的方法,其中在用户手动地调整所述经调整后的程序代码中的语句的顺序时选中了一语句时,向用户提示该语句可以被移动至的程序代码中的至少一个位置。The method according to claim 53, wherein when a sentence is selected when the user manually adjusts the sequence of the sentences in the adjusted program code, the user is prompted to at least one of the program codes to which the sentence can be moved A location.
  55. 根据权利要求52所述的方法,其中所述经调整后的程序代码能够被编译执行或者 被解释执行。The method according to claim 52, wherein the adjusted program code can be compiled and executed or interpreted and executed.
  56. 根据权利要求10所述的方法,其中,向用户提供可视辅助包括在图形用户界面上显示所述变量符号表,并且其中响应于用户选择了变量符号表中的变量符号,程序代码中的对应变量符号被突出显示。The method according to claim 10, wherein providing visual assistance to the user comprises displaying the variable symbol table on a graphical user interface, and wherein in response to the user selecting a variable symbol in the variable symbol table, the corresponding in the program code The variable symbol is highlighted.
  57. 一种计算机系统,包括:A computer system including:
    一个或多个处理器;和One or more processors; and
    耦接到所述一个或多个处理器的存储器,所述存储器存储有计算机指令,所述计算机指令当由所述一个或多个处理器执行时使所述一个或多个处理器执行根据权利要求1至56中任一项所述的方法的操作。A memory coupled to the one or more processors, the memory storing computer instructions that, when executed by the one or more processors, cause the one or more processors to execute according to the right The operation of the method described in any one of 1 to 56 is required.
  58. 一种计算机可读存储介质,存储有计算机指令,所述计算机指令当由处理器运行时使所述处理器执行根据权利要求1至56中任一项所述的方法。A computer-readable storage medium storing computer instructions that, when run by a processor, cause the processor to execute the method according to any one of claims 1 to 56.
PCT/CN2020/121830 2019-12-26 2020-10-19 Method and system for processing reference of variable in program code WO2021129074A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201911369988.8A CN111158663B (en) 2019-12-26 2019-12-26 Method and system for handling references to variables in program code
CN201911369988.8 2019-12-26

Publications (1)

Publication Number Publication Date
WO2021129074A1 true WO2021129074A1 (en) 2021-07-01

Family

ID=70558325

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/121830 WO2021129074A1 (en) 2019-12-26 2020-10-19 Method and system for processing reference of variable in program code

Country Status (2)

Country Link
CN (1) CN111158663B (en)
WO (1) WO2021129074A1 (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111158663B (en) * 2019-12-26 2021-07-02 深圳逻辑汇科技有限公司 Method and system for handling references to variables in program code
CN113031933B (en) * 2021-03-22 2024-01-09 北京达佳互联信息技术有限公司 Data processing method, device, electronic equipment, storage medium and program product
CN114896178B (en) * 2022-05-20 2022-12-02 广东天太机器人有限公司 Method, device and equipment for clearing memory and storage medium

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6167566A (en) * 1998-05-15 2000-12-26 Fujitsu Limited Variable retrieving apparatus and method and computer readable recording medium recording variable retrieving program therein
CN101599041A (en) * 2008-06-02 2009-12-09 松下电器产业株式会社 Automatically method of attaching that corrects mistakes and equipment thereof
US20100125836A1 (en) * 2008-11-20 2010-05-20 Ali Sazegari Compiling techniques for providing limited accuracy and enhanced performance granularity
CN102880468A (en) * 2012-09-12 2013-01-16 浙江大学 Code intelligent prompting method and system for electronic control unit (ECU) program development
CN103257919A (en) * 2012-02-21 2013-08-21 腾讯科技(深圳)有限公司 Inspection method and device for script programs
CN106469049A (en) * 2015-08-19 2017-03-01 腾讯科技(深圳)有限公司 A kind of method and device of file scan
CN107085533A (en) * 2017-03-27 2017-08-22 北京北大软件工程股份有限公司 A kind of analysis method and system of pointer modified influence
CN111158663A (en) * 2019-12-26 2020-05-15 深圳逻辑汇科技有限公司 Method and system for handling references to variables in program code

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140222410A1 (en) * 2012-03-22 2014-08-07 Xiao Dong Lin Hybrid emulation and kernel function processing systems and methods
CN103389895B (en) * 2012-08-30 2016-11-09 百度在线网络技术(北京)有限公司 A kind of generation method and system of front end page
EP3656392A1 (en) * 2013-06-25 2020-05-27 Vaccinex, Inc. Use of semaphorin-4d inhibitory molecules in combination with an immune modulating therapy to inhibit tumor growth and metastases
US10310827B2 (en) * 2017-04-08 2019-06-04 Oracle International Corporation Flow-based scoping
CN107516040A (en) * 2017-07-25 2017-12-26 中国人民解放军63928部队 A kind of Vulnerability Characteristics analysis and acquisition methods based on data controlling stream graph
CN108509400B (en) * 2018-02-07 2022-02-15 平安普惠企业管理有限公司 Document template generation method and device, computer equipment and storage medium
JP6891838B2 (en) * 2018-03-15 2021-06-18 オムロン株式会社 Development support equipment, development support methods, and development support programs
CN110275707A (en) * 2019-04-03 2019-09-24 杭州电子科技大学 A kind of PLC variable input method of compatible table input and text input

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6167566A (en) * 1998-05-15 2000-12-26 Fujitsu Limited Variable retrieving apparatus and method and computer readable recording medium recording variable retrieving program therein
CN101599041A (en) * 2008-06-02 2009-12-09 松下电器产业株式会社 Automatically method of attaching that corrects mistakes and equipment thereof
US20100125836A1 (en) * 2008-11-20 2010-05-20 Ali Sazegari Compiling techniques for providing limited accuracy and enhanced performance granularity
CN103257919A (en) * 2012-02-21 2013-08-21 腾讯科技(深圳)有限公司 Inspection method and device for script programs
CN102880468A (en) * 2012-09-12 2013-01-16 浙江大学 Code intelligent prompting method and system for electronic control unit (ECU) program development
CN106469049A (en) * 2015-08-19 2017-03-01 腾讯科技(深圳)有限公司 A kind of method and device of file scan
CN107085533A (en) * 2017-03-27 2017-08-22 北京北大软件工程股份有限公司 A kind of analysis method and system of pointer modified influence
CN111158663A (en) * 2019-12-26 2020-05-15 深圳逻辑汇科技有限公司 Method and system for handling references to variables in program code

Also Published As

Publication number Publication date
CN111158663A (en) 2020-05-15
CN111158663B (en) 2021-07-02

Similar Documents

Publication Publication Date Title
US10013417B2 (en) Classifying languages for objects and entities
WO2021129074A1 (en) Method and system for processing reference of variable in program code
US7634720B2 (en) System and method for providing context to an input method
JP7301922B2 (en) Semantic retrieval method, device, electronic device, storage medium and computer program
US8176003B2 (en) Automatic designation of XBRL taxonomy tags
CN1457041B (en) System for automatically annotating training data for natural language understanding system
KR100650427B1 (en) Integrated development tool for building a natural language understanding application
US10073827B2 (en) Method and system to generate a process flow diagram
US20180068221A1 (en) System and Method of Advising Human Verification of Machine-Annotated Ground Truth - High Entropy Focus
US20040111475A1 (en) Method and apparatus for selectively identifying misspelled character strings in electronic communications
US10977155B1 (en) System for providing autonomous discovery of field or navigation constraints
US11537797B2 (en) Hierarchical entity recognition and semantic modeling framework for information extraction
KR20100038378A (en) A method, system and computer program for intelligent text annotation
US20170004120A1 (en) Corrections for natural language processing
US20120158742A1 (en) Managing documents using weighted prevalence data for statements
US9460081B1 (en) Transcription correction using multi-token structures
US8315874B2 (en) Voice user interface authoring tool
CN111813409A (en) Code generation method, device, equipment and storage medium of interactive interface
CN110472234A (en) Sensitive text recognition method, device, medium and computer equipment
RU2640718C1 (en) Verification of information object attributes
US8219905B2 (en) Automatically detecting keyboard layout in order to improve the quality of spelling suggestions
JP2022538704A (en) Regular expression generation with span highlight alignment
US11036926B2 (en) Generating annotated natural language phrases
CN115510362A (en) System for automatically generating web front-end codes according to natural language description documents
CN110727428B (en) Method and device for converting service logic layer codes and electronic equipment

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20908198

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205 DATED 28/10/2022)

122 Ep: pct application non-entry in european phase

Ref document number: 20908198

Country of ref document: EP

Kind code of ref document: A1