|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Introduction & File FormatAboutFlowgorithm's Source Code Viewer allows flowcharts to be converted to several real-world programming languages. These include: Java, C#, Visual Basic .NET, Smalltalk, and many more. The generated source code is created by using program templates. These are files that contain syntactic information about the target programming language such as keywords, formatting, and operator precedence. This documentation outlines the format and Flowgorithm program templates. It is also useful to use existing templates to create new ones. File ExtensionProgram Templates use the file extension fpgt. However, the Source Code Viewer can open any extension from the file dialog. Basic File FormatProgram templates are saved in a simple text file using the INI format. The goal was to make them easy to both read and write by using just a simple text editor. Flowgorithm program templates support Unicode, so please feel free to use any of the special characters (not just ASCII). INI files recognize three basic syntactic elements: comments, section headers, and key/value declarations. From these, it is able to represent a non hierarchical tables. The elements are as follows:
The section name and key is used to uniquely identify a value. This is roughly equivalent to the tables and rows found in databases.
Line FormatEach line in the template contains up to three sub-values. These allow the following to specified for each line:
Lines do not need to specify all three values. If the indentation is left blank, for example, the system will assume 0 - or no change. FieldsMany of the different key/values contain "fields" which are denoted by curly brackets (braces). When a program is generated, text is inserted into these fields based on the current object (i.e. expression, statement, etc...). The contents of the field can be directly taken from the object or, in some cases, generated using other parts of the template. Field names are not case sensitive. Using a double open curly bracket (brace) is the override sequence. In the following example, the text key contains two fields: {Variable} and {Expression}.
Multiple LinesINI files, which Flowgorithm program templates are based upon, generally do not allow a key to contain multiples values (or lines). However, program templates allow any key to contain multiple values (or lines). These can represent different possible values or different lines in a generated statement. To add another value/line to a key, start the next line with an equals sign =.
FlagsWhen source code is generated, the system needs to either include or exclude lines based on information about the program itself. This can be related to whether a specific syntax is needed, different library calls are needed (based on the data type used in an statement), etc.... To control which lines are valid in the program template, the system makes use of flags. The flags are defined by the section in which they are meaningful and can be used to control the generated source code. Multiple flags can be delimited by commas. The line is only considered valid if - and only if - all the flags are matched. If a flag is preceded with a tilde ~ the system will match it if it is False. The following example makes use of several flags - in particular "inc" and "step". In the context of a For Statement, "Step" is set to true of the For Statement has an step value other than 1 and "inc" is true if the For Statement moves in ascending order (positive). The combination of these values will result in one line (beginning with for) to be selected.
IndentationMost programming languages allow the use of indentation to visually format the text. This allows blocks and other syntactic elements to be easy to distinguish and understand by the programmer. The last sub-value of a line can contain the change in the generated code's indentation. In the example below, the line that contains "--->BLOCK" (which has an empty flags) has a single "1" for indentation. This will cause the inserted text to be indented by 1 level. Note: this does not refer to characters, but the indentation level. The indentation level is automatically converted into a fixed number of spaces in the generated code.
|