Page 1 of 1

Templates and Constants

Posted: Sun Jul 10, 2005 8:34 am
by t3knomanser
This is a two-parter. The first feature, and I don't think I need to make much of an argument in favor of this one, is the ability to have templates. Pre-commented files customized with your name, copyright information, etc. Considering I use the same basic combination of rules a lot (the core element of my files is usually called "BASE", I often name my startshape "SCENE"), it would certainly make my life easier.

I have a hunch that there'll be more opposition to the second, because it bends the Context-Free part- constants. Very often, I'll use the same value in multiple places, as a scaling factor, a weighting, translation value, or what-have-you. Then, I decide I don't like it, and now, I have to change twenty locations in order to make that simple change. Constants would be a valuable shorthand, and really, they could be done not as an addition to the CFDG, but as a pre-processor directive. A literal substitution a la C pre-processor commands.

Posted: Sun Jul 10, 2005 9:07 am
by MtnViewJohn
How about if we had a menu called 'Library' which worked like the Examples menu but it just was built from the contents of some directory? You could put all your templates in a directory, tell Context Free where it is, and Context Free would enumerate the cfdg files under it and make a menu. We could even make it heirarchical.

Global constants are not a problem. Yevgen Korshykov has them in his online version of CFDG: http://www.korsh.com/cfdg/. I can see Context Free copying that. Also, it would be nice to have expressions. How many people look at 0.866 and see SQRT(3)/2?

Posted: Sun Jul 10, 2005 10:20 am
by t3knomanser
That's a fine solution for templates. And expressions would also be really cool, but it would certainly complicate the parser a great deal.

Posted: Sun Jul 10, 2005 10:26 am
by aaronstj
Expressions actually aren't that bad under lex/yacc. They're a cool little pair of programs, worth checking out how they work. And since yacc is used to parse context free grammars, it's very relevant.