Programming language analysis method and device, computer program

The method and device address the ambiguity in numerical programming languages by separating and converting ambiguous symbols, improving the interpreter's accuracy in processing such languages.

JP7768521B2Active Publication Date: 2025-11-12PEKING UNIV +1
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
JP2024540883
Authority / Receiving Office
JP · JP
Patent Type
Patents
Current Assignee / Owner
Priority Date
2022-01-20
Filing Date
2022-09-15
Publication Date
2025-11-12
Estimated Expiration
2042-09-15

AI Technical Summary

Technical Problem

Existing interpreters are prone to errors when processing numerical programming languages due to the ambiguity introduced by mathematical symbols, such as the single quotation mark, which can indicate either a delimiter or an operator, leading to discrepancies in syntax and abstract syntax trees.

Method used

A method and device that identify source code as a string of characters, parse it into lexical units, separate ambiguous symbols from non-ambiguous symbols, convert the ambiguous symbols, and analyze the non-ambiguous symbols using a semantic and syntactic analyzer to construct an abstract syntax tree.

Benefits of technology

Improves the interpreter's ability to accurately process numerical programming languages by resolving ambiguity, reducing errors and enhancing the accuracy of code analysis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 0007768521000001
    Figure 0007768521000001
  • Figure 0007768521000002
    Figure 0007768521000002
  • Figure 0007768521000003
    Figure 0007768521000003
Patent Text Reader

Abstract

This application discloses a method and apparatus for analyzing a programming language, and a non-volatile storage medium, which includes the steps of identifying a source code as a string, and parsing the string into a lexical unit list including a plurality of lexical units, dividing the plurality of lexical units into a first group of lexical units including a vocabulary symbol and a second group of lexical units not including a vocabulary symbol, converting the first group of lexical units into the second group of lexical units, and performing an analysis on the second group of lexical units obtained by converting the first group of lexical units and the second group of lexical units obtained by classifying the plurality of lexical units.
Need to check novelty before this filing date? Find Prior Art

Description

[Technical Field]

[0001] This application relates to the software field, specifically to a method and apparatus for analyzing a programming language, computer program Regarding. [Background technology]

[0002] FIG. 1 is a schematic diagram of the compilation and execution process of a conventional high-level programming language. As shown in FIG. 1, the compilation and execution process of a high-level language involves three types shown in FIG. 1: a) a compiled language (e.g., C language), in which a source code is compiled to generate a binary executable program that is then directly executed by a machine; b) a first-class interpreted language (e.g., Java language), in which a source code is converted by an interpreter into intermediate code (e.g., bytecode), which is then interpreted and executed in a virtual machine; and c) a second-class interpreted language (e.g., Lisp language), in which a source code is directly interpreted and executed by an interpreter.

[0003] A compiler is a program that translates a source language program (usually a high-level language) into a target language (usually a machine language represented in binary). Figure 2 shows a flowchart of the compiler's execution process. Ri, Ko The whole compilation process is as shown in Figure 2: Lexical analysis and It can be roughly divided into six steps: syntactic analysis, semantic analysis, intermediate code generation, code optimization, and target code generation.

[0004] Figure 3 is a flowchart showing the operation procedure of an interpreter. As shown in Figure 3, an interpreter is a program that interprets and executes source code. The entire interpretation process is roughly divided into four steps, including lexical analysis, syntactic analysis, semantic analysis, and intermediate code generation or direct interpretation and execution.

[0005] 1) The lexical analyzer scans the strings that make up the source program, i.e., reads the source program character by character from left to right, then identifies words (also called word symbols or symbols) based on word formation rules and reorganizes them into a list of lexical units.

[0006] 2) The parser uses the first component of each lexical unit obtained by lexical analysis to create a syntax tree, where each internal node in the tree represents an operation and its subnodes represent the components of the operation. Syntax analysis is a logical step that determines whether the structure of the source program is correct.

