summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-09-30 23:21:18 -0400
committerIan Moffett <ian@osmora.org>2025-09-30 23:21:18 -0400
commit9745e110b69bcf7e32896c444ddc4acd9ed0f8bf (patch)
treea7831c2e55463fc438cd0b036803491993452dae /src
parent2cf918c3e20164559f1bae5fbd83fb7a40e2190a (diff)
lex: np: Add lexer arithmetic operators
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'src')
-rw-r--r--src/sys/include/np/lex.h6
-rw-r--r--src/sys/np/core/np_lex.c18
-rw-r--r--src/sys/np/core/np_parse.c6
3 files changed, 30 insertions, 0 deletions
diff --git a/src/sys/include/np/lex.h b/src/sys/include/np/lex.h
index 0381afb..daca954 100644
--- a/src/sys/include/np/lex.h
+++ b/src/sys/include/np/lex.h
@@ -53,6 +53,12 @@ typedef enum {
TT_IDENT, /* '<IDENTIFIER>' */
TT_COMMA, /* ',' */
TT_STAR, /* '*' */
+ TT_MINUS, /* '-' */
+ TT_PLUS, /* '+' */
+ TT_SLASH, /* '/' */
+ TT_EQUALS, /* '=' */
+ TT_GT, /* '>' */
+ TT_LT, /* '<' */
/* Types */
TT_U8, /* 'u8' */
diff --git a/src/sys/np/core/np_lex.c b/src/sys/np/core/np_lex.c
index f870c0c..6e252a3 100644
--- a/src/sys/np/core/np_lex.c
+++ b/src/sys/np/core/np_lex.c
@@ -197,6 +197,24 @@ lex_nom(struct np_work *work, struct lex_token *res)
case '*':
res->token = TT_STAR;
break;
+ case '-':
+ res->token = TT_MINUS;
+ break;
+ case '+':
+ res->token = TT_PLUS;
+ break;
+ case '/':
+ res->token = TT_SLASH;
+ break;
+ case '=':
+ res->token = TT_EQUALS;
+ break;
+ case '>':
+ res->token = TT_GT;
+ break;
+ case '<':
+ res->token = TT_LT;
+ break;
default:
/* Stuff like '1var_name' is invalid */
if (!is_alpha(c)) {
diff --git a/src/sys/np/core/np_parse.c b/src/sys/np/core/np_parse.c
index 1959b1b..165fed5 100644
--- a/src/sys/np/core/np_parse.c
+++ b/src/sys/np/core/np_parse.c
@@ -46,6 +46,12 @@ static const char *stoktab[] = {
[TT_IDENT] = "<IDENTIFIER>",
[TT_COMMA] = "<TT_COMMA>",
[TT_STAR] = "<TT_STAR>",
+ [TT_MINUS] = "<TT_MINUS>",
+ [TT_PLUS] = "<TT_PLUS>",
+ [TT_SLASH] = "<TT_SLASH>",
+ [TT_EQUALS] = "<TT_EQUALS>",
+ [TT_GT] = "<TT_GREATER>",
+ [TT_LT] = "<TT_LESSTHAN>",
/* Types */
[TT_U8] = "<TT_U8>",