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