View Single Post
Old 05-19-2014, 11:50 AM   #9
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,449
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by eschwartz View Post
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.

Last edited by chaley; 05-19-2014 at 12:39 PM. Reason: Fixed grammar. See next post for details.
chaley is offline   Reply With Quote