/* 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