Graphviz
13.0.0~dev.20241220.2304
Loading...
Searching...
No Matches
exopen.c
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
/*
12
* Glenn Fowler
13
* AT&T Research
14
*
15
* expression library
16
*/
17
18
#include <
expr/exlib.h
>
19
#include <stdlib.h>
20
#include <stdio.h>
21
#include <string.h>
22
23
/*
24
* allocate a new expression program environment
25
*/
26
27
Expr_t
*
28
exopen
(
Exdisc_t
*
disc
)
29
{
30
Expr_t
* program;
31
Exid_t
* sym;
32
33
if
(!(program = calloc(1,
sizeof
(
Expr_t
))))
34
return
0;
35
program->symdisc.key = offsetof(
Exid_t
, name);
36
if
(!(program->
symbols
=
dtopen
(&program->symdisc,
Dtset
)) ||
37
!(program->
vm
=
vmopen
()) ||
38
!(program->ve =
vmopen
()))
39
{
40
exclose
(program, 1);
41
return
0;
42
}
43
program->
id
=
"libexpr:expr"
;
44
program->disc =
disc
;
45
setcontext
(program);
46
program->
file
[0] = stdin;
47
program->
file
[1] = stdout;
48
program->
file
[2] = stderr;
49
strcpy(program->main.name,
"main"
);
50
program->main.lex =
PROCEDURE
;
51
program->main.index =
PROCEDURE
;
52
dtinsert
(program->
symbols
, &program->main);
53
for
(sym =
exbuiltin
; *sym->
name
; sym++)
54
dtinsert
(program->
symbols
, sym);
55
if
((sym =
disc
->symbols))
56
for
(; *sym->
name
; sym++)
57
dtinsert
(program->
symbols
, sym);
58
return
program;
59
}
Dtset
CDT_API Dtmethod_t * Dtset
set with unique elements
Definition
dthash.c:277
dtinsert
#define dtinsert(d, o)
Definition
cdt.h:185
dtopen
CDT_API Dt_t * dtopen(Dtdisc_t *, Dtmethod_t *)
Definition
dtopen.c:9
exbuiltin
Exid_t exbuiltin[]
Definition
exdata.c:24
exlib.h
setcontext
#define setcontext(p)
Definition
exlib.h:126
exopen
Expr_t * exopen(Exdisc_t *disc)
Definition
exopen.c:28
PROCEDURE
#define PROCEDURE
Definition
exparse.c:269
disc
static Dtdisc_t disc
Definition
exparse.y:209
exclose
void exclose(Expr_t *, int)
Exdisc_s
Definition
expr.h:169
Exid_s
Definition
expr.h:93
Exid_s::name
char name[EX_NAMELEN]
Definition
expr.h:102
Expr_s
Definition
expr.h:200
Expr_s::symbols
Dt_t * symbols
Definition
expr.h:202
Expr_s::file
FILE * file[10]
Definition
expr.h:203
Expr_s::vm
Vmalloc_t * vm
Definition
expr.h:204
Expr_s::id
const char * id
Definition
expr.h:201
vmopen
Vmalloc_t * vmopen(void)
Definition
vmopen.c:18
lib
expr
exopen.c
Generated by
1.9.8