diff -r 2140694fd9aa Makefile.am --- a/Makefile.am Wed Aug 14 21:03:23 2013 +0200 +++ b/Makefile.am Thu Jun 05 18:11:24 2014 +0200 @@ -1,5 +1,5 @@ # Copyright (C) 1999, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2011, -# 2012, 2013 Free Software Foundation, Inc. +# 2012, 2013, 2014 Free Software Foundation, Inc. # # This file is part of GNU libmatheval # @@ -27,7 +27,10 @@ MAINTAINERCLEANFILES = Makefile.in aclocal.m4 configure config.h.in \ config.log config.status stamp-h.in $(AUX_DIST) -SUBDIRS = doc lib tests +if ENABLE_GUILE + guile_test=tests +endif +SUBDIRS = doc lib $(guile_test) pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libmatheval.pc diff -r 2140694fd9aa NEWS --- a/NEWS Wed Aug 14 21:03:23 2013 +0200 +++ b/NEWS Thu Jun 05 18:11:24 2014 +0200 @@ -1,11 +1,24 @@ Copyright (C) 1999, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2011, -2012, 2013 Free Software Foundation, Inc. +2012, 2013, 2014 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. +Version 2014.1.0 + +* Added evaluator_evaluate2 +* Forked from the original GNU libmatheval branch +* Added option for enabling support of GNU guile. Although it as now point + for most users, dropping GNU guile would have been stupid. The test suite + will not be functionnal anymore if GNU guile is not used, however. +* Removed dependency on yywrap, and so on @address@hidden +* Modified options for LEX/YACC parser generators in order to make parser's + symbols to be prefixed. This enables to link libmatheval in with project that + use other LEX/YACC-generated parsers. + + Version 1.1.11 * Fixed issue with linking Lex library. diff -r 2140694fd9aa configure.in --- a/configure.in Wed Aug 14 21:03:23 2013 +0200 +++ b/configure.in Thu Jun 05 18:11:24 2014 +0200 @@ -1,7 +1,8 @@ dnl Copyright (C) 1999, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2011, dnl 2012, 2013 Free Software Foundation, Inc. +dnl Copyright (C) 2014 Romain Garbi (DarkBatcher) dnl -dnl This file is part of GNU libmatheval +dnl This file is part of libmatheval dnl dnl GNU libmatheval is free software: you can redistribute it and/or dnl modify it under the terms of the GNU General Public License as @@ -19,18 +20,31 @@ dnl Process this file with autoconf to produce a configure script. AC_PREREQ(2.53) -AC_INIT([libmatheval],[1.1.11],address@hidden) +AC_INIT([libmatheval],[2014.1.0],address@hidden) AC_CONFIG_AUX_DIR([config]) AC_CONFIG_MACRO_DIR([m4]) AC_SUBST([ac_aux_dir]) -AM_INIT_AUTOMAKE([libmatheval], [1.1.11]) +AM_INIT_AUTOMAKE([libmatheval], [2014.1.0]) AC_CONFIG_SRCDIR([configure.in]) AM_CONFIG_HEADER([config.h]) +AC_ARG_ENABLE([guile], + [AC_HELP_STRING([--enable-guile], + [Enable the use of guile.])], + [], + [enable_guile=no]) + dnl Initialize the test suite. -AC_CONFIG_TESTDIR([tests]) +dnl This suite is using GNU guile, so that if you do not specify +dnl --enable-guile, it will not work + +AS_IF([test "x$enable_guile" != "xno"], + [AC_CONFIG_TESTDIR([tests]) AC_CONFIG_FILES([tests/matheval.sh], [chmod +x tests/matheval.sh]) AC_CONFIG_FILES([tests/Makefile]) +]) + +AM_CONDITIONAL([ENABLE_GUILE], [test "x$enable_guile" = "xno"]) dnl Checks for programs. AC_PROG_CC @@ -44,7 +58,7 @@ AC_PROG_MAKE_SET AC_PROG_YACC AM_MISSING_PROG([AUTOM4TE], [autom4te]) -GUILE_FLAGS +AS_IF([test "x$enable_guile" != "xno"], [GUILE_FLAGS]) dnl Checks for libraries. @@ -60,10 +74,11 @@ AC_CHECK_FUNCS([bzero memset], [break]) dnl Additional Guile feature checks. +AS_IF([test "x$enable_guile" != "xno"],[ AC_CHECK_TYPE([scm_t_bits], [AC_DEFINE([HAVE_SCM_T_BITS], [1], [Define to 1 if you have the `scm_t_bits' type.])], [], [#include ]) AC_CHECK_LIB([guile], [scm_c_define_gsubr], [AC_DEFINE([HAVE_SCM_C_DEFINE_GSUBR], [1], [Define to 1 if you have the `scm_c_define_gsubr' function.])], [], [$GUILE_LDFLAGS]) AC_CHECK_LIB([guile], [scm_make_gsubr], [AC_DEFINE([HAVE_SCM_MAKE_GSUBR], [1], [Define to 1 if you have the `scm_make_gsubr' function.])], [], [$GUILE_LDFLAGS]) -AC_CHECK_LIB([guile], [scm_num2dbl], [AC_DEFINE([HAVE_SCM_NUM2DBL], [1], [Define to 1 if you have the `scm_num2dbl' function.])], [], [$GUILE_LDFLAGS]) +AC_CHECK_LIB([guile], [scm_num2dbl], [AC_DEFINE([HAVE_SCM_NUM2DBL], [1], [Define to 1 if you have the `scm_num2dbl' function.])], [], [$GUILE_LDFLAGS])]) AC_CONFIG_FILES([Makefile doc/Makefile lib/Makefile]) AC_OUTPUT(libmatheval.pc) diff -r 2140694fd9aa lib/Makefile.am --- a/lib/Makefile.am Wed Aug 14 21:03:23 2013 +0200 +++ b/lib/Makefile.am Thu Jun 05 18:11:24 2014 +0200 @@ -1,5 +1,5 @@ # Copyright (C) 1999, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2011, -# 2012, 2013 Free Software Foundation, Inc. +# 2012, 2013, 2014 Free Software Foundation, Inc. # # This file is part of GNU libmatheval # @@ -29,13 +29,14 @@ g77_interface.c node.c symbol_table.c xmalloc.c xmath.c libmatheval_la_LDFLAGS = -version-info 1:0:0 -libmatheval_la_LIBADD = @LEXLIB@ -lm +libmatheval_la_LIBADD = -lm include_HEADERS = matheval.h noinst_HEADERS = common.h error.h node.h symbol_table.h xmalloc.h \ xmath.h -AM_YFLAGS = -d +AM_YFLAGS = -d -p evaluator_ +AM_LFLAGS = -Pevaluator_ -olex.yy.c .PHONY: beauty diff -r 2140694fd9aa lib/matheval.c --- a/lib/matheval.c Wed Aug 14 21:03:23 2013 +0200 +++ b/lib/matheval.c Thu Jun 05 18:11:24 2014 +0200 @@ -1,284 +1,312 @@ -/* - * Copyright (C) 1999, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2011, - * 2012, 2013 Free Software Foundation, Inc. - * - * This file is part of GNU libmatheval - * - * GNU libmatheval is free software: you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * GNU libmatheval is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU libmatheval. If not, see - * . - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#include "common.h" -#include "matheval.h" -#include "node.h" -#include "symbol_table.h" - -/* Minimal length of evaluator symbol table. */ -#define MIN_TABLE_LENGTH 211 - -/* Function used to parse string representing function (this function is - * generated by parser generator). */ -extern int yyparse(); - -/* Following variables are needed for parsing (parser is able to - * communicate with program from which it is used through global variables - * only). */ -char *input_string; /* String representing function. */ -Node *root; /* Root of tree representation of - * function. */ -SymbolTable *symbol_table; /* Evaluator symbol table. */ -int ok; /* Flag determining if parsing went OK. */ - -/* Data structure representing evaluator. */ -typedef struct { - Node *root; /* Root of tree representation of - * function. */ - SymbolTable *symbol_table; /* Evalutor symbol table. */ - char *string; /* Evaluator textual representation. */ - int count; /* Number of evaluator variables. */ - char **names; /* Array of pointers to evaluator variable - * names. */ -} Evaluator; - -void * -evaluator_create(char *string) -{ - Evaluator *evaluator; /* Evaluator representing function - * given by string. */ - char *stringn; /* Copy of string terminated by - * newline character. */ - - /* Copy string representing function and terminate it with newline - * (this is necessary because parser expect newline character to - * terminate its input). */ - stringn = XMALLOC(char, strlen(string) + 2); - - strcpy(stringn, string); - strcat(stringn, "\n"); - - /* Initialize global variables used by parser. */ - input_string = stringn; - root = NULL; - symbol_table = symbol_table_create(MIN_TABLE_LENGTH); - ok = 1; - - /* Do parsing. */ - yyparse(); - - /* Free copy of string representing function. */ - XFREE(stringn); - - /* Return null pointer as error indicator if parsing error - * occured. */ - if (!ok) { - symbol_table_destroy(symbol_table); - return NULL; - } - - /* Simplify tree represention of function. */ - root = node_simplify(root); - - /* Allocate memory for and initialize evaluator data structure. */ - evaluator = XMALLOC(Evaluator, 1); - evaluator->root = root; - evaluator->symbol_table = symbol_table; - evaluator->string = NULL; - evaluator->count = 0; - evaluator->names = NULL; - - return evaluator; -} - -void -evaluator_destroy(void *evaluator) -{ - /* Destroy tree represention of function, symbol table, array of - * pointers to evaluator variable names, as well as data structure - * representing evaluator. */ - node_destroy(((Evaluator *) evaluator)->root); - symbol_table_destroy(((Evaluator *) evaluator)->symbol_table); - XFREE(((Evaluator *) evaluator)->string); - XFREE(((Evaluator *) evaluator)->names); - XFREE(evaluator); -} - -double -evaluator_evaluate(void *evaluator, int count, char **names, - double *values) -{ - Record *record; /* Symbol table record corresponding to - * given variable name. */ - int i; /* Loop counter. */ - - /* Assign values to symbol table records corresponding to variable - * names. */ - for (i = 0; i < count; i++) { - record = - symbol_table_lookup(((Evaluator *) evaluator)-> - symbol_table, names[i]); - if (record && record->type == 'v') - record->data.value = values[i]; - } - - /* Evaluate function value using tree represention of function. */ - return node_evaluate(((Evaluator *) evaluator)->root); -} - -char * -evaluator_get_string(void *evaluator) -{ - int length; /* Length of evaluator textual - * representaion. */ - - /* If not already, create and remember evaluator textual - * representation. */ - if (!((Evaluator *) evaluator)->string) { - length = node_get_length(((Evaluator *) evaluator)->root); - ((Evaluator *) evaluator)->string = - XMALLOC(char, length + 1); - node_write(((Evaluator *) evaluator)->root, - ((Evaluator *) evaluator)->string); - ((Evaluator *) evaluator)->string[length] = 0; - } - - /* Return requsted information. */ - return ((Evaluator *) evaluator)->string; -} - -void -evaluator_get_variables(void *evaluator, char ***names, int *count) -{ - Record **records; /* Array of symbol table records - * containing evaluator variables. - */ - int i; /* Loop counter. */ - - /* If not already, find and remember evaluator variable names. */ - if (!((Evaluator *) evaluator)->names) { - symbol_table_clear_flags(((Evaluator *) evaluator)-> - symbol_table); - node_flag_variables(((Evaluator *) evaluator)->root); - ((Evaluator *) evaluator)->count = - symbol_table_get_flagged_count(((Evaluator *) - evaluator)-> - symbol_table); - records = - XMALLOC(Record *, ((Evaluator *) evaluator)->count); - symbol_table_get_flagged(((Evaluator *) evaluator)-> - symbol_table, records, - ((Evaluator *) evaluator)->count); - ((Evaluator *) evaluator)->names = - XMALLOC(char *, ((Evaluator *) evaluator)->count); - for (i = 0; i < ((Evaluator *) evaluator)->count; i++) - ((Evaluator *) evaluator)->names[i] = - records[i]->name; - XFREE(records); - } - - /* Return requested information. */ - *count = ((Evaluator *) evaluator)->count; - *names = ((Evaluator *) evaluator)->names; -} - -void * -evaluator_derivative(void *evaluator, char *name) -{ - Evaluator *derivative; /* Derivative function evaluator. */ - - /* Allocate memory for and initalize data structure for evaluator - * representing derivative of function given by evaluator. */ - derivative = XMALLOC(Evaluator, 1); - derivative->root = - node_simplify(node_derivative - (((Evaluator *) evaluator)->root, name, - ((Evaluator *) evaluator)->symbol_table)); - derivative->symbol_table = - symbol_table_assign(((Evaluator *) evaluator)->symbol_table); - derivative->string = NULL; - derivative->count = 0; - derivative->names = NULL; - - return derivative; -} - -double -evaluator_evaluate_x(void *evaluator, double x) -{ - char *names[] = { - "x" - }; /* Array of variable names. */ - double values[1]; /* Array of variable values. */ - - /* Evaluate function for given values of variable "x". */ - values[0] = x; - return evaluator_evaluate(evaluator, - sizeof(names) / sizeof(names[0]), names, - values); -} - -double -evaluator_evaluate_x_y(void *evaluator, double x, double y) -{ - char *names[] = { - "x", "y" - }; /* Array of variable names. */ - double values[2]; /* Array of variable values. */ - - /* Evaluate function for given values of variable "x" and "y". */ - values[0] = x, values[1] = y; - return evaluator_evaluate(evaluator, - sizeof(names) / sizeof(names[0]), names, - values); -} - -double -evaluator_evaluate_x_y_z(void *evaluator, double x, double y, double z) -{ - char *names[] = { - "x", "y", "z" - }; /* Array of variable names. */ - double values[3]; /* Array of variable values. */ - - /* Evaluate function for given values of variable "x", "y" and - * "z". */ - values[0] = x, values[1] = y, values[2] = z; - return evaluator_evaluate(evaluator, - sizeof(names) / sizeof(names[0]), names, - values); -} - -void * -evaluator_derivative_x(void *evaluator) -{ - /* Differentiate function using derivation variable "x". */ - return evaluator_derivative(evaluator, "x"); -} - -void * -evaluator_derivative_y(void *evaluator) -{ - /* Differentiate function using derivation variable "y". */ - return evaluator_derivative(evaluator, "y"); -} - -void * -evaluator_derivative_z(void *evaluator) -{ - /* Differentiate function using derivation variable "z". */ - return evaluator_derivative(evaluator, "z"); -} +/* + * Copyright (C) 1999, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2011, + * 2012, 2013, 2014 Free Software Foundation, Inc. + * + * This file is part of GNU libmatheval + * + * GNU libmatheval is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * GNU libmatheval is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU libmatheval. If not, see + * . + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include "common.h" +#include "matheval.h" +#include "node.h" +#include "symbol_table.h" + +/* Minimal length of evaluator symbol table. */ +#define MIN_TABLE_LENGTH 211 + +/* Function used to parse string representing function (this function is + * generated by parser generator). */ +extern int evaluator_parse(); + +/* Following variables are needed for parsing (parser is able to + * communicate with program from which it is used through global variables + * only). */ +char *input_string; /* String representing function. */ +Node *root; /* Root of tree representation of + * function. */ +SymbolTable *symbol_table; /* Evaluator symbol table. */ +int ok; /* Flag determining if parsing went OK. */ + +/* Data structure representing evaluator. */ +typedef struct { + Node *root; /* Root of tree representation of + * function. */ + SymbolTable *symbol_table; /* Evalutor symbol table. */ + char *string; /* Evaluator textual representation. */ + int count; /* Number of evaluator variables. */ + char **names; /* Array of pointers to evaluator variable + * names. */ +} Evaluator; + +void * +evaluator_create(char *string) +{ + Evaluator *evaluator; /* Evaluator representing function + * given by string. */ + char *stringn; /* Copy of string terminated by + * newline character. */ + + /* Copy string representing function and terminate it with newline + * (this is necessary because parser expect newline character to + * terminate its input). */ + stringn = XMALLOC(char, strlen(string) + 2); + + strcpy(stringn, string); + strcat(stringn, "\n"); + + /* Initialize global variables used by parser. */ + input_string = stringn; + root = NULL; + symbol_table = symbol_table_create(MIN_TABLE_LENGTH); + ok = 1; + + /* Do parsing. */ + evaluator_parse(); + + /* Free copy of string representing function. */ + XFREE(stringn); + + /* Return null pointer as error indicator if parsing error + * occured. */ + if (!ok) { + symbol_table_destroy(symbol_table); + return NULL; + } + + /* Simplify tree represention of function. */ + root = node_simplify(root); + + /* Allocate memory for and initialize evaluator data structure. */ + evaluator = XMALLOC(Evaluator, 1); + evaluator->root = root; + evaluator->symbol_table = symbol_table; + evaluator->string = NULL; + evaluator->count = 0; + evaluator->names = NULL; + + return evaluator; +} + +void +evaluator_destroy(void *evaluator) +{ + /* Destroy tree represention of function, symbol table, array of + * pointers to evaluator variable names, as well as data structure + * representing evaluator. */ + node_destroy(((Evaluator *) evaluator)->root); + symbol_table_destroy(((Evaluator *) evaluator)->symbol_table); + XFREE(((Evaluator *) evaluator)->string); + XFREE(((Evaluator *) evaluator)->names); + XFREE(evaluator); +} + +double +evaluator_evaluate(void *evaluator, int count, char **names, + double *values) +{ + Record *record; /* Symbol table record corresponding to + * given variable name. */ + int i; /* Loop counter. */ + + /* Assign values to symbol table records corresponding to variable + * names. */ + for (i = 0; i < count; i++) { + record = + symbol_table_lookup(((Evaluator *) evaluator)-> + symbol_table, names[i]); + if (record && record->type == 'v') + record->data.value = values[i]; + } + + /* Evaluate function value using tree represention of function. */ + return node_evaluate(((Evaluator *) evaluator)->root); +} + +double +evaluator_evaluate2(void *evaluator, double(*function)(const char*)) +{ + Record *record; /* Symbol table record corresponding to + * given variable name. */ + int i, /* Loop counter. */ + count; /* number of symbols in names */ + char** names; /* symbols name */ + + /* Get expression variables */ + evaluator_get_variables(evaluator, &names, &count); + + /* Assign values to symbol table records corresponding to variable + * names. */ + for (i = 0; i < count; i++) { + record = + symbol_table_lookup(((Evaluator *) evaluator)-> + symbol_table, names[i]); + /* if the symbol is a variable just call the callback function */ + + if (record && record->type == 'v') + record->data.value = function(names[i]); + } + + /* Return requsted information. */ + return node_evaluate(((Evaluator *) evaluator)->root); +} + +char * +evaluator_get_string(void *evaluator) +{ + int length; /* Length of evaluator textual + * representaion. */ + + /* If not already, create and remember evaluator textual + * representation. */ + if (!((Evaluator *) evaluator)->string) { + length = node_get_length(((Evaluator *) evaluator)->root); + ((Evaluator *) evaluator)->string = + XMALLOC(char, length + 1); + node_write(((Evaluator *) evaluator)->root, + ((Evaluator *) evaluator)->string); + ((Evaluator *) evaluator)->string[length] = 0; + } + + /* Return requsted information. */ + return ((Evaluator *) evaluator)->string; +} + +void +evaluator_get_variables(void *evaluator, char ***names, int *count) +{ + Record **records; /* Array of symbol table records + * containing evaluator variables. + */ + int i; /* Loop counter. */ + + /* If not already, find and remember evaluator variable names. */ + if (!((Evaluator *) evaluator)->names) { + symbol_table_clear_flags(((Evaluator *) evaluator)-> + symbol_table); + node_flag_variables(((Evaluator *) evaluator)->root); + ((Evaluator *) evaluator)->count = + symbol_table_get_flagged_count(((Evaluator *) + evaluator)-> + symbol_table); + records = + XMALLOC(Record *, ((Evaluator *) evaluator)->count); + symbol_table_get_flagged(((Evaluator *) evaluator)-> + symbol_table, records, + ((Evaluator *) evaluator)->count); + ((Evaluator *) evaluator)->names = + XMALLOC(char *, ((Evaluator *) evaluator)->count); + for (i = 0; i < ((Evaluator *) evaluator)->count; i++) + ((Evaluator *) evaluator)->names[i] = + records[i]->name; + XFREE(records); + } + + /* Return requested information. */ + *count = ((Evaluator *) evaluator)->count; + *names = ((Evaluator *) evaluator)->names; +} + +void * +evaluator_derivative(void *evaluator, char *name) +{ + Evaluator *derivative; /* Derivative function evaluator. */ + + /* Allocate memory for and initalize data structure for evaluator + * representing derivative of function given by evaluator. */ + derivative = XMALLOC(Evaluator, 1); + derivative->root = + node_simplify(node_derivative + (((Evaluator *) evaluator)->root, name, + ((Evaluator *) evaluator)->symbol_table)); + derivative->symbol_table = + symbol_table_assign(((Evaluator *) evaluator)->symbol_table); + derivative->string = NULL; + derivative->count = 0; + derivative->names = NULL; + + return derivative; +} + +double +evaluator_evaluate_x(void *evaluator, double x) +{ + char *names[] = { + "x" + }; /* Array of variable names. */ + double values[1]; /* Array of variable values. */ + + /* Evaluate function for given values of variable "x". */ + values[0] = x; + return evaluator_evaluate(evaluator, + sizeof(names) / sizeof(names[0]), names, + values); +} + +double +evaluator_evaluate_x_y(void *evaluator, double x, double y) +{ + char *names[] = { + "x", "y" + }; /* Array of variable names. */ + double values[2]; /* Array of variable values. */ + + /* Evaluate function for given values of variable "x" and "y". */ + values[0] = x, values[1] = y; + return evaluator_evaluate(evaluator, + sizeof(names) / sizeof(names[0]), names, + values); +} + +double +evaluator_evaluate_x_y_z(void *evaluator, double x, double y, double z) +{ + char *names[] = { + "x", "y", "z" + }; /* Array of variable names. */ + double values[3]; /* Array of variable values. */ + + /* Evaluate function for given values of variable "x", "y" and + * "z". */ + values[0] = x, values[1] = y, values[2] = z; + return evaluator_evaluate(evaluator, + sizeof(names) / sizeof(names[0]), names, + values); +} + +void * +evaluator_derivative_x(void *evaluator) +{ + /* Differentiate function using derivation variable "x". */ + return evaluator_derivative(evaluator, "x"); +} + +void * +evaluator_derivative_y(void *evaluator) +{ + /* Differentiate function using derivation variable "y". */ + return evaluator_derivative(evaluator, "y"); +} + +void * +evaluator_derivative_z(void *evaluator) +{ + /* Differentiate function using derivation variable "z". */ + return evaluator_derivative(evaluator, "z"); +} diff -r 2140694fd9aa lib/matheval.h --- a/lib/matheval.h Wed Aug 14 21:03:23 2013 +0200 +++ b/lib/matheval.h Thu Jun 05 18:11:24 2014 +0200 @@ -44,6 +44,9 @@ * value of this variable is undeterminated. */ extern double evaluator_evaluate(void *evaluator, int count, char **names, double *values); + + extern double evaluator_evaluate2(void *evaluator, + double(*function)(const char*)); /* Return textual representation of function given by evaluator. * Textual representation is built after evaluator simplification, diff -r 2140694fd9aa lib/parser.y --- a/lib/parser.y Wed Aug 14 21:03:23 2013 +0200 +++ b/lib/parser.y Thu Jun 05 18:11:24 2014 +0200 @@ -22,7 +22,7 @@ %{ /* * Copyright (C) 1999, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2011, - * 2012, 2013 Free Software Foundation, Inc. + * 2012, 2013, 2014 Free Software Foundation, Inc. * * GNU libmatheval is free software: you can redistribute it and/or * modify it under the terms of the GNU General Public License as diff -r 2140694fd9aa lib/scanner.l --- a/lib/scanner.l Wed Aug 14 21:03:23 2013 +0200 +++ b/lib/scanner.l Thu Jun 05 18:11:24 2014 +0200 @@ -1,6 +1,6 @@ /* * Copyright (C) 1999, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2011, - * 2012, 2013 Free Software Foundation, Inc. + * 2012, 2013, 2014 Free Software Foundation, Inc. * * This file is part of GNU libmatheval * @@ -22,7 +22,7 @@ %{ /* * Copyright (C) 1999, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2011, - * 2012, 2013 Free Software Foundation, Inc. + * 2012, 2013, 2014 Free Software Foundation, Inc. * * This file is part of GNU libmatheval * @@ -64,6 +64,9 @@ static int input_from_string (char *buffer, int max_size); %} +/* do not include the default yywrap, as long as it is not needed */ +%option noyywrap + /* Token definitions. */ whitespace [ \t]+ digit [0-9] @@ -78,7 +81,7 @@ {number} { /* Create node representing constant with appropriate value. */ - yylval.node = node_create ('n', atof (yytext)); + evaluator_lval.node = node_create ('n', atof (yytext)); return NUMBER; } @@ -87,13 +90,13 @@ /* Find symbol table record corresponding to constant name. */ record = symbol_table_lookup (symbol_table, yytext); - yylval.node = node_create ('c', record); + evaluator_lval.node = node_create ('c', record); return CONSTANT; } {function} { /* Find symbol table record corresponding to function name. */ - yylval.record = symbol_table_lookup (symbol_table, yytext); + evaluator_lval.record = symbol_table_lookup (symbol_table, yytext); return FUNCTION; } @@ -102,7 +105,7 @@ /* Insert variable into symbol table. */ record = symbol_table_insert (symbol_table, yytext, 'v'); - yylval.node = node_create ('v', record); + evaluator_lval.node = node_create ('v', record); return VARIABLE; }