A computer-implemented method for compiling a source code to a program code, the method comprising: generating, by a pattern graph provider, a pattern graph based on the source code, wherein the pattern graph corresponds to an intermediate representation of the source code according to a set of rules in a first programming language, wherein the set of rules comprises a specific replacement rule directing a pattern graph to be replaced by a corresponding replacement graph assigned to the pattern graph; replacing the pattern graph by the replacement graph assigned to the pattern graph, wherein instances of the pattern graph are registered together with their corresponding replacement graphs in a rule component of the set of rules; and generating the program code based on the replacement graph, wherein the pattern graph is generated such that the pattern graph matches the intermediate representation of the source code, wherein the pattern graph is generated such that a number of nodes of the first layer of nodes of the pattern graph matches a number of nodes of the first layer of nodes of the intermediate representation of the source code, and further generated such that the binary operations of the further layers of nodes of the pattern graph match the binary operations of the further layers of nodes of the intermediate representation of the source code, wherein the replacement graph comprises a first layer of nodes comprising expressions, in particular variables which first layer of nodes is concatenated with further layers of nodes comprising binary operations; and wherein the replacement graph has a same number of nodes of the first layer of nodes as the pattern graph and at least one different binary operation in the further layers of nodes. generating, by a pattern graph provider, a pattern graph based on the source code, wherein the pattern graph corresponds to an intermediate representation of the source code according to a set of rules in a first programming language, wherein the set of rules comprises a specific replacement rule directing a pattern graph to be replaced by a corresponding replacement graph assigned to the pattern graph; replacing the pattern graph by the replacement graph assigned to the pattern graph, wherein instances of the pattern graph are registered together with their corresponding replacement graphs in a rule component of the set of rules; and generating the program code based on the replacement graph, wherein the pattern graph is generated such that the pattern graph matches the intermediate representation of the source code, wherein the pattern graph is generated such that a number of nodes of the first layer of nodes of the pattern graph matches a number of nodes of the first layer of nodes of the intermediate representation of the source code, and further generated such that the binary operations of the further layers of nodes of the pattern graph match the binary operations of the further layers of nodes of the intermediate representation of the source code, wherein the replacement graph comprises a first layer of nodes comprising expressions, in particular variables which first layer of nodes is concatenated with further layers of nodes comprising binary operations; and wherein the replacement graph has a same number of nodes of the first layer of nodes as the pattern graph and at least one different binary operation in the further layers of nodes.