PageRenderTime 21ms CodeModel.GetById 16ms app.highlight 1ms RepoModel.GetById 2ms app.codeStats 0ms

/xbmc/visualizations/Milkdrop/vis_milkdrop/evallib/readme.txt

http://github.com/xbmc/xbmc
Plain Text | 112 lines | 75 code | 37 blank | 0 comment | 0 complexity | 2164029484b5cdeb95264ac6b70a8bac MD5 | raw file
  1
  2  Expression evaluation library v1.0 - by lone
  3  --------------------------------------------
  4
  5
  6    How to use
  7    ~~~~~~~~~~
  8
  9 
 10      ? resetVars
 11      -----------
 12
 13      void resetVars(void);
 14
 15      Resets the variables table. It is necessary to call it prior to evaluate your first
 16      expression or variables contents may be random instead of zero
 17
 18
 19      ? evaluate
 20      ----------
 21
 22      double evaluate(char *expression, int *col);
 23
 24      Evaluates an expression and returns the result.
 25      If a syntax error was encountered during the parsing of the expression, then col will
 26      be non-null and col-1 will be the index of the char which triggered the error.
 27
 28
 29    Limitations
 30    ~~~~~~~~~~~
 31
 32       ? you can set only up to 1024 variables.
 33       ? only decimal and hexadecimal bases available
 34       ? operators are limited to :
 35               + - / * % & | 
 36       ? functions are limited to :
 37               sin, cos, tan,
 38               asin, acos, atan,
 39               atan2, sqr, sqrt,
 40               pow, exp, log, log10
 41
 42
 43    Some examples
 44    ~~~~~~~~~~~~~
 45
 46      - assignments :
 47
 48               pi=3.1415927
 49               a=atan2(cos(pi/4),2)
 50
 51      - direct evaluations :
 52
 53               cos(pi/4)
 54               sin(45)
 55
 56      - base notations :
 57
 58               3bh      (this is 0x3B)
 59               17d      (this is 17)   
 60               17dh     (this is 0x17D) 
 61
 62
 63    Adding new functions
 64    ~~~~~~~~~~~~~~~~~~~~
 65
 66       The file EVAL.C contains the functions table (fnTable). Just add an entry with the name,
 67       the number of parameters, and a pointer to the function body. Implement the body and
 68       you're done. If your function ahs more than 2 parameters, you'll need to extend the grammar
 69       description file (CAL.Y) to add the FUNCTION3 (and eventually subsequent) token(s) and
 70       parsing informations.
 71
 72    SCAN.L & CAL.Y
 73    ~~~~~~~~~~~~~~
 74
 75       SCAN.L contains description for the lexical analyzer generator (LEX). Use makel.bat to rebuild
 76              LEXTAB.C
 77       CAL.Y  contains the LALR formal grammar description for the parser generator (BISON). Use makey.bat
 78              to rebuild CAL_TAB.C
 79
 80
 81    Compiling
 82    ~~~~~~~~~
 83
 84       Just include all source files to your project, and include EVAL.H into your main source code.
 85
 86License
 87-------
 88Copyright 2005 Nullsoft, Inc.
 89All rights reserved.
 90
 91Redistribution and use in source and binary forms, with or without modification, 
 92are permitted provided that the following conditions are met:
 93
 94  * Redistributions of source code must retain the above copyright notice,
 95    this list of conditions and the following disclaimer. 
 96
 97  * Redistributions in binary form must reproduce the above copyright notice,
 98    this list of conditions and the following disclaimer in the documentation
 99    and/or other materials provided with the distribution. 
100
101  * Neither the name of Nullsoft nor the names of its contributors may be used to 
102    endorse or promote products derived from this software without specific prior written permission. 
103 
104THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR 
105IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
106FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
107CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
108DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
109DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
110IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 
111OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
112