[0007] 3) The semantic analyzer uses the information in the syntax tree and symbol table to check whether the source program matches the semantics defined by the language, while also collecting type information and generating an abstract syntax tree. Semantic analysis is a logical step that checks context-related properties, primarily type checking, against a structurally correct source program.

[0008] Existing interpreters are sufficient for processing general programming languages ​​such as Lisp, but are insufficient for processing numerical programming languages. Numerical programming languages ​​introduce more mathematical symbols, which makes some symbols ambiguous, meaning that ambiguous code exists in source code. For example, a single quotation mark (') in source code can indicate the beginning or end of a character, or it can be used to indicate a matrix transpose. When a single quotation mark indicates the beginning or end of a character, its type is a delimiter; when a single quotation mark indicates a matrix transpose, its type is an operator. If the single quotation mark were a different type, the generated syntax tree and abstract syntax tree would be essentially different. Based on the architecture of existing interpreters, if an interpreter only treats a single quotation mark as a fixed type, errors would occur in the results.

[0009] No effective solution has been provided to the problem that mathematical symbols introduced into numerical programming languages ​​have ambiguity, making interpreters prone to errors when processing the numerical programming languages. Summary of the Invention [Problem to be solved by the invention]

[0010] The embodiments of the present application provide a programming language analysis method and device, and a non-volatile storage medium, which at least solve the technical problem that mathematical symbols introduced into a numerical calculation programming language have ambiguity, making it prone to errors when an interpreter processes the numerical calculation programming language. [Means for solving the problem]

[0011] According to one aspect of an embodiment of the present application, the method includes the steps of identifying source code as a string of characters and parsing the string into a lexical unit list including a plurality of lexical units; dividing the plurality of lexical units into first related lexical units which are lexical units including ambiguous symbols and second related lexical units which are lexical units not including ambiguous symbols; converting the first related lexical units into second related lexical units; and analyzing the second related lexical units obtained by converting the first related lexical units and the second related lexical units obtained by classifying the plurality of lexical units.

[0012] Alternatively, the step of dividing the plurality of lexical units into first related lexical units and second related lexical units includes the steps of obtaining token names of the plurality of lexical units, identifying a target token name having ambiguity from the token names, and identifying the lexical unit to which the target token name belongs as the first related lexical unit, and identifying the lexical unit to which token names other than the target token name belong as the second related lexical unit.

[0013] Alternatively, the step of converting the first related lexical unit into the second related lexical unit includes a step of inputting the first related lexical unit into a semantic analyzer for analysis to obtain the second related lexical unit, and the step of analyzing the second related lexical unit obtained by converting the first related lexical unit and the second related lexical unit obtained by classifying the multiple lexical units includes a step of inputting the second related lexical unit obtained by converting the first related lexical unit and the second related lexical unit obtained by classifying the multiple lexical units into a syntactic analyzer for analysis, and a step of inputting the analysis result of the syntactic analyzer on the second related lexical unit into the semantic analyzer for analysis.

[0014] Alternatively, the step of inputting the first related lexical unit into a semantic analyzer for analysis to obtain the second related lexical unit includes the steps of identifying a type of a token name of the first related lexical unit based on context information of the first related lexical unit, and modifying an attribute value of the first related lexical unit based on the type of the token name of the first related lexical unit to obtain the second related lexical unit.

[0015] Alternatively, the step of inputting the second related lexical unit obtained by converting the first related lexical unit and the second related lexical unit obtained by classifying the plurality of lexical units into a syntactic parser and performing analysis includes the step of assembling the second related lexical unit obtained by converting the first related lexical unit and the second related lexical unit obtained by classifying the plurality of lexical units into a syntactic parse tree.

[0016] Alternatively, the step of inputting the analysis result of the syntactic parser for the second class lexical unit to the semantic analyzer for analysis includes the step of performing a simplification process on the syntactic parse tree and constructing an abstract syntax tree.

[0017] Alternatively, parsing the string into a lexical unit list comprises parsing the string into a lexical unit list according to predetermined word construction rules, wherein each lexical unit in the lexical unit list comprises a token name and an attribute value, where the token name is the lexical unit itself and the attribute value is a type of the lexical unit.

[0018] According to another aspect of an embodiment of the present application, there is further provided an apparatus for parsing a programming language, including: a first parsing module configured to identify a source code as a string of characters and parse the string into a lexical unit list including a plurality of lexical units; a classification module configured to divide the plurality of lexical units into first related lexical units, which are lexical units including ambiguous symbols, and second related lexical units, which are lexical units not including ambiguous symbols; a conversion module configured to convert the first related lexical units into the second related lexical units; and a second parsing module configured to perform analysis on the second related lexical units obtained by converting the first related lexical units and the second related lexical units obtained by classifying the plurality of lexical units.

[0019] According to yet another aspect of an embodiment of the present application, there is further provided a non-volatile storage medium containing a program stored thereon, the program, when executed, controlling a device in which the program is located to perform the above-described method for parsing a programming language.

[0020] According to yet another aspect of an embodiment of the present application, there is further provided a processor used to execute a program stored in a memory, the processor executing the above-described method for analyzing a programming language when the program is executed.

[0021] In an embodiment of the present application, the following steps are used to classify the lexical unit list obtained as a result of the lexical analysis: identifying a source code as a string of characters and parsing the string into a lexical unit list including a plurality of lexical units; dividing the plurality of lexical units into first related lexical units, which are lexical units including ambiguous symbols, and second related lexical units, which are lexical units not including ambiguous symbols; converting the first related lexical units into second related lexical units; and analyzing the second related lexical units obtained by converting the first related lexical units and the second related lexical units obtained by classifying the plurality of lexical units. Thus, a classification process is performed on the lexical unit list obtained as a result of the lexical analysis, and ambiguous lexical units are converted into ambiguous lexical units. This achieves the objective of improving the ability of an interpreter to process ambiguous code, and achieves the technical effect of improving the accuracy with which an interpreter processes a numerical programming language. Furthermore, it solves the technical problem that the ambiguity of mathematical symbols introduced into a numerical programming language makes it prone to errors when an interpreter processes a numerical programming language. [Brief explanation of the drawings]

[0022] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application, and the exemplary embodiments and the description thereof are used to interpret the present application and do not constitute undue limitations on the present application.

[0023] [Figure 1] 1 is a schematic diagram of the compilation and execution process of a current high-level programming language. [Figure 2] 1 is a flowchart of the compiler execution process. [Figure 3] 1 is a flowchart of the interpreter execution process. [Figure 4] 1 is a flowchart of a method for analyzing a programming language according to an embodiment of the present application; [Figure 5a] FIG. 1 is a schematic diagram of an abstract syntax tree according to an embodiment of the present application. [Figure 5b] FIG. 2 is a schematic diagram of another abstract syntax tree according to an embodiment of the present application; [Figure 6] 1 is a structural block diagram of a programming language analysis device according to an embodiment of the present application; DETAILED DESCRIPTION OF THE INVENTION

[0024] In order to help those skilled in the art understand the solutions of the present application more clearly, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only some of the embodiments of the present application, and not all of the embodiments, and all other embodiments obtained by those skilled in the art without any creative efforts based on the embodiments of the present application fall within the protection scope of the present application.

[0025] It should be noted that terms such as "first," "second," and the like in the specification and claims of this application and in the drawings are used to distinguish between similar objects and are not necessarily used to describe a particular order or sequence. It should be understood that the data used are interchangeable under appropriate circumstances, and that the embodiments of this application described herein may therefore be performed in an order other than that shown or described herein. Furthermore, the terms "comprise" and "have," and their variants, are intended to be non-exclusive; for example, a process, method, system, product, or apparatus comprising a series of steps or elements is not necessarily limited to the explicitly listed steps or elements, but may include other steps or elements that are not explicitly listed or that are inherent to the process, method, product, or apparatus.

[0026] According to an embodiment of the present application, an embodiment of a method for parsing a programming language is provided, and it should be noted that the steps illustrated in the flowcharts of the drawings may be performed, for example, in a computer system as a set of computer-executable commands, and that although a logical order is shown in the flowcharts, in some cases the steps may be performed in an order different from that shown or described.

[0027] 4 is a flowchart of a method for analyzing a programming language according to an embodiment of the present application. As shown in FIG. 4, the method includes the following steps:

[0028] Step S402: identifying the source code as a string of characters and parsing the string of characters into a lexical unit list including a plurality of lexical units;

[0029] In this step, the source code is recognized and identified as a string of characters. The lexical analyzer receives the string of characters and parses the source program into a lexical unit list containing multiple lexical units according to the set word formation rules.

[0030] In step S404, the plurality of lexical units are divided into first group lexical units which are lexical units including ambiguous symbols and second group lexical units which are lexical units not including ambiguous symbols,

[0031] When step S404 is executed, a classification process is performed on the lexical unit list to separate lexical units into those that contain ambiguous codes and those that do not contain ambiguous codes.

[0032] In step S406, the first related lexical unit is converted into a second related lexical unit.

[0033] In step S408, analysis is performed on the second related lexical unit obtained by converting the first related lexical unit and the second related lexical unit obtained by classifying the multiple lexical units.

[0034] Through the above steps, a classification process is performed on the lexical unit list resulting from the lexical analysis, and ambiguous lexical units are converted into ambiguous lexical units, thereby achieving the objective of improving the interpreter's ability to process ambiguous code and achieving the technical effect of improving the accuracy with which the interpreter processes numerical programming languages.

[0035] According to one optional embodiment of the present application, dividing the plurality of lexical units into first and second similar lexical units in step S404 is achieved through the steps of obtaining token names of the plurality of lexical units, identifying ambiguous target token names from the token names, and identifying the lexical unit to which the target token name belongs as the first similar lexical unit, and identifying the lexical unit to which token names other than the target token name belong as the second similar lexical unit.

[0036] In this step, we find ambiguous symbols by token names of lexical units, mark this type of lexical unit as first class lexical unit, and mark other lexical units as second class lexical units.

[0037] According to another optional embodiment of the present application, performing step S406 of converting the first class lexical units into second class lexical units includes inputting the first class lexical units into a semantic analyzer for analysis to obtain the second class lexical units.

[0038] Alternatively, the step of inputting the first related lexical unit into a semantic analyzer for analysis to obtain the second related lexical unit includes the steps of identifying a type of a token name of the first related lexical unit based on context information of the first related lexical unit, and modifying an attribute value of the first related lexical unit based on the type of the token name of the first related lexical unit to obtain the second related lexical unit.

[0039] In this step, the semantic analyzer receives the first related lexical unit, determines the specific type of the word symbol of the first related lexical unit based on the context, modifies the attribute value of the first related lexical unit based on the determination result, and changes the type of the first related lexical unit to the second related lexical unit.

[0040] In some optional embodiments of the present application, performing step S408 of analyzing the second related lexical unit obtained by converting the first related lexical unit and the second related lexical unit obtained by classifying the plurality of lexical units includes inputting the second related lexical unit obtained by converting the first related lexical unit and the second related lexical unit obtained by classifying the plurality of lexical units to a syntactic analyzer for analysis, and inputting the analysis result of the syntactic analyzer on the second related lexical unit to a semantic analyzer for analysis.

[0041] In some optional embodiments of the present application, the step of inputting the second related lexical unit obtained by converting the first related lexical unit and the second related lexical unit obtained by classifying the plurality of lexical units into a parser for analysis includes the step of assembling the second related lexical unit obtained by converting the first related lexical unit and the second related lexical unit obtained by classifying the plurality of lexical units into a parse tree.

[0042] The parser receives the second class lexical units and assembles the lexical unit sequence into a parse tree based on the set grammar rules, using an adaptive LL(k) algorithm, where the first L in LL indicates parsing the lexical unit sequence from left to right, the second L indicates using leftmost derivation in the parsing process, k≧1, and k indicates forward matching of k lexical units in the matching process based on the grammar rules, and the adaptive LL(k) algorithm can dynamically analyze the syntax in the grammar parsing process and automatically rewrite left-recursive grammars into equivalent non-left-recursive forms.

[0043] According to one optional embodiment of the present application, the step of inputting the analysis result of the syntactic parser for the second class lexical unit to the semantic analyzer for analysis includes the step of performing a simplification process on the syntactic parse tree to construct an abstract syntax tree.

[0044] The semantic analyzer receives the lexical analysis tree, the lexical unit sequence, and the symbol table information, simplifies the syntax tree, and constructs an abstract syntax tree. The syntax analyzer outputs error information to the error processing module, and updates identifiers in the symbol table management module based on the results of the syntax analysis. The semantic analyzer outputs error information to the error processing module, and updates identifiers in the symbol table management module based on the results of the semantic analysis.

[0045] FIG. 5a is a schematic diagram of an abstract syntax tree according to an embodiment of the present application. As shown in FIG. 5a, a syntax tree corresponding to source code defining a simple matrix is ​​provided, where L represents a list, R represents a row, J represents a matrix, and F represents a built-in function, all of which are placed in a user-defined symbol table.

[0046] The source code corresponding to the syntax tree shown in Figure 5a is a = [1, 2; 2, exp(2)].

[0047] FIG. 5b is a schematic diagram of another abstract syntax tree according to an embodiment of the present application. As shown in FIG. 5b, a syntax tree corresponding to the source code of one user-defined function sum is provided, where C denotes the user-defined function.

[0048] The source code corresponding to the syntax tree shown in Figure 5b is sum(2, 3).

[0049] According to another optional embodiment of the present application, when performing step S402, parsing the string into a lexical unit list is performed by parsing the string into a lexical unit list according to a preset word construction rule, and each lexical unit in the lexical unit list includes a token name and an attribute value, where the token name is the lexical unit itself and the attribute value is the type of the lexical unit.

[0050] The parser receives a string and parses the source program into a list of lexical units based on the configured word formation rules. A lexical unit consists of a token name and an attribute value. The token name is the word itself and is used by the parser. The attribute value indicates the type of word and includes keywords, constants, operators, delimiters, and identifiers. Error information is output to the error processing module, and the identifier is input to the symbol management module.

[0051] The above method provided by the embodiments of the present application can solve the problem of ambiguous symbols in numerical calculation programming languages, and can also solve the problem of ambiguous symbols in other programming languages. A compiler based on this technical solution can be applied to numerical calculation programming languages ​​such as Maltab and Octave.

[0052] FIG. 6 is a structural block diagram of a programming language analysis device according to an embodiment of the present application. As shown in FIG. 6, the device includes:

[0053] a first parsing module 60 configured to identify the source code as a string of characters and to parse the string of characters into a lexical unit list comprising a plurality of lexical units;

[0054] a classification module 62 configured to classify the plurality of lexical units into first class lexical units, which are lexical units including ambiguous symbols, and second class lexical units, which are lexical units not including ambiguous symbols;

[0055] a conversion module 64 arranged to convert the first class lexical units into second class lexical units;

[0056] and a second analysis module 66 that is set up to analyze the second related lexical units obtained by converting the first related lexical units and the second related lexical units obtained by classifying the plurality of lexical units.

[0057] For a preferred embodiment of the embodiment shown in FIG. 6, please refer to the related description of the embodiment shown in FIG. 4, and the description will be omitted here.

[0058] An embodiment of the present application further provides a non-volatile storage medium containing a program stored thereon, the program, when executed, controlling a device in which the program resides to perform the above-described method for parsing a programming language.

[0059] The non-volatile storage medium is used to store a program that performs the following functions: identifies source code as a string of characters, and parses the string into a lexical unit list including a plurality of lexical units; divides the plurality of lexical units into first synonymous lexical units, which are lexical units including ambiguous symbols, and second synonymous lexical units, which are lexical units not including ambiguous symbols; converts the first synonymous lexical units into second synonymous lexical units; and analyzes the second synonymous lexical units obtained by converting the first synonymous lexical units and the second synonymous lexical units obtained by classifying the plurality of lexical units.

[0060] An embodiment of the present application further provides a processor that is used to execute a program stored in a memory, the processor executing the above-described method for parsing a programming language when the program is executed.

[0061] The processor is used to execute a program that performs the following functions: identifies source code as a string of characters, and parses the string into a lexical unit list including a plurality of lexical units; divides the plurality of lexical units into first synonymous lexical units, which are lexical units including ambiguous symbols, and second synonymous lexical units, which are lexical units not including ambiguous symbols; converts the first synonymous lexical units into second synonymous lexical units; and analyzes the second synonymous lexical units obtained by converting the first synonymous lexical units and the second synonymous lexical units obtained by classifying the plurality of lexical units.

[0062] The example numbers in the present application are for illustrative purposes only and do not indicate the superiority or inferiority of the examples.

[0063] In the above embodiments of the present application, the description of each embodiment focuses on specific points, and for parts that are not detailed in one embodiment, reference can be made to the relevant descriptions of other embodiments.

[0064] It should be understood that the disclosed technical contents in some embodiments provided in this application can be realized in other ways. The device embodiments described so far are merely exemplary. For example, the division of the units is merely a division of logical functions. In actual implementation, other division methods may be used. For example, multiple units or assemblies may be combined or integrated into another system, or some features may be omitted or not implemented. In other respects, the mutual couplings or direct couplings or communication connections shown or discussed may be indirect couplings or communication connections via interfaces, devices, or modules, and may be electrical or other forms.

[0065] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, i.e., they may be located in one place or distributed over multiple units, and some or all of the units can be selected according to actual needs to achieve the objectives of the solution of this embodiment.

[0066] Furthermore, each functional unit in each embodiment of the present application may be integrated into one processing unit, each unit may exist physically independently, or two or more units may be integrated into one unit. The integrated unit may be realized in the form of hardware or in the form of a software functional unit.

[0067] When the integrated unit is realized in the form of a software functional unit and sold or used as an independent product, it may be stored in a single computer-readable storage medium. Based on this understanding, the essence of the technical solution of the present application or a part contributing to the related technology, or all or a part of the technical solution, may be embodied in the form of a software product, and the computer software product may be stored in a single storage medium and include a plurality of commands that cause a computer device (which may be a personal computer, a server, a network device, etc.) to execute all or a part of the steps of the methods described in each embodiment of the present application. The storage medium may include various media capable of storing program code, such as a USB memory, a read-only memory (ROM), a random access memory (RAM), a removable hard disk, a magnetic disk, or an optical disk.

[0068] The above is only a preferred embodiment of the present application, and it should be noted that those skilled in the art may make some further improvements and modifications without departing from the principles of the present application, and these improvements and modifications should also be considered as within the protection scope of the present application. [Industrial Applicability]

[0069] The solution provided by the embodiments of the present application can be applied to the software field. The embodiments of the present application utilize the following steps to achieve the objective of improving the ability of an interpreter to process ambiguous code, and realize the technical effect of improving the accuracy with which an interpreter processes a numerical computation programming language: identifying a source code as a string of characters, and parsing the string into a lexical unit list including a plurality of lexical units; dividing the plurality of lexical units into first related lexical units, which are lexical units including ambiguous symbols, and second related lexical units, which are lexical units not including ambiguous symbols; converting the first related lexical units into second related lexical units; and analyzing the second related lexical units obtained by converting the first related lexical units and the second related lexical units obtained by classifying the plurality of lexical units.

Claims

1. A method for analyzing a programming language executed by an interpreter, comprising: identifying the source code as a string of characters and parsing the string of characters into a lexical unit list comprising a plurality of lexical units; Dividing the plurality of lexical units into first group lexical units which are lexical units including ambiguous symbols and second group lexical units which are lexical units not including ambiguous symbols; converting the first lexical unit to the second lexical unit; and performing an analysis on the second synonymous lexical unit obtained by converting the first synonymous lexical unit and the second synonymous lexical unit obtained by classifying the plurality of lexical units.

2. The step of dividing the plurality of lexical units into first related lexical units and second related lexical units includes: obtaining token names for the plurality of lexical units; identifying an ambiguous target token name from the token names; identifying a lexical unit to which the target token name belongs as the first similar lexical unit, and identifying a lexical unit to which token names other than the target token name belong among the token names as the second similar lexical unit.

3. converting the first lexical unit into the second lexical unit includes inputting the first lexical unit into a semantic analyzer for analysis to obtain the second lexical unit; 2. The method of claim 1, wherein the step of analyzing the second synonymous lexical unit obtained by converting the first synonymous lexical unit and the second synonymous lexical unit obtained by classifying the plurality of lexical units comprises: a step of inputting the second synonymous lexical unit obtained by converting the first synonymous lexical unit and the second synonymous lexical unit obtained by classifying the plurality of lexical units to a syntactic analyzer and analyzing the second synonymous lexical unit; and a step of inputting an analysis result of the syntactic analyzer on the second synonymous lexical unit to the semantic analyzer and analyzing the second synonymous lexical unit.

4. The step of inputting the first synonymous lexical unit into a semantic analyzer for analysis to obtain the second synonymous lexical unit includes: determining a type of a token name of the first lexical unit based on context information of the first lexical unit; and modifying an attribute value of the first lexical unit based on a type of a token name of the first lexical unit to obtain the second lexical unit.

5. The step of inputting the second synonymous lexical unit obtained by converting the first synonymous lexical unit and the second synonymous lexical unit obtained by classifying the plurality of lexical units into a syntactic analyzer and performing analysis includes:

4. The method of claim 3, further comprising assembling the second lexical unit obtained by converting the first lexical unit and the second lexical unit obtained by classifying the plurality of lexical units into a parse tree.

6. The step of inputting the analysis result of the syntactic analyzer for the second lexical unit to the semantic analyzer for analysis includes:

6. The method of claim 5, further comprising the step of performing a simplification process on the parse tree to construct an abstract syntax tree.

7. Parsing the string into a list of lexical units comprises:

2. The method of claim 1, further comprising parsing the string into the lexical unit list according to predetermined word formation rules, each lexical unit in the lexical unit list including a token name and an attribute value, the attribute value being a type of the lexical unit.

8. a first parsing module configured to identify the source code as a string of characters and to parse the string of characters into a lexical unit list including a plurality of lexical units; a classification module configured to classify the plurality of lexical units into first class lexical units, which are lexical units including ambiguous symbols, and second class lexical units, which are lexical units not including ambiguous symbols; a conversion module configured to convert the first lexical unit into the second lexical unit; a second analysis module configured to perform analysis on the second synonymous lexical units obtained by converting the first synonymous lexical units and the second synonymous lexical units obtained by classifying the plurality of lexical units.

9. A computer program that, when executed, controls a device in which it resides to execute the method for analyzing a programming language according to any one of claims 1 to 7.

10. A processor used to execute a program stored in a memory, the processor executing the method for analyzing a programming language according to any one of claims 1 to 7 when the program is executed.

Citation Information

Patent Citations

  • Purser preparing device corresponding to ambiguous grammar

    JP1993241850A

  • System and method for recognizing structure in text

    US20100088674A1

  • Method and device for managing ambiguities in the analysis of a source code

    US20170024193A1

  • System and method for directly accessing SAS datasets from a JAVA program

    US8943472B1

  • Parser generation

    WO2015006075A1