Version 2 Syntax

=Syntax Differences= There are a few syntax changes between version 2 and modern Context Free:

Rule Syntax
Context Free uses the shape token to introduce shape names and the rule token if a shape has more than one rule. Version 2 uses the rule token only and the shape's name must be repeated with each rule. Single rule example: vs.

Multiple rule example: vs.

Shape Adjustments
Basic shape adjustments in Context Free are surrounded by a single pair of square brackets: [adjustments]. Ordered shape adjustments have a doubled pair of square brackets: adjustments. In Version 2 curly brackets are used for basic shape adjustments and single square brackets are used for ordered shape adjustments. vs.

Targeted Color Adjustments
Version 2 supports targeted color changes, like |hue 45 to change the target or sat 0.2| to do a targeted color change. The current color target is stored behind the scenes and used whenever there is a targeted color change. These color adjustment forms are not supported in version 3. Instead version 3 provides an alternate color targeting adjustment, like hue 0.05 60, in which the target and the adjustment are both provided and there is no color target remembered behind the scenes.

When converting version 2 color target code to version 3 there are two cases to consider. If the color target is set and never changed then it is simply a manner of moving the target from where it was set to where it is needed. If the color target changes then the designer must explicitly carry the target from shape to shape as a parameter.

Loops
Version 2 had anonymous loops with integer constants for the loop count and it used a count* syntax for the loop header. vs.

Simple vs. Compound Loop Bodies
In Version 2, loops cannot be simple bodies of other loops. Only shape replacements, path operations, and path commands can be simple loop bodies. vs.

Importing CFDG Files
vs.

Configuration
Version 2 did not have configuration variables so it had specific directives for background color, tiling, and size. vs.

Paths
There are too many differences in path syntax to enumerate here. They have the same drawing model, but Version 3 uses the new parameter syntax while Version 2 path syntax was a hack on top of the shape adjustment syntax. Compare the Version 3 path page to the Version 2 path page.

=Conversion Tools= There is a simple script that translates version 2 cfdg files to version 3 syntax. Upload your cfdg file or directly enter the cfdg text into the web form. This translator cannot properly translate targeted color adjustments because the targeted color semantics changed between version 2 and version 3.