主权项 |
1. A method for modifying a file written in a formal language, comprising:
parsing, based on code of a parser, an input file written in a formal language to generate by the parser a data structure of the input file, the parser implemented using a formal language specification for the formal language of the input file; issuing, at an intermediate point in generation of the data structure of the input file by the parser and according to one or more query triggers in the code of the parser, one or more queries to a rule engine for evaluation of a first plurality of rules for modifying the input file, wherein the one or more queries include a subset of terminal symbols used to make up the data structure, wherein modifying the input file comprises altering the functionality of the input file by altering computer code of the input file according to the first plurality of rules;
the first plurality of rules comprising at least one rule distinct from the formal language specification used to implement the parser,the rule engine configured to analyze the one or more queries, determine whether the one or more queries trigger any of the first plurality of rules for modifying the input file, and communicate a query result to the parser, the query result instructing the parser to take an action in accordance with any of the triggered first plurality of rules as determined by the rule engine; generating, by the parser at the intermediate point, the data structure by executing the action indicated by the query result; and reusing the parser with a second plurality of rules distinct from the first plurality of rules. |