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