CPC G06F 40/211 (2020.01) [G06F 8/31 (2013.01); G06F 16/3329 (2019.01); G06F 40/284 (2020.01)] | 20 Claims |
1. A system comprising:
a memory; and
a processing system coupled to the memory, the processing system configured to:
annotate a context-free grammar, which describes a syntax of a programming language, with an annotation, the annotation identifying a token that is likely to be included in or excluded from a computer program in a manner that violates the context-free grammar;
create a language-agnostic computer program repair engine generator that is configured to generate a parser, which is configured to process strings of the computer program according to the context-free grammar by triggering calls to domain-agnostic edit operations over tokens in the computer program based on the annotation and to domain-specific repair rules, each domain-agnostic edit operation and each domain-specific repair rule indicating a change that is to be performed with regard to at least one identified token in a candidate string in the computer program based at least in part on a state of the parser, the state of the parser indicating which tokens in the candidate string precede the at least one identified token and which rules of the context-free grammar have been applied to the candidate string prior to the change being performed with regard to the at least one identified token;
configure the language-agnostic computer program repair engine generator to create a repair engine that converts the candidate string into a plurality of repaired strings that do not violate the context-free grammar and that do not violate a criterion for a valid computer program by applying, for each repaired string, at least one of one or more of the domain-agnostic edit operations or one or more of the domain-specific repair rules to the candidate string to satisfy the rules of the context-free grammar;
configure the language-agnostic computer program repair engine generator to cause the repair engine to calculate a plurality of differences between the candidate string and the plurality of respective repaired strings; and
configure the language-agnostic computer program repair engine generator to cause the repair engine to replace the candidate string with a designated repaired string, which is selected from the plurality of repaired strings, based at least in part on the difference between the designated repaired string and the candidate string being less than or equal to a difference threshold.
|