aboutsummaryrefslogtreecommitdiff
path: root/src/prc1/kw.c
blob: 45657b7424342c5362e1213435d51dec351d837a (plain) (blame)
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
#include "prv.h"
#include <stddef.h>
#include <string.h>

static const char *kws[] =
{
    /* headers */
    "public", "function",
    /* sections */
    "types", "storage", "linkage", "procedure", "locals", "globals", "imports",
    /* types */
    "union", "struct", "constant", "alias", "prototype",
    /* operators */
    "add", "subtract", "multiply", "divide", "negate", "xor", "bitor", "bitand",
    "leftshift", "rightshift", "call", "set",
    /* expressions */
    "address", "cast", "contents", "offset", "size",
    /* procedures */
    "using", "returning",
    /* built-in functions */
    "display", "warn",
    /* flow control */
    "while", "if", "else", "end", "return", "go", "label", /*"default",*/
    /* prepositions */
    "by", "from", "to", "than", "of", "etc",
    /* comparators */
    "is", "not", "equal", "greater", "smaller", "and", "or",
    /* built-in types */
    "void", "array", "pointer",
    /* built-in signed types */
    "byte", "halfword", "word", "long",
    /* built-in unsigned types */
    "ubyte", "uhalfword", "uword", "ulong"
};

int kw(const char *s)
{
    for (size_t i = 0; i < sizeof kws / sizeof *kws; i++)
        if (!strcmp(s, kws[i]))
            return 1;

    return 0;
}