summaryrefslogtreecommitdiff
path: root/apl9.h
blob: 6b5445c5ede0868ea2ac8470606c536539986d2f (plain) (blame)
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
/* Global definitions of limits and constants */
#define MAX_LINE_LENGTH 1024
#define MAX_LINE_TOKENS 1024

typedef enum
{
	ArrayTag,
	FunctionTag,
	HybridTag,
	MonadicOpTag,
	DyadicOpTag,
	BoundFunctionTag, /* Function with left arg bound */
	LParTag,
	RParTag,
	LCurlTag,
	RCurlTag,
	LBracketTag,
	RBracketTag
} datumTag;

typedef enum
{
	AtypeInt
} arrayDataType;

/* Data types */
typedef struct Array Array;
typedef struct Datum Datum;

struct Array
{
	arrayDataType type;
	int rank;
	int *shape;
	union {
		char *rawdata;
		vlong *intdata;
	};
};

struct Datum
{
	datumTag tag;
	Rune *strrep;
	union {
		Array *array;
	};
};

/* Function prototypes for the different source files */
/* print.c */
Rune *ppdatum(Datum);
Rune *ppdatums(Datum *, int);

/* lexer.c */
Datum *lexline(Rune *, int *);

/* array.c */
Array *mkscalarint(vlong);

/* eval.c */
Datum *eval(Datum *, int *);

/* Global variables */
Rune *errormsg; /* eval.c */