Claims
- 1. An apparatus for compiling source code, comprising:
a tokenizer for segmenting source code into a sequence of tagged segments; the source code including at least one instruction composing a first abstraction and a second abstraction with a selected composition operator; a parser for building a tree using the sequence of tagged segments; a type checker for performing a first pass of the tree to determine whether abstractions on the tree are well typed; a composer for reducing the at least one instruction composing the first and the second abstractions on the tree to a third abstraction; the composer substituting the first and the second abstractions on the tree with the third abstraction; wherein the type checker performs a second pass of the tree to determine whether the third abstraction is well typed.
- 2. The apparatus according to claim 1, wherein type checker decorates the tree with type information related to expressions on it to define a decorated tree.
- 3. The apparatus according to claim 2, wherein the type checker reevaluates whether the third abstraction is well typed by distinguishing between recursive and non-recursive abstractions.
- 4. The apparatus according to claim 3, wherein types of abstractions are declared in the source code.
- 5. The apparatus according to claim 3, wherein types of abstractions are undeclared in the source code.
- 6. The apparatus according to claim 5, wherein the type checker infers undeclared types in the source code.
- 7. The apparatus according to claim 2, further comprising an importer for resolving references to elements external to the source code.
- 8. The apparatus according to claim 7, further comprising:
a partial evaluator for pre-evaluating language instructions in the decorated tree to reduce its complexity; a code optimizer for evaluating the language instructions in the decorated tree to perform optimizations; a code generator for producing object code using the decorated tree.
- 9. The apparatus according to claim 7, further comprising:
a partial evaluator for pre-evaluating language instructions in the decorated tree to reduce their complexity; an intermediate format generator for producing intermediate code using the decorated tree.
- 10. A method for compiling source code, comprising:
segmenting source code into a sequence of tagged segments; the source code including at least one instruction composing a first abstraction and a second abstraction with a selected composition operator; building a tree using the sequence of tagged segments; performing a first pass of the tree to determine whether abstractions on the tree are well typed; reducing the at least one instruction composing the first and the second abstractions on the tree to a third abstraction; said reducing further comprising substituting the first and the second abstractions on the tree with-the third abstraction; wherein a second pass of the tree is performed to determine whether the third abstraction is well typed.
- 11. The method according to claim 10, further comprising decorating the tree with type information related to expressions on it to define a decorated tree.
- 12. The method according to claim 11, further comprising reevaluating whether the third abstraction is well typed by distinguishing between recursive and non-recursive abstractions.
- 13. The method according to claim 12, wherein types of abstractions are declared in the source code.
- 14. The method according to claim 12, wherein types of abstractions are undeclared in the source code.
- 15. The method according to claim 14, further comprising inferring undeclared types in the source code.
- 16. The method according to claim 11, further comprising resolving references to elements external to the source code.
- 17. The method according to claim 16, further comprising:
pre-evaluating language instructions in the decorated tree to reduce its complexity; evaluating the language instructions in the decorated tree to perform optimizations; producing object code using the decorated tree.
- 18. The method according to claim 16, further comprising:
pre-evaluating language instructions in the decorated tree to reduce their complexity; producing intermediate code using the decorated tree.
- 19. An article of manufacture for use in a machine, comprising:
a memory; instructions stored in the memory for compiling source code comprising instructions for defining: a tokenizer for segmenting source code into a sequence of tagged segments; the source code including at least one instruction composing a first abstraction and a second abstraction with a selected composition operator; a parser for building a tree using the sequence of tagged segments; a type checker for performing a first pass of the tree to determine whether abstractions on the tree are well typed; a composer for reducing the at least one instruction composing the first and the second abstractions on the tree to a third abstraction; the composer substituting the first and the second abstractions on the tree with the third abstraction; wherein the type checker performs a second pass of the tree to determine whether the third abstraction is well typed.
- 20. The article of manufacture according to claim 19, wherein type checker decorates the tree with type information related to expressions on it to define a decorated tree.
CROSS REFERENCE TO RELATED APPLICATIONS
[0001] Cross-reference is made to U.S. patent application Ser. No. 10/046,314, entitled “Symmetrical Structural Pattern Matching”, Ser. No. 10/046,191 entitled “Bi-Valuation Of Programming Statements”, which are assigned to the same assignee as the present invention and incorporated herein by reference. Cross-reference is also made to U.S. patent application filed concurrently herewith and entitled “Program Operators For Composing Abstractions”, which is assigned to the same assignee as the present invention and incorporated herein by reference.