genparse

genparse

Functions

#define func1_symb()
#define func2_symb()
#define func3_symb()
#define funcn_symb()
#define string_arg_func()
#define str0_func()
#define string_last_func()
#define string_mid_func()
#define fncall_func()
#define max_func()
#define unary_op()
#define binary_op()
#define bool_comp()
#define dot_op()
#define evalb3()
#define evalb2()
#define b1sym()
#define evalb1()
#define b2sym()
#define b3sym()
#define bnsym()
#define bare_data_type()
#define closing_sym()
#define r_return()
#define m_return()
#define reusable()
#define starting()
#define autoreg()
#define setting_obsval()
int parser_getc ()
void parser_ungetc ()
void parser_advance ()
int parser_char_index ()
int parser_next_nonspace_char ()
int parser_print_input ()
void lex ()
NODE * powterm ()
NODE * new_node ()
NODE * expr ()
NODE * newdbl ()
NODE * newempty ()
NODE * newb2 ()
NODE * obs_node ()
void context_error ()
void undefined_symbol_error ()
const char * getsymb ()
const char * getsymb_full ()
void set_parsing_query ()
void set_doing_genseries ()
int realgen ()
void gen_save_or_print ()
void gen_cleanup ()
void parser_free_aux_nodes ()
const char * constname ()
const char * dvarname ()
const char * mvarname ()
const char * bvarname ()
const char * dumname ()
int is_gretl_accessor ()
int mvar_lookup ()
int check_declarations ()
int cross_sectional_stat ()
int x_sectional_weighted_stat ()
double dvar_get_scalar ()
int * node_get_list ()
int gen_func_count ()
const char * gen_func_name ()
int model_var_count ()
const char * model_var_name ()
int data_var_count ()
const char * data_var_name ()
int bundle_var_count ()
const char * bundle_var_name ()
int gretl_const_count ()
const char * gretl_const_name ()

Types and Values

#define GENDEBUG
#define GENSTRLEN
#define NO_VNUM
typedef NODE
struct branch1
struct branch2
struct branch3
struct branchn
struct node
enum parser_flags
struct lhinfo
typedef parser
struct parser_

Description

Functions

func1_symb()

#define func1_symb(s) (s > F1_MIN && s < F1_MAX)

func2_symb()

#define func2_symb(s) (s > F1_MAX && s < F2_MAX)

func3_symb()

#define func3_symb(s) (s > F2_MAX && s < F3_MAX)

funcn_symb()

#define funcn_symb(s) (s > F3_MAX && s < FN_MAX)

string_arg_func()

#define             string_arg_func(s)

str0_func()

#define             str0_func(s)

string_last_func()

#define             string_last_func(s)

string_mid_func()

#define string_mid_func(s) (s == F_REDUCE || s == F_SCATTER)

fncall_func()

#define             fncall_func(s)

max_func()

#define             max_func(s)

unary_op()

#define unary_op(s)  (s >= 1 && s < U_MAX)

binary_op()

#define binary_op(s) (s > U_MAX && s < OP_MAX)

bool_comp()

#define bool_comp(s) (s >= B_EQ && s <= B_OR)

dot_op()

#define dot_op(s)    (s >= B_DOTMULT && s <= B_DOTNEQ)

evalb3()

#define evalb3(s) (func3_symb(s))

evalb2()

#define             evalb2(s)

b1sym()

#define             b1sym(s)

evalb1()

#define             evalb1(s)

b2sym()

#define             b2sym(s)

b3sym()

#define b3sym(s) (s == QUERY || func3_symb(s))

bnsym()

#define bnsym(s) (s == MDEF || s == FARGS)

bare_data_type()

#define bare_data_type(s) (s > PUNCT_MAX && s < DTYPE_MAX)

closing_sym()

#define closing_sym(s) (s == G_RPR || s == G_RBR || s == G_RCB)

r_return()

#define             r_return(s)

m_return()

#define m_return(s) (s == F_SVD)

reusable()

#define reusable(p) (p->flags & (P_COMPILE | P_EXEC))

starting()

#define starting(p) (p->flags & P_START)

autoreg()

#define autoreg(p) (p->flags & P_AUTOREG)

setting_obsval()

#define setting_obsval(p) (p->flags & P_OBSVAL)

parser_getc ()

int
parser_getc (parser *p);

parser_ungetc ()

void
parser_ungetc (parser *p);

parser_advance ()

void
parser_advance (parser *p,
                int n);

parser_char_index ()

int
parser_char_index (parser *p,
                   int c);

parser_next_nonspace_char ()

int
parser_next_nonspace_char (parser *p,
                           int skip);

parser_print_input ()

int
parser_print_input (parser *p);

lex ()

void
lex (parser *s);

powterm ()

NODE *
powterm (parser *p,
         NODE *l);

new_node ()

NODE *
new_node (int t);

expr ()

NODE *
expr (parser *s);

newdbl ()

NODE *
newdbl (double x);

newempty ()

NODE *
newempty (void);

newb2 ()

NODE *
newb2 (int t,
       NODE *l,
       NODE *r);

obs_node ()

NODE *
obs_node (parser *p);

context_error ()

void
context_error (int c,
               parser *p,
               const char *func);

undefined_symbol_error ()

void
undefined_symbol_error (const char *s,
                        parser *p);

