Download LPFG user`s manual - Algorithmic Botany
Transcript
2 The L+C modeling language L-system input files to lpfg use a new L-system-based modeling language, L+C. It is a declarative language which combines L-system constructs (notably, modules and productions) with the general-purpose programming language C++. L-system constructs have syntax which is similar to the traditional notation of L-systems (used, for instance, in cpfg); however, this syntax is also not too different from that of C++. The principle advantage of this hybrid approach is that the expressive power of C++ can be used in L+C programs; experience has shown that developing complex models is substantially easier in L+C than in traditional L-system notation. 2.1 L-system file A typical L-system program file has the following format: #include <lpfgall.h> derivation length: d; // declarations of data structures // declarations of functions // module declarations derivation length: n; axiom: module_list; // productions All elements of a program can appear in any order except for the following restrictions: 1) all elements referred to in a statement must be declared beforehand. Types used as parameters of a module must be declared before the module is declared. Modules that appear in an ignore or consider statement must be declared beforehand. 2) Productions are matched in the order in which they are declared. 2.1.1 Mandatory elements Every L-system must include the statements derivation length and axiom. 2.1.2 Include files The first line in the L-system is the #include statement. The lpfgall.h include file includes the following header files: • memory.h and stdlib.h are standard C header files. They are required by the code generated by the L2C translator. 9