mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* parse.y (IS_END, IS_SPCARG): macros for simplification.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27392 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
9f8b036123
commit
f25e99c55f
1 changed files with 15 additions and 19 deletions
34
parse.y
34
parse.y
|
@ -6413,7 +6413,9 @@ parser_prepare(struct parser_params *parser)
|
|||
}
|
||||
|
||||
#define IS_ARG() (lex_state == EXPR_ARG || lex_state == EXPR_CMDARG)
|
||||
#define IS_END() (lex_state == EXPR_END || lex_state == EXPR_ENDARG)
|
||||
#define IS_BEG() (lex_state == EXPR_BEG || lex_state == EXPR_MID || lex_state == EXPR_VALUE || lex_state == EXPR_CLASS)
|
||||
#define IS_SPCARG(c) (IS_ARG() && space_seen && !ISSPACE(c))
|
||||
|
||||
static int
|
||||
parser_yylex(struct parser_params *parser)
|
||||
|
@ -6555,7 +6557,7 @@ parser_yylex(struct parser_params *parser)
|
|||
return tOP_ASGN;
|
||||
}
|
||||
pushback(c);
|
||||
if (IS_ARG() && space_seen && !ISSPACE(c)) {
|
||||
if (IS_SPCARG(c)) {
|
||||
rb_warning0("`*' interpreted as argument prefix");
|
||||
c = tSTAR;
|
||||
}
|
||||
|
@ -6826,7 +6828,7 @@ parser_yylex(struct parser_params *parser)
|
|||
return tOP_ASGN;
|
||||
}
|
||||
pushback(c);
|
||||
if (IS_ARG() && space_seen && !ISSPACE(c)) {
|
||||
if (IS_SPCARG(c)) {
|
||||
rb_warning0("`&' interpreted as argument prefix");
|
||||
c = tAMPER;
|
||||
}
|
||||
|
@ -6884,9 +6886,8 @@ parser_yylex(struct parser_params *parser)
|
|||
lex_state = EXPR_BEG;
|
||||
return tOP_ASGN;
|
||||
}
|
||||
if (IS_BEG() ||
|
||||
(IS_ARG() && space_seen && !ISSPACE(c))) {
|
||||
if (IS_ARG()) arg_ambiguous();
|
||||
if (IS_BEG() || IS_SPCARG(c)) {
|
||||
if (!IS_BEG()) arg_ambiguous();
|
||||
lex_state = EXPR_BEG;
|
||||
pushback(c);
|
||||
if (c != -1 && ISDIGIT(c)) {
|
||||
|
@ -6918,9 +6919,8 @@ parser_yylex(struct parser_params *parser)
|
|||
lex_state = EXPR_ARG;
|
||||
return tLAMBDA;
|
||||
}
|
||||
if (IS_BEG() ||
|
||||
(IS_ARG() && space_seen && !ISSPACE(c))) {
|
||||
if (IS_ARG()) arg_ambiguous();
|
||||
if (IS_BEG() || IS_SPCARG(c)) {
|
||||
if (!IS_BEG()) arg_ambiguous();
|
||||
lex_state = EXPR_BEG;
|
||||
pushback(c);
|
||||
if (c != -1 && ISDIGIT(c)) {
|
||||
|
@ -7184,16 +7184,14 @@ parser_yylex(struct parser_params *parser)
|
|||
case ':':
|
||||
c = nextc();
|
||||
if (c == ':') {
|
||||
if (IS_BEG() ||
|
||||
lex_state == EXPR_CLASS || (IS_ARG() && space_seen)) {
|
||||
if (IS_BEG() || lex_state == EXPR_CLASS || IS_SPCARG(-1)) {
|
||||
lex_state = EXPR_BEG;
|
||||
return tCOLON3;
|
||||
}
|
||||
lex_state = EXPR_DOT;
|
||||
return tCOLON2;
|
||||
}
|
||||
if ((!space_seen && (lex_state == EXPR_END || lex_state == EXPR_ENDARG)) ||
|
||||
(c != -1 && ISSPACE(c))) {
|
||||
if ((IS_END() && !space_seen) || ISSPACE(c)) {
|
||||
pushback(c);
|
||||
lex_state = EXPR_BEG;
|
||||
return ':';
|
||||
|
@ -7223,12 +7221,10 @@ parser_yylex(struct parser_params *parser)
|
|||
return tOP_ASGN;
|
||||
}
|
||||
pushback(c);
|
||||
if (IS_ARG() && space_seen) {
|
||||
if (!ISSPACE(c)) {
|
||||
arg_ambiguous();
|
||||
lex_strterm = NEW_STRTERM(str_regexp, '/', 0);
|
||||
return tREGEXP_BEG;
|
||||
}
|
||||
if (IS_SPCARG(c)) {
|
||||
arg_ambiguous();
|
||||
lex_strterm = NEW_STRTERM(str_regexp, '/', 0);
|
||||
return tREGEXP_BEG;
|
||||
}
|
||||
switch (lex_state) {
|
||||
case EXPR_FNAME: case EXPR_DOT:
|
||||
|
@ -7420,7 +7416,7 @@ parser_yylex(struct parser_params *parser)
|
|||
lex_state = EXPR_BEG;
|
||||
return tOP_ASGN;
|
||||
}
|
||||
if (IS_ARG() && space_seen && !ISSPACE(c)) {
|
||||
if (IS_SPCARG(c)) {
|
||||
goto quotation;
|
||||
}
|
||||
switch (lex_state) {
|
||||
|
|
Loading…
Add table
Reference in a new issue