racc 1.4.15-java → 1.4.16-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/COPYING +22 -515
  3. data/Manifest.txt +3 -9
  4. data/README.ja.rdoc +3 -4
  5. data/README.rdoc +4 -4
  6. data/Rakefile +13 -55
  7. data/bin/racc +2 -4
  8. data/ext/racc/{cparse.c → cparse/cparse.c} +64 -31
  9. data/ext/racc/cparse/extconf.rb +8 -0
  10. data/lib/racc/cparse-jruby.jar +0 -0
  11. data/lib/racc/exception.rb +3 -5
  12. data/lib/racc/grammar.rb +5 -7
  13. data/lib/racc/grammarfileparser.rb +4 -3
  14. data/lib/racc/info.rb +4 -6
  15. data/lib/racc/iset.rb +2 -2
  16. data/lib/racc/logfilegenerator.rb +2 -2
  17. data/lib/racc/parser-text.rb +14 -11
  18. data/lib/racc/parser.rb +14 -11
  19. data/lib/racc/parserfilegenerator.rb +5 -7
  20. data/lib/racc/state.rb +11 -13
  21. data/test/assets/intp.y +4 -4
  22. data/test/assets/mailp.y +27 -27
  23. data/test/assets/mof.y +12 -12
  24. data/test/assets/nullbug2.y +2 -2
  25. data/test/assets/recv.y +20 -20
  26. data/test/assets/syntax.y +1 -1
  27. data/test/assets/twowaysql.y +1 -1
  28. data/test/helper.rb +65 -54
  29. data/test/regress/cadenza +60 -60
  30. data/test/regress/cast +8 -8
  31. data/test/regress/csspool +167 -167
  32. data/test/regress/edtf +115 -115
  33. data/test/regress/huia +75 -75
  34. data/test/regress/journey +12 -12
  35. data/test/regress/liquor +54 -54
  36. data/test/regress/machete +37 -37
  37. data/test/regress/mediacloth +83 -83
  38. data/test/regress/mof +60 -60
  39. data/test/regress/namae +29 -29
  40. data/test/regress/nasl +174 -174
  41. data/test/regress/nokogiri-css +59 -59
  42. data/test/regress/opal +352 -352
  43. data/test/regress/php_serialization +20 -20
  44. data/test/regress/riml +261 -261
  45. data/test/regress/ruby18 +353 -353
  46. data/test/regress/ruby22 +433 -433
  47. data/test/regress/tp_plus +125 -125
  48. data/test/regress/twowaysql +30 -30
  49. data/test/test_chk_y.rb +1 -0
  50. data/test/test_racc_command.rb +5 -24
  51. data/test/test_scan_y.rb +1 -0
  52. data/test/testscanner.rb +1 -1
  53. metadata +8 -75
  54. data/ext/racc/depend +0 -1
  55. data/ext/racc/extconf.rb +0 -7
  56. data/test/assets/bibtex.y +0 -141
  57. data/test/assets/rdblockparser.y +0 -576
  58. data/test/assets/rdinlineparser.y +0 -561
  59. data/test/regress/bibtex +0 -474
  60. data/test/regress/rdblockparser +0 -1061
  61. data/test/regress/rdinlineparser +0 -1243
@@ -10,9 +10,9 @@ bin/racc
10
10
  bin/racc2y
11
11
  bin/y2racc
12
12
  ext/racc/MANIFEST
13
- ext/racc/cparse.c
14
- ext/racc/depend
15
- ext/racc/extconf.rb
13
+ ext/racc/cparse/cparse.c
14
+ ext/racc/cparse/depend
15
+ ext/racc/cparse/extconf.rb
16
16
  ext/racc/com/headius/racc/Cparse.java
17
17
  fastcache/extconf.rb
18
18
  fastcache/fastcache.c
@@ -56,7 +56,6 @@ sample/yyerr.y
56
56
  setup.rb
57
57
  tasks/doc.rb
58
58
  tasks/email.rb
59
- test/assets/bibtex.y
60
59
  test/assets/cadenza.y
61
60
  test/assets/cast.y
62
61
  test/assets/chk.y
