exp - a multiple expession calculator.
exp [-vn0..4] [-o output-file] [input-file]
Input is an ascii format file including numeric expessions with variables. Input file can includes other input files thanks to an inclusion directive. exp reads the input files to write it as is in the output file, but the numeric expessions are replaced by their value.
-v verbose mode 0 : quiet mode 1 : messages mess(...) are printed 2 : few statistics 3 : all expressions are decomposed 4 : yacc messages -o output-file where exp writes (stdout by default). input-file where exp reads (stdin by default).
Except the expessionsi and offline comments, the output file is identical to the flattened view of the input files whatever they are. The expession forms can be either [expessions] or {expessions}. The first form is for floating point expessions, the second one is for integer expessions. By default, the print format is respectively %7.3f and %4d (cf. sprintf(3)). Offline comments begins with // and ends at the beginning of the next line. Examples · [ 3.0 + 12.1] print 15.100 · { 3.0 + 12.1} print 15 It is possible to have more that one expession separated by ; (semi- column). All the expessions of a list are computed, but only the last one is printed. If the last expession is empty, exp do not print anything (see Examples section). Examples · [ 6. *2.0; 3.0 + 12.1 ] print 15.100 · [ 6. *2.0; 3.0 + 12.1; ] print nothing It is possible to have comments in expessions. A comment begins with # (diese) and ends to the carriage return. Comment in expression is not copied to the output file. Example · [ 3.0 + 12.1 # comment ] print 15.100 Expessions Expession is a multi-level numeric expession using numbers, variables, arithmetic operators and numeric functions. Examples · [ i=3.0; i*12.1] print 15.100 · {i=3} print 3 {i++} print 4 Arithmetic Operators The operators, in order of increasing priority, are + - Addition and subtraction. * / Multiplication and division. ++ -- post-incrementation of 1, post-decrementation of 1. ( ) Grouping = Variable affectation. The return value is the one affected. Boolean Operators > < respectively greater than and lower than def(variable) True whenever variable is defined yet ndef(variable) True whenever variable is not defined yet Variables Expession values may be stored in simple variables. There are three forms of variable name. First, they can begin with a letter followed by any number of letters, digits and underscores; second, they can begin with " (double quote) followed by any number of any char and ended by a "; Third they can begin with �� (quote) then a regular expression (see regex(7)) ended by ��. exp is case sensitive. Examples · [ VAR_1=3.0; # first form "variable numero 2"=12.0; # second form ] print nothing · [ VAR_1 * "variable numero 2" ] print 15.100 When a variable appears in the right member of an affectation, exp uses its value. If it has never been defined, this causes a fatal error. If it appears the left member, the first time it is automatically created and its value is set, or its value is changed. Special variables float_fmt, integer_fmt and string_fmt special variables to redefine print format of floats, integers and strings. Defaults are %7.3f, %-8s and %4d. Those variables are the only variables with a non numerical value. Examples · [float_fmt = "%7.1f";] print nothing · [ 3.0 + 12.1] print 15.1 verbose is the variable passed in argument list, which can be modified by the program itself. Examples get details of expression calculation · [tmp = verbose; verbose = 3; ..expressions..; verbose = tmp;] Numeric functions Few numeric functions are available. The form is fun(args). The arguments take the form of a list of expessions, separated with a , (comma). The number of arguments depends on functions. It is possible to make a list of arguments with a regular expession (see regex(7)). Then all matching variable names are part of the list. min(args) max(args) The minimum (resp. maximum) value of its arguments. Examples · [min(3.0,12.1)] print 3.000 · [min('RW_ALU.*')] print min value of all variables begining by RW_ALU inf(step,val) sup(step,val) Two arguments. inf (resp. sup) function rounds the second argument (val) downwards (resp. upwards) to an integer number of the first argument (step). Examples · [step=0.3;value=1.6;inf(step,value)] print 1.500 Special functions and directives if(condition, expr1, expr2, ...) Calculates the condition if it is true (means greater than zero), the following expressions are all calculated. sort(args) rsort(args) sort (resp. reverse rsort) numerically all its arguments, each argument must be a variable, not directly a numeric expession. The return value is the sorted list of its arguments. message(args) writes its arguments to stdout using float_fmt, one argument per line. The form is : variable_name = value;, value is omitted if the variable has never been defined. Examples · [message('"'this is a message'"');] print this is a message · [a1b=0; a2b=1O; a3b=5; message(a*b);] print a1b = 0.000 a2b = 1O.000 a3b = 5.000 · [string_fmt=%6s; message(sort(a*b));] print a1b = 0.000 a3b = 5.000 a2b = 1O.000 #include "filename" Opens the file in argument then returns to the current file as soon as the new one is empty.
Input file # this is a test file [ # few variables WITDH = 2; LENGTH = 25 ; ] this message is unchanged but all expresions are computed length_div_2 = [LENGTH/2] length_mul_2 = {LENGTH*2} result = [max ('leng.*')] Output file # this is a test file this message is unchanged but all expresions are computed length_div_2 = 12.500 length_mul_2 = 50 result = 12.500
Written by Franck Wajsburt.
Alliance .rds file uses exp to be generated.
Personal Opportunity - Free software gives you access to billions of dollars of software at no cost. Use this software for your business, personal use or to develop a profitable skill. Access to source code provides access to a level of capabilities/information that companies protect though copyrights. Open source is a core component of the Internet and it is available to you. Leverage the billions of dollars in resources and capabilities to build a career, establish a business or change the world. The potential is endless for those who understand the opportunity.
Business Opportunity - Goldman Sachs, IBM and countless large corporations are leveraging open source to reduce costs, develop products and increase their bottom lines. Learn what these companies know about open source and how open source can give you the advantage.
Free Software provides computer programs and capabilities at no cost but more importantly, it provides the freedom to run, edit, contribute to, and share the software. The importance of free software is a matter of access, not price. Software at no cost is a benefit but ownership rights to the software and source code is far more significant.
Free Office Software - The Libre Office suite provides top desktop productivity tools for free. This includes, a word processor, spreadsheet, presentation engine, drawing and flowcharting, database and math applications. Libre Office is available for Linux or Windows.
The Free Books Library is a collection of thousands of the most popular public domain books in an online readable format. The collection includes great classical literature and more recent works where the U.S. copyright has expired. These books are yours to read and use without restrictions.
Source Code - Want to change a program or know how it works? Open Source provides the source code for its programs so that anyone can use, modify or learn how to write those programs themselves. Visit the GNU source code repositories to download the source.
Study at Harvard, Stanford or MIT - Open edX provides free online courses from Harvard, MIT, Columbia, UC Berkeley and other top Universities. Hundreds of courses for almost all major subjects and course levels. Open edx also offers some paid courses and selected certifications.
Linux Manual Pages - A man or manual page is a form of software documentation found on Linux/Unix operating systems. Topics covered include computer programs (including library and system calls), formal standards and conventions, and even abstract concepts.