-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtokens.c
52 lines (46 loc) · 990 Bytes
/
tokens.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
bast - ZX Basic text to tape
Copyright Edward Cree, 2010
License: GNU GPL v3+
tokens: ZX Basic tokens data
*/
#include "tokens.h"
void mktoktbl(void)
{
ntokens=0;
tokentable=NULL;
#include "addtokens.c"
addtokd("GOTO", 0xEC); // alias GOTO -> GO TO
addtokd("GOSUB", 0xED); // alias GOSUB -> GO SUB
addtokd("+", '+');
addtokd("-", '-');
addtokd("*", '*');
addtokd("/", '/');
addtokd("^", '^');
addtokd("=", '=');
addtokd(">", '>');
addtokd("<", '<');
addtokd("(", '(');
addtokd(")", ')');
addtokd(",", ',');
addtokd(";", ';');
addtokd(":", ':');
addtokd("#", '#');
// SE BASIC functions: &, ~, \\->\ (can't use \ as \xx is a hex char literal)
addtokd("&", '&');
addtokd("\\\\", '\\');
addtokd("~", '~');
}
void addtokd(char *text, unsigned char tok)
{
token data;
data.text=text;
data.tok=tok;
addtoken(data);
}
void addtoken(token data)
{
ntokens++;
tokentable=(token *)realloc(tokentable, ntokens*sizeof(token));
tokentable[ntokens-1]=data;
}