evaluator.cpp File Reference

This module contains main logic behind expression evaluation. More...

#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include "helper.h"
#include "functions.h"
#include "evaluator.h"

Include dependency graph for evaluator.cpp:


Defines

#define fillonearg   firstarg(co); arg1=evaluate(stats,cache,co,i,m); closing(co)
 Macro which fills arg1 with evaluated value of first argument and checks for beginning and closing parenthesis.
#define fillargs   ++(*co);firstarg(co); arg1=evaluate(stats,cache,co,i,m); nextarg(co); arg2=evaluate(stats,cache,co,i,m); closing(co)
 Macro which fills arg1 and arg2 with evaluated values of first two arguments and checks for beginning and closing parenthesis.

Functions

void clearblanks (const char **co)
 Get rid of blanks.
void clearnonblanks (const char **co)
 Get rid of non-blanks.
void firstarg (const char **co)
 Jump to the first argument (skip blanks and '(' ).
void skiparg (const char **co)
 Skip one argument.
void nextarg (const char **co)
 Jump to the next argument (skip blanks and ';' ).
void closing (const char **co)
 Jump to the end (skip blanks and ')' ).
MY_FLOAT evaluate (const tmpstats *stats, cache_type *cache, const char **co, int i, int m)
 Main evaluation logic.

Detailed Description

This module contains main logic behind expression evaluation.

Expressions uses prefix grammar. It takes prepared statistics and evaluates user specified condition. All logic is maintained in function evaluate. This module also contains some help functions and macros used in parsing expressions.

See also:
evaluate

tmpstats


Function Documentation

MY_FLOAT evaluate ( const tmpstats stats,
cache_type cache,
const char **  co,
int  i,
int  m 
)

Main evaluation logic.

Expressions uses prefix function notation and they are evaluated recursively. Main methods function can be found in file functions.h. This functions mainly parse expression and call appropriate functions. So parsing and logic is somehow divided. But some basic functions not related to the methods are also implemented here (like +, -, *, /, &, |). This is because it's simpler to implement shortcut evaluation here.

  • stats Statistics used to decide.
  • co Pointer to the expression.
  • i Current position in word.
  • m Length of the word.
See also:
tmpstats

References bentr(), bsqrs(), clearblanks(), closing(), dbentr(), dfentr(), evaluate(), fentr(), fillargs, fillonearg, firstarg(), fsqrs(), lalt(), nextarg(), ralt(), skiparg(), sqrs(), trian(), VPRINTF, and VWPRINTF.

Referenced by evaluate(), and find_it_thread().

void skiparg ( const char **  co  ) 

Skip one argument.

This function skips everything till next ';' or ')' on the same level. So if you call another function, it skips whole function call including all its arguments.

btw. I'm very proud of this function. That 'for' is really cute.

Referenced by evaluate().


Generated on Sat Dec 20 11:32:18 2008 for Affisix by  doxygen 1.5.7.1