Graphviz 12.0.1~dev.20240716.0800
Loading...
Searching...
No Matches
exlib.h
Go to the documentation of this file.
1/*************************************************************************
2 * Copyright (c) 2011 AT&T Intellectual Property
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * https://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors: Details at https://graphviz.org
9 *************************************************************************/
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
15/*
16 * Glenn Fowler
17 * AT&T Research
18 *
19 * expression library private definitions
20 */
21
22#ifndef _EXLIB_H
23#define _EXLIB_H
24
25#include <ast/ast.h>
26#include <cgraph/agxbuf.h>
27#include <sfio/sfio.h>
28#include <stdio.h>
29
30typedef struct Exinput_s /* input stack */
31{
32 struct Exinput_s*next; /* next in stack */
33 int close; /* close fp on pop */
34 char* file; /* previous file */
35 FILE* fp; /* expression file pointer */
36 int line; /* previous line */
37 int nesting; /* expression nesting level */
38 int peek; /* 1 char peek */
39 int unit; /* first frame in parse unit */
40 char* pushback; /* pushback buffer */
41 char* pp; /* pushback pointer */
43
44typedef struct Print_s /* compiled printf arg node */
45{
46 struct Print_s* next; /* next arg */
47 char* format; /* printf format for arg */
48 struct Exnode_s*param[3]; /* 0:width 1:precision 2:base */
49 struct Exnode_s*arg; /* arg to format */
51
52#define _EX_DATA_PRIVATE_ \
53 Exnode_t* next; /* free list link */ \
54 Extype_t value; /* dynamic variable value */ \
55 struct \
56 { \
57 Exid_t* procedure; /* called procedure */ \
58 Exnode_t* args; /* actual argument list */ \
59 } call; /* procedure call */ \
60 struct \
61 { \
62 Exnode_t* array; /* array name */ \
63 Exid_t* index; /* array index */ \
64 Exnode_t* statement; /* statement to apply */ \
65 } generate; /* associative array generator */ \
66 struct \
67 { \
68 Exid_t* array; /* array */ \
69 Exnode_t* string; /* string */ \
70 Exnode_t* seps; /* optional separators */ \
71 } split; /* string split */ \
72 struct \
73 { \
74 Exnode_t* descriptor; /* Expr_t.file index */ \
75 Print_t* args; /* compiler printf args */ \
76 } print; /* printf */ \
77 struct \
78 { \
79 Exnode_t* base; /* base string */ \
80 Exnode_t* pat; /* pattern or start index */ \
81 Exnode_t* repl; /* optional replacement or end index */ \
82 } string; /* string builtins */ \
83 struct \
84 { \
85 Exnode_t* args; /* formal arg list */ \
86 Exnode_t* body; /* body */ \
87 Dt_t* frame; /* local symbol frame */ \
88 int arity; /* # formal args */ \
89 } procedure; /* procedure args and body */ \
90 struct \
91 { \
92 Exnode_t* descriptor; /* Expr_t.file index */ \
93 Exnode_t* format; /* format arg */ \
94 Exnode_t* args; /* actual args */ \
95 } scan; /* printf */
96
97#define _EX_NODE_PRIVATE_ \
98 int subop; /* operator qualifier */
99
100#define _EX_PROG_PRIVATE_ \
101 Vmalloc_t* ve; /* eval tmp region */ \
102 Dt_t* frame; /* frame symbol table */ \
103 Dtdisc_t symdisc; /* Expr_t.symbols discipline */ \
104 Exdisc_t* disc; /* user discipline */ \
105 Exinput_t* input; /* input stack */ \
106 Expr_t* program; /* previous program on stack */ \
107 agxbuf tmp; /* tmp string buffer */ \
108 Extype_t loopret; /* return value */ \
109 Exid_t main; /* main procedure */ \
110 char line[512]; /* last few input tokens */ \
111 char* linep; /* line[] pointer */ \
112 int eof; /* lex hit eof */ \
113 int errors; /* fatal error count */ \
114 int formals; /* parsing formal args */ \
115 int linewrap; /* linep wrapped around line[] */ \
116 long long loopcount; /* break|continue|return count */ \
117 int loopop; /* break|continue|return op */ \
118 int nesting; /* exstatement() nesting */
119
120#include <expr/expr.h>
121#include <ctype.h>
122#include <ast/error.h>
123
124#define id_string (&exbuiltin[0])
125
126#define exunlex(p,c) ((p)->linep--,(p)->input->peek=(c))
127#define putcontext(p,c) (((p)->linep>=&(p)->line[sizeof((p)->line)]?(p)->linep=(p)->line,(p)->linewrap=1:0),*(p)->linep++=(c))
128#define setcontext(p) ((p)->linep=(p)->line,(p)->linewrap=0)
129
130typedef struct Switch_s /* switch parse state */
131{
132 struct Switch_s*prev; /* previous switch state */
133 Exnode_t* firstcase; /* first case block */
134 Exnode_t* lastcase; /* last case block */
135 Exnode_t* defcase; /* default case block */
136 Extype_t** base; /* label base pointer */
137 Extype_t** cur; /* current label pointer */
138 Extype_t** last; /* last label pointer */
139 int def; /* default label hit */
140 long type;
142
143typedef struct Exassoc_s /* associative array bucket */
144{
145 Dtlink_t link; /* table link */
146 Extype_t key; /* key */
147 Extype_t value; /* value */
148 char name[1]; /* index name */
150
151typedef struct Exstate_s /* ex global state */
152{
153 Exid_t* id; /* current declaration id */
154 long declare;
155 int nolabel; /* <id>':' not a label */
156 Exinput_t null; /* null input */
157 Expr_t* program; /* current program */
158 Exnode_t* procedure; /* current procedure */
159 Exref_t* refs; /* . reference list */
160 int assigned; /* declaration assignment */
161 int instatic; /* static declaration */
162 int statics; /* static used */
163 Switch_t* swstate; /* switch parse state */
164 char nullstring[1]; /* "" */
166
167extern Exid_t exbuiltin[];
168extern const char* exversion;
169extern Exstate_t expr;
170
171extern int ex_parse(void); /* yacc should do this */
172
173#endif
174
175#ifdef __cplusplus
176}
177#endif
struct Exassoc_s Exassoc_t
struct Switch_s Switch_t
Exid_t exbuiltin[]
Definition exdata.c:24
struct Exinput_s Exinput_t
struct Print_s Print_t
Exstate_t expr
int ex_parse(void)
const char * exversion
Definition exdata.c:22
struct Exstate_s Exstate_t
char name[1]
Definition exlib.h:148
Extype_t key
Definition exlib.h:146
Extype_t value
Definition exlib.h:147
Dtlink_t link
Definition exlib.h:145
Definition expr.h:93
int nesting
Definition exlib.h:37
char * pp
Definition exlib.h:41
char * file
Definition exlib.h:34
int line
Definition exlib.h:36
char * pushback
Definition exlib.h:40
int unit
Definition exlib.h:39
struct Exinput_s * next
Definition exlib.h:32
int close
Definition exlib.h:33
FILE * fp
Definition exlib.h:35
int peek
Definition exlib.h:38
Definition expr.h:202
int instatic
Definition exlib.h:161
int nolabel
Definition exlib.h:155
int assigned
Definition exlib.h:160
int statics
Definition exlib.h:162
Exid_t * id
Definition exlib.h:153
Exinput_t null
Definition exlib.h:156
Expr_t * program
Definition exlib.h:157
Exref_t * refs
Definition exlib.h:159
long declare
current declaration type
Definition exlib.h:154
Exnode_t * procedure
Definition exlib.h:158
char nullstring[1]
Definition exlib.h:164
Switch_t * swstate
Definition exlib.h:163
struct Exnode_s * param[3]
Definition exlib.h:48
char * format
Definition exlib.h:47
struct Exnode_s * arg
Definition exlib.h:49
struct Print_s * next
Definition exlib.h:46
Extype_t ** last
Definition exlib.h:138
int def
Definition exlib.h:139
Exnode_t * defcase
Definition exlib.h:135
struct Switch_s * prev
Definition exlib.h:132
long type
switch test type
Definition exlib.h:140
Extype_t ** cur
Definition exlib.h:137
Exnode_t * lastcase
Definition exlib.h:134
Extype_t ** base
Definition exlib.h:136
Exnode_t * firstcase
Definition exlib.h:133