npc

nanohard parser compiler
git clone git://git.kocotian.pl/npc.git
Log | Files | Refs

commit a6e7239db40a09e5971eb64442316a8f36e37a48
parent 4b7fb5ed3f45725b3303de4b72893ffcc649475e
Author: kocotian <kocotian@kocotian.pl>
Date:   Mon, 12 Apr 2021 19:28:37 +0200

stringizeType()

Diffstat:
Mparse.c | 43+++++++++++++++++++++++++++++++++++++++++++
Mparse.h | 1+
2 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/parse.c b/parse.c @@ -4,6 +4,49 @@ #include <parse.h> #include <unistd.h> +char * +stringizeType(TokenType t) +{ + switch (t) { + case TokenNULL: return "<null>"; break; + case TokenNumber: return "number"; break; + case TokenIdentifier: return "identifier"; break; + case TokenCharacter: return "character"; break; + case TokenString: return "string"; break; + case TokenKeyword: return "keyword"; break; + case TokenDefinitionType: return "definition type"; break; + case TokenBoolean: return "boolean"; break; + case TokenAssignment: return "assignment"; break; + case TokenLogicalEqual: return "logical equal"; break; + case TokenFunctionArrow: return "function arrow"; break; + case TokenPlus: return "plus"; break; + case TokenPlusEqual: return "plus equal"; break; + case TokenIncrement: return "increment"; break; + case TokenMinus: return "minus"; break; + case TokenMinusEqual: return "minus equal"; break; + case TokenDecrement: return "decrement"; break; + case TokenAnd: return "and"; break; + case TokenLogicalAnd: return "logical and"; break; + case TokenOr: return "or"; break; + case TokenLogicalOr: return "logical or"; break; + case TokenExclamation: return "exclamation"; break; + case TokenLogicalNotEqual: return "logical not equal"; break; + case TokenComment: return "comment"; break; + case TokenOpeningParenthesis: return "opening parenthesis"; break; + case TokenClosingParenthesis: return "closing parenthesis"; break; + case TokenOpeningBracket: return "opening bracket"; break; + case TokenClosingBracket: return "closing bracket"; break; + case TokenOpeningBrace: return "opening brace"; break; + case TokenClosingBrace: return "closing brace"; break; + case TokenSemicolon: return "semicolon"; break; + case TokenColon: return "colon"; break; + case TokenComma: return "comma"; break; + case TokenAt: return "at"; break; + case TokenDollar: return "dollar"; break; + } + return "<unknown>"; +} + ssize_t parse(String input, Token **output) { diff --git a/parse.h b/parse.h @@ -31,5 +31,6 @@ typedef struct { } Token; ssize_t parse(String input, Token **output); +char *stringizeType(TokenType t); #endif