aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordx <aryadevchavali1@gmail.com>2020-05-07 02:59:33 +0100
committerdx <aryadevchavali1@gmail.com>2020-05-07 02:59:33 +0100
commit2cffbe92b3da759147076f17d38f74870238a244 (patch)
tree53d67e065cdf9d6d63e0d4ef70956a0116da497c
parent510d6384033259be44b55e73283bafe38a53190a (diff)
downloadmdhtml-2cffbe92b3da759147076f17d38f74870238a244.tar.gz
mdhtml-2cffbe92b3da759147076f17d38f74870238a244.tar.bz2
mdhtml-2cffbe92b3da759147076f17d38f74870238a244.zip
+token checker function
This will check if a given character is a valid plain text token (*, _). This will allow me to abstract away and assess if some plain text needs to be further processed
-rw-r--r--Converter/includes/compiler.h5
-rw-r--r--Converter/src/compiler.c12
2 files changed, 17 insertions, 0 deletions
diff --git a/Converter/includes/compiler.h b/Converter/includes/compiler.h
index 3b89b49..df9c9b1 100644
--- a/Converter/includes/compiler.h
+++ b/Converter/includes/compiler.h
@@ -2,9 +2,14 @@
#define __COMPILER_H_
#include <stdlib.h>
+#include <stdbool.h>
typedef char *string;
+const static char TOKENS[] = {'*', '_'};
+const static size_t N_TOKENS = 2;
+
string compile_line(string line, size_t sz_line, string line_or_source);
int find_string(string src, string query, size_t sz_src, size_t sz_query);
+bool is_token(char c);
#endif // __COMPILER_H_
diff --git a/Converter/src/compiler.c b/Converter/src/compiler.c
index df97c22..042f809 100644
--- a/Converter/src/compiler.c
+++ b/Converter/src/compiler.c
@@ -9,6 +9,18 @@ int find_string(string src, string query, size_t sz_src, size_t sz_query)
return j;
}
+bool is_token(char c)
+{
+ bool token_check = false;
+ for (int i = 0; i < N_TOKENS; ++i)
+ if (c == TOKENS[i])
+ {
+ token_check = true;
+ break;
+ }
+ return token_check;
+}
+
void compile_inner_text(string dest, string src, size_t sz_src,
string line_or_source)
{