Graphviz 13.0.0~dev.20241220.2304
Loading...
Searching...
No Matches
expr.h File Reference
#include <ast/ast.h>
#include <inttypes.h>
#include <expr/exparse.h>
#include <assert.h>
#include <cdt.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <util/agxbuf.h>
#include <vmalloc/vmalloc.h>
Include dependency graph for expr.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Exid_s
 
struct  Exref_s
 
union  Exdata_u
 
struct  Exnode_s
 
struct  Exdisc_s
 
struct  Expr_s
 

Macros

#define EX_VERSION   20000101L
 
#define EX_CHARSTRING   (1<<0) /* '...' same as "..." */
 
#define EX_UNDECLARED   (1<<9) /* allow undeclared identifiers */
 
#define EX_ARRAY   (-3) /* getval() array elt */
 
#define EX_CALL   (-2) /* getval() function call elt */
 
#define EX_SCALAR   (-1) /* getval() scalar elt */
 
#define EX_NAMELEN   32 /* default Exid_t.name length */
 
#define EX_ID(n, l, i, t)   {{0}, (l), (i), (t), 0, 0, 0, 0, n}
 
#define DELETE_T   MINTOKEN /* exexpr() delete `type' */
 
#define INTEGRAL(t)   ((t)>=INTEGER&&(t)<=CHARACTER)
 
#define BUILTIN(t)   ((t) > MINTOKEN)
 
#define F   01 /* FLOATING */
 
#define I   02 /* INTEGER */
 
#define S   03 /* STRING */
 
#define TBITS   4
 
#define TMASK   ((1<<TBITS)-1)
 
#define A(n, t)   ((t)<<((n)*TBITS)) /* function arg n is type t */
 
#define N(t)   ((t)>>=TBITS) /* shift for next arg */
 
#define exalloc(p, n)   vmalloc((p)->vm, (n))
 

Typedefs

typedef EX_STYPE Extype_t
 
typedef union Exdata_u Exdata_t
 
typedef struct Exdisc_s Exdisc_t
 
typedef struct Exnode_s Exnode_t
 
typedef struct Expr_s Expr_t
 
typedef struct Exref_s Exref_t
 
typedef void(* Exerror_f) (Expr_t *, Exdisc_t *, int, const char *,...)
 
typedef void(* Exexit_f) (void *, int)
 
typedef struct Exid_s Exid_t
 

Functions

Exnode_texcast (Expr_t *, Exnode_t *, long, Exnode_t *, int)
 
Exnode_texnoncast (Exnode_t *)
 
void exclose (Expr_t *, int)
 
int excomp (Expr_t *p, const char *name, int line, FILE *fp, char *prefix)
 
char * excontext (Expr_t *, char *, int)
 
void exdump (Expr_t *, Exnode_t *, agxbuf *)
 
void exerror (const char *,...)
 
void exwarn (const char *,...)
 
Extype_t exeval (Expr_t *, Exnode_t *, void *)
 
Exnode_texexpr (Expr_t *, const char *, Exid_t *, int)
 
void exfreenode (Expr_t *, Exnode_t *)
 
Exnode_texnewnode (Expr_t *, long, bool, long, Exnode_t *, Exnode_t *)
 
char * exnospace (void)
 
Expr_texopen (Exdisc_t *)
 
int expop (Expr_t *)
 
int expush (Expr_t *, const char *, int, FILE *)
 
int extoken_fn (Expr_t *)
 
char * exstring (Expr_t *, char *)
 
void * exstralloc (Expr_t *, size_t)
 
char * extype (long int)
 
Extype_t exzero (long int)
 
char * exopname (long)
 
void exinit (void)
 
char * extypename (Expr_t *p, long)
 
int exisAssign (Exnode_t *)
 
static char * exprintf (Vmalloc_t *vm, const char *fmt,...)
 

Macro Definition Documentation

◆ A

#define A (   n,
 
)    ((t)<<((n)*TBITS)) /* function arg n is type t */

Definition at line 76 of file expr.h.

◆ BUILTIN

#define BUILTIN (   t)    ((t) > MINTOKEN)

Definition at line 58 of file expr.h.

◆ DELETE_T

#define DELETE_T   MINTOKEN /* exexpr() delete `type' */

Definition at line 55 of file expr.h.

◆ EX_ARRAY

#define EX_ARRAY   (-3) /* getval() array elt */

Definition at line 47 of file expr.h.

◆ EX_CALL

#define EX_CALL   (-2) /* getval() function call elt */

Definition at line 48 of file expr.h.

◆ EX_CHARSTRING

#define EX_CHARSTRING   (1<<0) /* '...' same as "..." */

Definition at line 44 of file expr.h.

◆ EX_ID

#define EX_ID (   n,
  l,
  i,
 
)    {{0}, (l), (i), (t), 0, 0, 0, 0, n}

Definition at line 53 of file expr.h.

◆ EX_NAMELEN

#define EX_NAMELEN   32 /* default Exid_t.name length */

Definition at line 51 of file expr.h.

◆ EX_SCALAR

#define EX_SCALAR   (-1) /* getval() scalar elt */

Definition at line 49 of file expr.h.

