summaryrefslogtreecommitdiff
path: root/src/user/app/kbasic/basic.h
diff options
context:
space:
mode:
authorAlex AUVOLAT <alexis211@gmail.com>2013-06-08 23:09:52 +0200
committerAlex AUVOLAT <alexis211@gmail.com>2013-06-08 23:09:52 +0200
commit4d65fcb9a8b6c7c6fd5a3390c46a96d11b6a80d4 (patch)
treec193acf64ff2db985f6664f161cf586c3caeb684 /src/user/app/kbasic/basic.h
parenteae9997d3c2dbaef53022ddabe61c1800a619499 (diff)
downloadTCE-4d65fcb9a8b6c7c6fd5a3390c46a96d11b6a80d4.tar.gz
TCE-4d65fcb9a8b6c7c6fd5a3390c46a96d11b6a80d4.zip
All FWIK is deleted. YOSH is now pure C. Not-working KBASIC included.
Diffstat (limited to 'src/user/app/kbasic/basic.h')
-rw-r--r--src/user/app/kbasic/basic.h75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/user/app/kbasic/basic.h b/src/user/app/kbasic/basic.h
new file mode 100644
index 0000000..b3491da
--- /dev/null
+++ b/src/user/app/kbasic/basic.h
@@ -0,0 +1,75 @@
+/* A tiny BASIC interpreter */
+
+/*
+ Thank the Internet for providing me with this program.
+ Please report any bugs/security holes to: katchup@adnab.fr.nf
+*/
+
+#ifndef DEF_BASIC_H
+#define DEF_BASIC_H
+
+
+// Token types
+#define DELIMITER 1
+#define VARIABLE 2
+#define NUMBER 3
+#define COMMAND 4
+#define STRING 5
+#define QUOTE 6
+
+// Keywords
+#define EOL 98 // Special characters
+#define FINISHED 99
+#define IF 1 // Control structures
+#define THEN 2
+#define FOR 3
+#define NEXT 4
+#define TO 5
+#define GOTO 6
+#define GOSUB 7
+#define RETURN 8
+#define END 9
+#define EXEC 10
+#define LOAD 11
+#define RUN 12
+#define LIST 13
+#define PRINT 20 // Built-in commands
+#define INPUT 21
+#define RND 50 // Built-in functions
+
+// Buffer size definitions
+#define TOK_LEN 80
+#define LAB_LEN 10 // Control structures
+#define NUM_LAB 100
+#define FOR_NEST 25
+#define SUB_NEST 25
+
+// Lexer
+extern char *program; // Data for program
+extern char *prog_ip; // Program instructino pointer
+extern char token[TOK_LEN];
+extern int token_type, tok;
+int get_token();
+void putback();
+void find_eol();
+char *load_file(char *fname);
+
+// Data structures
+int* find_var(char *s); // returns a pointer to the variable
+
+// Program structure
+void init();
+extern char *interp_name; /* given by command line argument 0 */
+void load_program(char *); // load and scan labels
+void insert_line(char *l, int n); // add line to program
+int start(char *entry); // start execution at given point
+void serror(int);
+
+// BASIC commands
+void exec_print(), input();
+void assignment();
+void get_exp(int*);
+
+
+#endif
+