summaryrefslogtreecommitdiff
path: root/lexer.h
diff options
context:
space:
mode:
Diffstat (limited to 'lexer.h')
-rw-r--r--lexer.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/lexer.h b/lexer.h
new file mode 100644
index 0000000..b8b14b0
--- /dev/null
+++ b/lexer.h
@@ -0,0 +1,43 @@
+static inline uint8_t isdelm(char c, uint8_t dbg) {
+ switch (c) {
+ default : return 0x00;
+ case '\0':
+ case '\n': return 0x01;
+ case ',' : return 0x02;
+ case '\"': return 0x04;
+ case '\'': return 0x08;
+ case '\t':
+ case ' ' : return 0x10;
+ }
+}
+
+static inline uint8_t get_ptok(char c, uint8_t dbg) {
+ switch (c) {
+ case '.' : return PTOK_DOT ;
+ case ':' : return PTOK_COLON ;
+ case '=' : return PTOK_EQU ;
+ case '+' : return PTOK_PLUS ;
+ case '-' : return PTOK_MINUS ;
+ case '>' : return PTOK_GT ;
+ case '<' : return PTOK_LT ;
+ case '(' : return PTOK_LBRACK ;
+ case ')' : return PTOK_RBRACK ;
+ case ',' : return PTOK_COMMA ;
+ case 'X': case 'x' : return PTOK_X ;
+ case 'Y': case 'y' : return PTOK_Y ;
+ case '\"': return PTOK_DQUOTE ;
+ case '\'': return PTOK_SQUOTE ;
+ case '#' : return PTOK_HASH ;
+ case ';' : return PTOK_SCOLON ;
+ case '$' : return PTOK_DOLLAR ;
+ case '%' : return PTOK_PERCENT;
+ default :
+ if (isdigit(c)) {
+ return PTOK_NUMBER;
+ } else if (isalpha(c) || c == '_') {
+ return PTOK_ALPHA;
+ } else {
+ return PTOK_OTHER;
+ }
+ }
+}