summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-18 13:16:30 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-18 13:16:30 +0000
commitf25e99c55f42d23aac050594a482cd2e1807e7ac (patch)
tree9beb3051c975174af8f76bdb21401b335b886c05 /parse.y
parent9f8b0361233fcd4bbc5cfb45ca41847ac960de16 (diff)
* 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
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y34
1 files changed, 15 insertions, 19 deletions
diff --git a/parse.y b/parse.y
index 3d8ec4100c..77f3e0a4f1 100644
--- a/parse.y
+++ b/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) {