preproc.c: Introduce macros parameters range expansion
commitc29404d7bad7308218ef04b8c22d4d9c54adbfad
authorCyrill Gorcunov <gorcunov@gmail.com>
Fri, 4 Jun 2010 21:50:23 +0000 (5 01:50 +0400)
committerCyrill Gorcunov <gorcunov@gmail.com>
Fri, 4 Jun 2010 21:50:59 +0000 (5 01:50 +0400)
tree33fd5c7b5a2eef8cb0f5c29548161c2834f7e113
parentca61119a01fd7174368a0144b6b5fe96ee2a26df
preproc.c: Introduce macros parameters range expansion

Introduce an ability to expand multi-line macros parameters in
a range/sequence manner.

For this purpose a special form is introduced %{x:y} which means to
expand %{x:y} to %{x},%{x+1},%{x+2},...,%{y}.

Both arguments could be negative or positive but MUST NOT be zero.

The arguments take into account possible %rotate as well.

Note that unlike the approach implemented in yasm we refer :-1 as
_last_ argument passed to a macro call, this makes possible to refer
the last element from macro via record as %{-1:-1} which could be
a convenient trick.

Also you can refer the argument in reverse order, ie it's legitime
to write %{5:4}, or even to reverse the all arguments %{-1:1}.

An example

 |
 | %macro mpar 1-*
 |     db %{1:-2}
 | %endmacro
 |
 | mpar 1,2,3,4,5,6

in result we'll get the sequence of 1,2,3,4,5

Reported-by: nasm64developer <nasm64developer@users.sf.net>
Inspired-by: Mathieu Monnier <mathieu.monnier@polytechnique.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
preproc.c