aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-06-27 01:41:50 -0400
committerB. Watson <urchlay@slackware.uk>2024-06-27 01:41:50 -0400
commit4251e9459250406dadeb0d2edf539c4f5207c21a (patch)
treecc0fb4287b9783d1c9cf4d9771a4ac1e59c6d9f5
parent35f4a061cc467b750e00894e4bea42e43599e26c (diff)
downloadbw-atari8-tools-4251e9459250406dadeb0d2edf539c4f5207c21a.tar.gz
bas.h: add rest of tokens.
-rw-r--r--bas.h172
-rw-r--r--tokens.c4
2 files changed, 139 insertions, 37 deletions
diff --git a/bas.h b/bas.h
index a464e0c..ed897ef 100644
--- a/bas.h
+++ b/bas.h
@@ -30,41 +30,143 @@
/* tokenized colon (statement separator) */
#define TOK_COLON 0x14
-/* BASIC tokens. Not a full set. BASIC uses 2 sets of tokens, one
- for commands and the other for operators (which is to say, everything
- *not* a command). */
-#define CMD_GOTO 0x0a
-#define CMD_GO_TO 0x0b
-#define CMD_ON 0x1e
-#define CMD_GOSUB 0x0c
-#define CMD_TRAP 0x0d
-#define CMD_IF 0x07
-#define CMD_LIST 0x04
-#define CMD_RESTORE 0x23
-#define CMD_REM 0x00
-#define CMD_DATA 0x01
-#define CMD_ERROR 0x37
-#define CMD_FOR 0x08
-#define CMD_NEXT 0x09
-#define CMD_LET 0x06
-#define CMD_ILET 0x36
-#define CMD_DIM 0x14
-#define CMD_READ 0x22
-#define CMD_INPUT 0x02
-#define CMD_GET 0x29
-#define CMD_LOCATE 0x31
-#define CMD_NOTE 0x1b
-#define OP_GOTO 0x17
-#define OP_GOSUB 0x18
-#define OP_THEN 0x1b
-#define OP_COMMA 0x12
-#define OP_ARR_COMMA 0x3c
-#define OP_SEMICOLON 0x15
-#define OP_EOS 0x14
-#define OP_EOL 0x16
-#define OP_NUMCONST 0x0e
-#define OP_STRCONST 0x0f
-#define OP_HASH 0x1c
+/* BASIC tokens. Full set, taken from Chapter 10 of De Re Atari.
+ I used a paper copy, but you can also find it on the web:
+ https://www.atariarchives.org/dere/chapt10.php
+ BASIC uses 2 sets of tokens, one for commands and the other for
+ operators (which is to say, everything *not* a command).
+ See tokens.h for the actual names. */
+
+/* commands (every statement begins with one of these) */
+#define CMD_REM 0x00
+#define CMD_DATA 0x01
+#define CMD_INPUT 0x02
+#define CMD_COLOR 0x03
+#define CMD_LIST 0x04
+#define CMD_ENTER 0x05
+#define CMD_LET 0x06
+#define CMD_IF 0x07
+#define CMD_FOR 0x08
+#define CMD_NEXT 0x09
+#define CMD_GOTO 0x0a
+#define CMD_GO_TO 0x0b
+#define CMD_GOSUB 0x0c
+#define CMD_TRAP 0x0d
+#define CMD_BYE 0x0e
+#define CMD_CONT 0x0f
+#define CMD_COM 0x10
+#define CMD_CLOSE 0x11
+#define CMD_CLR 0x12
+#define CMD_DEG 0x13
+#define CMD_DIM 0x14
+#define CMD_END 0x15
+#define CMD_NEW 0x16
+#define CMD_OPEN 0x17
+#define CMD_LOAD 0x18
+#define CMD_SAVE 0x19
+#define CMD_STATUS 0x1a
+#define CMD_NOTE 0x1b
+#define CMD_POINT 0x1c
+#define CMD_XIO 0x1d
+#define CMD_ON 0x1e
+#define CMD_POKE 0x1f
+#define CMD_PRINT 0x20
+#define CMD_RAD 0x21
+#define CMD_READ 0x22
+#define CMD_RESTORE 0x23
+#define CMD_RETURN 0x24
+#define CMD_RUN 0x25
+#define CMD_STOP 0x26
+#define CMD_POP 0x27
+#define CMD_QMARK 0x28 /* ? for PRINT */
+#define CMD_GET 0x29
+#define CMD_PUT 0x2a
+#define CMD_GRAPHICS 0x2b
+#define CMD_PLOT 0x2c
+#define CMD_POSITION 0x2d
+#define CMD_DOS 0x2e
+#define CMD_DRAWTO 0x2f
+#define CMD_SETCOLOR 0x30
+#define CMD_LOCATE 0x31
+#define CMD_SOUND 0x32
+#define CMD_LPRINT 0x33
+#define CMD_CSAVE 0x34
+#define CMD_CLOAD 0x35
+#define CMD_ILET 0x36 /* implied LET */
+#define CMD_ERROR 0x37
+
+/* operators. 0x00-0x0d and 0x0a-0x11 are not used.
+ 0x3d-0x54 are functions. */
+#define OP_NUMCONST 0x0e
+#define OP_STRCONST 0x0f
+#define OP_COMMA 0x12
+#define OP_DOLLAR 0x13
+#define OP_EOS 0x14
+#define OP_COLON 0x14
+#define OP_SEMICOLON 0x15
+#define OP_EOL 0x16
+#define OP_GOTO 0x17
+#define OP_GOSUB 0x18
+#define OP_TO 0x19
+#define OP_STEP 0x1a
+#define OP_THEN 0x1b
+#define OP_HASH 0x1c
+#define OP_NUM_LE 0x1d
+#define OP_NUM_NE 0x1e
+#define OP_NUM_GE 0x1f
+#define OP_NUM_LT 0x20
+#define OP_NUM_GT 0x21
+#define OP_NUM_EQ 0x22
+#define OP_POWER 0x23
+#define OP_MULT 0x24
+#define OP_PLUS 0x25
+#define OP_MINUS 0x26
+#define OP_DIVIDE 0x27
+#define OP_NOT 0x28
+#define OP_OR 0x29
+#define OP_AND 0x2a
+#define OP_GRP_LPAR 0x2b
+#define OP_GRP_RPAR 0x2c
+#define OP_NUM_ASSIGN 0x2d
+#define OP_STR_ASSIGN 0x2e
+#define OP_STR_LE 0x2f
+#define OP_STR_NE 0x30
+#define OP_STR_GE 0x31
+#define OP_STR_LT 0x32
+#define OP_STR_GT 0x33
+#define OP_STR_EQ 0x34
+#define OP_UPLUS 0x35
+#define OP_UMINUS 0x36
+#define OP_STR_LPAR 0x37
+#define OP_ARR_LPAR 0x38
+#define OP_DIM_ARR_LPAR 0x39
+#define OP_FUNC_LPAR 0x3a
+#define OP_DIM_STR_LPAR 0x3b
+#define OP_ARR_COMMA 0x3c
+#define OP_FUNC_STR 0x3d
+#define OP_FUNC_CHR 0x3e
+#define OP_FUNC_USR 0x3f
+#define OP_FUNC_ASC 0x40
+#define OP_FUNC_VAL 0x41
+#define OP_FUNC_LEN 0x42
+#define OP_FUNC_ADR 0x43
+#define OP_FUNC_ATN 0x44
+#define OP_FUNC_COS 0x45
+#define OP_FUNC_PEEK 0x46
+#define OP_FUNC_SIN 0x47
+#define OP_FUNC_RND 0x48
+#define OP_FUNC_FRE 0x49
+#define OP_FUNC_EXP 0x4a
+#define OP_FUNC_LOG 0x4b
+#define OP_FUNC_CLOG 0x4c
+#define OP_FUNC_SQR 0x4d
+#define OP_FUNC_SGN 0x4e
+#define OP_FUNC_ABS 0x4f
+#define OP_FUNC_INT 0x50
+#define OP_FUNC_PADDLE 0x51
+#define OP_FUNC_STICK 0x52
+#define OP_FUNC_PTRIG 0x53
+#define OP_FUNC_STRIG 0x54
/* variable types, bits 6-7 of byte 0 of each vvtable entry. */
#define TYPE_SCALAR 0
diff --git a/tokens.c b/tokens.c
index 08cf48a..32a818c 100644
--- a/tokens.c
+++ b/tokens.c
@@ -101,8 +101,8 @@ const char *operators[] = {
"+",
"-",
"(",
- "", /* $38, redunant for arrays */
- "", /* $39, ditto */
+ "", /* $38, redunant "(" for arrays */
+ "", /* $39, ditto for strings */
"(",
"(",
",",