From 4d65fcb9a8b6c7c6fd5a3390c46a96d11b6a80d4 Mon Sep 17 00:00:00 2001 From: Alex AUVOLAT Date: Sat, 8 Jun 2013 23:09:52 +0200 Subject: All FWIK is deleted. YOSH is now pure C. Not-working KBASIC included. --- src/user/app/kbasic/basic.h | 75 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 src/user/app/kbasic/basic.h (limited to 'src/user/app/kbasic/basic.h') 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 + -- cgit v1.2.3