summaryrefslogtreecommitdiff
path: root/apl9.h
diff options
context:
space:
mode:
authorPeter Mikkelsen <petermikkelsen10@gmail.com>2022-01-08 22:45:00 +0000
committerPeter Mikkelsen <petermikkelsen10@gmail.com>2022-01-08 22:45:00 +0000
commit1ef3119fe613823a2145126c58948361ca7d3cd8 (patch)
tree5252d957ae512e1a727c9dec2b31e7b2a1d63e56 /apl9.h
parent214cdacca02552649d63f9045fdb8a17cfbb6fca (diff)
Add initial code, just to get started
Diffstat (limited to 'apl9.h')
-rw-r--r--apl9.h65
1 files changed, 65 insertions, 0 deletions
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