My Project
Loading...
Searching...
No Matches
dynop.c File Reference
#include "gwion_util.h"
#include "gwion_ast.h"
#include "parser.h"

Go to the source code of this file.

Functions

ANN enum yytokentype op1 (const m_str str)
 
ANN enum yytokentype op2 (const m_str str)
 
static bool match (m_str str, char c)
 
ANN enum yytokentype op3 (const m_str str)
 

Function Documentation

◆ match()

static bool match ( m_str str,
char c )
inlinestatic

Definition at line 83 of file dynop.c.

83 {
84 return str[0] == c && str[1] == c && str[2] == c;
85}
const m_str str
Definition pparg.h:27

◆ op1()

ANN enum yytokentype op1 ( const m_str str)

Definition at line 5 of file dynop.c.

5 {
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}

◆ op2()

ANN enum yytokentype op2 ( const m_str str)

Definition at line 59 of file dynop.c.

59 {
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}

◆ op3()

ANN enum yytokentype op3 ( const m_str str)

Definition at line 87 of file dynop.c.

87 {
88 if (match(str, '<')) return L_HACK;
89 if (match(str, '>')) return R_HACK;
90 return DYNOP;
91}
static bool match(m_str str, char c)
Definition dynop.c:83