Quote:
Originally Posted by eschwartz
Thanks chaley! I made a typo. 
|
Easy to do.
Quote:
Fixed in my post, too. I even added an explanation -- is it good?
|
I am the wrong person to ask. Because of a misspent youth studying formal regular languages in the 70s I very much prefer something like
extended BNF notation for the syntax of regular languages. I struggle with textual descriptions, translating them in my head to figure out how the language parses. That said, reading yours, it seems correct.
FWIW: here is an extended BNF-like grammar for templates. Text in quotes represent tokens. The square brackets indicate what is between them is optional. I didn't bother with the grammar for the functions. The two variants could be easily expressed in one grammar but I chose not to introduce the or (|) operator.
Code:
"{" [ "field name" ] [ [ ":" [ "formatting" ] ] [ ":" "single Function" ] [ "|" [ "prefix" ] "|" [ "suffix" ] ] ] "}"
or
"{" [ "field name" ] [ [ ":" [ "formatting" ] ] [ ":'" "Template Program" "'" ] [ "|" [ "prefix" ] "|" [ "suffix" ] ] ] "}"
Some interesting things to note. According to the grammar:
- {} is a valid template. This is true.
- {:} is also a valid template.
- {::'function()'} is valid
- {::function()} is valid but probably meaningless for semantic reasons. There is no value to pass as the implied first argument.
Well, enough fun.