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
27Expr_t*
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}
CDT_API Dtmethod_t * Dtset
set with unique elements
Definition dthash.c:277
#define dtinsert(d, o)
Definition cdt.h:185
CDT_API Dt_t * dtopen(Dtdisc_t *, Dtmethod_t *)
Definition dtopen.c:9
Exid_t exbuiltin[]
Definition exdata.c:24
#define setcontext(p)
Definition exlib.h:126
Expr_t * exopen(Exdisc_t *disc)
Definition exopen.c:28
#define PROCEDURE
Definition exparse.c:269
static Dtdisc_t disc
Definition exparse.y:209
void exclose(Expr_t *, int)
Definition expr.h:93
char name[EX_NAMELEN]
Definition expr.h:102
Definition expr.h:200
Dt_t * symbols
Definition expr.h:202
FILE * file[10]
Definition expr.h:203
Vmalloc_t * vm
Definition expr.h:204
const char * id
Definition expr.h:201
Vmalloc_t * vmopen(void)
Definition vmopen.c:18