My Project
Loading...
Searching...
No Matches
dynop.c
Go to the documentation of this file.
1#include "gwion_util.h"
2#include "gwion_ast.h"
3#include "parser.h"
4
5ANN enum yytokentype op1(const m_str str) {
6 switch (*str) {
7 case '?':
8 return QUESTION;
9 break;
10 case ':':
11 return COLON;
12 break;
13 case '$':
14 return DOLLAR;
15 break;
16 case '+':
17 return PLUS;
18 break;
19 case '-':
20 return MINUS;
21 break;
22 case '*':
23 return TIMES;
24 break;
25 case '/':
26 return DIVIDE;
27 break;
28 case '%':
29 return PERCENT;
30 break;
31 case '~':
32 return TILDA;
33 break;
34 case '<':
35 return LT;
36 break;
37 case '>':
38 return GT;
39 break;
40 case '^':
41 return S_XOR;
42 break;
43 case '|':
44 return OR;
45 break;
46 case '&':
47 return S_AND;
48 break;
49 case '!':
50 return EXCLAMATION;
51 break;
52 case '@':
53 return AROBASE;
54 break;
55 }
56 return DYNOP;
57}
58
59ANN enum yytokentype op2(const m_str str) {
60 if (str[0] == str[1]) {
61 if (str[0] == '+') return PLUSPLUS;
62 if (str[0] == '-') return MINUSMINUS;
63 if (str[0] == '=') return EQ;
64 if (str[0] == '&') return AND;
65 if (str[0] == '|') return OR;
66 if (str[0] == '<') return SHIFT_LEFT;
67 if (str[0] == '>') return SHIFT_RIGHT;
68 }
69 if (str[0] == '<') {
70 if (str[1] == '=') return LE;
71 return DYNOP;
72 }
73 if (str[0] == '>') {
74 if (str[1] == '=') return GE;
75 return DYNOP;
76 }
77 if (str[0] == '!' && str[1] == '=') return NEQ;
78 if (str[0] == '?' && str[1] == ':') return QUESTIONCOLON;
79 if (str[0] == ':' && str[1] == ':') return COLONCOLON;
80 return DYNOP;
81}
82
83static inline bool match(m_str str, char c) {
84 return str[0] == c && str[1] == c && str[2] == c;
85}
86
87ANN enum yytokentype op3(const m_str str) {
88 if (match(str, '<')) return L_HACK;
89 if (match(str, '>')) return R_HACK;
90 return DYNOP;
91}
ANN enum yytokentype op2(const m_str str)
Definition dynop.c:59
ANN enum yytokentype op1(const m_str str)
Definition dynop.c:5
static bool match(m_str str, char c)
Definition dynop.c:83
ANN enum yytokentype op3(const m_str str)
Definition dynop.c:87
include this file to use gwion-ast library
const m_str str
Definition pparg.h:27