rubinius-melbourne 3.10 → 3.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -390,6 +390,10 @@ static int scan_hex(const char *start, size_t len, size_t *retlen);
390
390
  #define RE_OPTION_MULTILINE (4)
391
391
  #endif
392
392
 
393
+ #ifndef RE_OPTION_PEG
394
+ #define RE_OPTION_PEG (8)
395
+ #endif
396
+
393
397
  /* Must match up with options/kcode definitions in regexp.rb and regexp.cpp */
394
398
  #define RE_OPTION_DONT_CAPTURE_GROUP (128)
395
399
  #define RE_OPTION_CAPTURE_GROUP (256)
@@ -451,9 +455,7 @@ static int scan_hex(const char *start, size_t len, size_t *retlen);
451
455
  keyword_class
452
456
  keyword_module
453
457
  keyword_def
454
- keyword_defm
455
458
  keyword_fun
456
- keyword_funm
457
459
  keyword_undef
458
460
  keyword_begin
459
461
  keyword_rescue
@@ -1253,8 +1255,7 @@ op : '|' { $$ = '|'; }
1253
1255
  reswords : keyword__LINE__ | keyword__FILE__ | keyword__ENCODING__
1254
1256
  | keyword_BEGIN | keyword_END
1255
1257
  | keyword_alias | keyword_and | keyword_begin
1256
- | keyword_break | keyword_case | keyword_class | keyword_def
1257
- | keyword_defm | keyword_fun | keyword_funm
1258
+ | keyword_break | keyword_case | keyword_class | keyword_def | keyword_fun
1258
1259
  | keyword_defined | keyword_do | keyword_else | keyword_elsif
1259
1260
  | keyword_end | keyword_ensure | keyword_false
1260
1261
  | keyword_for | keyword_in | keyword_module | keyword_next
@@ -1891,27 +1892,6 @@ primary : literal
1891
1892
  in_def = $<num>4 & 1;
1892
1893
  cur_mid = $<id>3;
1893
1894
  }
1894
- | k_defm fname
1895
- {
1896
- $<id>$ = cur_mid;
1897
- cur_mid = $2;
1898
- local_push(0);
1899
- }
1900
- {
1901
- $<num>$ = in_def;
1902
- in_def = 1;
1903
- }
1904
- f_arglist
1905
- bodystmt
1906
- k_end
1907
- {
1908
- NODE* body = remove_begin($6);
1909
- $$ = NEW_DEFNM($2, $5, body, NOEX_PRIVATE);
1910
- nd_set_line($$, $<num>1);
1911
- local_pop();
1912
- in_def = $<num>4 & 1;
1913
- cur_mid = $<id>3;
1914
- }
1915
1895
  | k_fun fname
1916
1896
  {
1917
1897
  $<id>$ = cur_mid;
@@ -1933,27 +1913,6 @@ primary : literal
1933
1913
  in_def = $<num>4 & 1;
1934
1914
  cur_mid = $<id>3;
1935
1915
  }
1936
- | k_funm fname
1937
- {
1938
- $<id>$ = cur_mid;
1939
- cur_mid = $2;
1940
- local_push(0);
1941
- }
1942
- {
1943
- $<num>$ = in_def;
1944
- in_def = 1;
1945
- }
1946
- f_arglist
1947
- bodystmt
1948
- k_end
1949
- {
1950
- NODE* body = remove_begin($6);
1951
- $$ = NEW_FUNM($2, $5, body, NOEX_PRIVATE);
1952
- nd_set_line($$, $<num>1);
1953
- local_pop();
1954
- in_def = $<num>4 & 1;
1955
- cur_mid = $<id>3;
1956
- }
1957
1916
  | k_def singleton dot_or_colon {SET_LEX_STATE(EXPR_FNAME);} fname
1958
1917
  {
1959
1918
  $<num>4 = in_single;
@@ -1971,23 +1930,6 @@ primary : literal
1971
1930
  local_pop();
1972
1931
  in_single = $<num>4 & 1;
1973
1932
  }
