User:8680/tmp/AnimationWMLProgressiveStringSquareBracketExpansionSyntax

From The Battle for Wesnoth Wiki
Revision as of 23:56, 14 February 2014 by 8680 (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Each set of square brackets (‘[’ and ‘]’) contains a comma-separated list — an expansion list — of which each element can be:

  • a plain string — e.g., “abc” or “123”;
  • a range, expressed as two radix-10 integers, separated by a tilde — e.g., “1~5”; or
  • a repetition, notated as a string and a radix-10 integer, separated by an asterisk — e.g., “a*3”.

Ranges can not only be from a lesser number to a greater number (e.g., “1~5”), but can also be backward — from a greater number to a lesser number (e.g., “5~1”).

Range expansion

Each range x~y is expanded within its expansion list to a comma-separated list of radix-10 integers (which are plain strings), starting from the first endpoint x and ending at the second endpoint y.

If x < y, then the numbers in this list increase by increments of 1; if x > y, then the numbers in this list decrease by decrements of 1. E.g., “1~3” would become “1,2,3”, and “3~1” would become “3,2,1”.

If x = y, then this list has only one element, which is x (and is also y, of course). E.g., “2~2” would becomes “2”.

If either x or y (or both) are padded with leading zeros, then each number in the resultant list will be padded with leading zeros such that it is expressed in at least z+1 digits, where z is the quantity of leading zeros with which one or both endpoints are padded. E.g.,

  • “07~11” would become “07,08,09,10,11”,
  • “098~100” would become “98,99,100”,
  • “0098~100” would become “098,099,100”, and
  • “003~1” (or “3~001”) would become “003,002,001”.

If both endpoints are padded with leading zeros, they should both be padded with the same quantity of leading zeros.

Repetition expansion

Each repetition s*n is expanded within its expansion list to a comma-separated list with n elements, each of which is the string s. E.g., “abc*3” would become “abc,abc,abc”.

Square bracket expansion

A single progressive string value may contain multiple square-bracketed expansion lists, which must all be of the same length in elements (after range and repetition expansion). This length shall be referred to as L for the remainder of this section.

When a progressive string that contains expansion lists is processed to expand its expansion lists, it is transformed into a comma-separated list with L elements.

For each integer n from 1 to L, the n-th element of this list shall be a copy of the progressive string, with each expansion list it contains replaced with that expansion list’s n-th element (after range and repetition expansion).

This page was last edited on 14 February 2014, at 23:56.