Pocketsand
Pocketsand

Reputation: 1281

What does '+' mean in W3C syntax representation for TTML timeExpression?

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:

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>+

Upvotes: 1

Views: 73

Answers (2)

Nigel Megitt
Nigel Megitt

Reputation: 158

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.

Upvotes: 1

Alex K.
Alex K.

Reputation: 175796

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.

Upvotes: 3

Related Questions