/* $Id: parse.h,v 1.18 2004/04/03 04:17:37 jmuelmen Exp $ */ /* Parse action and related types */ #include #include #ifndef _AMBUSH_PARSE_INC_ #define _AMBUSH_PARSE_INC_ 1 #define STRING_LIT_LEN 256 typedef struct { enum { val_int, val_float, val_time, val_period, val_string } val_type; union { int v_int; time_t v_time; time_t v_period; double v_float; char v_string[STRING_LIT_LEN]; } value; pthread_mutex_t mut; pthread_mutex_t cond_mut; pthread_cond_t has_returned; int returned; } value_t; /* parse_action_t defines the result of a parsed statement; the * scheduler knows what to do with these things. */ #define MAX_ARGS 10 typedef value_t (*func_t) (value_t *, int); struct parse_action_struct { enum { func_s, begin_atomic, end_atomic, begin_sequential, end_sequential, if_s, at_s, sched_s, call_s } type; union { void (*func) (value_t *, value_t **, int); struct { func_t func; struct parse_action_struct *arg_list; } func_call; /* function call: pointer to the function, pointer to the argument list */ struct { /* end of predicate/consequent statement: skip to here */ struct parse_action_struct *eop; struct parse_action_struct *eos; int cancel; pthread_mutex_t mut; } statement; } statement; value_t *args[MAX_ARGS]; /* arguments to the function */ int n_args; value_t ret; }; typedef struct parse_action_struct parse_action_t; /* parse action utility functions */ parse_action_t *parse_action_create (void (*) (value_t *, value_t **, int), value_t **, int); void parse_action_process (parse_action_t *); /* copy values --- without stepping on their mutices */ void value_copy (value_t *dest, const value_t *src); void value_init (value_t *); void value_destroy (value_t *); #endif /* _AMBUSH_PARSE_INC_ */