- Added the ability to start a line with a number and store it for later execution
- Added the ability to force immediate mode processing (calculator mode) by beginning a line with = - Expanded parser testing - Expression execution seems to be broken now, everything is returning error code 0 and not returning results
This commit is contained in:
62
src/basic.h
62
src/basic.h
@@ -1,23 +1,29 @@
|
||||
#ifndef _BASIC_H_
|
||||
#define _BASIC_H_
|
||||
|
||||
#define BASIC_OPTP_ADD 1
|
||||
#define BASIC_OPTP_SUB 2
|
||||
#define BASIC_OPTP_MUL 3
|
||||
#define BASIC_OPTP_DIV 4
|
||||
#define BASIC_OPTP_MOD 5
|
||||
#define BASIC_OPTP_EQL 6
|
||||
#define BASIC_OPTP_ASN 7
|
||||
#define BASIC_MAX_LINES 1000
|
||||
#define BASIC_MAX_LINE_LENGTH 256
|
||||
|
||||
#define BASIC_LVAL_EXPR 0
|
||||
#define BASIC_LVAL_VAR 1
|
||||
#define BASIC_LVAL_CONST 2
|
||||
#define BASIC_RVAL_EXPR 3
|
||||
#define BASIC_RVAL_VAR 4
|
||||
#define BASIC_RVAL_CONST 5
|
||||
#define BASIC_OPTP_ADD 1 /* Add */
|
||||
#define BASIC_OPTP_SUB 2 /* Subtract */
|
||||
#define BASIC_OPTP_MUL 3 /* Multiply */
|
||||
#define BASIC_OPTP_DIV 4 /* Divide */
|
||||
#define BASIC_OPTP_MOD 5 /* Modulus */
|
||||
#define BASIC_OPTP_EQL 6 /* Equality test */
|
||||
#define BASIC_OPTP_ASN 7 /* Assignment */
|
||||
#define BASIC_OPTP_STOR 8 /* Store line for later */
|
||||
|
||||
#define BASIC_FOUND_LVAL 0x0001
|
||||
#define BASIC_FOUND_RVAL 0x0002
|
||||
#define BASIC_LVAL_EXPR 0
|
||||
#define BASIC_LVAL_VAR 1
|
||||
#define BASIC_LVAL_CONST 2
|
||||
#define BASIC_RVAL_EXPR 3
|
||||
#define BASIC_RVAL_VAR 4
|
||||
#define BASIC_RVAL_CONST 5
|
||||
#define BASIC_RVAL_PTR 6 /* Only used internally */
|
||||
|
||||
#define BASIC_PARSE_FOUND_LVAL 1
|
||||
#define BASIC_PARSE_FOUND_RVAL 2
|
||||
#define BASIC_PARSE_FIRSTTOKEN 4
|
||||
|
||||
#define BASIC_ERR_SYNTAX_MULTIPLE_LVALUES 1
|
||||
#define BASIC_ERR_SYNTAX_TOKEN_LENGTH 2
|
||||
@@ -34,6 +40,19 @@
|
||||
#define BASIC_TOKENIZER_MAX_LENGTH 512
|
||||
#define BASIC_VARNAME_MAX_LENGTH 16
|
||||
|
||||
struct basic_line {
|
||||
int lineno;
|
||||
char content[BASIC_MAX_LINE_LENGTH];
|
||||
struct basic_line *nextline;
|
||||
};
|
||||
typedef struct basic_line basic_line;
|
||||
|
||||
struct basic_program {
|
||||
char name[128];
|
||||
basic_line *first;
|
||||
};
|
||||
typedef struct basic_program basic_program;
|
||||
|
||||
union basic_value {
|
||||
char c;
|
||||
int i;
|
||||
@@ -67,19 +86,6 @@ struct basic_variable {
|
||||
};
|
||||
typedef struct basic_variable basic_variable;
|
||||
|
||||
struct basic_line {
|
||||
int lineno;
|
||||
char content[256];
|
||||
struct basic_line *nextline;
|
||||
};
|
||||
typedef struct basic_line basic_line;
|
||||
|
||||
struct basic_program {
|
||||
char name[128];
|
||||
basic_line *first;
|
||||
};
|
||||
typedef struct basic_program basic_program;
|
||||
|
||||
#define BASIC_CONST_TRUE 1
|
||||
#define BASIC_CONST_FALSE 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user