Graphviz 12.0.1~dev.20240716.0800
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:193
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:128
Expr_t * exopen(Exdisc_t *disc)
Definition exopen.c:28
#define PROCEDURE
Definition exparse.c:270
void exclose(Expr_t *, int)
Exid_t * symbols
Definition expr.h:174
Definition expr.h:93
char name[EX_NAMELEN]
Definition expr.h:103
Definition expr.h:202
Dt_t * symbols
Definition expr.h:204
FILE * file[10]
Definition expr.h:205
Vmalloc_t * vm
Definition expr.h:206
const char * id
Definition expr.h:203
Vmalloc_t * vmopen(void)
Definition vmopen.c:18