1974
- | k_defm singleton dot_or_colon {SET_LEX_STATE(EXPR_FNAME);} fname
1975
- {
1976
- $<num>4 = in_single;
1977
- in_single = 1;
1978
- SET_LEX_STATE(EXPR_ENDFN | EXPR_LABEL); /* force for args */
1979
- local_push(0);
1980
- }
1981
- f_arglist
1982
- bodystmt
1983
- k_end
1984
- {
1985
- NODE* body = remove_begin($8);
1986
- $$ = NEW_DEFSM($2, $5, $7, body);
1987
- nd_set_line($$, $<num>1);
1988
- local_pop();
1989
- in_single = $<num>4 & 1;
1990
- }
1991
1933
  | keyword_break
1992
1934
  {
1993
1935
  $$ = NEW_BREAK(0);
@@ -2075,13 +2017,6 @@ k_def : keyword_def
2075
2017
  }
2076
2018
  ;
2077
2019
 
2078
- k_defm : keyword_defm
2079
- {
2080
- token_info_push("defm");
2081
- $<num>$ = sourceline;
2082
- }
2083
- ;
2084
-
2085
2020
  k_fun : keyword_fun
2086
2021
  {
2087
2022
  token_info_push("fun");
@@ -2089,13 +2024,6 @@ k_fun : keyword_fun
2089
2024
  }
2090
2025
  ;
2091
2026
 
2092
- k_funm : keyword_funm
2093
- {
2094
- token_info_push("funm");
2095
- $<num>$ = sourceline;
2096
- }
2097
- ;
2098
-
2099
2027
  k_end : keyword_end
