diff options
| author | Xavier Del Campo Romero <xavi92@disroot.org> | 2026-09-05 17:14:53 +0200 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi92@disroot.org> | 2026-09-26 03:41:55 +0200 |
| commit | 3c0819236e4f07c8f57aaf1ca46d0d68aa761558 (patch) | |
| tree | bd8b57cf5420cabc4ec29815052df545b55026f9 /src/prc1/kw.c | |
| parent | a3f56c76444fee090e62a59f257ed5f60b4e552b (diff) | |
| download | prc-3c0819236e4f07c8f57aaf1ca46d0d68aa761558.tar.gz | |
Move source to src/prc1
Diffstat (limited to 'src/prc1/kw.c')
| -rw-r--r-- | src/prc1/kw.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/prc1/kw.c b/src/prc1/kw.c new file mode 100644 index 0000000..d5e22ca --- /dev/null +++ b/src/prc1/kw.c @@ -0,0 +1,41 @@ +#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", "xor", "bitor", "bitand", + "leftshift", "rightshift", "address", "size", "call", "set", + /* 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; +} |
