racc 1.4.14-java → 1.4.15-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 +5 -5
  2. data/Manifest.txt +50 -0
  3. data/ext/racc/com/headius/racc/Cparse.java +66 -23
  4. data/ext/racc/cparse.c +1 -1
  5. data/ext/racc/depend +1 -1
  6. data/lib/racc/cparse-jruby.jar +0 -0
  7. data/lib/racc/info.rb +2 -2
  8. data/test/assets/bibtex.y +141 -0
  9. data/test/assets/cadenza.y +170 -0
  10. data/test/assets/cast.y +926 -0
  11. data/test/assets/csspool.y +729 -0
  12. data/test/assets/edtf.y +583 -0
  13. data/test/assets/huia.y +318 -0
  14. data/test/assets/journey.y +47 -0
  15. data/test/assets/liquor.y +313 -0
  16. data/test/assets/machete.y +423 -0
  17. data/test/assets/macruby.y +2197 -0
  18. data/test/assets/mediacloth.y +599 -0
  19. data/test/assets/mof.y +649 -0
  20. data/test/assets/namae.y +302 -0
  21. data/test/assets/nasl.y +626 -0
  22. data/test/assets/nokogiri-css.y +255 -0
  23. data/test/assets/opal.y +1807 -0
  24. data/test/assets/php_serialization.y +98 -0
  25. data/test/assets/rdblockparser.y +576 -0
  26. data/test/assets/rdinlineparser.y +561 -0
  27. data/test/assets/riml.y +665 -0
  28. data/test/assets/ruby18.y +1943 -0
  29. data/test/assets/ruby19.y +2174 -0
  30. data/test/assets/ruby20.y +2350 -0
  31. data/test/assets/ruby21.y +2359 -0
  32. data/test/assets/ruby22.y +2381 -0
  33. data/test/assets/tp_plus.y +622 -0
  34. data/test/assets/twowaysql.y +278 -0
  35. data/test/helper.rb +50 -34
  36. data/test/regress/bibtex +474 -0
  37. data/test/regress/cadenza +796 -0
  38. data/test/regress/cast +3425 -0
  39. data/test/regress/csspool +2318 -0
  40. data/test/regress/edtf +1794 -0
  41. data/test/regress/huia +1392 -0
  42. data/test/regress/journey +222 -0
  43. data/test/regress/liquor +885 -0
  44. data/test/regress/machete +833 -0
  45. data/test/regress/mediacloth +1463 -0
  46. data/test/regress/mof +1368 -0
  47. data/test/regress/namae +634 -0
  48. data/test/regress/nasl +2058 -0
  49. data/test/regress/nokogiri-css +836 -0
  50. data/test/regress/opal +6429 -0
  51. data/test/regress/php_serialization +336 -0
  52. data/test/regress/rdblockparser +1061 -0
  53. data/test/regress/rdinlineparser +1243 -0
  54. data/test/regress/riml +3297 -0
  55. data/test/regress/ruby18 +6351 -0
  56. data/test/regress/ruby22 +7456 -0
  57. data/test/regress/tp_plus +1933 -0
  58. data/test/regress/twowaysql +556 -0
  59. data/test/test_racc_command.rb +177 -0
  60. metadata +80 -25
  61. data/.gemtest +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 681c95b1332a75dbfee93167ec7bf86c0c517b1f
4
- data.tar.gz: 0dab7c12b7c6c1c8c5e2fd79a0637ce96dd1542a
2
+ SHA256:
3
+ metadata.gz: d14cd257f2c716b0fdc3bfb7fba4d61a7c533c479a1808799ae92c50e754d7e1
4
+ data.tar.gz: 057103c586a4caaa16d85a54ae1fa43899502cf55477a7e0f11b0f212f2706f8
5
5
  SHA512:
6
- metadata.gz: 7516f3e60e718065087662ee30e66c269683bc64e0f4be03b78609c60b7a21bdeecaccc39a3ec0d205e6de6e273d780abb0b2b419d0773c0e065c7c71b93e64c
7
- data.tar.gz: 830e23296524399742599fb6a93f4ad51f551167659b35c08f6727d1243dcd77a5a792d93bff88fae6b490b26afa5a5482cf7f93472a62cd64b0375f67a10a63
6
+ metadata.gz: c563570f7170d6635c9d2c823eba49c1f38a5166f4b76bd60a370398ebfa8b965da36317534681e4e12ce586eaa9adce890254788a45294fb24892987bc587d8
7
+ data.tar.gz: 1a7738695939d89c197eff4bd8ee6dc6cb04e8fea7a3ae8370b22ad1ba05da7bb6b9707105b8e3a21fe985e64de2c3d39e2ae5db9e0d6a28839830cf0b058079
@@ -56,36 +56,86 @@ sample/yyerr.y
56
56
  setup.rb