getsymb ()

const char *
getsymb (int t);

getsymb_full ()

const char *
getsymb_full (int t,
              const parser *p);

set_parsing_query ()

void
set_parsing_query (int s);

set_doing_genseries ()

void
set_doing_genseries (int s);

realgen ()

int
realgen (const char *s,
         parser *p,
         DATASET *dset,
         PRN *prn,
         int flags,
         int targtype);

gen_save_or_print ()

void
gen_save_or_print (parser *p,
                   PRN *prn);

gen_cleanup ()

void
gen_cleanup (parser *p);

parser_free_aux_nodes ()

void
parser_free_aux_nodes (parser *p);

constname ()

const char *
constname (int c);

dvarname ()

const char *
dvarname (int t);

mvarname ()

const char *
mvarname (int t);

bvarname ()

const char *
bvarname (int t);

dumname ()

const char *
dumname (int t);

is_gretl_accessor ()

int
is_gretl_accessor (const char *s);

mvar_lookup ()

int
mvar_lookup (const char *s);

check_declarations ()

int
check_declarations (char ***pS,
                    parser *p);

cross_sectional_stat ()

int
cross_sectional_stat (double *x,
                      const int *list,
                      const DATASET *dset,
                      int f);

x_sectional_weighted_stat ()

int
x_sectional_weighted_stat (double *x,
                           const int *list,
                           const int *wlist,
                           const DATASET *dset,
                           int f);

dvar_get_scalar ()

double
dvar_get_scalar (int i,
                 const DATASET *dset);

node_get_list ()

int *
node_get_list (NODE *n,
               parser *p);

gen_func_count ()

int
gen_func_count (void);

gen_func_name ()

const char *
gen_func_name (int i);

model_var_count ()

int
model_var_count (void);

model_var_name ()

const char *
model_var_name (int i);

data_var_count ()

int
data_var_count (void);

data_var_name ()

const char *
data_var_name (int i);

bundle_var_count ()

int
bundle_var_count (void);

bundle_var_name ()

const char *
bundle_var_name (int i);

gretl_const_count ()

int
gretl_const_count (void);

gretl_const_name ()

const char *
gretl_const_name (int i);

Types and Values

GENDEBUG

#define GENDEBUG 0

GENSTRLEN

#define GENSTRLEN 128

NO_VNUM

#define NO_VNUM -1

NODE

typedef struct node NODE;

struct branch1

struct branch1 {
    NODE *b;  
};

struct branch2

struct branch2 {
    NODE *l, *r; 
};

struct branch3

struct branch3 {
    NODE *l, *m, *r; 
};

struct branchn

struct branchn {
    int n_nodes;
    NODE **n;
};

struct node

struct node {
    short t;       /* type identifier */
    unsigned char flags; /* AUX_NODE etc., see above */
    int vnum;      /* associated series ID number */
    char *vname;   /* associated variable name */
    user_var *uv;  /* associated named variable */
    union val v;   /* value (of whatever type) */
    NODE *aux;     /* auxiliary (result) node */
    int refcount;  /* reference counter, used by aux nodes */
};

enum parser_flags

Members

P_DISCARD

   

P_START

   

P_AUTOREG

   

P_DECL

   

P_PRIV

   

P_COMPILE

   

P_EXEC

   

P_NATEST

   

P_UFRET

   

P_QUIET

   

P_GETSTR

   

P_SLAVE

   

P_MMASK

   

P_SLICING

   

P_LAGPRSE

   

P_DELTAN

   

P_CATCH

   

P_NODECL

   

P_LISTDEF

   

P_ANON

   

P_VOID

   

P_NOEXEC

   

P_MSAVE

   

P_OBSVAL

   

P_ALIASED

   

struct lhinfo

struct lhinfo {
    int t;                 /* type of pre-existing LHS variable, if any */
    char name[VNAMELEN];   /* name of LHS variable */   
    char *label;           /* descriptive string for series */
    int vnum;              /* ID number of pre-existing LHS series */
    user_var *uv;          /* address of pre-existing LHS variable */
    char *expr;            /* expression on left */
    GretlType gtype;       /* gretl type of LHS array, if any, or
			      of LHS bundle member */
    gretl_matrix *mret;    /* matrix output (possibly under bundle or array) */
};

parser

typedef struct parser_ parser;

struct parser_

struct parser_ {
    const char *input; /* complete input string */
    const char *point; /* remaining unprocessed input */
    const char *rhs;   /* for use in labelling */
    DATASET *dset;     /* convenience pointer to dataset */
    PRN *prn;          /* for printing messages */
    int flags;         /* various attributes (see @parser_flags above) */
    int targ;          /* target type */
    int op;            /* assignment operator (possibly inflected) */
    struct lhinfo lh;  /* left-hand side info */
    NODE *lhtree;      /* LHS syntax tree, if needed */
    NODE *lhres;       /* result of eval() on @lhtree */
    NODE *tree;        /* RHS syntax tree */
    NODE *ret;         /* result of eval() on @tree */
    /* below: parser state variables */
    NODE *aux;          /* convenience pointer to current auxiliary node */
    int callcount;
    int dset_n;
    int obs;
    int sym;
    int upsym;
    int ch;
    double xval;
    int idnum;
    char *idstr;
    void *data;
    int err;
};