@@ -93,8 +92,6 @@ test/assets/opal.y
93
92
  test/assets/opt.y
94
93
  test/assets/percent.y
95
94
  test/assets/php_serialization.y
96
- test/assets/rdblockparser.y
97
- test/assets/rdinlineparser.y
98
95
  test/assets/recv.y
99
96
  test/assets/riml.y
100
97
  test/assets/rrconf.y
@@ -113,7 +110,6 @@ test/assets/yyerr.y
113
110
  test/bench.y
114
111
  test/helper.rb
115
112
  test/infini.y
116
- test/regress/bibtex
117
113
  test/regress/cadenza
118
114
  test/regress/cast
119
115
  test/regress/csspool
@@ -129,8 +125,6 @@ test/regress/nasl
129
125
  test/regress/nokogiri-css
130
126
  test/regress/opal
131
127
  test/regress/php_serialization
132
- test/regress/rdblockparser
133
- test/regress/rdinlineparser
134
128
  test/regress/riml
135
129
  test/regress/ruby18
136
130
  test/regress/ruby22
@@ -76,10 +76,9 @@
76
76
  == ライセンス
77
77
 
78
78
  このパッケージに付属するファイルの著作権は青木峰郎が保持します。
79
- ライセンスは GNU Lesser General Public License (LGPL) version 2
80
- です。ただしユーザが書いた規則ファイルや、Racc がそこから生成し
81
- た Ruby スクリプトはその対象外です。好きなライセンスで配布して
82
- ください。
79
+ ライセンスは Ruby ライセンスです。ただしユーザが書いた規則
80
+ ファイルや、Racc がそこから生成した Ruby スクリプトはその対象
81
+ 外です。好きなライセンスで配布してください。
83
82
 
84
83
 
85
84
  == バグなど
@@ -68,10 +68,10 @@
68
68
 
69
69
  == License
70
70
 
71
- Racc is distributed under the terms of the GNU Lesser General
72
- Public License version 2. Note that you do NOT need to follow
73
- LGPL for your own parser (racc outputs). You can provide those
74
- files under any licenses you want.
71
+ Racc is distributed under the same terms of ruby.
72
+ (see the file COPYING). Note that you do NOT need to follow
73
+ ruby license for your own parser (racc outputs).
74
+ You can distribute those files under any licenses you want.
75
75
 
76
76
 
77
77
  == Bug Reports
data/Rakefile CHANGED
@@ -1,12 +1,12 @@
1
1
  # -*- ruby -*-
2
2
 
3
- require 'rubygems'
4
- require 'hoe'
3
+ require 'rake/testtask'
5
4
 
5
+ Rake::TestTask.new(:test) do |t|
6
+ t.test_files = FileList["test/**/test_*.rb"]
7
+ end
6
8
  gem 'rake-compiler', '>= 0.4.1'
7
9
 
8
- Hoe.plugin :debugging, :doofus, :git, :isolate, :gemspec
9
-
10
10
  def java?
11
11
  /java/ === RUBY_PLATFORM
12
12
  end
@@ -14,40 +14,6 @@ def jruby?
14
14
  Object.const_defined?(:RUBY_ENGINE) and 'jruby' == RUBY_ENGINE
15
15
  end
16
16
 
17
- HOE = Hoe.spec 'racc' do
18
- developer 'Aaron Patterson', 'aaron@tenderlovemaking.com'
19
- license "MIT"
20
-
21
- self.extra_rdoc_files = Dir['*.rdoc']
22
- self.history_file = 'ChangeLog'
23
- self.readme_file = 'README.rdoc'
24
-
25
- dependency 'rake-compiler', '>= 0.4.1', :developer
26
- dependency 'minitest', '~> 4.7', :developer # stick to stdlib's version
27
-
28
- if java?
29
- self.spec_extras[:platform] = 'java'
30
- else
31
- self.spec_extras[:extensions] = %w[ext/racc/extconf.rb]
32
- end
33
-
34
- self.clean_globs << "lib/#{self.name}/*.{so,bundle,dll,jar}" # from hoe/compiler
35
-
36
- end
37
-
38
- def add_file_to_gem relative_path
39
- target_path = File.join gem_build_path, relative_path
40
- target_dir = File.dirname(target_path)
41
- mkdir_p target_dir unless File.directory?(target_dir)
42
- rm_f target_path
43
- safe_ln relative_path, target_path
44
- HOE.spec.files += [relative_path]
45
- end
46
-
47
- def gem_build_path
48
- File.join 'pkg', HOE.spec.full_name
49
- end
50
-
51
17
  file 'lib/racc/parser-text.rb' => ['lib/racc/parser.rb'] do |t|
