URL compiler

It is able to expand a given URL in a combinatorial set of URLs, which may be interpreted either as indexes or as files.

The given URL is parsed against a grammar, which identifies some portions of it as expressions.

Since an expression denotes a sequence of values, the given URL is expanded into a collection of strings, considering each value for each expression.

The following picture describes the expansion mechanism, in the case that the given URL contains the expressions [“a”,”b”] and [“c”,”d”]

The URL expansion mechanism

Introduction to expressions

An expression is a portion of the given URL, which is delimited by a couple of square brackets. It denotes a sequence of values, which are used to expand the given URL into a collection of strings.

Synopsis A simple expression is a comma-separated list of elements. It denotes the sequence of values, obtained merging the sequences, which are denoted by each element.

[element1, element2, ..., elementN]

Elements may be:

  • ranges
  • strings

Ranges

A range is a multi-valued element which denotes a sequence of integers.

Synopsis

left [ - right ][ { step [ , width [ , padding ] ] } ] 

Each couple of brackets denotes an optional part of the syntax

  • left [mandatory] –> The left extreme of the range
  • right –> The right extreme of the range
  • step –> The difference between two consecutive values (default: 1)
  • width –> The minimum field width (default: 0, that is to say no padding is applied)
  • padding –> The padding character (default: “0”)

Examples

 1 denotes 1

1{1,5} denotes 00001

999{1,2} denotes 999

1-10 denotes 1, 2, 3, ..., 10

1-10{2} denotes 1, 3, 5, ... 9

1-10{2,2} denotes 01, 03, 05, ... 09

1-10{2,2,"*"} denotes *1, *3, *5, ... *9 

Strings

A string is a sequence of zero or more characters surrounded by double quotation marks (”). It is a single-valued element which denotes the same sequence of characters.

Synopsis

"characters"  

Examples

"string" denotes string  

References

The given URL may be interpreted as a sequence of expressions, which are alternated with literals (which are a sequence of characters between two consecutive expressions).

For example, in the following url the two expressions are colored in bold: http://www.fioreltech.net/[1-10]/hello/[1-10]

The expressions are indexed from left to right starting from zero. A reference to an expression is a token of the form \n, where n is the index of the referenced expression.

A reference cannot point either directly or indirectly the expression which contains it.

Synopsis

[\n]

The expression expands to the same value as the n-th expression.

[\n : sequence]

The expression expands to the i-th value of the sequence when the n-th expression expands to its i-th value.

Sequence is a comma-separated list of elements, which denotes a sequence of as much values as the referenced expression.

In both cases the expansion is conditioned by the referenced expression so that the first expression has just a value for each expansion of the second expression.

Examples

http://www.fioreltech.net/[1-12{1,2}]/[\0 : "january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november","december"]/index.html  

expands to

 http://www.fioreltech.net/01/january/index.html
http://www.fioreltech.net/02/february/index.html
http://www.fioreltech.net/03/march/index.html
http://www.fioreltech.net/04/april/index.html
http://www.fioreltech.net/05/may/index.html
http://www.fioreltech.net/06/june/index.html
http://www.fioreltech.net/07/july/index.html
http://www.fioreltech.net/08/august/index.html
http://www.fioreltech.net/09/september/index.html
http://www.fioreltech.net/10/october/index.html
http://www.fioreltech.net/11/november/index.html
http://www.fioreltech.net/12/december/index.html