1

I want to understand the valid formats of timeExpressions in TTML. This section of the specification describes the syntax. Here is an extract:

<timeExpression>
  : clock-time
  | offset-time

clock-time
  : hours ":" minutes ":" seconds ( fraction | ":" frames ( "." sub-frames )? )?

offset-time
  : time-count fraction? metric

hours
  : <digit> <digit>
  | <digit> <digit> <digit>+

                                    -- ✂ --

I the nomenclature of the document is familiar to some extent, e.g. I understand:

  • | means OR
  • (...) groups
  • ? means optional

but what does + mean?


I would assume it means 'one or more' as it does in a regex but, if that were the case, why would the specification read:

hours
  : <digit> <digit>
  | <digit> <digit> <digit>+

Instead of simply:

hours
  : <digit> <digit>+
Mogsdad
  • 44,709
  • 21
  • 151
  • 275
Pocketsand
  • 1,261
  • 10
  • 15
  • That doc says it uses Kleene operators and in that grammar `+` does mean one-or-more. Perhaps they chose 2 representations to make it clearer that leading zeros are required. – Alex K. Aug 24 '17 at 11:47
  • 1
    Ahhh, yes, thank you. That would make sense. If you want to put that in an answer I will accept it. – Pocketsand Aug 24 '17 at 11:58

2 Answers2

3

The doc states that:

The allowed content of the information item is shown as a grammar fragment, using the Kleene operators ?, * and +.

And in that grammar + does mean one-or-more.

As hours needs to be zero padded for values < 10, perhaps the two definitions are intended to illustrate that.

Alex K.
  • 171,639
  • 30
  • 264
  • 288
1

The + means that one or more of the fragments may be present. The reason for making the distinction between 2 digit hours and 3-or-more digits hours components is I believe to hint that in some timebases the hours can be 2 digit only, whereas in others they can be more. In either case though, the minimum number of digits is 2. I agree that just showing <digit> <digit>+ would effectively mean the same thing but it wouldn't carry the subtle connotation that sometimes the maximum number of digits is 2.

The reason the "2 or more digits" entry doesn't say <digit> <digit> | <digit> <digit> <digit>* is that the two would be indistinguishable when 2 digits are present. This is a nicety though, as far as I can tell.

Nigel Megitt
  • 158
  • 5