View Single Post
Old 04-01-2021, 04:19 PM   #11
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: 11,778
Karma: 7029857
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Question:
What is B used for? In the templates I have that use it, it's just null ''s.
I am probably giving you more than you want to know.

That notation describes the "form" of valid calls of the function. It uses 'placeholders' to distinguish between different values. The notation "[, something]" says that the ", something" is optional: zero or one occurrence of what is between the brackets. The notation "[, something]*" says that it is optional but you can have zero to "a lot" of occurrences. Often "somethings" with the same name are the same thing, while "somethings" with different names are not necessarily the same thing.

The notation is an approximation of a formal grammar. I tend to use approximations of EBNF grammars. In this formal system, things that are literal would be in quotes. In that case, what you referenced should be formally written
Code:
'strcat' '(' expression [ ',' expression ]* ')'
where the word 'expression' refers to another grammar element describing what it can be. I often use approximations because I am lazy.

This template language grammar is intended to be formal. I think it is correct but I haven't put it through a grammar verifier to be sure.

Taking all the above together, "strcat(a, [, b]*)" says that the literal 'strcat' is followed by:
  • a literal '('
  • a value, whatever that is. I used 'a' for 'expression'
  • a sequence of zero or more
    • a literal comma
    • a value. I used 'b' to say it need not be the same as 'a'.
  • a literal ');
chaley is offline   Reply With Quote