◆ EX_UNDECLARED

#define EX_UNDECLARED   (1<<9) /* allow undeclared identifiers */

Definition at line 45 of file expr.h.

◆ EX_VERSION

#define EX_VERSION   20000101L

Definition at line 38 of file expr.h.

◆ exalloc

#define exalloc (   p,
 
)    vmalloc((p)->vm, (n))

Definition at line 79 of file expr.h.

◆ F

#define F   01 /* FLOATING */

Definition at line 70 of file expr.h.

◆ I

#define I   02 /* INTEGER */

Definition at line 71 of file expr.h.

◆ INTEGRAL

#define INTEGRAL (   t)    ((t)>=INTEGER&&(t)<=CHARACTER)

Definition at line 57 of file expr.h.

◆ N

#define N (   t)    ((t)>>=TBITS) /* shift for next arg */

Definition at line 77 of file expr.h.

◆ S

#define S   03 /* STRING */

Definition at line 72 of file expr.h.

◆ TBITS

#define TBITS   4

Definition at line 74 of file expr.h.

◆ TMASK

#define TMASK   ((1<<TBITS)-1)

Definition at line 75 of file expr.h.

Typedef Documentation

◆ Exdata_t

typedef union Exdata_u Exdata_t

Definition at line 83 of file expr.h.

◆ Exdisc_t

typedef struct Exdisc_s Exdisc_t

Definition at line 84 of file expr.h.

◆ Exerror_f

typedef void(* Exerror_f) (Expr_t *, Exdisc_t *, int, const char *,...)

Definition at line 89 of file expr.h.

◆ Exexit_f

typedef void(* Exexit_f) (void *, int)

Definition at line 90 of file expr.h.

◆ Exid_t

typedef struct Exid_s Exid_t

◆ Exnode_t

typedef struct Exnode_s Exnode_t

Definition at line 85 of file expr.h.

◆ Expr_t

typedef struct Expr_s Expr_t

Definition at line 86 of file expr.h.

◆ Exref_t

typedef struct Exref_s Exref_t

Definition at line 87 of file expr.h.

◆ Extype_t

typedef EX_STYPE Extype_t

Definition at line 81 of file expr.h.

Function Documentation

◆ excast()

Exnode_t * excast ( Expr_t ,
Exnode_t ,
long  ,
Exnode_t ,
int   
)
extern

Referenced by exexpr(), and prformat().

Here is the caller graph for this function:

◆ exclose()

void exclose ( Expr_t ,
int   
)
extern

Referenced by exopen(), and freeCompileProg().

Here is the caller graph for this function:

◆ excomp()

int excomp ( Expr_t p,
const char *  name,
int  line,
FILE *  fp,
char *  prefix 
)
extern

Compile an expression

The callee takes ownership of the pointer prefix and will free it during expop or exclose.

Parameters
pProgram structure to store result in
nameFilename of originating source file
lineLine number of originating source file
fpHandle to source file
prefixOptional program text to include ahead of the file content
Returns
0 on success

Referenced by compile().

Here is the caller graph for this function:

◆ excontext()

char * excontext ( Expr_t p,
char *  buf,
int  n 
)
extern

Definition at line 27 of file excontext.c.

References gv_isspace().

Referenced by make_msg().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ exdump()

void exdump ( Expr_t ex,
Exnode_t node,
agxbuf xb 
)
extern

Definition at line 629 of file excc.c.

References agxbprint(), agxbputc(), dtfirst, dtnext, Excc_t::expr, gen(), PROCEDURE, and Expr_s::symbols.

Referenced by deparse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ exerror()

void exerror ( const char *  format,
  ... 
)
extern

Definition at line 62 of file exerror.c.

References expr, format, free(), make_msg(), and Exstate_s::program.

Referenced by addItem(), assignable(), cloneGraph(), cloneO(), cloneSubg(), closeFile(), convert(), copy(), deref(), eval(), ex_error(), exnospace(), exsubstr(), extoken_fn(), freadFile(), fwriteFile(), getArg(), getval(), lookup(), nxtAttr(), openFile(), prformat(), print(), readFile(), readLine(), refval(), scan(), scformat(), setval(), stringOf(), strToTvtype(), toKind(), tvtypeToStr(), typeChk(), writeFile(), xConvert(), and xPrint().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ exeval()

Extype_t exeval ( Expr_t ex,
Exnode_t exnode,
void *  env 
)
extern

Definition at line 1965 of file exeval.c.

References Exnode_s::compiled, eval(), FLOATING, EX_STYPE::floating, Exnode_s::floating, EX_STYPE::integer, Exnode_s::integer, RETURN, STRING, EX_STYPE::string, Exnode_s::string, and Exnode_s::type.

Referenced by eval(), evalEdge(), evalNode(), gvpr_core(), and prformat().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ exexpr()

Exnode_t * exexpr ( Expr_t ex,
const char *  name,
Exid_t sym,
int  type 
)
extern

Definition at line 26 of file exexpr.c.

References Exnode_s::data, DELETE_T, dtmatch, excast(), exfreenode(), Exid_s::lex, NAME, NULL, PROCEDURE, Expr_s::symbols, type, and Exid_s::value.

