varaq-wasm-c/tokenizer.c

741 lines
18 KiB
C
Raw Normal View History

2023-02-04 14:06:00 -05:00
#include "tokenizer.h"
#include "common.h"
/*
Adapted from Section 6.6 of The C Programming Language
by Brian Kernighan and Dennis Ritchie
*/
typedef struct Map Map;
struct Map
{
2023-03-04 13:20:59 -05:00
struct Map* next;
char* keyword;
2023-02-04 14:06:00 -05:00
TokenType token;
};
#define HASHSIZE 150
2023-03-04 13:20:59 -05:00
static Map* hashtab[HASHSIZE];
2023-02-04 14:06:00 -05:00
unsigned int
2023-03-04 13:20:59 -05:00
hash(char* s)
2023-02-04 14:06:00 -05:00
{
unsigned int hashval;
for (hashval = 0; *s != '\0'; s++)
hashval = *s + 31 * hashval;
return hashval % HASHSIZE;
}
2023-03-04 13:20:59 -05:00
Map*
lookup(char* s)
2023-02-04 14:06:00 -05:00
{
2023-03-04 13:20:59 -05:00
Map* np;
for (np = hashtab[hash(s)]; np != NULL; np = np->next)
if (strcmp(s, np->keyword) == 0)
2023-02-04 14:06:00 -05:00
return np;
return NULL;
}
TokenType
2023-03-04 13:20:59 -05:00
get(char* s)
2023-02-04 14:06:00 -05:00
{
2023-03-04 13:20:59 -05:00
Map* np;
for (np = hashtab[hash(s)]; np != NULL; np = np->next)
if (strcmp(s, np->keyword) == 0)
2023-02-04 14:06:00 -05:00
return np->token;
return TOKEN_IDENTIFIER;
}
2023-03-04 13:20:59 -05:00
Map*
put(char* keyword, TokenType token)
2023-02-04 14:06:00 -05:00
{
2023-03-04 13:20:59 -05:00
Map* np;
2023-02-04 14:06:00 -05:00
unsigned int hashval;
2023-03-04 13:20:59 -05:00
if ((np = lookup(keyword)) == NULL) {
np = (Map*)malloc(sizeof(*np));
if (np == NULL || (np->keyword = strdup(keyword)) == NULL)
return NULL;
hashval = hash(keyword);
np->next = hashtab[hashval];
hashtab[hashval] = np;
}
2023-02-04 14:06:00 -05:00
np->token = token;
return np;
}
void
2023-03-04 13:20:59 -05:00
initMap()
2023-02-04 14:06:00 -05:00
{
2023-03-04 13:20:59 -05:00
put("and", TOKEN_AND);
put("atan", TOKEN_ATAN);
put("add", TOKEN_ADD);
put("bep", TOKEN_COMPLAIN);
put("complain", TOKEN_COMPLAIN);
put("compl", TOKEN_COMPL);
put("compose", TOKEN_COMPOSE);
put("contradict", TOKEN_CONTRADICT);
put("cons", TOKEN_CONS);
put("cos", TOKEN_COS);
put("chImmoH", TOKEN_CLEAR);
put("chIm'a'", TOKEN_EMPTY);
put("cher", TOKEN_SET);
put("boq", TOKEN_ADD);
put("choose", TOKEN_CHOOSE);
put("chov", TOKEN_EVAL);
put("chuv", TOKEN_MOD);
put("cha'", TOKEN_DISP);
put("clear", TOKEN_CLEAR);
put("dup", TOKEN_DUP);
put("dump", TOKEN_DUMP);
put("disp", TOKEN_DISP);
put("div", TOKEN_DIV);
put("DuD", TOKEN_MIX);
put("e", TOKEN_E);
put("exch", TOKEN_EXCH);
put("eval", TOKEN_EVAL);
put("escape", TOKEN_ESCAPE);
put("empty?", TOKEN_EMPTY);
put("explode", TOKEN_EXPLODE);
put("eq?", TOKEN_EQ);
put("forget", TOKEN_FORGET);
put("gt?", TOKEN_GT);
put("ge?", TOKEN_GE);
put("ghap", TOKEN_XOR);
put("ghurmI'", TOKEN_E);
put("ghurtaH", TOKEN_LN);
put("ghorqu'", TOKEN_SHATTER);
put("ghobe'chugh", TOKEN_IFNO);
put("HIja'chugh", TOKEN_IFYES);
put("Hotlh", TOKEN_DUMP);
put("HeHmI'", TOKEN_PI);
put("Habwav", TOKEN_IDIV);
put("HabmI''a'", TOKEN_INT);
put("idiv", TOKEN_IDIV);
put("int?", TOKEN_INT);
put("isolate", TOKEN_ISOLATE);
put("ifyes", TOKEN_IFYES);
put("ifno", TOKEN_IFNO);
put("je", TOKEN_AND);
put("jor", TOKEN_EXPLODE);
put("joq", TOKEN_OR);
put("ln", TOKEN_LN);
put("lt?", TOKEN_LT);
put("le?", TOKEN_LE);
put("listen", TOKEN_LISTEN);
put("loS'ar", TOKEN_SQRT);
put("log", TOKEN_LOG);
put("log3", TOKEN_LOG3);
put("latlh", TOKEN_DUP);
put("law'moH", TOKEN_MUL);
put("law'qa'moH", TOKEN_POW);
put("law''a'", TOKEN_GT);
put("law'rap'a'", TOKEN_GE);
put("maHghurtaH", TOKEN_LOG);
put("mix", TOKEN_MIX);
put("mi'moH", TOKEN_NUMBERIZE);
put("muv", TOKEN_CONS);
put("mul", TOKEN_MUL);
put("mod", TOKEN_MOD);
put("mobmoH", TOKEN_ISOLATE);
put("mIScher", TOKEN_SETRAND);
put("mIS", TOKEN_RAND);
put("mI''a'", TOKEN_FLOAT);
put("nIHghoS", TOKEN_SHIFTRIGHT);
put("ne?", TOKEN_NE);
put("negative?", TOKEN_NEGATIVE);
put("name", TOKEN_NAME);
put("nargh", TOKEN_ESCAPE);
put("naQmoH", TOKEN_COMPOSE);
put("number?", TOKEN_ISNUMBER);
put("numberize", TOKEN_NUMBERIZE);
put("null?", TOKEN_NULL);
put("or", TOKEN_OR);
put("pi", TOKEN_PI);
put("pagh'a'", TOKEN_NULL);
put("pop", TOKEN_POP);
put("pong", TOKEN_NAME);
put("pow", TOKEN_POW);
put("poSghoS", TOKEN_SHIFTLEFT);
put("puS'a'", TOKEN_LT);
put("puSrap'a'", TOKEN_LE);
put("qaw", TOKEN_REMEMBER);
put("qawHa'", TOKEN_FORGET);
put("qojmI'", TOKEN_TAN);
put("qojHa'", TOKEN_ATAN);
put("Qo'moH", TOKEN_COMPL);
put("remember", TOKEN_REMEMBER);
put("repeat", TOKEN_REPEAT);
put("rand", TOKEN_RAND);
put("rap'a'", TOKEN_EQ);
put("rapbe'a'", TOKEN_NE);
put("set", TOKEN_SET);
put("split", TOKEN_SPLIT);
put("shatter", TOKEN_SHATTER);
put("strcut", TOKEN_STRCUT);
put("streq?", TOKEN_STREQ);
put("strmeasure", TOKEN_STRMEASURE);
put("strtie", TOKEN_STRTIE);
put("tlheghrar", TOKEN_STRTIE);
put("sub", TOKEN_SUB);
put("sub1", TOKEN_SUB1);
put("sqrt", TOKEN_SQRT);
put("sin", TOKEN_SIN);
put("clip", TOKEN_CLIP);
put("poD", TOKEN_CLIP);
put("smooth", TOKEN_SMOOTH);
put("Hab", TOKEN_SMOOTH);
put("howmuch", TOKEN_HOWMUCH);
put("'ar", TOKEN_HOWMUCH);
put("setrand", TOKEN_SETRAND);
put("shift right", TOKEN_SHIFTRIGHT);
put("shift left", TOKEN_SHIFTLEFT);
put("SIj", TOKEN_SPLIT);
put("boqHa'", TOKEN_SUB);
put("tam", TOKEN_EXCH);
put("tan", TOKEN_TAN);
put("taH'a'", TOKEN_NEGATIVE);
put("tlhoch", TOKEN_CONTRADICT);
put("tlheghpe'", TOKEN_STRCUT);
put("tlheghjuv", TOKEN_STRMEASURE);
put("tlheghrap'a'", TOKEN_STREQ);
put("vangqa'", TOKEN_REPEAT);
put("wIv", TOKEN_CHOOSE);
put("woD", TOKEN_POP);
put("wav", TOKEN_DIV);
put("wa'teq", TOKEN_SUB1);
put("wa'chel", TOKEN_ADD1);
put("wejghurtaH", TOKEN_LOG3);
put("xor", TOKEN_XOR);
put("\'Ij", TOKEN_LISTEN);
put("time", TOKEN_TIME);
put("poH", TOKEN_TIME);
2023-02-04 14:06:00 -05:00
// Wrong word in original spec, old one meant "waving hands or flapping"
// Also fixes the conflicting joq issue meaning sin or 'or'
2023-03-04 13:20:59 -05:00
put("yu'eghHa'", TOKEN_COS);
put("yu'egh", TOKEN_SIN);
2023-02-04 14:06:00 -05:00
// This one has a special case too as it is the same as the '~' operator
2023-03-04 13:20:59 -05:00
put("lI'moH", TOKEN_TILDE);
put("woDHa'", TOKEN_GARBAGE_COLLECT);
put("gc", TOKEN_GARBAGE_COLLECT);
2023-02-04 14:06:00 -05:00
}
typedef struct Tokenizer Tokenizer;
struct Tokenizer
{
2023-03-04 13:20:59 -05:00
char* start;
char* current;
2023-02-04 14:06:00 -05:00
int32_t line;
};
Tokenizer tokenizer;
void
2023-03-04 13:20:59 -05:00
initTokenizer(char* src)
2023-02-04 14:06:00 -05:00
{
tokenizer.start = src;
tokenizer.current = src;
tokenizer.line = 1;
}
static bool
2023-03-04 13:20:59 -05:00
isAlpha(char c)
2023-02-04 14:06:00 -05:00
{
2023-03-04 13:20:59 -05:00
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' ||
c == '\'' || c == '?';
2023-02-04 14:06:00 -05:00
}
static bool
2023-03-04 13:20:59 -05:00
isDigit(char c)
2023-02-04 14:06:00 -05:00
{
return (c >= '0' && c <= '9') || c == '-';
}
static bool
2023-03-04 13:20:59 -05:00
isAtEnd()
2023-02-04 14:06:00 -05:00
{
return *tokenizer.current == '\0';
}
static Token
2023-03-04 13:20:59 -05:00
makeToken(TokenType type)
2023-02-04 14:06:00 -05:00
{
Token token;
token.type = type;
token.start = tokenizer.start;
token.length = (int32_t)(tokenizer.current - tokenizer.start);
token.line = tokenizer.line;
return token;
}
static Token
2023-03-04 13:20:59 -05:00
errorToken(char* msg)
2023-02-04 14:06:00 -05:00
{
Token token;
token.type = TOKEN_ERROR;
token.start = msg;
2023-03-04 13:20:59 -05:00
token.length = (int32_t)strlen(msg);
2023-02-04 14:06:00 -05:00
token.line = tokenizer.line;
return token;
}
static char
2023-03-04 13:20:59 -05:00
advance()
2023-02-04 14:06:00 -05:00
{
tokenizer.current++;
return tokenizer.current[-1];
}
static char
2023-03-04 13:20:59 -05:00
peek()
2023-02-04 14:06:00 -05:00
{
return *tokenizer.current;
}
static char
2023-03-04 13:20:59 -05:00
peekNext()
2023-02-04 14:06:00 -05:00
{
2023-03-04 13:20:59 -05:00
if (isAtEnd())
2023-02-04 14:06:00 -05:00
return '\0';
return tokenizer.current[1];
}
static bool
2023-03-04 13:20:59 -05:00
match(char expected)
2023-02-04 14:06:00 -05:00
{
2023-03-04 13:20:59 -05:00
if (isAtEnd())
2023-02-04 14:06:00 -05:00
return false;
if (*tokenizer.current != expected)
return false;
tokenizer.current++;
return true;
}
static void
2023-03-04 13:20:59 -05:00
skipWhitespace()
2023-02-04 14:06:00 -05:00
{
2023-03-04 13:20:59 -05:00
for (;;) {
char c = peek();
switch (c) {
case ' ':
case '\r':
case '\t':
advance();
break;
case '\n':
tokenizer.line++;
advance();
break;
case '/':
if (peekNext() == '/') {
// Ignore the preprocessor import until end of the line.
while (peek() != '\n' && !isAtEnd())
advance();
} else {
2023-02-04 14:06:00 -05:00
return;
}
2023-03-04 13:20:59 -05:00
break;
case '(':
if (peekNext() == '*') {
advance(); // consume (
advance(); // consume *
while (!isAtEnd() && peek() != '*' && peekNext() != ')')
advance(); // Consume contents
advance(); // consume *
advance(); // consume )
}
break;
default:
return;
2023-02-04 14:06:00 -05:00
}
2023-03-04 13:20:59 -05:00
}
2023-02-04 14:06:00 -05:00
}
static TokenType
2023-03-04 13:20:59 -05:00
checkKeyword(int start, int length, char* rest, TokenType type)
2023-02-04 14:06:00 -05:00
{
2023-03-04 13:20:59 -05:00
if (tokenizer.current - tokenizer.start == start + length &&
memcmp(tokenizer.start + start, rest, length) == 0) {
return type;
}
2023-02-04 14:06:00 -05:00
return TOKEN_IDENTIFIER;
}
static TokenType
2023-03-04 13:20:59 -05:00
identifierType()
2023-02-04 14:06:00 -05:00
{
2023-03-04 13:20:59 -05:00
char* check;
2023-02-04 14:06:00 -05:00
int32_t size = tokenizer.current - tokenizer.start;
2023-03-04 13:20:59 -05:00
check = (char*)malloc(sizeof(size));
strncpy(check, tokenizer.start, size);
2023-02-04 14:06:00 -05:00
check[size] = '\0';
2023-03-04 13:20:59 -05:00
TokenType t = get(check);
free(check);
2023-02-04 14:06:00 -05:00
return t;
}
static Token
2023-03-04 13:20:59 -05:00
identifier()
2023-02-04 14:06:00 -05:00
{
2023-03-04 13:20:59 -05:00
while (isAlpha(peek()) || isDigit(peek()))
advance();
return makeToken(identifierType());
2023-02-04 14:06:00 -05:00
}
static Token
2023-03-04 13:20:59 -05:00
number()
2023-02-04 14:06:00 -05:00
{
bool is_float = false;
2023-03-04 13:20:59 -05:00
while (isDigit(peek()))
advance();
2023-02-04 14:06:00 -05:00
// Look for a fractional part.
2023-03-04 13:20:59 -05:00
if (peek() == '.' && isDigit(peekNext())) {
is_float = true;
// Consume the ".".
advance();
while (isDigit(peek()))
advance();
}
2023-02-04 14:06:00 -05:00
2023-03-04 13:20:59 -05:00
return makeToken(TOKEN_FLOAT); // or measure if ends in postscript
2023-02-04 14:06:00 -05:00
}
static Token
2023-03-04 13:20:59 -05:00
string()
2023-02-04 14:06:00 -05:00
{
2023-03-04 13:20:59 -05:00
while (peek() != '"' && !isAtEnd()) {
if (peek() == '\n')
tokenizer.line++;
advance();
}
2023-02-04 14:06:00 -05:00
2023-03-04 13:20:59 -05:00
if (isAtEnd())
return errorToken("Unterminated string.");
2023-02-04 14:06:00 -05:00
// The closing quote.
2023-03-04 13:20:59 -05:00
advance();
return makeToken(TOKEN_STRING);
2023-02-04 14:06:00 -05:00
}
Token
2023-03-04 13:20:59 -05:00
nextToken()
2023-02-04 14:06:00 -05:00
{
2023-03-04 13:20:59 -05:00
skipWhitespace();
2023-02-04 14:06:00 -05:00
tokenizer.start = tokenizer.current;
2023-03-04 13:20:59 -05:00
if (isAtEnd())
return makeToken(TOKEN_EOF);
char c = advance();
if (isAlpha(c))
return identifier();
if (isDigit(c))
return number();
switch (c) {
2023-02-04 14:06:00 -05:00
case '(':
2023-03-04 13:20:59 -05:00
return makeToken(TOKEN_LEFT_PAREN);
2023-02-04 14:06:00 -05:00
case ')':
2023-03-04 13:20:59 -05:00
return makeToken(TOKEN_RIGHT_PAREN);
2023-02-04 14:06:00 -05:00
case '{':
2023-03-04 13:20:59 -05:00
return makeToken(TOKEN_LEFT_BRACE);
2023-02-04 14:06:00 -05:00
case '}':
2023-03-04 13:20:59 -05:00
return makeToken(TOKEN_RIGHT_BRACE);
2023-02-04 14:06:00 -05:00
case '-':
2023-03-04 13:20:59 -05:00
return makeToken(TOKEN_NEGATIVE);
2023-02-04 14:06:00 -05:00
case '~':
2023-03-04 13:20:59 -05:00
return makeToken(TOKEN_TILDE);
2023-02-04 14:06:00 -05:00
case '/':
2023-03-04 13:20:59 -05:00
return makeToken(TOKEN_SLASH);
2023-02-04 14:06:00 -05:00
case '"':
2023-03-04 13:20:59 -05:00
return string();
}
2023-02-04 14:06:00 -05:00
2023-03-04 13:20:59 -05:00
return errorToken("Unexpected character.");
2023-02-04 14:06:00 -05:00
}
void
2023-03-04 13:20:59 -05:00
debug_printToken(Token t)
2023-02-04 14:06:00 -05:00
{
2023-03-04 13:20:59 -05:00
char* str;
int32_t size = tokenizer.current - tokenizer.start;
str = (char*)malloc(sizeof(size));
strncpy(str, tokenizer.start, size);
str[size] = '\0';
switch (t.type) {
2023-02-04 14:06:00 -05:00
case TOKEN_LEFT_PAREN:
2023-03-04 13:20:59 -05:00
printf("TOKEN_LEFT_PAREN %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_RIGHT_PAREN:
2023-03-04 13:20:59 -05:00
printf("TOKEN_RIGHT_PAREN %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_LEFT_BRACE:
2023-03-04 13:20:59 -05:00
printf("TOKEN_LEFT_BRACE %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_RIGHT_BRACE:
2023-03-04 13:20:59 -05:00
printf("TOKEN_RIGHT_BRACE %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_TILDE:
2023-03-04 13:20:59 -05:00
printf("TOKEN_TILDE %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_SLASH:
2023-03-04 13:20:59 -05:00
printf("TOKEN_SLASH %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_MINUS:
2023-03-04 13:20:59 -05:00
printf("TOKEN_MINUS %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_IDENTIFIER:
2023-03-04 13:20:59 -05:00
printf("TOKEN_IDENTIFIER %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_STRING:
2023-03-04 13:20:59 -05:00
printf("TOKEN_STRING %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_FLOAT:
2023-03-04 13:20:59 -05:00
printf("TOKEN_FLOAT %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_LIST:
2023-03-04 13:20:59 -05:00
printf("TOKEN_LIST %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_ERROR:
2023-03-04 13:20:59 -05:00
printf("TOKEN_ERROR %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_FALSE:
2023-03-04 13:20:59 -05:00
printf("TOKEN_FALSE %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_TRUE:
2023-03-04 13:20:59 -05:00
printf("TOKEN_TRUE %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_PI:
2023-03-04 13:20:59 -05:00
printf("TOKEN_PI %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_E:
2023-03-04 13:20:59 -05:00
printf("TOKEN_E %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_EOF:
2023-03-04 13:20:59 -05:00
printf("TOKEN_EOF %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_POP:
2023-03-04 13:20:59 -05:00
printf("TOKEN_POP %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_DUP:
2023-03-04 13:20:59 -05:00
printf("TOKEN_DUP %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_EXCH:
2023-03-04 13:20:59 -05:00
printf("TOKEN_EXCH %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_CLEAR:
2023-03-04 13:20:59 -05:00
printf("TOKEN_CLEAR %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_REMEMBER:
2023-03-04 13:20:59 -05:00
printf("TOKEN_REMEMBER %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_FORGET:
2023-03-04 13:20:59 -05:00
printf("TOKEN_FORGET %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_DUMP:
2023-03-04 13:20:59 -05:00
printf("TOKEN_DUMP %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_NAME:
2023-03-04 13:20:59 -05:00
printf("TOKEN_NAME %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_SET:
2023-03-04 13:20:59 -05:00
printf("TOKEN_SET %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_IFYES:
2023-03-04 13:20:59 -05:00
printf("TOKEN_IFYES %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_IFNO:
2023-03-04 13:20:59 -05:00
printf("TOKEN_IFNO %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_CHOOSE:
2023-03-04 13:20:59 -05:00
printf("TOKEN_CHOOSE %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_EVAL:
2023-03-04 13:20:59 -05:00
printf("TOKEN_EVAL %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_ESCAPE:
2023-03-04 13:20:59 -05:00
printf("TOKEN_ESCAPE %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_REPEAT:
2023-03-04 13:20:59 -05:00
printf("TOKEN_REPEAT %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_SPLIT:
2023-03-04 13:20:59 -05:00
printf("TOKEN_SPLIT %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_CONS:
2023-03-04 13:20:59 -05:00
printf("TOKEN_CONS %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_SHATTER:
2023-03-04 13:20:59 -05:00
printf("TOKEN_SHATTER %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_EMPTY:
2023-03-04 13:20:59 -05:00
printf("TOKEN_EMPTY %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_COMPOSE:
2023-03-04 13:20:59 -05:00
printf("TOKEN_COMPOSE %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_STREQ:
2023-03-04 13:20:59 -05:00
printf("TOKEN_STREQ %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_STRCUT:
2023-03-04 13:20:59 -05:00
printf("TOKEN_STRCUT %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_STRMEASURE:
2023-03-04 13:20:59 -05:00
printf("TOKEN_STRMEASURE %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_STRTIE:
2023-03-04 13:20:59 -05:00
printf("TOKEN_STRTIE %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_EXPLODE:
2023-03-04 13:20:59 -05:00
printf("TOKEN_EXPLODE %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_ADD:
2023-03-04 13:20:59 -05:00
printf("TOKEN_ADD %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_SUB:
2023-03-04 13:20:59 -05:00
printf("TOKEN_SUB %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_MUL:
2023-03-04 13:20:59 -05:00
printf("TOKEN_MUL %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_DIV:
2023-03-04 13:20:59 -05:00
printf("TOKEN_DIV %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_IDIV:
2023-03-04 13:20:59 -05:00
printf("TOKEN_IDIV %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_MOD:
2023-03-04 13:20:59 -05:00
printf("TOKEN_MOD %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_POW:
2023-03-04 13:20:59 -05:00
printf("TOKEN_POW %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_SQRT:
2023-03-04 13:20:59 -05:00
printf("TOKEN_SQRT %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_ADD1:
2023-03-04 13:20:59 -05:00
printf("TOKEN_ADD1 %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_SUB1:
2023-03-04 13:20:59 -05:00
printf("TOKEN_SUB1 %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_SIN:
2023-03-04 13:20:59 -05:00
printf("TOKEN_SIN %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_COS:
2023-03-04 13:20:59 -05:00
printf("TOKEN_COS %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_TAN:
2023-03-04 13:20:59 -05:00
printf("TOKEN_TAN %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_ATAN:
2023-03-04 13:20:59 -05:00
printf("TOKEN_ATAN %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_LN:
2023-03-04 13:20:59 -05:00
printf("TOKEN_LN %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_LOG:
2023-03-04 13:20:59 -05:00
printf("TOKEN_LOG %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_LOG3:
2023-03-04 13:20:59 -05:00
printf("TOKEN_LOG3 %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_CLIP:
2023-03-04 13:20:59 -05:00
printf("TOKEN_CLIP %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_SMOOTH:
2023-03-04 13:20:59 -05:00
printf("TOKEN_SMOOTH %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_HOWMUCH:
2023-03-04 13:20:59 -05:00
printf("TOKEN_HOWMUCH %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_SETRAND:
2023-03-04 13:20:59 -05:00
printf("TOKEN_SETRAND %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_RAND:
2023-03-04 13:20:59 -05:00
printf("TOKEN_RAND %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_INT:
2023-03-04 13:20:59 -05:00
printf("TOKEN_INT %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_NUMBERIZE:
2023-03-04 13:20:59 -05:00
printf("TOKEN_NUMBERIZE %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_ISOLATE:
2023-03-04 13:20:59 -05:00
printf("TOKEN_ISOLATE %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_MIX:
2023-03-04 13:20:59 -05:00
printf("TOKEN_MIX %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_CONTRADICT:
2023-03-04 13:20:59 -05:00
printf("TOKEN_CONTRADICT %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_COMPL:
2023-03-04 13:20:59 -05:00
printf("TOKEN_COMPL %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_SHIFTRIGHT:
2023-03-04 13:20:59 -05:00
printf("TOKEN_SHIFTRIGHT %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_SHIFTLEFT:
2023-03-04 13:20:59 -05:00
printf("TOKEN_SHIFTLEFT %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_GT:
2023-03-04 13:20:59 -05:00
printf("TOKEN_GT %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_LT:
2023-03-04 13:20:59 -05:00
printf("TOKEN_LT %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_EQ:
2023-03-04 13:20:59 -05:00
printf("TOKEN_EQ %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_GE:
2023-03-04 13:20:59 -05:00
printf("TOKEN_GE %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_LE:
2023-03-04 13:20:59 -05:00
printf("TOKEN_LE %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_NE:
2023-03-04 13:20:59 -05:00
printf("TOKEN_NE %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_NULL:
2023-03-04 13:20:59 -05:00
printf("TOKEN_NULL %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_NEGATIVE:
2023-03-04 13:20:59 -05:00
printf("TOKEN_NEGATIVE %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_ISNULL:
2023-03-04 13:20:59 -05:00
printf("TOKEN_ISNULL %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_ISINT:
2023-03-04 13:20:59 -05:00
printf("TOKEN_ISINT %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_ISNUMBER:
2023-03-04 13:20:59 -05:00
printf("TOKEN_ISNUMBER %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_AND:
2023-03-04 13:20:59 -05:00
printf("TOKEN_AND %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_OR:
2023-03-04 13:20:59 -05:00
printf("TOKEN_OR %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_XOR:
2023-03-04 13:20:59 -05:00
printf("TOKEN_XOR %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_DISP:
2023-03-04 13:20:59 -05:00
printf("TOKEN_DISP %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_LISTEN:
2023-03-04 13:20:59 -05:00
printf("TOKEN_LISTEN %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_COMPLAIN:
2023-03-04 13:20:59 -05:00
printf("TOKEN_COMPLAIN %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_TIME:
2023-03-04 13:20:59 -05:00
printf("TOKEN_TIME %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
case TOKEN_GARBAGE_COLLECT:
2023-03-04 13:20:59 -05:00
printf("TOKEN_GARBAGE_COLLECT %s line_no=%d\n", str, t.line);
2023-02-04 14:06:00 -05:00
break;
2023-03-04 13:20:59 -05:00
}
free(str);
2023-02-04 14:06:00 -05:00
}