Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

sobj_pexpr.c File Reference


Detailed Description

Parser for the text serialization of expression objects.

#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <assert.h>
#include "sobject_p.h"

Include dependency graph for sobj_pexpr.c:

Include dependency graph

Data Structures

struct  sobj_pexpr_elt
 An element of the parser expression stack. More...
struct  sobj_pexpr
 Expression parser object. More...

Defines

#define OP_NULL   ((enum sobj_expr_type)0)
 Invalid operation ID.
#define OP_COND_SEP   (SOBJ_EXPR_RESERVED_1)
 Operation ID representing the conditional separator ``:''.

Functions

void sobj_pexpr_init (struct sobj_pexpr *)
 Initialize an expression parser object.
void sobj_pexpr_deinit (struct sobj_pexpr *)
 Deinitialize an expression parser object.
sobj_pexprnew_sobj_pexpr (void)
 Create a new instance of an expression parser object.
void delete_sobj_pexpr (struct sobj_pexpr *)
 Delete an instance of an expression parser object.
void sobj_pexpr_push (struct sobj_pexpr *, struct sobj *, enum sobj_expr_type)
 Push an object or operator sign onto the evaluation stack.
sobj_pexpr_eltsobj_pexpr_top (struct sobj_pexpr *)
 Get the top element of the evaluation stack.
void sobj_pexpr_pop (struct sobj_pexpr *, int)
 Remove a number of elements from the evaluation stack.
int sobj_pexpr_count (struct sobj_pexpr *)
 Return the number of elements on the evaluation stack.
void sobj_pexpr_reduce (struct sobj_pexpr *, struct sobj_env *, int)
 Parser reduction function.
sobjsobj_pexpr_parse (struct sobj_env *env, const char **ptr, int offset)
 Internal function for parsing a text serialization of an expression object.

Variables

sobj_pexpr sobj_pexpr_static = { .stack = 0 }
 A static instance of an parser expression.
const int sobj_pexpr_minstack = 4
 Minimum number of elements on an evaluation stack.

Define Documentation

#define OP_COND_SEP   (SOBJ_EXPR_RESERVED_1)
 

Operation ID representing the conditional separator ``:''.

#define OP_NULL   ((enum sobj_expr_type)0)
 

Invalid operation ID.


Function Documentation

void delete_sobj_pexpr struct sobj_pexpr pexpr  )  [static]
 

Delete an instance of an expression parser object.

Parameters:
pexpr The expression parser object.

struct sobj_pexpr * new_sobj_pexpr void   )  [static]
 

Create a new instance of an expression parser object.

Returns:
The new instance.

int sobj_pexpr_count struct sobj_pexpr pexpr  )  [static]
 

Return the number of elements on the evaluation stack.

Parameters:
pexpr The expression parser object.
Returns:
The number of elements on the evaluation stack.

void sobj_pexpr_deinit struct sobj_pexpr pexpr  )  [static]
 

Deinitialize an expression parser object.

All storage held by the object is released.

Parameters:
pexpr The expression parser object.

void sobj_pexpr_init struct sobj_pexpr pexpr  )  [static]
 

Initialize an expression parser object.

Parameters:
pexpr Pointer to an uninitialized expression parser object.

struct sobj* sobj_pexpr_parse struct sobj_env env,
const char **  ptr,
int  offset
 

Internal function for parsing a text serialization of an expression object.

Parameters:
env The environment (for error reporting). This may be a null-pointer.
ptr Pointer to the callers parsing pointer into the text serialization. *ptr should point to the first character of the expression serialization. On success *ptr will be advanced to the first character following the expression serialization.
offset The offset of the first character of the expression serialization relative to the first character of the entire serialization (required for error reporting).
Returns:
On success, a simple object representing the expression is returned. In case of a parsing error, a null-pointer is returned.

void sobj_pexpr_pop struct sobj_pexpr pexpr,
int  count
[static]
 

Remove a number of elements from the evaluation stack.

Parameters:
pexpr The expression parser object.
count The number of elements to be removed.

void sobj_pexpr_push struct sobj_pexpr pexpr,
struct sobj sobj,
enum sobj_expr_type  op
[static]
 

Push an object or operator sign onto the evaluation stack.

Parameters:
pexpr The expression parser object.
sobj If not a null-pointer, the object to be pushed.
op If not OP_NULL, the operand sign to be pushed.

void sobj_pexpr_reduce struct sobj_pexpr pexpr,
struct sobj_env env,
int  priority
[static]
 

Parser reduction function.

The function reduces elements on the top of the stack if the specified priority is smaller or equal to the priority of the operation on the stack.

Parameters:
pexpr The parser object.
env The environment. This may be a null-pointer.
priority The reduction priority.

struct sobj_pexpr_elt * sobj_pexpr_top struct sobj_pexpr pexpr  )  [static]
 

Get the top element of the evaluation stack.

Returns:
The top element of the stack.


Variable Documentation

const int sobj_pexpr_minstack = 4 [static]
 

Minimum number of elements on an evaluation stack.

To avoid unnecessary bounds checking on an evaluation stack, a number of dummy elements is held on the stack. This constants defines the number of dummy elements.

struct sobj_pexpr sobj_pexpr_static = { .stack = 0 } [static]
 

A static instance of an parser expression.

This instance is used if only a single expression parser object is needed. If more than one expression parser objects are created, the additional parser objects are allocated from the heap.


Generated on Sat Jul 23 16:05:29 2005 for sobject by  doxygen 1.3.9.1