aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorc+12023-10-12 21:02:04 -0400
committerc+12023-10-12 21:02:04 -0400
commit85bb2db8dee7898c890f5d1fc0b3874bee3d88ba (patch)
tree384109ce9295a9c6ce0791993a8c9314c516d781 /src
parent58c7a71a50318940e747c365cc3f207dba432977 (diff)
update examples
Diffstat (limited to 'src')
-rw-r--r--src/include/token.h7
-rw-r--r--src/lexer.c51
-rw-r--r--src/main.c2
3 files changed, 55 insertions, 5 deletions
diff --git a/src/include/token.h b/src/include/token.h
index 6779755..5a3a36c 100644
--- a/src/include/token.h
+++ b/src/include/token.h
@@ -9,16 +9,15 @@ typedef struct TOKEN_STRUC {
/* token type */
enum TOKEN_TYPE {
TOKEN_UNKNOWN,
- TOKEN_CHAR_DELIM,
- TOKEN_STR_DELIM,
- TOKEN_COMMENT_DELIM,
+ TOKEN_CHAR,
+ TOKEN_STR,
TOKEN_EXPR_END,
TOKEN_SET,
TOKEN_LGROUP,
TOKEN_RGROUP,
TOKEN_APPLY,
TOKEN_LIST_DELIM,
- TOKEN_TAG_DELIM,
+ TOKEN_TAG,
TOKEN_NAMESPACE_DELIM,
TOKEN_LBLOCK,
TOKEN_RBLOCK,
diff --git a/src/lexer.c b/src/lexer.c
index efdc718..ba0e8e1 100644
--- a/src/lexer.c
+++ b/src/lexer.c
@@ -4,6 +4,8 @@
#include <stdio.h>
#include "include/lexer.h"
+#include "include/syntax.h"
+#include "include/token.h"
lexer_t* lexer_init(char* src) {
lexer_t* lexer;
@@ -57,11 +59,60 @@ void lexer_do_reg(lexer_t* lexer) {
case SYNTAX_APPLY:
lexer_add_current_char(lexer, TOKEN_APPLY);
break;
+ case SYNTAX_TAG_DELIM:
+ lexer_add_current_char(lexer, TOKEN_TAG_DELIM);
+ break;
+ case SYNTAX_NAMESPACE_DELIM:
+ lexer_add_current_char(lexer, TOKEN_NAMESPACE_DELIM);
+ break;
+ case SYNTAX_SET:
+ lexer_add_current_char(lexer, TOKEN_SET);
+ break;
+ case SYNTAX_LLIST:
+ lexer_add_current_char(lexer, TOKEN_LLIST);
+ break;
+ case SYNTAX_RLIST:
+ lexer_add_current_char(lexer, TOKEN_RLIST);
+ break;
+ case SYNTAX_LGROUP:
+ lexer_add_current_char(lexer, TOKEN_LGROUP);
+ break;
+ case SYNTAX_RGROUP:
+ lexer_add_current_char(lexer, TOKEN_RGROUP);
+ break;
+ case SYNTAX_EXPR_END:
+ lexer_add_current_char(lexer, TOKEN_EXPR_END);
+ break;
+ case SYNTAX_STR_DELIM:
+ lexer_add_current_char(lexer, TOKEN_STR_DELIM);
+ break;
+ case SYNTAX_CHAR_DELIM:
+ lexer_add_current_char(lexer, TOKEN_CHAR_DELIM);
+ break;
+ case SYNTAX_LIST_DELIM:
+ lexer_add_current_char(lexer, TOKEN_LIST_DELIM);
+ break;
default:
lexer_add_current_char(lexer, TOKEN_UNKNOWN);
}
}
+void lexer_do_chr(lexer_t* lexer) {
+ if (*lexer->src == '\'') {
+ lexer->state = LEXER_STATE_REG;
+ } else {
+ token_t* t;
+
+ t = token_init(TOKEN_CHAR, *lexer->src);
+
+ lexer_add_token(lexer, t);
+ }
+}
+
+void lexer_do_str(lexer_t* lexer) {
+
+}
+
void lexer_run(lexer_t* lexer) {
while (*lexer->src) {
if (lexer->state == LEXER_STATE_REG) { lexer_do_reg(lexer); }
diff --git a/src/main.c b/src/main.c
index 7146c14..2284444 100644
--- a/src/main.c
+++ b/src/main.c
@@ -28,7 +28,7 @@ int main(int argc, char* argv[]) {
pp_run(pp);
free(src);
src = pp->psrc;
- log_dbg(pp->psrc);
+ log_inf("pre-processed source: %s", pp->psrc);
/* destroy pre-processor */
pp_destroy(pp);
HLKT_ASS(src);