forked from AOP-PHP/AOP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLexer.l
107 lines (100 loc) · 3.16 KB
/
Lexer.l
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
//--------------------------------------------------------- ./scanner.l
#include <php.h>
#include "Lexer.h"
#include "ext/pcre/php_pcre.h"
#include "aop.h"
int scan(scanner_state *s, scanner_token *t) {
// char *cursor = s->start;
int r=SCANNER_RETCODE_IMPOSSIBLE;
char *q=s->start;//keep initial start
#define YYCTYPE char
#define YYCURSOR (s->start)
#define YYLIMIT (s->end)
#define YYMARKER (s->marker)
while(SCANNER_RETCODE_IMPOSSIBLE == r) {
/*!re2c
re2c:indent:top = 2;
re2c:yyfill:enable = 0;
LABEL = [a-zA-Z0-9_\x7f-\xff\\*]*;
SPACE = [ \t$]*;
'()' {
t->TOKEN = TOKEN_FUNCTION;
return 0;
}
'->' {
t->TOKEN = TOKEN_CLASS;
return 0;
}
'::' {
t->TOKEN = TOKEN_CLASS;
return 0;
}
'read' {
t->TOKEN = TOKEN_PROPERTY;
t->int_val = AOP_KIND_READ;
return 0;
}
'write' {
t->TOKEN = TOKEN_PROPERTY;
t->int_val = AOP_KIND_WRITE;
return 0;
}
'public' {
t->TOKEN = TOKEN_SCOPE;
t->int_val = ZEND_ACC_PUBLIC;
return 0;
}
'protected' {
t->TOKEN = TOKEN_SCOPE;
t->int_val = ZEND_ACC_PROTECTED;
return 0;
}
'private' {
t->TOKEN = TOKEN_SCOPE;
t->int_val = ZEND_ACC_PRIVATE;
return 0;
}
'static' {
t->TOKEN = TOKEN_STATIC;
t->int_val = 1;
return 0;
}
"|" {
t->TOKEN = TOKEN_OR;
return 0;
}
'!public' {
t->TOKEN = TOKEN_SCOPE;
t->int_val = ZEND_ACC_PROTECTED | ZEND_ACC_PRIVATE;
return 0;
}
'!protected' {
t->TOKEN = TOKEN_SCOPE;
t->int_val = ZEND_ACC_PUBLIC | ZEND_ACC_PRIVATE;
return 0;
}
'!private' {
t->TOKEN = TOKEN_SCOPE;
t->int_val = ZEND_ACC_PUBLIC | ZEND_ACC_PROTECTED;
return 0;
}
'!static' {
t->TOKEN = TOKEN_STATIC;
t->int_val = 0;
return 0;
}
LABEL {
t->str_val = estrndup(q,YYCURSOR - q);
t->TOKEN = TOKEN_TEXT;
return 0;
}
SPACE {
t->TOKEN = TOKEN_SPACE;
return 0;
}
"\000" { r = SCANNER_RETCODE_EOF; break; }
[^] { r = SCANNER_RETCODE_ERR; break; }
*/
}
return r;
}