lib/intExp.c File Reference

#include "common.h"
#include "kxTok.h"

Include dependency graph for intExp.c:

Go to the source code of this file.

Defines

#define nextTok()   (tok = tok->next)

Functions

static double expression ()
static double number ()
static double atom ()
static double uMinus ()
static double mulDiv ()
static double addSub ()
double doubleExp (char *text)
int intExp (char *text)

Variables

static char const rcsid [] = "$Id: intExp.c,v 1.6 2003/05/06 07:33:43 kate Exp $"
static struct kxToktok


Define Documentation

 
#define nextTok (  )     (tok = tok->next)

Definition at line 14 of file intExp.c.

Referenced by addSub(), atom(), mulDiv(), number(), and uMinus().


Function Documentation

static double addSub (  )  [static]

Definition at line 111 of file intExp.c.

References kxtAdd, kxtSub, mulDiv(), nextTok, tok, and kxTok::type.

Referenced by expression().

00113 {
00114 double val;
00115 val = mulDiv();
00116 for (;;)
00117     {
00118     if (tok->type == kxtAdd)
00119         {
00120         nextTok();
00121         val += mulDiv();
00122         }
00123     else if (tok->type == kxtSub)
00124         {
00125         nextTok();
00126         val -= mulDiv();
00127         }
00128     else
00129         break;
00130     }
00131 return val;
00132 }

Here is the call graph for this function:

Here is the caller graph for this function:

static double atom (  )  [static]

Definition at line 51 of file intExp.c.

References errAbort(), expression(), kxtCloseParen, kxtOpenParen, nextTok, number(), tok, and kxTok::type.

Referenced by uMinus().

00053 {
00054 double val;
00055 if (tok->type == kxtOpenParen)
00056     {
00057     nextTok();
00058     val = expression();
00059     if (tok->type == kxtCloseParen)
00060         {
00061         nextTok();
00062         return val;
00063         }
00064     else
00065         {
00066         errAbort("Unmatched parenthesis");
00067         return 0;
00068         }
00069     }
00070 else
00071     return number();
00072 }

Here is the call graph for this function:

Here is the caller graph for this function:

double doubleExp ( char *  text  ) 

Definition at line 140 of file intExp.c.

References expression(), FALSE, kxTokenize(), slFreeList(), and tok.

Referenced by intExp().

00142 {
00143 double val;
00144 struct kxTok *tokList = tok = kxTokenize(text, FALSE);
00145 val = expression();
00146 slFreeList(&tokList);
00147 return val;
00148 }

Here is the call graph for this function:

Here is the caller graph for this function:

static double expression (  )  [static]

Definition at line 134 of file intExp.c.

References addSub().

Referenced by atom(), and doubleExp().

00136 {
00137 return addSub();
00138 }

Here is the call graph for this function:

Here is the caller graph for this function:

int intExp ( char *  text  ) 

Definition at line 150 of file intExp.c.

References doubleExp(), and round.

Referenced by cgiIntExp().

00152 {
00153 return round(doubleExp(text));
00154 }

Here is the call graph for this function:

Here is the caller graph for this function:

static double mulDiv (  )  [static]

Definition at line 89 of file intExp.c.

References kxtDiv, kxtMul, nextTok, tok, kxTok::type, and uMinus().

Referenced by addSub().

00091 {
00092 double val = uMinus();
00093 for (;;)
00094     {
00095     if (tok->type == kxtMul)
00096         {
00097         nextTok();
00098         val *= uMinus();
00099         }
00100     else if (tok->type == kxtDiv)
00101         {
00102         nextTok();
00103         val /= uMinus();
00104         }
00105     else
00106         break;
00107     }
00108 return val;
00109 }

Here is the call graph for this function:

Here is the caller graph for this function:

static double number (  )  [static]

Definition at line 38 of file intExp.c.

References errAbort(), nextTok, kxTok::string, and tok.

Referenced by atom().

00040 {
00041 double val;
00042 if (tok == NULL)
00043     errAbort("Parse error in numerical expression");
00044 if (!isdigit(tok->string[0]))
00045     errAbort("Expecting number, got %s", tok->string);
00046 val = atof(tok->string);
00047 nextTok();
00048 return val;
00049 }

Here is the call graph for this function:

Here is the caller graph for this function:

static double uMinus (  )  [static]

Definition at line 75 of file intExp.c.

References atom(), kxtSub, nextTok, tok, and kxTok::type.

Referenced by mulDiv().

00077 {
00078 double val;
00079 if (tok->type == kxtSub)
00080     {
00081     nextTok();
00082     val = -atom();
00083     return val;
00084     }
00085 else
00086     return atom();
00087 }

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

char const rcsid[] = "$Id: intExp.c,v 1.6 2003/05/06 07:33:43 kate Exp $" [static]

Definition at line 10 of file intExp.c.

struct kxTok* tok [static]

Definition at line 12 of file intExp.c.

Referenced by addSub(), atom(), doubleExp(), keyExpParse(), kxTokenizeFancy(), kxTokNew(), mulDiv(), number(), parseAndExp(), parseOrExp(), and uMinus().


Generated on Tue Dec 25 19:56:44 2007 for blat by  doxygen 1.5.2