57
57
  tasks/doc.rb
58
58
  tasks/email.rb
59
+ test/assets/bibtex.y
60
+ test/assets/cadenza.y
61
+ test/assets/cast.y
59
62
  test/assets/chk.y
60
63
  test/assets/conf.y
64
+ test/assets/csspool.y
61
65
  test/assets/digraph.y
62
66
  test/assets/echk.y
67
+ test/assets/edtf.y
63
68
  test/assets/err.y
64
69
  test/assets/error_recovery.y
65
70
  test/assets/expect.y
66
71
  test/assets/firstline.y
72
+ test/assets/huia.y
67
73
  test/assets/ichk.y
68
74
  test/assets/intp.y
75
+ test/assets/journey.y
76
+ test/assets/liquor.y
77
+ test/assets/machete.y
78
+ test/assets/macruby.y
79
+ test/assets/mediacloth.y
69
80
  test/assets/mailp.y
81
+ test/assets/mof.y
82
+ test/assets/namae.y
83
+ test/assets/nasl.y
70
84
  test/assets/newsyn.y
71
85
  test/assets/noend.y
86
+ test/assets/nokogiri-css.y
72
87
  test/assets/nonass.y
73
88
  test/assets/normal.y
74
89
  test/assets/norule.y
75
90
  test/assets/nullbug1.y
76
91
  test/assets/nullbug2.y
92
+ test/assets/opal.y
77
93
  test/assets/opt.y
78
94
  test/assets/percent.y
95
+ test/assets/php_serialization.y
96
+ test/assets/rdblockparser.y
97
+ test/assets/rdinlineparser.y
79
98
  test/assets/recv.y
99
+ test/assets/riml.y
80
100
  test/assets/rrconf.y
101
+ test/assets/ruby18.y
102
+ test/assets/ruby19.y
103
+ test/assets/ruby20.y
104
+ test/assets/ruby21.y
105
+ test/assets/ruby22.y
81
106
  test/assets/scan.y
82
107
  test/assets/syntax.y
108
+ test/assets/tp_plus.y
109
+ test/assets/twowaysql.y
83
110
  test/assets/unterm.y
84
111
  test/assets/useless.y
85
112
  test/assets/yyerr.y
86
113
  test/bench.y
87
114
  test/helper.rb
88
115
  test/infini.y
116
+ test/regress/bibtex
117
+ test/regress/cadenza
118
+ test/regress/cast
119
+ test/regress/csspool
120
+ test/regress/edtf
121
+ test/regress/journey
122
+ test/regress/huia
123
+ test/regress/liquor
124
+ test/regress/machete
125
+ test/regress/mediacloth
126
+ test/regress/mof
127
+ test/regress/namae
128
+ test/regress/nasl
129
+ test/regress/nokogiri-css
130
+ test/regress/opal
131
+ test/regress/php_serialization
132
+ test/regress/rdblockparser
133
+ test/regress/rdinlineparser
134
+ test/regress/riml
135
+ test/regress/ruby18
136
+ test/regress/ruby22
137
+ test/regress/tp_plus
138
+ test/regress/twowaysql
89
139
  test/scandata/brace
90
140
  test/scandata/gvar
91
141
  test/scandata/normal
@@ -1,3 +1,17 @@
1
+ /*
2
+ Cparse.java -- Racc Runtime Core for JRuby
3
+
4
+ Copyright (c) 2016 Charles Oliver Nutter <headius@headius.com>
5
+
6
+ Ported from and distributed under the same licence as cparse.c
7
+
8
+ cparse.c -- Racc Runtime Core
9
+
10
+ Copyright (c) 1999-2006 Minero Aoki
11
+
12
+ This library is free software.
13
+ You can distribute/modify this program under the same terms of ruby.
14
+ */
1
15
  package com.headius.racc;
2
16
 
3
17
  import org.jruby.Ruby;
@@ -7,6 +21,7 @@ import org.jruby.RubyClass;
7
21
  import org.jruby.RubyContinuation;
8
22
  import org.jruby.RubyFixnum;
9
23
  import org.jruby.RubyHash;
24
+ import org.jruby.RubyKernel;
10
25
  import org.jruby.RubyModule;
11
26
  import org.jruby.RubyNumeric;
12
27
  import org.jruby.RubyObject;
@@ -24,13 +39,14 @@ import org.jruby.runtime.CallSite;
24
39
  import org.jruby.runtime.Helpers;
