diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-02-11 02:14:06 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-02-11 02:14:06 +0000 |
commit | 58e97c4e6d553edc4211f8da50b0529cc8f279d7 (patch) | |
tree | 4041936a85fdaae6fc226ac4c634c559cb81caad /template/id.h.tmpl | |
parent | 70f772c3efb1caeb3333ba95b778967c6810695e (diff) | |
download | bundler-58e97c4e6d553edc4211f8da50b0529cc8f279d7.tar.gz |
parse.y: TOKEN2ID
* parse.y (TOKEN2ID): add macro which maps static tokens to IDs.
* template/id.h.tmpl (TOKEN2*ID, DEFINE_*ID_FROM_TOKEN): separate
into macros, token to ID mapping and enum definitions.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57598 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'template/id.h.tmpl')
-rw-r--r-- | template/id.h.tmpl | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/template/id.h.tmpl b/template/id.h.tmpl index ab5c98b6c4..687cbbbe40 100644 --- a/template/id.h.tmpl +++ b/template/id.h.tmpl @@ -57,6 +57,11 @@ enum ruby_id_types { % end #define RUBY_TOKEN(t) RUBY_TOKEN_##t +#define RUBY_TOKEN2ID_TYPE(tok, type) ((tok<<RUBY_ID_SCOPE_SHIFT)|type|RUBY_ID_STATIC_SYM) +% types.each do |type| +#define TOKEN2<%=type%>ID(tok) RUBY_TOKEN2ID_TYPE(tok, RUBY_ID_<%=type%>) +% end + enum ruby_method_ids { % ids[:token_op].uniq {|_, op| op}.each do |id, op, token| id<%=id%> = <%=token ? "RUBY_TOKEN(#{token})" : "'#{op}'"%>, @@ -66,16 +71,23 @@ enum ruby_method_ids { id<%=token%>, % end tPRESERVED_ID_END, -% ids.values_at(*types).flatten.each do |token| +% prev = 'tPRESERVED_ID_END' +% types.each do |type| +% tokens = ids[type] + tTOKEN_<%=type%>_BEGIN = <%=prev%>-1, +% tokens.each do |token| t<%=token%>, +% end +% prev = "tTOKEN_#{type}_END" + <%=prev%>, % end - tNEXT_ID, + tNEXT_ID = <%=prev%>, % types.each do |type| -% types = ids[type] or next -% types.empty? and next -#define TOKEN2<%=type%>ID(n) id##n = ((t##n<<ID_SCOPE_SHIFT)|ID_<%=type%>|ID_STATIC_SYM) -% types.each do |token| - TOKEN2<%=type%>ID(<%=token%>), +% tokens = ids[type] +#define DEFINE_<%=type%>ID_FROM_TOKEN(n) id##n = TOKEN2<%=type%>ID(t##n) +% tokens or next +% tokens.each do |token| + DEFINE_<%=type%>ID_FROM_TOKEN(<%=token%>), % end % end tLAST_OP_ID = tPRESERVED_ID_END-1, |