Parsability of code snippets
AssigneeFujitsu Limited
InventorsSonal Mahajan, Mukul R. Prasad
Life of this patent
Estimating the term…
Abstract
Operations may include obtaining a code artifact in which the code artifact is a code snippet is of a software language of interest. The operations may also include identifying fault locations of the code snippet that each correspond to a parsing error. In addition, the operations may include implementing repairs for each identified fault location in which, for each fault location, a respective repair is implemented for its corresponding parsing error such that the code snippet is modified into a parsable code snippet.
Claims15
A method comprising:
- obtaining a code artifact in which the code artifact includes a code snippet of a software language of interest, the code snippet including a plurality of syntax errors with respect to the software language of interest;
- identifying an undefined token in a particular line of code of the code snippet, the undefined token being undefined with respect to the software language of interest, wherein identifying the undefined token includes determining that an arrangement of characters in the particular line of code matches a regular expression that corresponds to an undefined statement or an undefined expression of the software language of interest;
- replacing the undefined token with a dummy code fragment of the software language of interest;
- identifying, as fault locations of the code snippet, portions of the code snippet that each have at least one incongruency that relates to a parsing error, one of the fault locations including the particular line of code having the dummy code fragment incorporated therein, wherein identifying the fault locations includes:
- building a parse tree of the code snippet that represents syntactic relationships of elements of the code snippet;
- and
- identifying error nodes of the parse tree in which each error node indicates a respective fault location;
- and
- implementing repairs for each identified fault location in which, for each fault location, a respective repair is implemented to correct a corresponding incongruency such that the code snippet is modified into a parsable code snippet.
One or more non-transitory computer-readable media configured to store one or more instructions that, in response to being executed by at least one system, cause the at least one system to perform operations, the operations comprising:
- obtaining a code artifact in which the code artifact includes a code snippet of a software language of interest, the code snippet including a plurality of syntax errors with respect to the software language of interest;
- identifying an undefined token in a particular line of code of the code snippet, the undefined token being undefined with respect to the software language of interest, wherein identifying the undefined token includes determining that an arrangement of characters in the particular line of code matches a regular expression that corresponds to an undefined statement or an undefined expression of the software language of interest;
- replacing the undefined token with a dummy code fragment of the software language of interest;
- identifying, as fault locations of the code snippet, portions of the code snippet that each have at least one incongruency that relates to a parsing error, one of the fault locations including the particular line of code having the dummy code fragment incorporated therein, wherein identifying the fault locations includes:
- building a parse tree of the code snippet that represents syntactic relationships of elements of the code snippet;
- and
- identifying error nodes of the parse tree in which each error node indicates a respective fault location;
- and
- implementing repairs for each identified fault location in which, for each fault location, a respective repair is implemented to correct a corresponding incongruency such that the code snippet is modified into a parsable code snippet.
A system comprising:
- one or more computer-readable storage media configured to store instructions;
- and
- one or more processors communicatively coupled to the one or more computer-readable storage media and configured to, in response to execution of the instructions, cause the system to perform operations, the operations comprising:
- obtaining a code artifact in which the code artifact includes a code snippet of a software language of interest, the code snippet including a plurality of syntax errors with respect to the software language of interest;
- identifying an undefined token in a particular line of code of the code snippet, the undefined token being undefined with respect to the software language of interest;
- identifying, as fault locations of the code snippet, portions of the code snippet that each have at least one incongruency that relates to a parsing error, wherein identifying the fault locations includes:
- building a parse tree of the code snippet that represents syntactic relationships of elements of the code snippet;
- and
- identifying error nodes of the parse tree in which each error node indicates a respective fault location;
- and
- implementing repairs for each identified fault location in which, for each fault location, a respective repair is implemented to correct a corresponding incongruency such that the code snippet is modified into a parsable code snippet.
Dependencies are inferred from the claim text.