Page 1 of 1

Version 3 syntax translation

Posted: Fri Dec 23, 2011 5:21 pm
by MtnViewJohn
I have added a version 2 to version 3 syntax translation capability to the gallery. Check it out at Individual designs also have Translate buttons that also take you to that page. Please try it out and post here if you have any cfdg files that fail to translate.

Re: Version 3 syntax translation

Posted: Sat Dec 24, 2011 11:29 am
by Monkstone
Excellent, I expect will mainly work. Interesting fails with [link design:2335] crosstile [/link] see my manual translation [link design:2722] here [/link], however that is on that had me stumped for a while.

Re: Version 3 syntax translation

Posted: Sat Dec 24, 2011 7:52 pm
by MtnViewJohn
I think that the wavy path in crosstile looks the way it does because of a bug in bezier rotation in version 2.

Re: Version 3 syntax translation

Posted: Sun Feb 05, 2012 7:07 am
by kipling
HI John

I have only just seriously started looking at CF3 ... I've been busy.

It is nice to see a lot of new features come to life. It is also nice to see that you have managed a fair shift in how the language works while still keeping a lot of the character.

I tried the translate option on a cfdg with target colours, and it doesn't work - it does a fairly literal translation, which when given to ContextFree gives "Parse error - Color target feature unavailable in shapes".

I understand that the intended replacement uses the new target syntax. However, this assumes that the rule "knows" the target colour, and the only examples given in the new docs have a constant colour as the target. So I am guessing that the way to have an inherited target colour is to explicitly pass this information down the object hierarchy via shape parameters. I haven't actually tried this myself, nor figured out whether every quirk of the old behaviour can be simulated in CF3.

Once I have figured it out I'll update the tutorial on colour targets.

If my guess about the "correct" way to get the old target behaviour is correct, my second guess is that there is not much to be gained from having a tool that automatically translates these. Maybe it should throw a warning, though.

Re: Version 3 syntax translation

Posted: Sun Feb 05, 2012 11:01 am
by MtnViewJohn
I will update the translation tool to inform the user if it has punted on translating color targets.

The translator tool is very dumb. Comments and white space are copied over directly. All lexical elements are directly translated to the new syntax. There is a little bit of intelligence to detect shapes with just one rule so that the superfluous rule tokens can be stripped out. To properly translate color targets would require converting the cfdg file to an abstract syntax tree and doing some analysis to push the color target changes down to where they are required. Mark was planning to write this in Haskell. But I created the dumb translator in PHP to facilitate the release of version 3 beta and Mark moved on to other projects.

Re: Version 3 syntax translation

Posted: Sun Feb 12, 2012 10:43 pm
by kipling
OK thanks. I figured that the translator operated mostly at the syntactic level.
On colour targets, I understand why it makes sense to minimise the number of variables passed through the object hierarchy, particularly those that a bit obscure.
I have had some fun with the new symmetry options, in particular the "roll your own symmetry group" feature. I'll be putting something on the gallery (and maybe the wiki) once I get it polished.