1EXP(1.0)                                                              EXP(1.0)
2
3
4

EXP

6       exp - a multiple expession calculator.
7
8
9

SYNOPSIS

11       exp [-vn0..4] [-o output-file] [input-file]
12
13

DESCRIPTION

15       Input  is  an ascii format file including numeric expessions with vari‐
16       ables.  Input file can includes other input files thanks to  an  inclu‐
17       sion  directive.   exp  reads  the input files to write it as is in the
18       output file, but the numeric expessions are replaced by their value.
19
20

OPTIONS

22       -v     verbose mode
23              0 : quiet mode
24              1 : messages mess(...) are printed
25              2 : few statistics
26              3 : all expressions are decomposed
27              4 : yacc messages
28
29       -o output-file
30              where exp writes (stdout by default).
31
32       input-file
33              where exp reads (stdin by default).
34
35

EXP FORMAT FILES

37       Except the expessionsi and offline comments, the output file is identi‐
38       cal  to  the  flattened view of the input files whatever they are.  The
39       expession forms can be either [expessions] or {expessions}.  The  first
40       form  is  for  floating point expessions, the second one is for integer
41       expessions. By default, the print format is respectively %7.3f and  %4d
42       (cf.  sprintf(3)).   Offline  comments  begins  with // and ends at the
43       beginning of the next line.
44
45       Examples
46
47       ·  [ 3.0 + 12.1] print 15.100
48
49       ·  { 3.0 + 12.1} print 15
50
51       It is possible to have more that one expession separated  by  ;  (semi-
52       column).  All  the expessions of a list are computed, but only the last
53       one is printed. If the last expession is empty, exp do not  print  any‐
54       thing (see Examples section).
55
56       Examples
57
58       ·  [ 6. *2.0;
59            3.0 + 12.1 ] print 15.100
60
61       ·  [ 6. *2.0;
62            3.0 + 12.1; ] print nothing
63
64       It  is possible to have comments in expessions. A comment begins with #
65       (diese) and ends to the carriage return.  Comment in expression is  not
66       copied to the output file.
67
68       Example
69
70       ·  [ 3.0 + 12.1 # comment
71          ] print 15.100
72
73
74   Expessions
75       Expession  is a multi-level numeric expession using numbers, variables,
76       arithmetic operators and numeric functions.
77
78       Examples
79
80       ·  [ i=3.0; i*12.1] print 15.100
81
82
83       ·  {i=3} print 3
84          {i++} print 4
85
86   Arithmetic Operators
87       The operators, in order of increasing priority, are
88
89
90       + -    Addition and subtraction.
91
92       * /    Multiplication and division.
93
94       ++ --  post-incrementation of 1, post-decrementation of 1.
95
96       ( )    Grouping
97
98       =      Variable affectation. The return value is the one affected.
99
100
101   Boolean Operators
102       > <    respectively greater than and lower than
103
104       def(variable)
105              True whenever variable is defined yet
106
107       ndef(variable)
108              True whenever variable is not defined yet
109
110
111   Variables
112       Expession values may be stored in simple variables.   There  are  three
113       forms  of  variable name.  First, they can begin with a letter followed
114       by any number of letters, digits  and  underscores;  second,  they  can
115       begin  with  "  (double  quote)  followed by any number of any char and
116       ended by a "; Third they can  begin  with  ´  (quote)  then  a  regular
117       expression (see regex(7)) ended by ´.  exp is case sensitive.
118
119       Examples
120
121       ·  [ VAR_1=3.0;                # first form
122            "variable numero 2"=12.0; # second form
123          ] print nothing
124
125       ·  [ VAR_1 * "variable numero 2" ] print 15.100
126
127       When a variable appears in the right member of an affectation, exp uses
128       its value. If it has never been defined, this causes a fatal error.  If
129       it  appears the left member, the first time it is automatically created
130       and its value is set, or its value is changed.
131
132
133   Special variables
134       float_fmt, integer_fmt and string_fmt  special  variables  to  redefine
135       print  format of floats, integers and strings. Defaults are %7.3f, %-8s
136       and %4d. Those variables are the only variables with  a  non  numerical
137       value.
138
139       Examples
140
141       ·  [float_fmt = "%7.1f";] print nothing
142
143       ·  [ 3.0 + 12.1] print 15.1
144
145       verbose  is the variable passed in argument list, which can be modified
146       by the program itself.
147
148       Examples  get details of expression calculation
149
150       ·  [tmp = verbose; verbose = 3; ..expressions..;
151          verbose = tmp;]
152
153   Numeric functions
154       Few numeric functions are available. The form is fun(args).  The  argu‐
155       ments  take  the  form  of  a  list  of  expessions, separated with a ,
156       (comma). The number of arguments depends on functions.  It is  possible
157       to  make  a  list of arguments with a regular expession (see regex(7)).
158       Then all matching variable names are part of the list.
159
160       min(args) max(args)
161              The minimum (resp. maximum) value of its arguments.
162
163              Examples
164
165              ·  [min(3.0,12.1)] print 3.000
166
167              ·  [min('RW_ALU.*')] print min value of all variables  beginning
168                 by RW_ALU
169
170
171       inf(step,val) sup(step,val)
172              Two  arguments. inf (resp. sup) function rounds the second argu‐
173              ment (val) downwards (resp.  upwards) to an  integer  number  of
174              the first argument (step).
175
176              Examples
177
178              ·  [step=0.3;value=1.6;inf(step,value)] print 1.500
179
180
181   Special functions and directives
182       if(condition, expr1, expr2, ...)
183              Calculates  the  condition  if  it  is  true (means greater than
184              zero), the following expressions are all calculated.
185
186       sort(args) rsort(args)
187              sort (resp. reverse rsort) numerically all its  arguments,  each
188              argument  must  be a variable, not directly a numeric expession.
189              The return value is the sorted list of its arguments.
190
191       message(args)
192              writes its arguments to stdout using float_fmt, one argument per
193              line.  The form is : variable_name = value;, value is omitted if
194              the variable has never been defined.
195              Examples
196
197              ·  [message('"'this is a message'"');] print
198                 this is a message
199
200              ·  [a1b=0; a2b=1O; a3b=5; message(a*b);] print
201                 a1b      =  0.000
202                 a2b      = 1O.000
203                 a3b      =  5.000
204
205              ·  [string_fmt=%6s; message(sort(a*b));] print
206                    a1b =  0.000
207                    a3b =  5.000
208                    a2b = 1O.000
209
210
211       #include "filename"
212              Opens the file in argument then returns to the current  file  as
213              soon as the new one is empty.
214
215

EXAMPLES

217       Input file
218              # this is a test file
219              [ # few variables
220                WITDH = 2;
221                LENGTH = 25 ;
222              ]
223              this message is unchanged but all expressions are computed
224                length_div_2 = [LENGTH/2]
225                length_mul_2 = {LENGTH*2}
226                result = [max ('leng.*')]
227
228       Output file
229              # this is a test file
230
231              this message is unchanged but all expressions are computed
232                length_div_2 =   12.500
233                length_mul_2 =   50
234                result =   12.500
235
236

AUTHOR

238       Written by Franck Wajsburt.
239
240

SEE ALSO

242       Alliance .rds file uses exp to be generated.
243
244
245
246
247UPMC/ASIM/LIP6                  March 18, 2002                        EXP(1.0)
Impressum