Grammar of Time Series