Difference between revisions of "User:8680/tmp/AnimationWMLProgressiveStringSquareBracketExpansionSyntax"

From The Battle for Wesnoth Wiki
Line 7: Line 7:
 
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”).
 
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 =====
+
==== 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''.
+
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 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”.
Line 15: Line 15:
 
If ''x'' = ''y'', then this list has only one element, which is ''x''. E.g., “2~2” would becomes “2”.
 
If ''x'' = ''y'', then this list has only one element, which is ''x''. E.g., “2~2” would becomes “2”.
  
If either ''x'' or ''y'' are padded with leading zeros, then each number in the resultant list will be padded with leading zeros such that it is expressed in as many digits as the endpoint (either of ''x'' or ''y'') that is padded with the most leading zeros. E.g., “07~11” would become “07,08,09,10,11”, and “003~1” would become “003,002,001”.
+
If either ''x'' or ''y'' are padded with leading zeros, then each number in the resultant list will be padded with leading zeros such that it is expressed in as many digits as the endpoint (either of ''x'' or ''y'') that is padded with the most leading zeros. E.g., “07~11” would become “07,08,09,10,11”, and “003~1” (or “3~001”) would become “003,002,001”.
  
====== Square bracket expansion ======
+
==== 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.
 
A single progressive string value may contain multiple square-bracketed expansion lists, which must all be of the same length in elements.

Revision as of 07:04, 10 February 2014

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

  1. a plain string — e.g., “abc” or “123”;
  2. a range, expressed as two radix-10 integers, separated by a tilde — e.g., “1~5”; or
  3. 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. E.g., “2~2” would becomes “2”.

If either x or y are padded with leading zeros, then each number in the resultant list will be padded with leading zeros such that it is expressed in as many digits as the endpoint (either of x or y) that is padded with the most leading zeros. E.g., “07~11” would become “07,08,09,10,11”, and “003~1” (or “3~001”) would become “003,002,001”.

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.

When a progressive string that contains expansion lists is processed to expand its expansion lists, it is transformed into a comma-separated list, which is generated as follows:

For each integer n from 1 to L, where L is the length in elements of each expansion list:

If