The various GMac system components will never be complete, they are under continuous development to mature into an incrementally useful system. Some features will be added in time, but the basic architecture described here will remain unchanged:
GMacCompiler: This is the core of GMac, a source-to-source compiler that can generate an Abstract Syntax Tree (GMacAST) from a GA-based Domain-Specific Language (GMacDSL) code. The GMacCompiler is an optimizing transcompiler; it can perform high-level domain-specific optimizations backed up by a powerful Computer Algebra System (CAS), like Mathematica or Python’s SymPy for example, to generate the desired code. The GMacCompiler has two sub-components:
- The GMacCompiler Front End: The main role of the front end is to translate GMacDSL code into a GMacAST structure. The front end follows the traditional lexer>parser>semantic analyzer sequence of compiler front ends. It interacts with the GMacIDE, the user interface of GMac, by accepting GMacDSL code and reporting any errors in the code through the GMacIDE interface. It also occasionally requests symbolic computations from the CAS to complete the translation process successfully.
- The GMacCompiler Back End: The back end is responsible for generating text code from the GMacAST structure translated from GMacDSL code. The generation process is highly configurable through an Application Programming Interface (GMacAPI). Using GMacAPI we can reshape with full control the information abstractly encoded in the GMacAST structure into text files having any desired folder, file, and text structure. We can select a target language to convert GMacDSL macros into executable code in a given target language. The GMacAPI infrastructure can be extended easily to add more target languages as desired.
GMacDSL: The use of GA for expressing geometric ideas is very effective. GMacDSL is designed to be a good and simple expressive language for general GA operations on multivectors in any arbitrary GA model of geometry. GMacDSL is not Turing-Complete; it has no looping or conditional branching constructs. These constructs are left for the main GC system application code and the GMac scripting engine. GMacDSL primarily focuses on representing geometric objects in two main ways:
- Direct representation using multivectors of some GA frame.
- Non-recursive combinatorial structures of multivectors and scalars.
GMacDSL also focuses on implementing GA operations on these two types of representations using Geometric Macros: solid parametric blocks containing a sequence of simple commands that assign GA computational expressions to local and output variables of the block. The GMacCompiler front end translates GMacDSL code into GMacAST structures that can be used for interactive scripting through GMacIDE, or for configurable code generation through the GMacCompiler back end and GMacAPI.
GMacAST: When a GA model encoded in GMacDSL has compiled into an Abstract Syntax Tree it is ready for many interesting uses through scripting and code generation. The GMacAST is a set of simple .NET classes that are written in C# but accessible through any .NET language to hold the minimum necessary abstract information for code generation and scripting interaction processes. The GMacAST is accessible through GMacIDE and GMacAPI. Learning the full structure of GMacAST as provided by the GMacAST Guide is necessary for effective use of the GMac system.
GMac Scripting: After we have a GMacAST we can easily interact with it computationally through the GMac scripting engine to test the GA model we encoded with GMacDSL. Scripting can provide many insights into the GA model prototype we created. Scripting also provides more computational power to GA models implemented in the non-Turing-Complete GMacDSL like looping, conditional branching, and others.
GMacAPI: The GMacCompiler backend can be configured using GMacAPI to generate efficient text code in any desired language. GMacAPI is a set of .NET classes created with C# but usable by any .NET language (C++, C#, VB.NET, F#, IronPython, etc.) to specify how to use the information and geometric macros encoded in the GMacAST structure to generate files with desired structure in terms of folders, files, and text. GMacAPI has a set of classes specifically designed for easily controllable template-based or free text generation from arbitrary sources. GMacAPI can also specify binding patterns to associate target language variables or constant values with parts of input parameters to the geometric macros. The net result is a flexible, powerful, and efficient means for implementing configurable low-level code generation from GMacDSL GA-based high-level code.
GMacIDE: This is the main user interface of GMac where we can write GMacDSL code, interact with the GMacCompiler, and use the GMac scripting engine. The main interaction services GMacIDE can provide are:
- Write GMacDSL source code with the help of a project management and code highlighting capable interface.
- Compile GMacDSL code into a GMacAST structure and report any errors in the code.
- Explore the details of the compiled GMacAST in various ways.
- Explore a single high-level geometric macro to see how it translates into low-level code with some statistics on the intermediate optimizations performed.
- Interact with the compiled GMacAST computationally through the GMac scripting engine.
- Provide an extendable interface for generating a set of useful code libraries using a given GMacAST structure.
GMac Guides: GMac is a sophisticated compiler and code composition system based on Geometric Algebra. In order to fully understand and effectively use the GMac system, you need to study the GMac Guides carefully.
In addition to GMac guides, we will provide practical examples of using GMac for real geometric computing problems as tutorials and illustrations of the GMac system operation. You can find these examples in the GMac Samples page that will contain full source code and updated as new samples are created.