mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
id.h.tmpl: ANDOP and OROP
* template/id.h.tmpl (token_op_ids): define && and || for ripper. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48154 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5a277b4070
commit
d8e1bf2760
3 changed files with 14 additions and 18 deletions
24
parse.y
24
parse.y
|
@ -801,8 +801,8 @@ static void token_info_pop(struct parser_params*, const char *token);
|
|||
%token tNEQ RUBY_TOKEN(NEQ) "!="
|
||||
%token tGEQ RUBY_TOKEN(GEQ) ">="
|
||||
%token tLEQ RUBY_TOKEN(LEQ) "<="
|
||||
%token tANDOP "&&"
|
||||
%token tOROP "||"
|
||||
%token tANDOP RUBY_TOKEN(ANDOP) "&&"
|
||||
%token tOROP RUBY_TOKEN(OROP) "||"
|
||||
%token tMATCH RUBY_TOKEN(MATCH) "=~"
|
||||
%token tNMATCH RUBY_TOKEN(NMATCH) "!~"
|
||||
%token tDOT2 RUBY_TOKEN(DOT2) ".."
|
||||
|
@ -2298,7 +2298,7 @@ arg : lhs '=' arg
|
|||
/*%%%*/
|
||||
$$ = logop(NODE_AND, $1, $3);
|
||||
/*%
|
||||
$$ = dispatch3(binary, $1, ripper_intern("&&"), $3);
|
||||
$$ = dispatch3(binary, $1, ID2SYM(idANDOP), $3);
|
||||
%*/
|
||||
}
|
||||
| arg tOROP arg
|
||||
|
@ -2306,7 +2306,7 @@ arg : lhs '=' arg
|
|||
/*%%%*/
|
||||
$$ = logop(NODE_OR, $1, $3);
|
||||
/*%
|
||||
$$ = dispatch3(binary, $1, ripper_intern("||"), $3);
|
||||
$$ = dispatch3(binary, $1, ID2SYM(idOROP), $3);
|
||||
%*/
|
||||
}
|
||||
| keyword_defined opt_nl {in_defined = 1;} arg
|
||||
|
@ -10718,20 +10718,10 @@ ripper_id2sym(ID id)
|
|||
if ((name = keyword_id_to_str(id))) {
|
||||
return ID2SYM(rb_intern(name));
|
||||
}
|
||||
switch (id) {
|
||||
case tOROP:
|
||||
name = "||";
|
||||
break;
|
||||
case tANDOP:
|
||||
name = "&&";
|
||||
break;
|
||||
default:
|
||||
if (!rb_id2str(id)) {
|
||||
rb_bug("cannot convert ID to string: %ld", (unsigned long)id);
|
||||
}
|
||||
return ID2SYM(id);
|
||||
if (!rb_id2str(id)) {
|
||||
rb_bug("cannot convert ID to string: %ld", (unsigned long)id);
|
||||
}
|
||||
return ID2SYM(rb_intern(name));
|
||||
return ID2SYM(id);
|
||||
}
|
||||
|
||||
static ID
|
||||
|
|
4
symbol.c
4
symbol.c
|
@ -51,6 +51,8 @@ static ID register_static_symid_str(ID, VALUE);
|
|||
#define tLSHFT RUBY_TOKEN(LSHFT)
|
||||
#define tRSHFT RUBY_TOKEN(RSHFT)
|
||||
#define tCOLON2 RUBY_TOKEN(COLON2)
|
||||
#define tANDOP RUBY_TOKEN(ANDOP)
|
||||
#define tOROP RUBY_TOKEN(OROP)
|
||||
|
||||
static const struct {
|
||||
unsigned short token;
|
||||
|
@ -74,6 +76,8 @@ static const struct {
|
|||
{tLSHFT, "<<"},
|
||||
{tRSHFT, ">>"},
|
||||
{tCOLON2, "::"},
|
||||
{tANDOP, "&&"},
|
||||
{tOROP, "||"},
|
||||
};
|
||||
|
||||
#define op_tbl_count numberof(op_tbl)
|
||||
|
|
|
@ -18,7 +18,7 @@ op_id_offset = 128
|
|||
token_op_ids = %w[
|
||||
tDOT2 tDOT3 tUPLUS tUMINUS tPOW tDSTAR tCMP tLSHFT tRSHFT
|
||||
tLEQ tGEQ tEQ tEQQ tNEQ tMATCH tNMATCH tAREF tASET
|
||||
tCOLON2 tCOLON3
|
||||
tCOLON2 tCOLON3 tANDOP tOROP
|
||||
]
|
||||
|
||||
defs = File.join(File.dirname(File.dirname(erb.filename)), "defs/id.def")
|
||||
|
@ -92,6 +92,8 @@ enum ruby_method_ids {
|
|||
idAREF = RUBY_TOKEN(AREF),
|
||||
idASET = RUBY_TOKEN(ASET),
|
||||
idCOLON2 = RUBY_TOKEN(COLON2),
|
||||
idANDOP = RUBY_TOKEN(ANDOP),
|
||||
idOROP = RUBY_TOKEN(OROP),
|
||||
tPRESERVED_ID_BEGIN = <%=op_id_offset + token_op_ids.size - 1%>,
|
||||
% ids[:preserved].each do |token|
|
||||
id<%=token%>,
|
||||
|
|
Loading…
Reference in a new issue