npc

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

commit 93f3c7a129c6f437a119b66d30303bf3231ccc92
parent a6e7239db40a09e5971eb64442316a8f36e37a48
Author: kocotian <kocotian@kocotian.pl>
Date:   Mon, 12 Apr 2021 19:28:57 +0200

Definition Types, Booleans

Diffstat:
Mparse.c | 21+++++++++++++++++++--
Mparse.h | 2+-
2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/parse.c b/parse.c @@ -77,11 +77,28 @@ parse(String input, Token **output) || (input.data[i] >= '0' && input.data[i] <= '9')) && (i < input.len)) ++i; --i; - /* define token Keyword */ + /* next */ (*output)[osiz].value.len = (size_t)((input.data + i) - (*output)[osiz].value.data) + 1; - if (!Strcmpc((*output)[osiz].value, "define")) { + if (0); + /* define token Keyword */ + else if ((!Strcmpc((*output)[osiz].value, "define") + || (!Strcmpc((*output)[osiz].value, "match")) + || (!Strcmpc((*output)[osiz].value, "next")) + )) { (*output)[osiz].type = TokenKeyword; } + /* define token DefinitionType */ + else if ((!Strcmpc((*output)[osiz].value, "token") + || (!Strcmpc((*output)[osiz].value, "function")) + )) { + (*output)[osiz].type = TokenDefinitionType; + } + /* define token Boolean */ + else if ((!Strcmpc((*output)[osiz].value, "true") + || (!Strcmpc((*output)[osiz].value, "false")) + )) { + (*output)[osiz].type = TokenBoolean; + } } /* define token Character */ else if (input.data[i] == '\'') { diff --git a/parse.h b/parse.h @@ -8,7 +8,7 @@ typedef enum { TokenNULL, /* Literals */ TokenNumber, TokenIdentifier, TokenCharacter, TokenString, - TokenKeyword, + TokenKeyword, TokenDefinitionType, TokenBoolean, /* Operators */ TokenAssignment, TokenLogicalEqual, TokenFunctionArrow, TokenPlus, TokenPlusEqual, TokenIncrement,