diff options
Diffstat (limited to 'src/parse.y')
| -rw-r--r-- | src/parse.y | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/src/parse.y b/src/parse.y index ab5caa28e..2c7e788d9 100644 --- a/src/parse.y +++ b/src/parse.y @@ -42,11 +42,7 @@ static void yywarning(parser_state *p, const char *s); static void backref_error(parser_state *p, node *n); static void tokadd(parser_state *p, int32_t c); -#ifndef isascii -#define isascii(c) (((c) & ~0x7f) == 0) -#endif - -#define identchar(c) (isalnum(c) || (c) == '_' || !isascii(c)) +#define identchar(c) (ISALNUM(c) || (c) == '_' || !ISASCII(c)) typedef unsigned int stack_type; @@ -2879,15 +2875,15 @@ var_ref : variable | keyword_self { $$ = new_self(p); - } + } | keyword_true { $$ = new_true(p); - } + } | keyword_false { $$ = new_false(p); - } + } | keyword__FILE__ { if (!p->filename) { @@ -3381,7 +3377,9 @@ nextc(parser_state *p) c = (unsigned char)*p->s++; } } - p->column++; + if (c >= 0) { + p->column++; + } if (c == '\r') { c = nextc(p); if (c != '\n') { @@ -3396,16 +3394,17 @@ nextc(parser_state *p) if (!p->cxt) return -1; else { if (p->cxt->partial_hook(p) < 0) - return -1; - return -2; + return -1; /* end of program(s) */ + return -2; /* end of a file in the program files */ } } static void pushback(parser_state *p, int c) { - if (c < 0) return; - p->column--; + if (c >= 0) { + p->column--; + } p->pb = cons((node*)(intptr_t)c, p->pb); } @@ -3429,7 +3428,7 @@ peekc_n(parser_state *p, int n) do { c0 = nextc(p); - if (c0 < 0) return c0; + if (c0 == -1) return c0; /* do not skip partial EOF */ list = push(list, (node*)(intptr_t)c0); } while(n--); if (p->pb) { @@ -3785,7 +3784,7 @@ read_escape(parser_state *p) eof: case -1: - case -2: + case -2: /* end of a file */ yyerror(p, "Invalid escape character syntax"); return '\0'; @@ -3915,7 +3914,8 @@ parse_string(parser_state *p) return tHD_LITERAL_DELIM; } } - } while (ISSPACE(c = nextc(p))); + c = nextc(p); + } while (ISSPACE(c)); pushback(p, c); return tLITERAL_DELIM; } @@ -4100,7 +4100,7 @@ parser_yylex(parser_state *p) case '#': /* it's a comment */ skip(p, '\n'); /* fall through */ - case -2: /* end of partial script. */ + case -2: /* end of a file */ case '\n': maybe_heredoc: heredoc_treat_nextline(p); @@ -4135,7 +4135,7 @@ parser_yylex(parser_state *p) goto retry; } case -1: /* EOF */ - case -2: /* end of partial script */ + case -2: /* end of a file */ goto normal_newline; default: pushback(p, c); @@ -4209,14 +4209,14 @@ parser_yylex(parser_state *p) static const char end[] = "\n=end"; if (peeks(p, begin)) { c = peekc_n(p, sizeof(begin)-1); - if (c < 0 || isspace(c)) { + if (c < 0 || ISSPACE(c)) { do { if (!skips(p, end)) { yyerror(p, "embedded document meets end of file"); return 0; } c = nextc(p); - } while (!(c < 0 || isspace(c))); + } while (!(c < 0 || ISSPACE(c))); if (c != '\n') skip(p, '\n'); p->lineno++; p->column = 0; @@ -4247,7 +4247,6 @@ parser_yylex(parser_state *p) return '='; case '<': - last_state = p->lstate; c = nextc(p); if (c == '<' && p->lstate != EXPR_DOT && @@ -4341,7 +4340,7 @@ parser_yylex(parser_state *p) yyerror(p, "incomplete character syntax"); return 0; } - if (isspace(c)) { + if (ISSPACE(c)) { if (!IS_ARG()) { int c2; switch (c) { @@ -4378,7 +4377,7 @@ parser_yylex(parser_state *p) p->lstate = EXPR_VALUE; return '?'; } - token_column = newtok(p); + newtok(p); /* need support UTF-8 if configured */ if ((isalnum(c) || c == '_')) { int c2 = nextc(p); @@ -4542,7 +4541,7 @@ parser_yylex(parser_state *p) is_float = seen_point = seen_e = nondigit = 0; p->lstate = EXPR_END; - token_column = newtok(p); + newtok(p); if (c == '-' || c == '+') { tokadd(p, c); c = nextc(p); @@ -5164,7 +5163,6 @@ parser_yylex(parser_state *p) { int result = 0; - last_state = p->lstate; switch (tok(p)[0]) { case '$': p->lstate = EXPR_END; @@ -5194,7 +5192,7 @@ parser_yylex(parser_state *p) pushback(p, c); } } - if (result == 0 && isupper((int)(unsigned char)tok(p)[0])) { + if (result == 0 && ISUPPER(tok(p)[0])) { result = tCONSTANT; } else { |