2100
2028
  {
2101
2029
  token_info_pop("end");
@@ -4141,6 +4069,9 @@ static int parser_regx_options(rb_parser_state* parser_state) {
4141
4069
  case 'o':
4142
4070
  options |= RE_OPTION_ONCE;
4143
4071
  break;
4072
+ case 'p':
4073
+ options |= RE_OPTION_PEG;
4074
+ break;
4144
4075
  case 'G':
4145
4076
  options |= RE_OPTION_CAPTURE_GROUP;
4146
4077
  break;
@@ -34,43 +34,43 @@ static const struct kwtable *reserved_word(const char *, unsigned int);
34
34
  #define rb_reserved_word(str, len) reserved_word(str, len)
35
35
  struct kwtable;
36
36
 
37
- #define TOTAL_KEYWORDS 44
37
+ #define TOTAL_KEYWORDS 42
38
38
  #define MIN_WORD_LENGTH 2
39
39
  #define MAX_WORD_LENGTH 12
40
- #define MIN_HASH_VALUE 7
41
- #define MAX_HASH_VALUE 50
42
- /* maximum key range = 44, duplicates = 0 */
40
+ #define MIN_HASH_VALUE 4
41
+ #define MAX_HASH_VALUE 46
42
+ /* maximum key range = 43, duplicates = 0 */
43
43
 
44
44
  static inline unsigned int hash(const char* str, unsigned int len)
45
45
  {
46
46
  static const unsigned char asso_values[] =
47
47
  {
48
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
49
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
50
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
51
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
52
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
53
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
54
- 51, 51, 51, 30, 51, 51, 15, 51, 18, 10,
55
- 12, 14, 51, 51, 51, 51, 11, 51, 14, 51,
56
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
57
- 51, 51, 51, 51, 51, 12, 51, 6, 4, 35,
58
- 11, 1, 1, 29, 51, 27, 51, 3, 4, 20,
59
- 4, 10, 16, 51, 12, 1, 5, 8, 51, 12,
60
- 19, 18, 51, 51, 51, 51, 51, 51, 51, 51,
61
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
62
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
63
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
64
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
65
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
66
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
67
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
68
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
69
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
70
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
71
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
72
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
73
- 51, 51, 51, 51, 51, 51
48
+ 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
49
+ 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
50
+ 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
51
+ 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
52
+ 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
53
+ 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
54
+ 47, 47, 47, 19, 47, 47, 14, 47, 16, 9,
55
+ 11, 13, 47, 47, 47, 47, 10, 47, 13, 47,
56
+ 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
57
+ 47, 47, 47, 47, 47, 11, 47, 9, 16, 19,
58
+ 15, 1, 4, 17, 47, 1, 47, 16, 1, 14,
59
+ 1, 1, 21, 47, 5, 4, 9, 9, 47, 24,
60
+ 18, 8, 47, 47, 47, 47, 47, 47, 47, 47,
61
+ 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
62
+ 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
63
+ 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
64
+ 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
65
+ 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
66
+ 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
67
+ 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
68
+ 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
69
+ 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
70
+ 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
71
+ 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
72
+ 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
73
+ 47, 47, 47, 47, 47, 47
74
74
  };
75
75
  int hval = len;
76
76
 
@@ -91,60 +91,59 @@ const struct kwtable* rb_reserved_word(const char* str, unsigned int len)
91
91
  {
92
92
  static const struct kwtable wordlist[] =
93
93
  {
94
- {""}, {""}, {""}, {""}, {""}, {""}, {""},
94
+ {""}, {""}, {""}, {""},
95
+ {"in", {keyword_in, keyword_in}, EXPR_VALUE},
96
+ {""},
97
+ {"nil", {keyword_nil, keyword_nil}, EXPR_END},
98
+ {"if", {keyword_if, modifier_if}, EXPR_VALUE},
99
+ {"or", {keyword_or, keyword_or}, EXPR_VALUE},
100
+ {"fun", {keyword_fun, keyword_fun}, EXPR_FNAME},
95
101
  {"else", {keyword_else, keyword_else}, EXPR_BEG},
96
- {"elsif", {keyword_elsif, keyword_elsif}, EXPR_VALUE},
102
+ {"false", {keyword_false, keyword_false}, EXPR_END},
97
103
  {"ensure", {keyword_ensure, keyword_ensure}, EXPR_BEG},
98
104
  {"self", {keyword_self, keyword_self}, EXPR_END},
99
- {"false", {keyword_false, keyword_false}, EXPR_END},
100
- {"fun", {keyword_fun, keyword_fun}, EXPR_FNAME},
101
- {"break", {keyword_break, keyword_break}, EXPR_MID},
105
+ {"elsif", {keyword_elsif, keyword_elsif}, EXPR_VALUE},
102
106
  {"then", {keyword_then, keyword_then}, EXPR_BEG},
103
- {"nil", {keyword_nil, keyword_nil}, EXPR_END},
104
- {"def", {keyword_def, keyword_def}, EXPR_FNAME},
107
+ {"rescue", {keyword_rescue, modifier_rescue}, EXPR_MID},
108
+ {"for", {keyword_for, keyword_for}, EXPR_VALUE},
109
+ {"do", {keyword_do, keyword_do}, EXPR_BEG},
110
+ {"alias", {keyword_alias, keyword_alias}, EXPR_FNAME},
111
+ {"unless", {keyword_unless, modifier_unless}, EXPR_VALUE},
112
+ {"return", {keyword_return, keyword_return}, EXPR_MID},
105
113
  {"not", {keyword_not, keyword_not}, EXPR_ARG},
106
114
  {"true", {keyword_true, keyword_true}, EXPR_END},
107
- {"unless", {keyword_unless, modifier_unless}, EXPR_VALUE},
108
- {"rescue", {keyword_rescue, modifier_rescue}, EXPR_MID},
109
- {"when", {keyword_when, keyword_when}, EXPR_VALUE},
110
115
  {"until", {keyword_until, modifier_until}, EXPR_VALUE},
111
- {"do", {keyword_do, keyword_do}, EXPR_BEG},
112
- {"or", {keyword_or, keyword_or}, EXPR_VALUE},
116
+ {"redo", {keyword_redo, keyword_redo}, EXPR_END},
117
+ {"def", {keyword_def, keyword_def}, EXPR_FNAME},
118
+ {"retry", {keyword_retry, keyword_retry}, EXPR_END},
119
+ {"case", {keyword_case, keyword_case}, EXPR_VALUE},
120
+ {"yield", {keyword_yield, keyword_yield}, EXPR_ARG},
121
+ {"when", {keyword_when, keyword_when}, EXPR_VALUE},
122
+ {"while", {keyword_while, modifier_while}, EXPR_VALUE},
123
+ {"next", {keyword_next, keyword_next}, EXPR_MID},
113
124
  {"undef", {keyword_undef, keyword_undef}, EXPR_FNAME},
114
125
  {"end", {keyword_end, keyword_end}, EXPR_END},
115
- {"return", {keyword_return, keyword_return}, EXPR_MID},
116
- {"for", {keyword_for, keyword_for}, EXPR_VALUE},
117
- {"funm", {keyword_funm, keyword_funm}, EXPR_FNAME},
118
- {"if", {keyword_if, modifier_if}, EXPR_VALUE},
119
- {"and", {keyword_and, keyword_and}, EXPR_VALUE},
120
- {"next", {keyword_next, keyword_next}, EXPR_MID},
121
- {"in", {keyword_in, keyword_in}, EXPR_VALUE},
122
126
  {"super", {keyword_super, keyword_super}, EXPR_ARG},
123
- {"yield", {keyword_yield, keyword_yield}, EXPR_ARG},
124
- {"defm", {keyword_defm, keyword_defm}, EXPR_FNAME},
125
- {"redo", {keyword_redo, keyword_redo}, EXPR_END},
126
127
  {"module", {keyword_module, keyword_module}, EXPR_VALUE},
127
- {"alias", {keyword_alias, keyword_alias}, EXPR_FNAME},
128
- {"retry", {keyword_retry, keyword_retry}, EXPR_END},
129
- {"case", {keyword_case, keyword_case}, EXPR_VALUE},
128
+ {"class", {keyword_class, keyword_class}, EXPR_CLASS},
129
+ {"break", {keyword_break, keyword_break}, EXPR_MID},
130
130
  {"begin", {keyword_begin, keyword_begin}, EXPR_BEG},
131
131
  {"__LINE__", {keyword__LINE__, keyword__LINE__}, EXPR_END},
132
132
  {"__FILE__", {keyword__FILE__, keyword__FILE__}, EXPR_END},
133
- {"while", {keyword_while, modifier_while}, EXPR_VALUE},
133
+ {"and", {keyword_and, keyword_and}, EXPR_VALUE},
134
134
  {"__ENCODING__", {keyword__ENCODING__, keyword__ENCODING__}, EXPR_END},
135
- {"class", {keyword_class, keyword_class}, EXPR_CLASS},
136
- {"BEGIN", {keyword_BEGIN, keyword_BEGIN}, EXPR_END},
137
135
  {"END", {keyword_END, keyword_END}, EXPR_END},
136
+ {"BEGIN", {keyword_BEGIN, keyword_BEGIN}, EXPR_END},
138
137
  {"defined?", {keyword_defined, keyword_defined}, EXPR_ARG}
139
138
  };
140
139
 
141
- if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) {
140
+ if(len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) {
142
141
  int key = hash(str, len);
143
142
 
144
143
  if(key <= MAX_HASH_VALUE && key >= 0) {
145
144
  const char *s = wordlist[key].name;
146
145
 
147
- if(*str == *s && !strcmp (str + 1, s + 1))
146
+ if (*str == *s && !strcmp (str + 1, s + 1))
148
147
  return &wordlist[key];
149
148
  }
150
149
  }
@@ -170,10 +170,7 @@ namespace MELBOURNE {
170
170
 
171
171
  #define NEW_DEFN(i,a,d,p) NEW_NODE(NODE_DEFN,0,i,NEW_SCOPE(a,d))
172
172
  #define NEW_DEFS(r,i,a,d) NEW_NODE(NODE_DEFS,r,i,NEW_SCOPE(a,d))
173
- #define NEW_DEFNM(i,a,d,p) NEW_NODE(NODE_DEFNM,0,i,NEW_SCOPE(a,d))
174
- #define NEW_DEFSM(r,i,a,d) NEW_NODE(NODE_DEFSM,r,i,NEW_SCOPE(a,d))
175
173
  #define NEW_FUN(i,a,d,p) NEW_NODE(NODE_FUN,0,i,NEW_SCOPE(a,d))
176
- #define NEW_FUNM(i,a,d,p) NEW_NODE(NODE_FUNM,0,i,NEW_SCOPE(a,d))
177
174
  #define NEW_IFUNC(f,c) NEW_NODE(NODE_IFUNC,f,c,0)
178
175
  #define NEW_SCOPE(a,b) NEW_NODE(NODE_SCOPE,local_tbl(),b,a)
179
176
  #define NEW_BLOCK(a) NEW_NODE(NODE_BLOCK,a,0,0)
@@ -86,10 +86,7 @@ namespace MELBOURNE {
86
86
  "block_pass\0"
87
87
  "defn\0"
88
88
  "defs\0"
89
- "defnm\0"
90
- "defsm\0"
91
89
  "fun\0"
92
- "funm\0"
93
90
  "alias\0"
94
91
  "valias\0"
95
92
  "undef\0"
@@ -211,52 +208,49 @@ namespace MELBOURNE {
211
208
  504,
212
209
  509,
213
210
  514,
214
- 520,
215
- 526,
216
- 530,
217
- 535,
218
- 541,
219
- 548,
220
- 554,
221
- 560,
222
- 567,
223
- 574,
211
+ 518,
212
+ 524,
213
+ 531,
214
+ 537,
215
+ 543,
216
+ 550,
217
+ 557,
218
+ 564,
219
+ 571,
220
+ 576,
224
221
  581,
225
- 588,
222
+ 587,
226
223
  593,
227
224
  598,
228
- 604,
229
- 610,
230
- 615,
231
- 619,
232
- 624,
233
- 630,
234
- 638,
235
- 646,
236
- 654,
237
- 661,
238
- 669,
239
- 674,
225
+ 602,
226
+ 607,
227
+ 613,
228
+ 621,
229
+ 629,
230
+ 637,
231
+ 644,
232
+ 652,
233
+ 657,
234
+ 663,
235
+ 668,
240
236
  680,
241
- 685,
237
+ 689,
242
238
  697,
243
- 706,
244
- 714,
245
- 721,
246
- 730,
247
- 735,
248
- 740,
249
- 746,
250
- 753,
251
- 759,
252
- 768,
253
- 775,
254
- 784,
255
- 794
239
+ 704,
240
+ 713,
241
+ 718,
242
+ 723,
243
+ 729,
244
+ 736,
245
+ 742,
246
+ 751,
247
+ 758,
248
+ 767,
249
+ 777
256
250
  };
257
251
 
258
252
  const char *get_node_type_string(enum node_type node) {
259
- if(node < 121) {
253
+ if(node < 118) {
260
254
  return node_types + node_types_offsets[node];
261
255
  } else {
262
256
  #define NODE_STRING_MESSAGE_LEN 20
@@ -83,10 +83,7 @@ namespace MELBOURNE {
83
83
  NODE_BLOCK_PASS,
84
84
  NODE_DEFN,
85
85
  NODE_DEFS,
86
- NODE_DEFNM,
87
- NODE_DEFSM,
88
86
  NODE_FUN,
89
- NODE_FUNM,
90
87
  NODE_ALIAS,
91
88
  NODE_VALIAS,
92
89
  NODE_UNDEF,
@@ -78,10 +78,7 @@ node_types = %w[
78
78
  block_pass
79
79
  defn
80
80
  defs
81
- defnm
82
- defsm
83
81
  fun
84
- funm
85
82
  alias
86
83
  valias
87
84
  undef
@@ -34,9 +34,7 @@ namespace MELBOURNE {
34
34
  ID rb_sData;
35
35
  ID rb_sDefined;
36
36
  ID rb_sDefn;
37
- ID rb_sDefnm;
38
37
  ID rb_sDefs;
39
- ID rb_sDefsm;
40
38
  ID rb_sDot2;
41
39
  ID rb_sDot3;
42
40
  ID rb_sDRegx;
@@ -56,7 +54,6 @@ namespace MELBOURNE {
56
54
  ID rb_sFloat;
57
55
  ID rb_sFor;
58
56
  ID rb_sFun;
59
- ID rb_sFunm;
60
57
  ID rb_sGAsgn;
61
58
  ID rb_sGVar;
62
59
  ID rb_sHash;
@@ -156,9 +153,7 @@ namespace MELBOURNE {
156
153
  rb_sData = rb_intern("process_data");
157
154
  rb_sDefined = rb_intern("process_defined");
158
155
  rb_sDefn = rb_intern("process_defn");
159
- rb_sDefnm = rb_intern("process_defnm");
160
156
  rb_sDefs = rb_intern("process_defs");
161
- rb_sDefsm = rb_intern("process_defsm");
162
157
  rb_sDot2 = rb_intern("process_dot2");
163
158
  rb_sDot3 = rb_intern("process_dot3");
164
159
  rb_sDRegx = rb_intern("process_dregx");
@@ -178,7 +173,6 @@ namespace MELBOURNE {
178
173
  rb_sFloat = rb_intern("process_float");
179
174
  rb_sFor = rb_intern("process_for");
180
175
  rb_sFun = rb_intern("process_fun");
181
- rb_sFunm = rb_intern("process_funm");
182
176
  rb_sGAsgn = rb_intern("process_gasgn");
183
177
  rb_sGVar = rb_intern("process_gvar");
184
178
  rb_sHash = rb_intern("process_hash");