52
18
  source = 'lib/racc/parser.rb'
53
19
 
@@ -62,20 +28,10 @@ end
62
28
  }
63
29
  end
64
30
 
65
- unless jruby?
66
- # MRI
67
- require "rake/extensiontask"
68
- Rake::ExtensionTask.new "cparse", HOE.spec do |ext|
69
- ext.lib_dir = File.join 'lib', 'racc'
70
- ext.ext_dir = File.join 'ext', 'racc'
71
- end
72
-
73
- task :compile => 'lib/racc/parser-text.rb'
74
- #
75
- else
31
+ if jruby?
76
32
  # JRUBY
77
33
  require "rake/javaextensiontask"
78
- Rake::JavaExtensionTask.new("cparse", HOE.spec) do |ext|
34
+ Rake::JavaExtensionTask.new("cparse") do |ext|
79
35
  jruby_home = RbConfig::CONFIG['prefix']
80
36
  ext.lib_dir = File.join 'lib', 'racc'
81
37
  ext.ext_dir = File.join 'ext', 'racc'
@@ -88,13 +44,15 @@ else
88
44
  end
89
45
 
90
46
  task :compile => ['lib/racc/parser-text.rb']
91
-
92
- task gem_build_path => [:compile] do
93
- add_file_to_gem 'lib/racc/cparse-jruby.jar'
47
+ else
48
+ # MRI
49
+ require "rake/extensiontask"
50
+ Rake::ExtensionTask.new "cparse" do |ext|
51
+ ext.lib_dir = File.join 'lib', 'racc'
52
+ ext.ext_dir = File.join 'ext', 'racc', 'cparse'
94
53
  end
95
54
 
55
+ task :compile => 'lib/racc/parser-text.rb'
96
56
  end
97
57
 
98
58
  task :test => :compile
99
-
100
- Hoe.add_include_dirs('.:lib/racc')
data/bin/racc CHANGED
@@ -5,10 +5,8 @@
5
5
  # Copyright (c) 1999-2006 Minero Aoki
6
6
  #
7
7
  # This program is free software.
8
- # You can distribute/modify this program under the terms of
9
- # the GNU LGPL, Lesser General Public License version 2.1.
10
- # For details of LGPL, see the file "COPYING".
11
- #
8
+ # You can distribute/modify this program under the same terms of ruby.
9
+ # see the file "COPYING".
12
10
 
13
11
  require 'racc/static'
14
12
  require 'optparse'
@@ -1,9 +1,9 @@
1
1
  /*
2
2
 
3
3
  cparse.c -- Racc Runtime Core
4
-
4
+
5
5
  Copyright (c) 1999-2006 Minero Aoki
6
-
6
+
7
7
  This library is free software.
8
8
  You can distribute/modify this program under the same terms of ruby.
9
9
 
@@ -13,6 +13,13 @@
13
13
 
14
14
  #include <ruby.h>
15
15
 
16
+ #ifndef FALSE
17
+ #define FALSE 0
18
+ #endif
19
+ #ifndef TRUE
20
+ #define TRUE 1
21
+ #endif
22
+
16
23
  /* -----------------------------------------------------------------------
17
24
  Important Constants
18
25
  ----------------------------------------------------------------------- */
@@ -189,7 +196,7 @@ static VALUE racc_yyparse _((VALUE parser, VALUE lexer, VALUE lexmid,
189
196
  VALUE arg, VALUE sysdebug));
190
197
 
191
198
  static void call_lexer _((struct cparse_params *v));