Referenced by compile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ exfreenode()

void exfreenode ( Expr_t ,
Exnode_t  
)
extern

Referenced by exexpr(), if(), and if().

Here is the caller graph for this function:

◆ exinit()

void exinit ( void  )
extern

Referenced by compileProg().

Here is the caller graph for this function:

◆ exisAssign()

int exisAssign ( Exnode_t )
extern

Referenced by checkGuard().

Here is the caller graph for this function:

◆ exnewnode()

Exnode_t * exnewnode ( Expr_t ,
long  ,
bool  ,
long  ,
Exnode_t ,
Exnode_t  
)
extern

◆ exnoncast()

Exnode_t * exnoncast ( Exnode_t )
extern

Referenced by checkGuard().

Here is the caller graph for this function:

◆ exnospace()

char * exnospace ( void  )
extern

Definition at line 25 of file exnospace.c.

References exerror().

Referenced by eval(), exprintf(), exsplit(), extoken_fn(), extokens(), getdyn(), if(), str_add(), str_and(), str_ior(), str_mod(), str_mpy(), and str_xor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ exopen()

Expr_t * exopen ( Exdisc_t disc)
extern

Definition at line 28 of file exopen.c.

References disc, dtinsert, dtopen(), Dtset, exbuiltin, exclose(), Expr_s::file, Expr_s::id, Exid_s::name, PROCEDURE, setcontext, Expr_s::symbols, Expr_s::vm, and vmopen().

Referenced by compileProg().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ exopname()

char * exopname ( long  op)
extern

Definition at line 41 of file excc.c.

References AND, EQ, GE, LE, LSH, NE, OR, and RSH.

Referenced by gen().

Here is the caller graph for this function:

◆ expop()

int expop ( Expr_t )
extern

Referenced by lex().

Here is the caller graph for this function:

◆ exprintf()

static char * exprintf ( Vmalloc_t vm,
const char *  fmt,
  ... 
)
inlinestatic

Construct a vmalloc-backed string.

Parameters
vmAllocator to use.
fmtprintf-style format sting.
...printf-style varargs.
Returns
Dynamically allocated string.

Definition at line 269 of file expr.h.

References exnospace(), len(), NULL, and vmalloc().

Referenced by eval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ expush()

int expush ( Expr_t ,
const char *  ,
int  ,
FILE *   
)
extern

Referenced by extoken_fn().

Here is the caller graph for this function:

◆ exstralloc()

void * exstralloc ( Expr_t ex,
size_t  sz 
)
extern

Definition at line 2008 of file exeval.c.

References vmalloc().

Referenced by bbOf(), toLower(), toUpper(), and xyOf().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ exstring()

char * exstring ( Expr_t ex,
char *  s 
)
extern

Definition at line 2000 of file exeval.c.

References vmstrdup().

Referenced by bbOf(), canon(), colorx(), nameOf(), readLine(), and xyOf().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ extoken_fn()

int extoken_fn ( Expr_t ex)
extern

Definition at line 311 of file extoken.c.

References agxbclear(), agxbput(), agxbputc(), agxbuse(), AND, CHARACTER, chrtoi(), DEC, DECLARE, dtinsert, dtmatch, dtview(), DYNAMIC, EQ, error_info, EX_CHARSTRING, ex_lval, EX_NAMELEN, exerror(), exnospace(), expr, expush(), extoken_fn(), exunlex, FLOATING, EX_STYPE::floating, GE, gv_isalnum(), gv_isalpha(), gv_isdigit(), gv_isspace(), gv_isxdigit(), ID, EX_STYPE::id, id_string, INC, Exid_s::index, INTEGER, EX_STYPE::integer, LABEL, LE, lex, Exid_s::lex, Error_info_s::line, LSH, NAME, Exid_s::name, NE, Exstate_s::nolabel, NULL, EX_STYPE::op, OR, PRAGMA, RSH, setcontext, streq(), stresc(), STRING, EX_STYPE::string, Expr_s::symbols, UNREACHABLE, UNSIGNED, Expr_s::vm, vmalloc(), and vmstrdup().

Referenced by extoken_fn().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ extype()

char * extype ( long int  type)
extern

Definition at line 24 of file extype.c.

References FLOATING, STRING, type, and UNSIGNED.

Referenced by gen().

Here is the caller graph for this function:

◆ extypename()

char * extypename ( Expr_t p,
long   
)
extern

Referenced by xConvert(), and xPrint().

Here is the caller graph for this function:

◆ exwarn()

void exwarn ( const char *  format,
  ... 
)
extern

Definition at line 79 of file exerror.c.

References ERROR_WARNING, expr, format, free(), make_msg(), and Exstate_s::program.

Referenced by exsub(), readFile(), and writeFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ exzero()

Extype_t exzero ( long int  type)
extern

Definition at line 24 of file exzero.c.

References expr, FLOATING, EX_STYPE::floating, INTEGER, EX_STYPE::integer, Exstate_s::nullstring, STRING, EX_STYPE::string, type, and UNSIGNED.

Referenced by eval(), getdyn(), and refval().

Here is the caller graph for this function: