Skip to content

Commit 87bee46

Browse files
committed
Renamed _xx_scanner_state members
`start' -> `cursor' `end' -> `limit' Also added `marker'
1 parent fe764df commit 87bee46

File tree

5 files changed

+132
-115
lines changed

5 files changed

+132
-115
lines changed

parser/base.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ void xx_parse_program(zval *return_value, char *program, size_t program_length,
9292
* Initialize the scanner state
9393
*/
9494
state->active_token = 0;
95-
state->start = program;
95+
state->cursor = program;
9696
state->start_length = 0;
9797
state->active_file = file_path;
9898
state->active_line = 1;
@@ -102,15 +102,15 @@ void xx_parse_program(zval *return_value, char *program, size_t program_length,
102102
state->method_line = 0;
103103
state->method_char = 0;
104104

105-
state->end = state->start;
105+
state->limit = state->cursor;
106106

107107
token.value = NULL;
108108

109109
while (0 <= (scanner_status = xx_get_token(state, &token))) {
110110

111111
state->active_token = token.opcode;
112112

113-
state->start_length = (program + program_length - state->start);
113+
state->start_length = (program + program_length - state->cursor);
114114

115115
switch (token.opcode) {
116116
case XX_T_IGNORE:
@@ -536,7 +536,7 @@ void xx_parse_program(zval *return_value, char *program, size_t program_length,
536536
break;
537537
}
538538

539-
state->end = state->start;
539+
state->limit = state->cursor;
540540
}
541541

542542
if (status != FAILURE) {
@@ -545,8 +545,8 @@ void xx_parse_program(zval *return_value, char *program, size_t program_length,
545545
case XX_SCANNER_RETCODE_IMPOSSIBLE:
546546
if (error_msg && Z_TYPE_P(error_msg) == IS_NULL) {
547547
error = emalloc(sizeof(char) * 1024);
548-
if (state->start) {
549-
snprintf(error, 1024, "Scanner error: %d %s", scanner_status, state->start);
548+
if (state->cursor) {
549+
snprintf(error, 1024, "Scanner error: %d %s", scanner_status, state->cursor);
550550
} else {
551551
snprintf(error, 1024, "Scanner error: %d", scanner_status);
552552
}
@@ -569,7 +569,7 @@ void xx_parse_program(zval *return_value, char *program, size_t program_length,
569569
}
570570

571571
state->active_token = 0;
572-
state->start = NULL;
572+
state->cursor = NULL;
573573

574574
if (parser_status->status != XX_PARSING_OK) {
575575
status = FAILURE;

parser/parser.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8635,7 +8635,7 @@ void xx_parse_program(zval *return_value, char *program, size_t program_length,
86358635
* Initialize the scanner state
86368636
*/
86378637
state->active_token = 0;
8638-
state->start = program;
8638+
state->cursor = program;
86398639
state->start_length = 0;
86408640
state->active_file = file_path;
86418641
state->active_line = 1;
@@ -8645,15 +8645,15 @@ void xx_parse_program(zval *return_value, char *program, size_t program_length,
86458645
state->method_line = 0;
86468646
state->method_char = 0;
86478647

8648-
state->end = state->start;
8648+
state->limit = state->cursor;
86498649

86508650
token.value = NULL;
86518651

86528652
while (0 <= (scanner_status = xx_get_token(state, &token))) {
86538653

86548654
state->active_token = token.opcode;
86558655

8656-
state->start_length = (program + program_length - state->start);
8656+
state->start_length = (program + program_length - state->cursor);
86578657

86588658
switch (token.opcode) {
86598659
case XX_T_IGNORE:
@@ -9079,7 +9079,7 @@ void xx_parse_program(zval *return_value, char *program, size_t program_length,
90799079
break;
90809080
}
90819081

9082-
state->end = state->start;
9082+
state->limit = state->cursor;
90839083
}
90849084

90859085
if (status != FAILURE) {
@@ -9088,8 +9088,8 @@ void xx_parse_program(zval *return_value, char *program, size_t program_length,
90889088
case XX_SCANNER_RETCODE_IMPOSSIBLE:
90899089
if (error_msg && Z_TYPE_P(error_msg) == IS_NULL) {
90909090
error = emalloc(sizeof(char) * 1024);
9091-
if (state->start) {
9092-
snprintf(error, 1024, "Scanner error: %d %s", scanner_status, state->start);
9091+
if (state->cursor) {
9092+
snprintf(error, 1024, "Scanner error: %d %s", scanner_status, state->cursor);
90939093
} else {
90949094
snprintf(error, 1024, "Scanner error: %d", scanner_status);
90959095
}
@@ -9112,7 +9112,7 @@ void xx_parse_program(zval *return_value, char *program, size_t program_length,
91129112
}
91139113

91149114
state->active_token = 0;
9115-
state->start = NULL;
9115+
state->cursor = NULL;
91169116

91179117
if (parser_status->status != XX_PARSING_OK) {
91189118
status = FAILURE;

parser/scanner.c

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
/* Generated by re2c 1.1.1 */
22
#line 1 "parser/scanner.re"
3-
4-
/*
5-
* This file is part of the Zephir Parser.
3+
/* This file is part of the Zephir Parser.
64
*
75
* (c) Zephir Team <team@zephir-lang.com>
86
*
9-
* For the full copyright and license information, please view the LICENSE
10-
* file that was distributed with this source code.
7+
* For the full copyright and license information, please view
8+
* the LICENSE file that was distributed with this source code.
119
*/
1210

1311
#ifdef HAVE_CONFIG_H
1412
# include "config.h"
1513
#endif
1614

1715
#include <php.h>
16+
1817
#include "xx.h"
1918
#include "scanner.h"
2019

21-
#define YYCTYPE unsigned char
22-
#define YYCURSOR (s->start)
23-
#define YYLIMIT (s->end)
24-
#define YYMARKER qm
20+
// for re2c...
21+
#define YYCTYPE char
22+
#define YYCURSOR (s->cursor)
23+
#define YYLIMIT (s->limit)
24+
#define YYMARKER (s->marker)
2525

2626
int xx_get_token(xx_scanner_state *s, xx_scanner_token *token) {
2727

28-
char *start = YYCURSOR, *qm;
28+
char *cursor = YYCURSOR;
2929
int status = XX_SCANNER_RETCODE_IMPOSSIBLE;
3030
int is_constant = 0, j;
3131

@@ -173,7 +173,7 @@ int xx_get_token(xx_scanner_state *s, xx_scanner_token *token) {
173173
YYDEBUG(8, *YYCURSOR);
174174
#line 985 "parser/scanner.re"
175175
{
176-
s->active_char += (YYCURSOR - start);
176+
s->active_char += (YYCURSOR - cursor);
177177
token->opcode = XX_T_IGNORE;
178178
return 0;
179179
}
@@ -455,9 +455,9 @@ int xx_get_token(xx_scanner_state *s, xx_scanner_token *token) {
455455
#line 37 "parser/scanner.re"
456456
{
457457
token->opcode = XX_T_INTEGER;
458-
token->value = estrndup(start, YYCURSOR - start);
459-
token->len = YYCURSOR - start;
460-
s->active_char += (YYCURSOR - start);
458+
token->value = estrndup(cursor, YYCURSOR - cursor);
459+
token->len = YYCURSOR - cursor;
460+
s->active_char += (YYCURSOR - cursor);
461461
return 0;
462462
}
463463
#line 464 "parser/scanner.c"
@@ -598,14 +598,14 @@ int xx_get_token(xx_scanner_state *s, xx_scanner_token *token) {
598598
#line 586 "parser/scanner.re"
599599
{
600600

601-
if (start[0] == '$') {
602-
token->value = estrndup(start + 1, YYCURSOR - start - 1);
603-
token->len = YYCURSOR - start - 1;
604-
s->active_char += (YYCURSOR - start - 1);
601+
if (cursor[0] == '$') {
602+
token->value = estrndup(cursor + 1, YYCURSOR - cursor - 1);
603+
token->len = YYCURSOR - cursor - 1;
604+
s->active_char += (YYCURSOR - cursor - 1);
605605
} else {
606-
token->value = estrndup(start, YYCURSOR - start);
607-
token->len = YYCURSOR - start;
608-
s->active_char += (YYCURSOR - start);
606+
token->value = estrndup(cursor, YYCURSOR - cursor);
607+
token->len = YYCURSOR - cursor;
608+
s->active_char += (YYCURSOR - cursor);
609609
}
610610

611611
if (token->len > 3 && token->value[0] == '_') {
@@ -1074,11 +1074,11 @@ int xx_get_token(xx_scanner_state *s, xx_scanner_token *token) {
10741074
YYDEBUG(94, *YYCURSOR);
10751075
#line 503 "parser/scanner.re"
10761076
{
1077-
start++;
1077+
cursor++;
10781078
token->opcode = XX_T_STRING;
1079-
token->value = estrndup(start, YYCURSOR - start - 1);
1080-
token->len = YYCURSOR - start - 1;
1081-
s->active_char += (YYCURSOR - start - 1);
1079+
token->value = estrndup(cursor, YYCURSOR - cursor - 1);
1080+
token->len = YYCURSOR - cursor - 1;
1081+
s->active_char += (YYCURSOR - cursor - 1);
10821082
return 0;
10831083
}
10841084
#line 1085 "parser/scanner.c"
@@ -1147,11 +1147,11 @@ int xx_get_token(xx_scanner_state *s, xx_scanner_token *token) {
11471147
YYDEBUG(107, *YYCURSOR);
11481148
#line 481 "parser/scanner.re"
11491149
{
1150-
start++;
1150+
cursor++;
11511151
token->opcode = XX_T_CHAR;
1152-
token->value = estrndup(start, YYCURSOR - start - 1);
1153-
token->len = YYCURSOR - start - 1;
1154-
s->active_char += (YYCURSOR - start);
1152+
token->value = estrndup(cursor, YYCURSOR - cursor - 1);
1153+
token->len = YYCURSOR - cursor - 1;
1154+
s->active_char += (YYCURSOR - cursor);
11551155
return 0;
11561156
}
11571157
#line 1158 "parser/scanner.c"
@@ -1275,7 +1275,7 @@ int xx_get_token(xx_scanner_state *s, xx_scanner_token *token) {
12751275
YYDEBUG(128, *YYCURSOR);
12761276
#line 556 "parser/scanner.re"
12771277
{
1278-
s->active_char += (YYCURSOR - start);
1278+
s->active_char += (YYCURSOR - cursor);
12791279
token->opcode = XX_T_IGNORE;
12801280
return 0;
12811281
}
@@ -2312,9 +2312,9 @@ int xx_get_token(xx_scanner_state *s, xx_scanner_token *token) {
23122312
#line 46 "parser/scanner.re"
23132313
{
23142314
token->opcode = XX_T_DOUBLE;
2315-
token->value = estrndup(start, YYCURSOR - start);
2316-
token->len = YYCURSOR - start;
2317-
s->active_char += (YYCURSOR - start);
2315+
token->value = estrndup(cursor, YYCURSOR - cursor);
2316+
token->len = YYCURSOR - cursor;
2317+
s->active_char += (YYCURSOR - cursor);
23182318
return 0;
23192319
}
23202320
#line 2321 "parser/scanner.c"
@@ -3365,12 +3365,12 @@ int xx_get_token(xx_scanner_state *s, xx_scanner_token *token) {
33653365
YYDEBUG(297, *YYCURSOR);
33663366
#line 492 "parser/scanner.re"
33673367
{
3368-
start++; /* ~ */
3369-
start++; /* " */
3368+
cursor++; /* ~ */
3369+
cursor++; /* " */
33703370
token->opcode = XX_T_ISTRING;
3371-
token->value = estrndup(start, YYCURSOR - start - 1);
3372-
token->len = YYCURSOR - start - 1;
3373-
s->active_char += (YYCURSOR - start);
3371+
token->value = estrndup(cursor, YYCURSOR - cursor - 1);
3372+
token->len = YYCURSOR - cursor - 1;
3373+
s->active_char += (YYCURSOR - cursor);
33743374
return 0;
33753375
}
33763376
#line 3377 "parser/scanner.c"
@@ -3388,11 +3388,11 @@ int xx_get_token(xx_scanner_state *s, xx_scanner_token *token) {
33883388
YYDEBUG(300, *YYCURSOR);
33893389
#line 563 "parser/scanner.re"
33903390
{
3391-
start++;
3392-
start++;
3391+
cursor++;
3392+
cursor++;
33933393
token->opcode = XX_T_CBLOCK;
3394-
token->value = estrndup(start, YYCURSOR - start - 2);
3395-
token->len = YYCURSOR - start - 2;
3394+
token->value = estrndup(cursor, YYCURSOR - cursor - 2);
3395+
token->len = YYCURSOR - cursor - 2;
33963396
{
33973397
int k, ch = s->active_char;
33983398
for (k = 0; k < (token->len - 1); k++) {
@@ -4670,8 +4670,8 @@ int xx_get_token(xx_scanner_state *s, xx_scanner_token *token) {
46704670
#line 534 "parser/scanner.re"
46714671
{
46724672
token->opcode = XX_T_IGNORE;
4673-
token->value = estrndup(start, YYCURSOR - start - 1);
4674-
token->len = YYCURSOR - start - 1;
4673+
token->value = estrndup(cursor, YYCURSOR - cursor - 1);
4674+
token->len = YYCURSOR - cursor - 1;
46754675
{
46764676
int k, ch = s->active_char;
46774677
for (k = 0; k < (token->len - 1); k++) {
@@ -4695,10 +4695,10 @@ int xx_get_token(xx_scanner_state *s, xx_scanner_token *token) {
46954695
YYDEBUG(377, *YYCURSOR);
46964696
#line 513 "parser/scanner.re"
46974697
{
4698-
start++;
4698+
cursor++;
46994699
token->opcode = XX_T_COMMENT;
4700-
token->value = estrndup(start, YYCURSOR - start - 1);
4701-
token->len = YYCURSOR - start - 1;
4700+
token->value = estrndup(cursor, YYCURSOR - cursor - 1);
4701+
token->len = YYCURSOR - cursor - 1;
47024702
{
47034703
int k, ch = s->active_char;
47044704
for (k = 0; k < (token->len - 1); k++) {

0 commit comments

Comments
 (0)