-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathscanner.h
184 lines (169 loc) · 4.85 KB
/
scanner.h
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/*
+--------------------------------------------------------------------------+
| Zephir Language |
+--------------------------------------------------------------------------+
| Copyright (c) 2013-2014 Zephir Team and contributors |
+--------------------------------------------------------------------------+
| This source file is subject the MIT license, that is bundled with |
| this package in the file LICENSE, and is available through the |
| world-wide-web at the following url: |
| http://zephir-lang.com/license.html |
| |
| If you did not receive a copy of the MIT license and are unable |
| to obtain it through the world-wide-web, please send a note to |
| license@zephir-lang.com so we can mail you a copy immediately. |
+--------------------------------------------------------------------------+
*/
#define XX_SCANNER_RETCODE_EOF -1
#define XX_SCANNER_RETCODE_ERR -2
#define XX_SCANNER_RETCODE_IMPOSSIBLE -3
/** Modes */
#define XX_T_IGNORE 297
/* Literals & Identifiers */
#define XX_T_INTEGER 301
#define XX_T_DOUBLE 302
#define XX_T_STRING 303
#define XX_T_NULL 304
#define XX_T_FALSE 305
#define XX_T_TRUE 306
#define XX_T_IDENTIFIER 307
#define XX_T_ARRAY 308
#define XX_T_CHAR 309
#define XX_T_TYPE_INTEGER 320
#define XX_T_TYPE_DOUBLE 321
#define XX_T_TYPE_BOOL 322
#define XX_T_TYPE_STRING 323
#define XX_T_TYPE_VAR 324
#define XX_T_TYPE_LONG 325
#define XX_T_TYPE_ULONG 326
#define XX_T_TYPE_CHAR 327
#define XX_T_TYPE_UCHAR 328
#define XX_T_TYPE_UINTEGER 329
#define XX_T_TYPE_ARRAY 330
#define XX_T_TYPE_CALLABLE 331
#define XX_T_TYPE_OBJECT 332
#define XX_T_TYPE_RESOURCE 333
#define XX_T_TYPE_NULL 334
#define XX_T_TYPE_THIS 335
#define XX_T_NAMESPACE 350
#define XX_T_CLASS 351
#define XX_T_PUBLIC 352
#define XX_T_PROTECTED 353
#define XX_T_EXTENDS 354
#define XX_T_FUNCTION 355
#define XX_T_LET 356
#define XX_T_COMMENT 357
#define XX_T_ECHO 358
#define XX_T_CONST 359
#define XX_T_ABSTRACT 360
#define XX_T_IMPLEMENTS 361
#define XX_T_INTERFACE 362
#define XX_T_IF 363
#define XX_T_ELSE 364
#define XX_T_WHILE 365
#define XX_T_NEW 366
#define XX_T_RETURN 367
#define XX_T_LOOP 368
#define XX_T_BREAK 369
#define XX_T_CONTINUE 370
#define XX_T_INSTANCEOF 371
#define XX_T_TYPEOF 372
#define XX_T_ISSET 373
#define XX_T_UNSET 374
#define XX_T_THROW 375
#define XX_T_FOR 376
#define XX_T_IN 377
#define XX_T_FETCH 378
#define XX_T_SWITCH 379
#define XX_T_CASE 380
#define XX_T_DEFAULT 381
#define XX_T_REVERSE 382
#define XX_T_PRIVATE 383
#define XX_T_STATIC 384
#define XX_T_INLINE 385
#define XX_T_FINAL 386
#define XX_T_CONSTANT 387
#define XX_T_DO 388
#define XX_T_REQUIRE 389
#define XX_T_CLONE 390
#define XX_T_EMPTY 391
#define XX_T_VOID 392
#define XX_T_LIKELY 393
#define XX_T_UNLIKELY 394
#define XX_T_USE 395
#define XX_T_AS 396
#define XX_T_TRY 397
#define XX_T_CATCH 398
#define XX_T_DEPRECATED 399
/* Operators */
#define XX_T_AT '@'
#define XX_T_DOT '.'
#define XX_T_COMMA ','
#define XX_T_ASSIGN '='
#define XX_T_LESS '<'
#define XX_T_GREATER '>'
#define XX_T_COLON ':'
#define XX_T_DOTCOMMA ';'
#define XX_T_QUESTION '?'
#define XX_T_BRACKET_OPEN '{'
#define XX_T_BRACKET_CLOSE '}'
#define XX_T_SBRACKET_OPEN '['
#define XX_T_SBRACKET_CLOSE ']'
#define XX_T_PARENTHESES_OPEN '('
#define XX_T_PARENTHESES_CLOSE ')'
#define XX_T_BITWISE_OR '|'
#define XX_T_BITWISE_AND '&'
#define XX_T_BITWISE_XOR '^'
#define XX_T_ARROW 400
#define XX_T_EQUALS 401
#define XX_T_IDENTICAL 402
#define XX_T_ADD '+'
#define XX_T_SUB '-'
#define XX_T_MUL '*'
#define XX_T_DIV '/'
#define XX_T_MOD '%'
#define XX_T_INCR 403
#define XX_T_DECR 404
#define XX_T_NOTEQUALS 405
#define XX_T_NOTIDENTICAL 406
#define XX_T_NOT 407
#define XX_T_GREATEREQUAL 408
#define XX_T_LESSEQUAL 409
#define XX_T_ADDASSIGN 410
#define XX_T_SUBASSIGN 411
#define XX_T_MULASSIGN 412
#define XX_T_DIVASSIGN 413
#define XX_T_CONCATASSIGN 414
#define XX_T_AND 415
#define XX_T_OR 416
#define XX_T_DOUBLECOLON 417
#define XX_T_MODASSIGN 418
#define XX_T_BITWISE_SHIFTLEFT 419
#define XX_T_BITWISE_SHIFTRIGHT 420
#define XX_T_CBLOCK 451
#define XX_T_ELSEIF 452
#include <string>
/* List of tokens and their names */
typedef struct _xx_token_names {
int code;
const char *name;
} xx_token_names;
/* Active token state */
typedef struct _xx_scanner_state {
int active_token;
char* start;
char* end;
unsigned int start_length;
int mode;
unsigned int active_line;
unsigned int active_char;
char *active_file;
} xx_scanner_state;
/* Extra information tokens */
typedef struct _xx_scanner_token {
int opcode;
std::string value;
int len;
} xx_scanner_token;
int xx_get_token(xx_scanner_state *s, xx_scanner_token *token);
extern const xx_token_names xx_tokens[];