25
40
  import org.jruby.runtime.MethodIndex;
26
41
  import org.jruby.runtime.ObjectAllocator;
42
+ import org.jruby.runtime.Signature;
27
43
  import org.jruby.runtime.ThreadContext;
28
44
  import org.jruby.runtime.Visibility;
29
45
  import org.jruby.runtime.builtin.IRubyObject;
30
46
  import org.jruby.runtime.load.Library;
31
47
 
32
48
  public class Cparse implements Library {
33
- public static final String RACC_VERSION = "1.4.14"; // TODO: parse from Cparse.c
49
+ public static final String RACC_VERSION = "1.4.15"; // TODO: parse from Cparse.c
34
50
 
35
51
  public enum TokenType {
36
52
  DEFAULT(-1),
@@ -233,10 +249,6 @@ public class Cparse implements Library {
233
249
  shift(context, act, tok, val);
234
250
  }
235
251
 
236
- private int REDUCE(ThreadContext context, int act) {
237
- return reduce(context, act);
238
- }
239
-
240
252
  public void parse_main(ThreadContext context, IRubyObject tok, IRubyObject val, boolean resume) {
241
253
  Ruby runtime = context.runtime;
242
254
 
@@ -267,7 +279,7 @@ public class Cparse implements Library {
267
279
  i = assert_integer(tmp);
268
280
 
269
281
  D_printf("read_next=%d\n", read_next);
270
- if (read_next && (this.t != vFINAL_TOKEN)) {
282
+ if (read_next && (!this.t.equals(vFINAL_TOKEN))) {
271
283
  if (this.lex_is_iterator) {
272
284
  D_puts("resuming...");
273
285
  if (this.fin != 0) throw runtime.newArgumentError("token given after EOF");
@@ -354,7 +366,21 @@ public class Cparse implements Library {
354
366
  }
355
367
  else if (act < 0 && act > -(this.reduce_n)) {
356
368
  D_puts("reduce");
357
- REDUCE(context, act);
369
+ { // macro REDUCE
370
+ switch (reduce(context, act)) {
371
+ case 0: /* normal */
372
+ break;
373
+ case 1: /* yyerror */
374
+ branch = USER_YYERROR;
375
+ continue BRANCH;
376
+ case 2: /* yyaccept */
377
+ D_puts("u accept");
378
+ branch = ACCEPT;
379
+ continue BRANCH;
380
+ default:
381
+ break;
382
+ }
383
+ }
358
384
  }
359
385
  else if (act == -(this.reduce_n)) {
360
386
  branch = ERROR; continue BRANCH;
@@ -367,6 +393,7 @@ public class Cparse implements Library {
367
393
  throw runtime.newRaiseException(RaccBug, "[Cparse Bug] unknown act value " + act);
368
394
  }
369
395
 
396
+ // fall through
370
397
  case ERROR_RECOVERED:
371
398
 
372
399
  if (this.debug) {
@@ -389,9 +416,10 @@ public class Cparse implements Library {
389
416
  call_onerror.call(context, this.parser, this.parser, this.t, val, this.vstack);
390
417
  }
391
418
 
419
+ // fall through
392
420
  case USER_YYERROR:
393
421
  if (this.errstatus == 3) {
394
- if (this.t == vFINAL_TOKEN) {
422
+ if (this.t.equals(vFINAL_TOKEN)) {
395
423
  this.retval = runtime.getFalse();
396
424
  this.fin = CP_FIN_EOT;
397
425
  return;
@@ -464,7 +492,21 @@ public class Cparse implements Library {
464
492
  }
465
493
  else if (act < 0 && act > -(this.reduce_n)) {
466
494
  D_puts("e reduce");
467
- REDUCE(context, act);
495
+ { // macro REDUCE
496
+ switch (reduce(context, act)) {
497
+ case 0: /* normal */
498
+ break;
499
+ case 1: /* yyerror */
500
+ branch = USER_YYERROR;
501
+ continue BRANCH;
502
+ case 2: /* yyaccept */
503
+ D_puts("u accept");
504
+ branch = ACCEPT;
505
+ continue BRANCH;
506
+ default:
507
+ break;
508
+ }
509
+ }
468
510
  }
469
511
  else if (act == this.shift_n) {
470
512
  D_puts("e accept");
@@ -489,17 +531,18 @@ public class Cparse implements Library {
489
531
  }
490
532
 
491
533
  private int reduce(ThreadContext context, int act) {
492
- IRubyObject code;
493
534
  ruleno = -act * 3;
494
535
  IRubyObject tag = context.runtime.newSymbol("racc_jump");
495
- RubyContinuation rbContinuation = new RubyContinuation(context.runtime, context.runtime.newSymbol("racc_jump"));
496
- try {
497
- context.pushCatch(rbContinuation.getContinuation());
498
- code = reduce0(context);
499
- errstatus = assert_integer(parser.getInstanceVariable(ID_ERRSTATUS));
500
- } finally {
501
- context.popCatch();
502
- }
536
+ IRubyObject code = RubyKernel.rbCatch19(context, this,
537
+ tag,
538
+ CallBlock19.newCallClosure(this, getMetaClass(), Signature.NO_ARGUMENTS,
539
+ new BlockCallback() {
540
+ @Override
541
+ public IRubyObject call(ThreadContext context, IRubyObject[] args, Block block) {
542
+ return reduce0(context);
543
+ }
544
+ }, context));
545
+ errstatus = assert_integer(parser.getInstanceVariable(ID_ERRSTATUS));
503
546
  return assert_integer(code);
504
547
  }
505
548
 
@@ -527,13 +570,13 @@ public class Cparse implements Library {
527
570
  /* call action */
528
571
  if (len == 0) {
529
572
  tmp = context.nil;
530
- if (mid != sym_noreduce)
573
+ if (!mid.equals(sym_noreduce))
531
574
  tmp_v = runtime.newArray();
532
575
  if (this.debug)
533
576
  tmp_t = runtime.newArray();
534
577
  }
535
578
  else {
536
- if (mid != sym_noreduce) {
579
+ if (!mid.equals(sym_noreduce)) {
537
580
  tmp_v = GET_TAIL(context, this.vstack, len);
538
581
  tmp = ((RubyArray)tmp_v).entry(0);
539
582
  }
@@ -547,7 +590,7 @@ public class Cparse implements Library {
547
590
  }
548
591
  CUT_TAIL(context, this.state, len);
549
592
  }
550
- if (mid != sym_noreduce) {
593
+ if (!mid.equals(sym_noreduce)) {
551
594
  if (this.use_result_var) {
552
595
  tmp = Helpers.invoke(context, this.parser, mid.toString(), tmp_v, this.vstack, tmp);
553
596
  }
@@ -590,7 +633,7 @@ public class Cparse implements Library {
590
633
  D_puts("(goto) check[i] == nil");
591
634
  branch = NOTFOUND; continue BRANCH;
592
635
  }
593
- if (tmp != runtime.newFixnum(k1)) {
636
+ if (!tmp.equals(runtime.newFixnum(k1))) {
594
637
  D_puts("(goto) check[i] != table[i]");
595
638
  branch = NOTFOUND; continue BRANCH;
596
639
  }
@@ -759,7 +802,7 @@ public class Cparse implements Library {
759
802
  }
760
803
  }, context));
761
804
  } catch (LexerUnroll maybeOurs) {
762
- if (maybeOurs == lexerUnroll) {
805
+ if (maybeOurs.equals(lexerUnroll)) {
763
806
  return;
764
807
  }
765
808
  }
@@ -17,7 +17,7 @@
17
17
  Important Constants
18
18
  ----------------------------------------------------------------------- */
19
19
 
20
- #define RACC_VERSION "1.4.14"
20
+ #define RACC_VERSION "1.4.15"
21
21
 
22
22
  #define DEFAULT_TOKEN -1
23
23
  #define ERROR_TOKEN 1
@@ -1 +1 @@
1
- cparse.o: cparse.c $(hdrdir)/ruby.h $(topdir)/config.h $(hdrdir)/defines.h
1
+ cparse.o: cparse.c $(hdrdir)/ruby/ruby.h $(topdir)/config.h $(hdrdir)/ruby/defines.h
Binary file
@@ -1,5 +1,5 @@
1
1
  #
2
- # $Id: 22e498362c014749b453953e8d986243c0b8660c $
2
+ # $Id: 6c7f0a682cba7c1dce1b4e63faeca2b8c7cdf7c7 $
3
3
  #
4
4
  # Copyright (c) 1999-2006 Minero Aoki
5
5
  #
@@ -10,7 +10,7 @@
10
10
  #
11
11
 
12
12
  module Racc
13
- VERSION = '1.4.14'
13
+ VERSION = '1.4.15'
14
14
  Version = VERSION
15
15
  Copyright = 'Copyright (c) 1999-2006 Minero Aoki'
16
16
  end
@@ -0,0 +1,141 @@
1
+ #--
2
+ # BibTeX-Ruby
3
+ # Copyright (C) 2010-2011 Sylvester Keil <http://sylvester.keil.or.at>
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ #++
18
+ #
19
+ # A BibTeX grammar for the parser generator +racc+
20
+ #
21
+
22
+ # -*- racc -*-
23
+
24
+ class BibTeX::Parser
25
+
26
+ token AT COMMA COMMENT CONTENT ERROR EQ LBRACE META_CONTENT KEY
27
+ NAME NUMBER PREAMBLE RBRACE SHARP STRING STRING_LITERAL
28
+
29
+ expect 0
30
+
31
+ rule
32
+
33
+ bibliography : /* empty */ { result = BibTeX::Bibliography.new(@options) }
34
+ | objects { result = val[0] }
35
+
36
+ objects : object { result = BibTeX::Bibliography.new(@options) << val[0] }
37
+ | objects object { result << val[1] }
38
+
39
+ object : AT at_object { result = val[1] }
40
+ | META_CONTENT { result = BibTeX::MetaContent.new(val[0]) }
41
+ | ERROR { result = BibTeX::Error.new(val[0]) }
42
+
43
+ at_object : comment { result = val[0] }
44
+ | string { result = val[0] }
45
+ | preamble { result = val[0] }
46
+ | entry { result = val[0] }
47
+
48
+ comment : COMMENT LBRACE content RBRACE { result = BibTeX::Comment.new(val[2]) }
49
+
50
+ content : /* empty */ { result = '' }
51
+ | CONTENT { result = val[0] }
52
+
53
+ preamble : PREAMBLE LBRACE string_value RBRACE { result = BibTeX::Preamble.new(val[2]) }
54
+
55
+ string : STRING LBRACE string_assignment RBRACE { result = BibTeX::String.new(val[2][0],val[2][1]); }
56
+
57
+ string_assignment : NAME EQ string_value { result = [val[0].downcase.to_sym, val[2]] }
58
+
59
+ string_value : string_literal { result = [val[0]] }
60
+ | string_value SHARP string_literal { result << val[2] }
61
+
62
+ string_literal : NAME { result = val[0].downcase.to_sym }
63
+ | LBRACE content RBRACE { result = val[1] }
64
+ | STRING_LITERAL { result = val[0] }
65
+
66
+ entry : entry_head assignments RBRACE { result = val[0] << val[1] }
67
+ | entry_head assignments COMMA RBRACE { result = val[0] << val[1] }
68
+ | entry_head RBRACE { result = val[0] }
69
+
70
+ entry_head : NAME LBRACE opt_key { result = BibTeX::Entry.new(:bibtex_type => val[0].downcase.to_sym, :bibtex_key => val[2]) }
71
+
72
+ opt_key : { missing_key }
73
+ | KEY
74
+
75
+ assignments : assignment { result = val[0] }
76
+ | assignments COMMA assignment { result.merge!(val[2]) }
77
+
78
+ assignment : NAME EQ value { result = { val[0].downcase.to_sym => val[2] } }
79
+
80
+ value : string_value { result = val[0] }
81
+ | NUMBER { result = val[0] }
82
+
83
+ end
84
+
85
+ ---- header
86
+ require 'bibtex/lexer'
87
+
88
+ ---- inner
89
+
90
+ attr_reader :lexer, :options
91
+
92
+ @defaults = {
93
+ :include => [:errors],
94
+ :allow_missing_keys => false,
95
+ :debug => false
96
+ }.freeze
97
+
98
+ class << self
99
+ attr_reader :defaults
100
+ end
101
+
102
+ def initialize(options = {})
103
+ @options = Parser.defaults.merge(options)
104
+ @lexer = Lexer.new(@options)
105
+ end
106
+
107
+ def parse(input)
108
+ @yydebug = debug?
109
+
110
+ lexer.analyse(input)
111
+ do_parse
112
+ #yyparse(@lexer,:each)
113
+ end
114
+
115
+ def next_token
116
+ lexer.next_token
117
+ end
118
+
119
+ def debug?
120
+ options[:debug] || ENV['DEBUG']
121
+ end
122
+
123
+ def allow_missing_keys?
124
+ options[:allow_missing_keys]
125
+ end
126
+
127
+ def missing_key
128
+ unless allow_missing_keys?
129
+ raise ParseError, "Failed to parse BibTeX entry: cite-key missing"
130
+ end
131
+ end
132
+
133
+ def on_error(tid, val, vstack)
134
+ message =
135
+ "Failed to parse BibTeX on value #{val.inspect} (#{token_to_str(tid) || '?'}) #{ vstack.inspect}"
136
+
137
+ BibTeX.log.error message
138
+ raise ParseError, message
139
+ end
140
+
141
+ # -*- racc -*-