192
- static VALUE lexer_i _((VALUE block_args, VALUE data, VALUE self));
199
+ static VALUE lexer_i _((RB_BLOCK_CALL_FUNC_ARGLIST(block_args, data)));
193
200
 
194
201
  static VALUE assert_array _((VALUE a));
195
202
  static long assert_integer _((VALUE n));
@@ -197,6 +204,7 @@ static VALUE assert_hash _((VALUE h));
197
204
  static VALUE initialize_params _((VALUE vparams, VALUE parser, VALUE arg,
198
205
  VALUE lexer, VALUE lexmid));
199
206
  static void cparse_params_mark _((void *ptr));
207
+ static size_t cparse_params_memsize _((const void *ptr));
200
208
 
201
209
  static void parse_main _((struct cparse_params *v,
202
210
  VALUE tok, VALUE val, int resume));
@@ -204,7 +212,7 @@ static void extract_user_token _((struct cparse_params *v,
204
212
  VALUE block_args, VALUE *tok, VALUE *val));
205
213
  static void shift _((struct cparse_params* v, long act, VALUE tok, VALUE val));
206
214
  static int reduce _((struct cparse_params* v, long act));
207
- static VALUE reduce0 _((VALUE block_args, VALUE data, VALUE self));
215
+ static rb_block_call_func reduce0;
208
216
 
209
217
  #ifdef DEBUG
210
218
  # define D_puts(msg) if (v->sys_debug) puts(msg)
@@ -214,35 +222,52 @@ static VALUE reduce0 _((VALUE block_args, VALUE data, VALUE self));
214
222
  # define D_printf(fmt,arg)
215
223
  #endif
216
224
 
225
+ #undef RUBY_UNTYPED_DATA_WARNING
226
+ #define RUBY_UNTYPED_DATA_WARNING 1
227
+
228
+ static const rb_data_type_t cparse_params_type = {
229
+ "racc/cparse",
230
+ {
231
+ cparse_params_mark,
232
+ RUBY_TYPED_DEFAULT_FREE,
233
+ cparse_params_memsize,
234
+ },
235
+ #ifdef RUBY_TYPED_FREE_IMMEDIATELY
236
+ 0, 0,
237
+ RUBY_TYPED_FREE_IMMEDIATELY,
238
+ #endif
239
+ };
240
+
217
241
  static VALUE
218
242
  racc_cparse(VALUE parser, VALUE arg, VALUE sysdebug)
219
243
  {
220
- volatile VALUE vparams;
244
+ VALUE vparams;
221
245
  struct cparse_params *v;
222
246
 
223
- vparams = Data_Make_Struct(CparseParams, struct cparse_params,
224
- cparse_params_mark, -1, v);
247
+ vparams = TypedData_Make_Struct(CparseParams, struct cparse_params,
248
+ &cparse_params_type, v);
225
249
  D_puts("starting cparse");
226
250
  v->sys_debug = RTEST(sysdebug);
227
251
  vparams = initialize_params(vparams, parser, arg, Qnil, Qnil);
228
- v->lex_is_iterator = Qfalse;
252
+ v->lex_is_iterator = FALSE;
229
253
  parse_main(v, Qnil, Qnil, 0);
230
254
 
255
+ RB_GC_GUARD(vparams);
231
256
  return v->retval;
232
257
  }
233
258
 
234
259
  static VALUE
235
260
  racc_yyparse(VALUE parser, VALUE lexer, VALUE lexmid, VALUE arg, VALUE sysdebug)
236
261
  {
237
- volatile VALUE vparams;
262
+ VALUE vparams;
238
263
  struct cparse_params *v;
239
264
 
240
- vparams = Data_Make_Struct(CparseParams, struct cparse_params,
241
- cparse_params_mark, -1, v);
265
+ vparams = TypedData_Make_Struct(CparseParams, struct cparse_params,
266
+ &cparse_params_type, v);
242
267
  v->sys_debug = RTEST(sysdebug);
243
268
  D_puts("start C yyparse");
244
269
  vparams = initialize_params(vparams, parser, arg, lexer, lexmid);
245
- v->lex_is_iterator = Qtrue;
270
+ v->lex_is_iterator = TRUE;
246
271
  D_puts("params initialized");
247
272
  parse_main(v, Qnil, Qnil, 0);
248
273
  call_lexer(v);
@@ -251,6 +276,7 @@ racc_yyparse(VALUE parser, VALUE lexer, VALUE lexmid, VALUE arg, VALUE sysdebug)
251
276
  rb_id2name(v->lexmid));
