EP0735467A2

Compiler with generic front end and dynamically loadable back ends

Abstract

A system and method provides for variable target outputs from a compiler with only a single execution. The compiler includes a front end, a generic back end, and plurality of individual back ends that are dynamically loaded by the compiler during execution. The front end produces an abstract syntax tree which is then processed by the generic back end and the individual back ends to produce a number of back end trees, each adapted for a specific back end, and representative of the desired structure of the various target outputs, including target code files, or events. The generic back end traverses the abstract syntax tree, and on each node of the tree, invokes each back end that has a node of its back end tree attached thereto. The back end can then modify its own back end tree, and attach further back end nodes to other nodes of the abstract syntax tree. In turn the generic back end will invoke such added attached nodes, until all attached back end nodes on all the nodes of the abstract syntax tree have been processed. This results in completed back end trees for all of the back ends, requiring only a single pass of the front end to produce the abstract syntax tree. The individual back ends then process their respective back end trees to produce their target outputs. A look up operation is provided in the generic back end that returns one or more back end nodes in response to a request therefore specifying a node of the abstract syntax tree, and a family identification value of a back end node.

EP0735467A2, drawing sheet 1
Sheet 1 of 8

Term

Term ended

Projected expiry passed 14 March 2016, 10.5 years ago.

  1. Priority
  2. Filed
  3. Published
  4. Projected expiry
  5. Today

18 claims: 7 independent, 11 dependent

  1. 1
    An apparatus for compiling a source code file and producing variable target outputs therefrom, comprising:a front end that accepts the source code file and produces thereform an abstract syntax tree that represents the syntactic structure of the source code file, the abstract syntax tree having at least one abstract syntax tree node;at least one back end that produces an associated back end tree from the abstract syntax tree, and further produces from the back end tree a target output, the back end tree having at least one back end tree node;and, a generic back end that controls the at least one back end to produce the associated back end tree, such that each back end is independent of the generic back end, and dynamically loaded by the apparatus during execution.
  2. 8
    The apparatus of one of claims 1 to 7 further comprising:a memory device that stores the abstract syntax tree, the at least one back end tree, the generic back end, and the at least one back end;and a processing device that executes the generic back end and the at least one back end to produce from the at least one back end at least one target output.
  3. 9
    The apparatus of one of claims 1 to 8, wherein each back end and each back end node associated with the back end has a family identification value, wherein the generic back end further comprises:a look up operation that returns zero or more nodes from at least one back end tree having a family identification value and attached to a node of the abstract syntax tree in response to a request from a back end specifying the family identification value and the node of the abstract syntax tree.
  4. 10
    A method for compiling a source code file and producing variable target outputs thereform, comprising the steps of:providing a source code file;executing a compiler having a front end and a generic back end;loading at least one back end to operate with the generic back end;creating an abstract syntax tree from the source code with the front end, the abstract syntax tree including a root node and at least one child node;generating a back end tree associated with each back end;and    producing from each back end tree a target output.
  5. 16
    The method of one of claims 10 to 15, wherein the step of selecting nodes of the abstract syntax tree is performed recursively.
  6. 17
    The methods of one of claims 10 to 16, wherein each back end and back end node associated therewith has a family identification value, further comprising the steps of:receiving a request specifying a family identification value and a node of the abstract syntax tree;and    returning zero or more back end nodes from at least one back end tree having a same family identification value and attached to the node of the abstract syntax tree.
  7. 18
    A computer system for compiling a source code file and producing variable target outputs thereform, comprising:a memory device that stores: an abstract syntax tree that represents the syntactic structure of the source code file and having at least one abstract syntax tree node;at least one back end tree derived from the abstract syntax tree, each back end tree having at least one back end tree node and associated with a back end;at least one back end that produces from the abstract syntax tree a back end tree associated with the back ends and further produces from the back end tree a target output, each back end independent of a compiler, and dynamically loaded by the compiler during execution, each back end invoked by the generic back end in the selected order;the compiler comprising: a front end that accepts the source code file and produces thereform the abstract syntax tree;a generic back end that coordinates construction of the at least one back end tree by invoking a back end associated with at least one back end tree node attached to an abstract syntax tree node in a selected order;a processing device that executes the generic back end and the at least one back end to produce from the at least one back end at least one target output.