aboutsummaryrefslogtreecommitdiff
path: root/src/tokenize.c
diff options
context:
space:
mode:
authorkoekeishiya <aasvi93@hotmail.com>2018-08-30 14:09:56 +0200
committerkoekeishiya <aasvi93@hotmail.com>2018-08-30 14:09:56 +0200
commit3d90dbeaa9cf13058ed349ba7beb2532c571c7fb (patch)
tree8acf5e60cda157093349c474402ab53d43422d65 /src/tokenize.c
parent822c4603547aa927b62efb6f77dd0c6b56ec7f33 (diff)
downloadskhd-3d90dbeaa9cf13058ed349ba7beb2532c571c7fb.tar.gz
skhd-3d90dbeaa9cf13058ed349ba7beb2532c571c7fb.zip
first iteration
Diffstat (limited to 'src/tokenize.c')
-rw-r--r--src/tokenize.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/tokenize.c b/src/tokenize.c
index 5040a7c..8445a71 100644
--- a/src/tokenize.c
+++ b/src/tokenize.c
@@ -63,6 +63,22 @@ eat_hex(struct tokenizer *tokenizer)
}
}
+internal void
+eat_string(struct tokenizer *tokenizer)
+{
+ /*
+ * NOTE(koekeishiya): This is NOT proper string parsing code, as we do
+ * not check for escaped '"' here. At the time of writing, this is only
+ * supposed to be used for parsing names of processes, and such names
+ * should not contain escaped quotes at all. We are lazy and simply do
+ * the most basic implementation that fulfills our current requirement.
+ */
+
+ while (*tokenizer->at && *tokenizer->at != '"') {
+ advance(tokenizer);
+ }
+}
+
internal inline bool
isidentifier(char c)
{
@@ -130,6 +146,19 @@ get_token(struct tokenizer *tokenizer)
case ',': { token.type = Token_Comma; } break;
case '<': { token.type = Token_Insert; } break;
case '@': { token.type = Token_Capture; } break;
+ case '[': { token.type = Token_BeginList; } break;
+ case ']': { token.type = Token_EndList; } break;
+ case '"': {
+ token.text = tokenizer->at;
+ token.line = tokenizer->line;
+ token.cursor = tokenizer->cursor;
+
+ eat_string(tokenizer);
+ token.length = tokenizer->at - token.text;
+ token.type = Token_String;
+
+ advance(tokenizer);
+ } break;
case '#': {
eat_comment(tokenizer);
token = get_token(tokenizer);