File: main.c

package info (click to toggle)
yorick 1.4-14
  • links: PTS
  • area: main
  • in suites: potato
  • size: 5,948 kB
  • ctags: 6,609
  • sloc: ansic: 63,898; yacc: 889; makefile: 605; sh: 65; lisp: 60; fortran: 19
file content (76 lines) | stat: -rw-r--r-- 2,316 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
    MAIN.C
    A simple but adequate main for a Yorick-based code.

    $Id: main.c,v 1.1 1993/08/27 18:32:09 munro Exp $
 */
/*    Copyright (c) 1994.  The Regents of the University of California.
                    All rights reserved.  */

typedef void BuiltIn(int);

#ifndef __cplusplus
extern int ym_argc;
extern char **ym_argv;
extern void YMainLoop(void);      /* task.c */

extern void YorickInit(BuiltIn **, void **, char **, char **);
/* Codger-generated arrays from ycode.c used in call to YorickInit */
extern BuiltIn *yBuiltIns[];
extern void *yGlobals[];
extern char *yLinkNames[];
extern char *initialIncludes[];

extern int matherr(int *);
void YError(const char *);        /* ydata.h */
void YWarning(const char *);      /* ydata.h */
#else
/* Note __cplusplus is for version 2.0, c_plusplus for version 1.2 */
extern "C" {
extern int ym_argc;
extern char **ym_argv;
extern void YMainLoop(void);      /* task.c */

extern void YorickInit(BuiltIn **, void **, char **, char **);
/* Codger-generated arrays from ycode.c used in call to YorickInit */
extern BuiltIn *yBuiltIns[];
extern void *yGlobals[];
extern char *yLinkNames[];
extern char *initialIncludes[];

extern int matherr(int *);
void YError(const char *);        /* ydata.h */
void YWarning(const char *);      /* ydata.h */
}
#endif

int main(int argc, char *argv[])
{
  ym_argc= argc;
  ym_argv= argv;
  YorickInit(yBuiltIns, yGlobals, yLinkNames, initialIncludes);
  YMainLoop();
  return 0;
}

/* On UNIX systems, the math library routines defined in math.h call
   matherr to signal many errors -- for Yorick, want this to halt
   the virtual machine immediately.  This is not a part of the
   ANSI C standard.  The function is placed here rather than in
   libyor.a to be sure that it will in fact replace the default
   version in libm.a.  */
#ifndef UNDERFLOW
/* matherr may be called for silly reasons such as underflow or
   loss of precision, which must NOT cause Yorick to abort.
   On SunOS, HPUX, and UNICOS, at least, the type numbers less
   than 4 are serious, while those greater or equal to 4 are not.  */
#define UNDERFLOW 4
#endif
/* ARGSUSED */
int matherr(int *type)
{
  extern int y_catch_category;
  y_catch_category= 0x01;
  if (*type<UNDERFLOW) YError("math library exception handler called");
  return 1;
}