build/expression.c File Reference

Simple logical expression parser. More...

#include "system.h"
#include <rpmbuild.h>
#include <rpmlib.h>
#include "debug.h"

Go to the source code of this file.

Data Structures

struct  _value
 Encapsulation of a "value". More...
struct  _parseState
 Parser state. More...

Defines

#define DEBUG(x)
#define valueIsInteger(v)   ((v)->type == VALUE_TYPE_INTEGER)
#define valueIsString(v)   ((v)->type == VALUE_TYPE_STRING)
#define valueSameType(v1, v2)   ((v1)->type == (v2)->type)
#define EXPRBUFSIZ   BUFSIZ
Parser tokens
#define TOK_EOF   1
#define TOK_INTEGER   2
#define TOK_STRING   3
#define TOK_IDENTIFIER   4
#define TOK_ADD   5
#define TOK_MINUS   6
#define TOK_MULTIPLY   7
#define TOK_DIVIDE   8
#define TOK_OPEN_P   9
#define TOK_CLOSE_P   10
#define TOK_EQ   11
#define TOK_NEQ   12
#define TOK_LT   13
#define TOK_LE   14
#define TOK_GT   15
#define TOK_GE   16
#define TOK_NOT   17
#define TOK_LOGICAL_AND   18
#define TOK_LOGICAL_OR   19

Typedefs

typedef struct _valueValue
 Encapsulation of a "value".
typedef struct _parseStateParseState
 Parser state.

Functions

static Value valueMakeInteger (int i)
static Value valueMakeString (const char *s)
static void valueFree (Value v)
static int rdToken (ParseState state)
static Value doLogical (ParseState state)
static Value doPrimary (ParseState state)
static Value doMultiplyDivide (ParseState state)
static Value doAddSubtract (ParseState state)
static Value doRelational (ParseState state)
int parseExpressionBoolean (Spec spec, const char *expr)
 Evaluate boolean expression.
char * parseExpressionString (Spec spec, const char *expr)
 Evaluate string expression.


Detailed Description

Simple logical expression parser.

This module implements a basic expression parser with support for integer and string datatypes. For ease of programming, we use the top-down "recursive descent" method of parsing. While a table-driven bottom-up parser might be faster, it does not really matter for the expressions we will be parsing.

Copyright (C) 1998 Tom Dyas <tdyas@eden.rutgers.edu> This work is provided under the GPL or LGPL at your choice.

Definition in file expression.c.


Define Documentation

#define DEBUG (  ) 

Definition at line 27 of file expression.c.

#define EXPRBUFSIZ   BUFSIZ

Definition at line 137 of file expression.c.

#define TOK_ADD   5

Definition at line 120 of file expression.c.

#define TOK_CLOSE_P   10

Definition at line 125 of file expression.c.

#define TOK_DIVIDE   8

Definition at line 123 of file expression.c.

#define TOK_EOF   1

Definition at line 116 of file expression.c.

#define TOK_EQ   11

Definition at line 126 of file expression.c.

#define TOK_GE   16

Definition at line 131 of file expression.c.

#define TOK_GT   15

Definition at line 130 of file expression.c.

#define TOK_IDENTIFIER   4

Definition at line 119 of file expression.c.

#define TOK_INTEGER   2

Definition at line 117 of file expression.c.

#define TOK_LE   14

Definition at line 129 of file expression.c.

#define TOK_LOGICAL_AND   18

Definition at line 133 of file expression.c.

#define TOK_LOGICAL_OR   19

Definition at line 134 of file expression.c.

#define TOK_LT   13

Definition at line 128 of file expression.c.

#define TOK_MINUS   6

Definition at line 121 of file expression.c.

#define TOK_MULTIPLY   7

Definition at line 122 of file expression.c.

#define TOK_NEQ   12

Definition at line 127 of file expression.c.

#define TOK_NOT   17

Definition at line 132 of file expression.c.

#define TOK_OPEN_P   9

Definition at line 124 of file expression.c.

#define TOK_STRING   3

Definition at line 118 of file expression.c.

#define valueIsInteger (  )     ((v)->type == VALUE_TYPE_INTEGER)

Definition at line 95 of file expression.c.

#define valueIsString (  )     ((v)->type == VALUE_TYPE_STRING)

Definition at line 96 of file expression.c.

#define valueSameType ( v1,
v2   )     ((v1)->type == (v2)->type)

Definition at line 97 of file expression.c.


Typedef Documentation

typedef struct _parseState * ParseState

Parser state.

typedef struct _value * Value

Encapsulation of a "value".


Function Documentation

static Value doAddSubtract ( ParseState  state  )  [static]

Parameters:
state expression parser state

Definition at line 464 of file expression.c.

static Value doLogical ( ParseState  state  )  [static]

Parameters:
state expression parser state

Definition at line 623 of file expression.c.

static Value doMultiplyDivide ( ParseState  state  )  [static]

Parameters:
state expression parser state

Definition at line 410 of file expression.c.

static Value doPrimary ( ParseState  state  )  [static]

Parameters:
state expression parser state

Definition at line 329 of file expression.c.

static Value doRelational ( ParseState  state  )  [static]

Parameters:
state expression parser state

Definition at line 527 of file expression.c.

static int rdToken ( ParseState  state  )  [static]

Parameters:
state expression parser state

Definition at line 184 of file expression.c.

static void valueFree ( Value  v  )  [static]

Definition at line 69 of file expression.c.

static Value valueMakeInteger ( int  i  )  [static]

Definition at line 43 of file expression.c.

static Value valueMakeString ( const char *  s  )  [static]

Definition at line 56 of file expression.c.


Generated on Wed Oct 21 08:56:33 2009 for rpm by  doxygen 1.5.9