252
277
  }
253
278
 
279
+ RB_GC_GUARD(vparams);
254
280
  return v->retval;
255
281
  }
256
282
 
@@ -264,9 +290,8 @@ call_lexer(struct cparse_params *v)
264
290
  static VALUE
265
291
  lexer_iter(VALUE data)
266
292
  {
267
- struct cparse_params *v;
293
+ struct cparse_params *v = rb_check_typeddata(data, &cparse_params_type);
268
294
 
269
- Data_Get_Struct(data, struct cparse_params, v);
270
295
  rb_funcall(v->lexer, v->lexmid, 0);
271
296
  return Qnil;
272
297
  }
@@ -279,18 +304,17 @@ call_lexer(struct cparse_params *v)
279
304
  #endif
280
305
 
281
306
  static VALUE
282
- lexer_i(VALUE block_args, VALUE data, VALUE self)
307
+ lexer_i(RB_BLOCK_CALL_FUNC_ARGLIST(block_args, data))
283
308
  {
284
- struct cparse_params *v;
309
+ struct cparse_params *v = rb_check_typeddata(data, &cparse_params_type);
285
310
  VALUE tok, val;
286
311
 
287
- Data_Get_Struct(data, struct cparse_params, v);
288
312
  if (v->fin)
289
313
  rb_raise(rb_eArgError, "extra token after EndOfToken");
290
314
  extract_user_token(v, block_args, &tok, &val);
291
315
  parse_main(v, tok, val, 1);
292
316
  if (v->fin && v->fin != CP_FIN_ACCEPT)
293
- rb_iter_break();
317
+ rb_iter_break();
294
318
  return Qnil;
295
319
  }
296
320
 
@@ -317,9 +341,8 @@ assert_integer(VALUE n)
317
341
  static VALUE
318
342
  initialize_params(VALUE vparams, VALUE parser, VALUE arg, VALUE lexer, VALUE lexmid)
