Skip to content
Snippets Groups Projects
Commit cfee93b0 authored by Houtan Bastani's avatar Houtan Bastani
Browse files

preprocessor: submodule update: macro functions

parent ec3e32a1
Branches
Tags
No related merge requests found
...@@ -10587,8 +10587,8 @@ strings. ...@@ -10587,8 +10587,8 @@ strings.
   
It is possible to construct macro-expressions which can be assigned to It is possible to construct macro-expressions which can be assigned to
macro-variables or used within a macro-directive. The expressions are macro-variables or used within a macro-directive. The expressions are
constructed using literals of the four basic types (integers, strings, constructed using literals of five basic types (integers, strings, arrays of
arrays of strings, arrays of integers), macro-variables names and strings, arrays of integers, and string functions), macro-variable names, and
standard operators. standard operators.
   
String literals have to be enclosed between @strong{double} quotes String literals have to be enclosed between @strong{double} quotes
...@@ -10651,6 +10651,14 @@ getting the length of an array: @code{length} operator (for example: ...@@ -10651,6 +10651,14 @@ getting the length of an array: @code{length} operator (for example:
@code{[1,2,3]}) @code{[1,2,3]})
@end itemize @end itemize
   
The following operators can be used on string functions:
@itemize
@item
comparison operators: @code{==}, @code{!=}
@item
concatenation of two strings: @code{+}
@end itemize
Macro-expressions can be used at two places: Macro-expressions can be used at two places:
@itemize @itemize
@item @item
...@@ -10706,7 +10714,7 @@ file will be searched for in the folders provided by @ref{-I} and ...@@ -10706,7 +10714,7 @@ file will be searched for in the folders provided by @ref{-I} and
@end deffn @end deffn
   
@deffn {Macro directive} @@#define @var{MACRO_VARIABLE} = @var{MACRO_EXPRESSION} @deffn {Macro directive} @@#define @var{MACRO_VARIABLE} = @var{MACRO_EXPRESSION}
Defines a macro-variable. Defines a macro-variable or macro-function
   
@customhead{Example 1} @customhead{Example 1}
@example @example
...@@ -10716,6 +10724,8 @@ Defines a macro-variable. ...@@ -10716,6 +10724,8 @@ Defines a macro-variable.
@@#define w = [ "US", "EA" ] // String array @@#define w = [ "US", "EA" ] // String array
@@#define z = 3 + v[2] // Equals 5 @@#define z = 3 + v[2] // Equals 5
@@#define t = ("US" in w) // Equals 1 (true) @@#define t = ("US" in w) // Equals 1 (true)
@@#define f(x) = " + @@@{x@} + @@@{y@}" // Defines a function 'f' with argument 'x'
// that returns the string: ' + @@@{x@} + US'
@end example @end example
   
@customhead{Example 2} @customhead{Example 2}
...@@ -10723,15 +10733,16 @@ Defines a macro-variable. ...@@ -10723,15 +10733,16 @@ Defines a macro-variable.
@example @example
@@#define x = [ "B", "C" ] @@#define x = [ "B", "C" ]
@@#define i = 2 @@#define i = 2
@@#define f(x) = " + @@@{x@}"
   
model; model;
A = @@@{x[i]@}; A = @@@{x[i] + f("D")@};
end; end;
@end example @end example
is strictly equivalent to: is strictly equivalent to:
@example @example
model; model;
A = C; A = C + D;
end; end;
@end example @end example
   
......
Subproject commit e376267a2867aff79989503f77a2fd2204ed9c8b Subproject commit 244552393baec541e0d02a2c378a21a6c9409989
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment