From 1ef3119fe613823a2145126c58948361ca7d3cd8 Mon Sep 17 00:00:00 2001 From: Peter Mikkelsen Date: Sat, 8 Jan 2022 22:45:00 +0000 Subject: Add initial code, just to get started --- apl9.h | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 apl9.h (limited to 'apl9.h') diff --git a/apl9.h b/apl9.h new file mode 100644 index 0000000..6b5445c --- /dev/null +++ b/apl9.h @@ -0,0 +1,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 */ \ No newline at end of file -- cgit v1.2.3