summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--parse.y24
-rw-r--r--symbol.c4
-rw-r--r--template/id.h.tmpl4
3 files changed, 14 insertions, 18 deletions
diff --git a/parse.y b/parse.y
index 55ea63e..87866c0 100644
--- a/parse.y
+++ b/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
diff --git a/symbol.c b/symbol.c
index 1795415..d4d7b5e 100644
--- a/symbol.c
+++ b/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)
diff --git a/template/id.h.tmpl b/template/id.h.tmpl
index 6db478b..92dbc47 100644
--- a/template/id.h.tmpl
+++ b/template/id.h.tmpl
@@ -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%>,