319
343
  {
320
- struct cparse_params *v;
344
+ struct cparse_params *v = rb_check_typeddata(vparams, &cparse_params_type);
321
345
 
322
- Data_Get_Struct(vparams, struct cparse_params, v);
323
346
  v->value_v = vparams;
324
347
  v->parser = parser;
325
348
  v->lexer = lexer;
@@ -348,7 +371,7 @@ initialize_params(VALUE vparams, VALUE parser, VALUE arg, VALUE lexer, VALUE lex
348
371
  v->use_result_var = RTEST(rb_ary_entry(arg, 13));
349
372
  }
350
373
  else {
351
- v->use_result_var = Qtrue;
374
+ v->use_result_var = TRUE;
352
375
  }
353
376
 
354
377
  v->tstack = v->debug ? NEW_STACK() : Qnil;
@@ -364,7 +387,7 @@ initialize_params(VALUE vparams, VALUE parser, VALUE arg, VALUE lexer, VALUE lex
364
387
  v->retval = Qnil;
365
388
  v->fin = 0;
366
389
 
367
- v->lex_is_iterator = Qfalse;
390
+ v->lex_is_iterator = FALSE;
368
391
 
369
392
  rb_iv_set(parser, "@vstack", v->vstack);
370
393
  if (v->debug) {
@@ -402,6 +425,12 @@ cparse_params_mark(void *ptr)
402
425
  rb_gc_mark(v->retval);
403
426
  }
404
427
 
428
+ static size_t
429
+ cparse_params_memsize(const void *ptr)
430
+ {
431
+ return sizeof(struct cparse_params);
432
+ }
433
+
405
434
  static void
406
435
  extract_user_token(struct cparse_params *v, VALUE block_args,
407
436
  VALUE *tok, VALUE *val)
@@ -413,12 +442,12 @@ extract_user_token(struct cparse_params *v, VALUE block_args,
413
442
  return;
414
443
  }
415
444
 
416
- if (TYPE(block_args) != T_ARRAY) {
445
+ if (!RB_TYPE_P(block_args, T_ARRAY)) {
417
446
  rb_raise(rb_eTypeError,
418
- "%s() %s %s (must be Array[2])",
447
+ "%s() %s %"PRIsVALUE" (must be Array[2])",
419
448
  v->lex_is_iterator ? rb_id2name(v->lexmid) : "next_token",
420
449
  v->lex_is_iterator ? "yielded" : "returned",
421
- rb_class2name(CLASS_OF(block_args)));
450
+ rb_obj_class(block_args));
422
451
  }
423
452
  if (RARRAY_LEN(block_args) != 2) {
424
453
  rb_raise(rb_eArgError,
@@ -457,7 +486,7 @@ parse_main(struct cparse_params *v, VALUE tok, VALUE val, int resume)
457
486
 
458
487
  if (resume)
459
488
  goto resume;
460
-
489
+
461
490
  while (1) {
462
491
  D_puts("");
463
492
  D_puts("---- enter new loop ----");
@@ -516,7 +545,7 @@ parse_main(struct cparse_params *v, VALUE tok, VALUE val, int resume)
516
545
  act_fixed:
517
546
  D_printf("act=%ld\n", act);
518
547
  goto handle_act;
519
-
548
+
520
549
  notfound:
521
550
  D_puts("(act) not found: use default");
522
551
  act_value = AREF(v->action_default, v->curstate);
@@ -617,7 +646,7 @@ parse_main(struct cparse_params *v, VALUE tok, VALUE val, int resume)
617
646
 
618
647
  D_puts("(err) found: can handle error token");
619
648
  break;
620
-
649
+
621
650
  error_pop:
622
651
  D_puts("(err) act not found: can't handle error token; pop");
623
652
 
@@ -679,9 +708,9 @@ reduce(struct cparse_params *v, long act)
679
708
  }
680
709
 
681
710
  static VALUE
682
- reduce0(VALUE val, VALUE data, VALUE self)
711
+ reduce0(RB_BLOCK_CALL_FUNC_ARGLIST(_, data))
683
712
  {
684
- struct cparse_params *v;
713
+ struct cparse_params *v = rb_check_typeddata(data, &cparse_params_type);
685
714
  VALUE reduce_to, reduce_len, method_id;
686
715
  long len;
687
716
  ID mid;
@@ -689,7 +718,6 @@ reduce0(VALUE val, VALUE data, VALUE self)
689
718
  long i, k1, k2;
690
719
  VALUE goto_state;
691
720
 
692
- Data_Get_Struct(data, struct cparse_params, v);
693
721
  reduce_len = rb_ary_entry(v->reduce_table, v->ruleno);
694
722
  reduce_to = rb_ary_entry(v->reduce_table, v->ruleno+1);
695
723
  method_id = rb_ary_entry(v->reduce_table, v->ruleno+2);
@@ -791,6 +819,8 @@ reduce0(VALUE val, VALUE data, VALUE self)
791
819
  void
792
820
  Init_cparse(void)
793
821
  {
822
+ #undef rb_intern
823
+ #define rb_intern(str) rb_intern_const(str)
794
824
  VALUE Racc, Parser;
795
825
  ID id_racc = rb_intern("Racc");
796
826
 
@@ -810,6 +840,9 @@ Init_cparse(void)
810
840
  rb_str_new2("$originalId: cparse.c,v 1.8 2006/07/06 11:39:46 aamine Exp $"));
811
841
 
812
842
  CparseParams = rb_define_class_under(Racc, "CparseParams", rb_cObject);
843
+ rb_undef_alloc_func(CparseParams);
844
+ rb_undef_method(CparseParams, "initialize");
845
+ rb_undef_method(CparseParams, "initialize_copy");
813
846
 
814
847
  RaccBug = rb_eRuntimeError;
815
848