68 "-- shouldn't appear --",
83 fatal(
char * fmt, ...)
87 fprintf( stderr,
"\nNewgen Fatal Error -- " ) ;
88 vfprintf( stderr, fmt, args) ;
103 fprintf( stderr,
"\nNewgen User Error -- " ) ;
104 vfprintf( stderr, fmt, args ) ;
121 for( sp =
keywords ; *sp != NULL ; sp++ ) {
122 if( strcmp( s, *sp ) == 0 ) {
123 user(
"Trying to use the reserved word %s\n", s ) ;
139 {
"bool",
"1",
"B%d",
"newgen:gen-true",
"~S"},
140 {
"char",
"#\\a",
"#\\%c",
"#\\space",
"~C"},
141 {
"int",
"0",
"%d",
"0",
"~D"},
142 {
"float",
"0.0",
"%f",
"0.0",
"~F"},
143 {
"string",
"\"\"",
"\"%s\"",
"\"\"",
"~S"},
144 {NULL,
"-- HELP --",
"-- HELP --",
"-- HELP --",
"-- HELP --"},
156 for( ip = Inline, bp =
Domains ; ip->
name != NULL ; ip++, bp++ ) {
165 bp->
name =
"Name for tabulated domain" ;
199 if( bp->
name == NULL ) {
203 else if( strcmp( bp->
name,
name ) == 0 ) break ;
208 fatal(
"lookup: Domains overflow on %s -- new\n",
name ) ;
213 user(
"Unknown domain <%s>\n",
name ) ;
240 if( bp->
domain == NULL ) {
242 (void)
fprintf(stderr,
"Introducing %s at index %d\n",
254 user(
"Redeclaration skipped: <%s>\n",
name ) ;
267 struct domainlist *l ;
271 fatal(
"print_domainlist: null",
"" ) ;
273 for( ; l->cdr != NULL ; l = l->cdr ) {
329 struct intlist *ilp ;
335 for( ilp = dp->
ar.
dimensions ; ilp != NULL ; ilp = ilp->cdr )
386 struct domainlist *dlp ;
410 for( dlp = dp->
co.
components ; dlp != NULL ; dlp = dlp->cdr ) {
443 user(
"compile: tabulated first %s domain isn't string\n",
469 if( (
id = fopen(
filename,
"w" )) == NULL ) {
470 user(
"Cannot open spec file %s in write mode\n",
filename ) ;
491 user(
"not enough arguments provided, need 3, got %d!", argc);
505 if( (p=
malloc( (
unsigned)size )) == NULL && size != 0)
506 fatal(
"alloc: No more memory for %s bytes\n",
i2a( size )) ;
void reconnect(int op, union domain *dp)
void init(void)
INIT initializes global data structures.
int error_seen
Have we seen a user error somewhere ?
char * alloc(int size)
ALLOC is an "iron-clad" version of malloc(3).
static char * Op_names[]
Warning: this table knows about the actual values used for AND_OP and OR_OP.
static int current_first
RECONNECT replaces the (STRUCT BINDING *) members of the DP domain which are, on entry,...
struct gen_binding * new_binding(char *name, union domain *val)
NEW_BINDING introduces a new pair (NAME, VAL) in the Domains table.
__attribute__((__noreturn__))
FATAL generates a fatal error by printing (according to FORMAT) the given MSG.
int Current_op
Used to check, while parsing specs, that a constructed domain use only one operator type.
void print_domains(FILE *out)
PRINT_DOMAINS prints on the OUT stream the Domains table.
void check_not_keyword(char *s)
CHECK_NOT_KEYWORD checks if S isn't a reserved word.
void gen_write_spec(char *filename)
GEN_WRITE_SPEC prints the Domains table in the given FILENAME.
struct gen_binding * lookup(char *name, int action)
LOOKUP checks whether a given NAME is in the Domains table.
void print_domainlist(out, l, op)
PRINT_DOMAINLIST prints, in the OUT stream, the List of domains, bound together by an OPerator.
void print_domain(FILE *out, union domain *dp)
PRINT_DOMAIN prints on the OUT stream a domain denoted by the DP pointer.
void compile(void)
COMPILE reconnects the Domains table (for not compiled types – note that an inlined type is already c...
int build(int argc, char *argv[])
BUILD (in fact, the "main" function) parses the specifications and generates the manipulation functio...
void print_persistant(out, dp)
int gen_size(int domain)
GEN_SIZE returns the size (in gen_chunks) of an object of type defined by the BP type.
void gencode(string file)
generate the code necessary to manipulate every internal non-inlinable type in the Domains table.
struct gen_binding * Tabulated_bp
pointer to tabulated domain hack
int Read_spec_mode
extern int Current_first ;
struct gen_binding Domains[MAX_DOMAIN]
in build.c
char * i2a(int)
I2A (Integer TO Ascii) yields a string for a given Integer.
#define IS_INLINABLE(bp)
Different kinds of BINDING structure pointers.
#define MAX_DOMAIN
MAX_DOMAIN is the maximum number of entries in the DOMAINS table.
void user(char *,...)
External routines.
#define UNIT_TYPE_NAME
The UNIT_TYPE_NAME is the used to type expressions which only perform side-effects.
#define NEW_BINDING
Action parameter to the LOOKUP() function in the symbol table.
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
struct inlinable * inlined
gen_tabulated_p tabulated
number of chunks to hold this data.
INLINE[] gives, for each inlinable (i.e., unboxed) type, its NAME, its initial VALUE and its printing...
A DOMAIN union describes the structure of a user type.
struct gen_binding * element
struct domainlist * components
struct intlist * dimensions
struct gen_binding * constructand