racc 1.4.9-java → 1.4.12-java

Sign up to get free protection for your applications and to get access to all the features.
data/ext/racc/cparse.c CHANGED
@@ -17,7 +17,7 @@
17
17
  Important Constants
18
18
  ----------------------------------------------------------------------- */
19
19
 
20
- #define RACC_VERSION "1.4.9"
20
+ #define RACC_VERSION "1.4.12"
21
21
 
22
22
  #define DEFAULT_TOKEN -1
23
23
  #define ERROR_TOKEN 1
@@ -65,6 +65,10 @@ static ID id_d_e_pop;
65
65
  # define LONG2NUM(i) INT2NUM(i)
66
66
  #endif
67
67
 
68
+ #ifndef HAVE_RB_ARY_SUBSEQ
69
+ # define rb_ary_subseq(ary, beg, len) rb_ary_new4(len, RARRAY_PTR(ary) + beg)
70
+ #endif
71
+
68
72
  static ID value_to_id _((VALUE v));
69
73
  static inline long num_to_long _((VALUE n));
70
74
 
@@ -84,7 +88,7 @@ num_to_long(VALUE n)
84
88
  }
85
89
 
86
90
  #define AREF(s, idx) \
87
- ((0 <= idx && idx < RARRAY_LEN(s)) ? RARRAY_PTR(s)[idx] : Qnil)
91
+ ((0 <= idx && idx < RARRAY_LEN(s)) ? rb_ary_entry(s, idx) : Qnil)
88
92
 
89
93
  /* -----------------------------------------------------------------------
90
94
  Parser Stack Interfaces
@@ -98,7 +102,7 @@ get_stack_tail(VALUE stack, long len)
98
102
  {
99
103
  if (len < 0) return Qnil; /* system error */
100
104
  if (len > RARRAY_LEN(stack)) len = RARRAY_LEN(stack);
101
- return rb_ary_new4(len, RARRAY_PTR(stack) + RARRAY_LEN(stack) - len);
105
+ return rb_ary_subseq(stack, RARRAY_LEN(stack) - len, len);
102
106
  }
103
107
 
104
108
  static void
@@ -115,7 +119,7 @@ cut_stack_tail(VALUE stack, long len)
115
119
  #define PUSH(s, i) rb_ary_store(s, RARRAY_LEN(s), i)
116
120
  #define POP(s) rb_ary_pop(s)
117
121
  #define LAST_I(s) \
118
- ((RARRAY_LEN(s) > 0) ? RARRAY_PTR(s)[RARRAY_LEN(s) - 1] : Qnil)
122
+ ((RARRAY_LEN(s) > 0) ? rb_ary_entry(s, RARRAY_LEN(s) - 1) : Qnil)
119
123
  #define GET_TAIL(s, len) get_stack_tail(s, len)
120
124
  #define CUT_TAIL(s, len) cut_stack_tail(s, len)
121
125
 
@@ -327,21 +331,21 @@ initialize_params(VALUE vparams, VALUE parser, VALUE arg, VALUE lexer, VALUE lex
327
331
  Check_Type(arg, T_ARRAY);
328
332
  if (!(13 <= RARRAY_LEN(arg) && RARRAY_LEN(arg) <= 14))
329
333
  rb_raise(RaccBug, "[Racc Bug] wrong arg.size %ld", RARRAY_LEN(arg));
330
- v->action_table = assert_array (RARRAY_PTR(arg)[ 0]);
331
- v->action_check = assert_array (RARRAY_PTR(arg)[ 1]);
332
- v->action_default = assert_array (RARRAY_PTR(arg)[ 2]);
333
- v->action_pointer = assert_array (RARRAY_PTR(arg)[ 3]);
334
- v->goto_table = assert_array (RARRAY_PTR(arg)[ 4]);
335
- v->goto_check = assert_array (RARRAY_PTR(arg)[ 5]);
336
- v->goto_default = assert_array (RARRAY_PTR(arg)[ 6]);
337
- v->goto_pointer = assert_array (RARRAY_PTR(arg)[ 7]);
338
- v->nt_base = assert_integer(RARRAY_PTR(arg)[ 8]);
339
- v->reduce_table = assert_array (RARRAY_PTR(arg)[ 9]);
340
- v->token_table = assert_hash (RARRAY_PTR(arg)[10]);
341
- v->shift_n = assert_integer(RARRAY_PTR(arg)[11]);
342
- v->reduce_n = assert_integer(RARRAY_PTR(arg)[12]);
334
+ v->action_table = assert_array (rb_ary_entry(arg, 0));
335
+ v->action_check = assert_array (rb_ary_entry(arg, 1));
336
+ v->action_default = assert_array (rb_ary_entry(arg, 2));
337
+ v->action_pointer = assert_array (rb_ary_entry(arg, 3));
338
+ v->goto_table = assert_array (rb_ary_entry(arg, 4));
339
+ v->goto_check = assert_array (rb_ary_entry(arg, 5));
340
+ v->goto_default = assert_array (rb_ary_entry(arg, 6));
341
+ v->goto_pointer = assert_array (rb_ary_entry(arg, 7));
342
+ v->nt_base = assert_integer(rb_ary_entry(arg, 8));
343
+ v->reduce_table = assert_array (rb_ary_entry(arg, 9));
344
+ v->token_table = assert_hash (rb_ary_entry(arg, 10));
345
+ v->shift_n = assert_integer(rb_ary_entry(arg, 11));
346
+ v->reduce_n = assert_integer(rb_ary_entry(arg, 12));
343
347
  if (RARRAY_LEN(arg) > 13) {
344
- v->use_result_var = RTEST(RARRAY_PTR(arg)[13]);
348
+ v->use_result_var = RTEST(rb_ary_entry(arg, 13));
345
349
  }
346
350
  else {
347
351
  v->use_result_var = Qtrue;
@@ -557,7 +561,7 @@ parse_main(struct cparse_params *v, VALUE tok, VALUE val, int resume)
557
561
 
558
562
  accept:
559
563
  if (v->debug) rb_funcall(v->parser, id_d_accept, 0);
560
- v->retval = RARRAY_PTR(v->vstack)[0];
564
+ v->retval = rb_ary_entry(v->vstack, 0);
561
565
  v->fin = CP_FIN_ACCEPT;
562
566
  return;
563
567
 
@@ -686,9 +690,9 @@ reduce0(VALUE val, VALUE data, VALUE self)
686
690
  VALUE goto_state;
687
691
 
688
692
  Data_Get_Struct(data, struct cparse_params, v);
689
- reduce_len = RARRAY_PTR(v->reduce_table)[v->ruleno];
690
- reduce_to = RARRAY_PTR(v->reduce_table)[v->ruleno+1];
691
- method_id = RARRAY_PTR(v->reduce_table)[v->ruleno+2];
693
+ reduce_len = rb_ary_entry(v->reduce_table, v->ruleno);
694
+ reduce_to = rb_ary_entry(v->reduce_table, v->ruleno+1);
695
+ method_id = rb_ary_entry(v->reduce_table, v->ruleno+2);
692
696
  len = NUM2LONG(reduce_len);
693
697
  mid = value_to_id(method_id);
694
698
 
@@ -703,10 +707,10 @@ reduce0(VALUE val, VALUE data, VALUE self)
703
707
  else {
704
708
  if (mid != id_noreduce) {
705
709
  tmp_v = GET_TAIL(v->vstack, len);
706
- tmp = RARRAY_PTR(tmp_v)[0];
710
+ tmp = rb_ary_entry(tmp_v, 0);
707
711
  }
708
712
  else {
709
- tmp = RARRAY_PTR(v->vstack)[ RARRAY_LEN(v->vstack) - len ];
713
+ tmp = rb_ary_entry(v->vstack, RARRAY_LEN(v->vstack) - len);
710
714
  }
711
715
  CUT_TAIL(v->vstack, len);
712
716
  if (v->debug) {
data/ext/racc/extconf.rb CHANGED
@@ -1,5 +1,7 @@
1
- # $Id: 7151daa60cd95ecbb70f5e5a8db13142d1fe2d7c $
1
+ # $Id: 1e30abedf4eea155815d1efa5500ec817b10a2ab $
2
2
 
3
3
  require 'mkmf'
4
4
 
5
+ have_func('rb_ary_subseq')
6
+
5
7
  create_makefile 'racc/cparse'
data/lib/racc/compat.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #
2
- # $Id: b40c10cc1a30073bf591fef553277971e3c4cd75 $
2
+ # $Id: 14fa1118eb3a23e85265e4f7afe2d5a297d69f9c $
3
3
  #
4
4
  # Copyright (c) 1999-2006 Minero Aoki
5
5
  #
@@ -21,14 +21,6 @@ unless Object.method_defined?(:__send!)
21
21
  end
22
22
  end
23
23
 
24
- unless String.method_defined?(:to_a)
25
- class String
26
- def to_a
27
- lines.to_a
28
- end
29
- end
30
- end
31
-
32
24
  unless Array.method_defined?(:map!)
33
25
  class Array
34
26
  if Array.method_defined?(:collect!)
Binary file
@@ -1,5 +1,5 @@
1
1
  #
2
- # $Id: 3f7136294dbfbc25783f216ca3168a37c671960b $
2
+ # $Id: 5e1871defa15d288d2252e6a76bb2c4cf2119ed3 $
3
3
  #
4
4
  # Copyright (c) 1999-2006 Minero Aoki
5
5
  #
@@ -258,7 +258,7 @@ module Racc
258
258
  line = @scanner.lineno
259
259
  _, *blocks = *@scanner.epilogue.split(/^----/)
260
260
  blocks.each do |block|
261
- header, *body = block.to_a
261
+ header, *body = block.lines.to_a
262
262
  label0, pathes = *header.sub(/\A-+/, '').split('=', 2)
263
263
  label = canonical_label(label0)
264
264
  (pathes ? pathes.strip.split(' ') : []).each do |path|
data/lib/racc/info.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #
2
- # $Id: 70655d6dde5488a467b21dcae9ef4fcf92b33fec $
2
+ # $Id: 90afb43b1438ad2bb681a529146d1cb5cd7e45ac $
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.9'
13
+ VERSION = '1.4.12'
14
14
  Version = VERSION
15
15
  Copyright = 'Copyright (c) 1999-2006 Minero Aoki'
16
16
  end
@@ -1,7 +1,7 @@
1
1
  module Racc
2
2
  PARSER_TEXT = <<'__end_of_file__'
3
3
  #
4
- # $Id: 891566e6b68142589f193e8e7bd3372e1e258373 $
4
+ # $Id: a7af944d201a32a63d2536cdd589d8e9910848e0 $
5
5
  #
6
6
  # Copyright (c) 1999-2006 Minero Aoki
7
7
  #
@@ -28,6 +28,158 @@ end
28
28
 
29
29
  # Racc is a LALR(1) parser generator.
30
30
  # It is written in Ruby itself, and generates Ruby programs.
31
+ #
32
+ # == Command-line Reference
33
+ #
34
+ # racc [-o<var>filename</var>] [--output-file=<var>filename</var>]
35
+ # [-e<var>rubypath</var>] [--embedded=<var>rubypath</var>]
36
+ # [-v] [--verbose]
37
+ # [-O<var>filename</var>] [--log-file=<var>filename</var>]
38
+ # [-g] [--debug]
39
+ # [-E] [--embedded]
40
+ # [-l] [--no-line-convert]
41
+ # [-c] [--line-convert-all]
42
+ # [-a] [--no-omit-actions]
43
+ # [-C] [--check-only]
44
+ # [-S] [--output-status]
45
+ # [--version] [--copyright] [--help] <var>grammarfile</var>
46
+ #
47
+ # [+filename+]
48
+ # Racc grammar file. Any extention is permitted.
49
+ # [-o+outfile+, --output-file=+outfile+]
50
+ # A filename for output. default is <+filename+>.tab.rb
51
+ # [-O+filename+, --log-file=+filename+]
52
+ # Place logging output in file +filename+.
53
+ # Default log file name is <+filename+>.output.
54
+ # [-e+rubypath+, --executable=+rubypath+]
55
+ # output executable file(mode 755). where +path+ is the Ruby interpreter.
56
+ # [-v, --verbose]
57
+ # verbose mode. create +filename+.output file, like yacc's y.output file.
58
+ # [-g, --debug]
59
+ # add debug code to parser class. To display debuggin information,
60
+ # use this '-g' option and set @yydebug true in parser class.
61
+ # [-E, --embedded]
62
+ # Output parser which doesn't need runtime files (racc/parser.rb).
63
+ # [-C, --check-only]
64
+ # Check syntax of racc grammer file and quit.
65
+ # [-S, --output-status]
66
+ # Print messages time to time while compiling.
67
+ # [-l, --no-line-convert]
68
+ # turns off line number converting.
69
+ # [-c, --line-convert-all]
70
+ # Convert line number of actions, inner, header and footer.
71
+ # [-a, --no-omit-actions]
72
+ # Call all actions, even if an action is empty.
73
+ # [--version]
74
+ # print Racc version and quit.
75
+ # [--copyright]
76
+ # Print copyright and quit.
77
+ # [--help]
78
+ # Print usage and quit.
79
+ #
80
+ # == Generating Parser Using Racc
81
+ #
82
+ # To compile Racc grammar file, simply type:
83
+ #
84
+ # $ racc parse.y
85
+ #
86
+ # This creates Ruby script file "parse.tab.y". The -o option can change the output filename.
87
+ #
88
+ # == Writing A Racc Grammar File
89
+ #
90
+ # If you want your own parser, you have to write a grammar file.
91
+ # A grammar file contains the name of your parser class, grammar for the parser,
92
+ # user code, and anything else.
93
+ # When writing a grammar file, yacc's knowledge is helpful.
94
+ # If you have not used yacc before, Racc is not too difficult.
95
+ #
96
+ # Here's an example Racc grammar file.
97
+ #
98
+ # class Calcparser
99
+ # rule
100
+ # target: exp { print val[0] }
101
+ #
102
+ # exp: exp '+' exp
103
+ # | exp '*' exp
104
+ # | '(' exp ')'
105
+ # | NUMBER
106
+ # end
107
+ #
108
+ # Racc grammar files resemble yacc files.
109
+ # But (of course), this is Ruby code.
110
+ # yacc's $$ is the 'result', $0, $1... is
111
+ # an array called 'val', and $-1, $-2... is an array called '_values'.
112
+ #
113
+ # See the {Grammar File Reference}[rdoc-ref:lib/racc/rdoc/grammar.en.rdoc] for
114
+ # more information on grammar files.
115
+ #
116
+ # == Parser
117
+ #
118
+ # Then you must prepare the parse entry method. There are two types of
119
+ # parse methods in Racc, Racc::Parser#do_parse and Racc::Parser#yyparse
120
+ #
121
+ # Racc::Parser#do_parse is simple.
122
+ #
123
+ # It's yyparse() of yacc, and Racc::Parser#next_token is yylex().
124
+ # This method must returns an array like [TOKENSYMBOL, ITS_VALUE].
125
+ # EOF is [false, false].
126
+ # (TOKENSYMBOL is a Ruby symbol (taken from String#intern) by default.
127
+ # If you want to change this, see the grammar reference.
128
+ #
129
+ # Racc::Parser#yyparse is little complicated, but useful.
130
+ # It does not use Racc::Parser#next_token, instead it gets tokens from any iterator.
131
+ #
132
+ # For example, <code>yyparse(obj, :scan)</code> causes
133
+ # calling +obj#scan+, and you can return tokens by yielding them from +obj#scan+.
134
+ #
135
+ # == Debugging
136
+ #
137
+ # When debugging, "-v" or/and the "-g" option is helpful.
138
+ #
139
+ # "-v" creates verbose log file (.output).
140
+ # "-g" creates a "Verbose Parser".
141
+ # Verbose Parser prints the internal status when parsing.
142
+ # But it's _not_ automatic.
143
+ # You must use -g option and set +@yydebug+ to +true+ in order to get output.
144
+ # -g option only creates the verbose parser.
145
+ #
146
+ # === Racc reported syntax error.
147
+ #
148
+ # Isn't there too many "end"?
149
+ # grammar of racc file is changed in v0.10.
150
+ #
151
+ # Racc does not use '%' mark, while yacc uses huge number of '%' marks..
152
+ #
153
+ # === Racc reported "XXXX conflicts".
154
+ #
155
+ # Try "racc -v xxxx.y".
156
+ # It causes producing racc's internal log file, xxxx.output.
157
+ #
158
+ # === Generated parsers does not work correctly
159
+ #
160
+ # Try "racc -g xxxx.y".
161
+ # This command let racc generate "debugging parser".
162
+ # Then set @yydebug=true in your parser.
163
+ # It produces a working log of your parser.
164
+ #
165
+ # == Re-distributing Racc runtime
166
+ #
167
+ # A parser, which is created by Racc, requires the Racc runtime module;
168
+ # racc/parser.rb.
169
+ #
170
+ # Ruby 1.8.x comes with Racc runtime module,
171
+ # you need NOT distribute Racc runtime files.
172
+ #
173
+ # If you want to include the Racc runtime module with your parser.
174
+ # This can be done by using '-E' option:
175
+ #
176
+ # $ racc -E -omyparser.rb myparser.y
177
+ #
178
+ # This command creates myparser.rb which `includes' Racc runtime.
179
+ # Only you must do is to distribute your parser file (myparser.rb).
180
+ #
181
+ # Note: parser.rb is LGPL, but your parser is not.
182
+ # Your own parser is completely yours.
31
183
  module Racc
32
184
 
33
185
  unless defined?(Racc_No_Extentions)
@@ -37,12 +189,17 @@ module Racc
37
189
  class Parser
38
190
 
39
191
  Racc_Runtime_Version = ::Racc::VERSION
40
- Racc_Runtime_Revision = '$Id: 891566e6b68142589f193e8e7bd3372e1e258373 $'
192
+ Racc_Runtime_Revision = '$Id: a7af944d201a32a63d2536cdd589d8e9910848e0 $'
41
193
 
42
194
  Racc_Runtime_Core_Version_R = ::Racc::VERSION
43
- Racc_Runtime_Core_Revision_R = '$Id: 891566e6b68142589f193e8e7bd3372e1e258373 $'.split[1]
195
+ Racc_Runtime_Core_Revision_R = '$Id: a7af944d201a32a63d2536cdd589d8e9910848e0 $'.split[1]
44
196
  begin
45
- require 'racc/cparse'
197
+ if RUBY_ENGINE == 'jruby'
198
+ require 'racc/cparse-jruby.jar'
199
+ com.headius.racc.Cparse.new.load(JRuby.runtime, false)
200
+ else
201
+ require 'racc/cparse'
202
+ end
46
203
  # Racc_Runtime_Core_Version_C = (defined in extention)
47
204
  Racc_Runtime_Core_Revision_C = Racc_Runtime_Core_Id_C.split[2]
48
205
  unless new.respond_to?(:_racc_do_parse_c, true)
@@ -58,6 +215,8 @@ module Racc
58
215
  Racc_Runtime_Core_Revision = Racc_Runtime_Core_Revision_C # :nodoc:
59
216
  Racc_Runtime_Type = 'c' # :nodoc:
60
217
  rescue LoadError
218
+ puts $!
219
+ puts $!.backtrace
61
220
  Racc_Main_Parsing_Routine = :_racc_do_parse_rb
62
221
  Racc_YY_Parse_Method = :_racc_yyparse_rb
63
222
  Racc_Runtime_Core_Version = Racc_Runtime_Core_Version_R
@@ -171,7 +330,7 @@ module Racc
171
330
  # RECEIVER#METHOD_ID is a method to get next token.
172
331
  # It must 'yield' the token, which format is [TOKEN-SYMBOL, VALUE].
173
332
  def yyparse(recv, mid)
174
- __send__(Racc_YY_Parse_Method, recv, mid, _racc_setup(), true)
333
+ __send__(Racc_YY_Parse_Method, recv, mid, _racc_setup(), false)
175
334
  end
176
335
 
177
336
  def _racc_yyparse_rb(recv, mid, arg, c_debug)
data/lib/racc/parser.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #
2
- # $Id: 891566e6b68142589f193e8e7bd3372e1e258373 $
2
+ # $Id: a7af944d201a32a63d2536cdd589d8e9910848e0 $
3
3
  #
4
4
  # Copyright (c) 1999-2006 Minero Aoki
5
5
  #
@@ -26,6 +26,158 @@ end
26
26
 
27
27
  # Racc is a LALR(1) parser generator.
28
28
  # It is written in Ruby itself, and generates Ruby programs.
29
+ #
30
+ # == Command-line Reference
31
+ #
32
+ # racc [-o<var>filename</var>] [--output-file=<var>filename</var>]
33
+ # [-e<var>rubypath</var>] [--embedded=<var>rubypath</var>]
34
+ # [-v] [--verbose]
35
+ # [-O<var>filename</var>] [--log-file=<var>filename</var>]
36
+ # [-g] [--debug]
37
+ # [-E] [--embedded]
38
+ # [-l] [--no-line-convert]
39
+ # [-c] [--line-convert-all]
40
+ # [-a] [--no-omit-actions]
41
+ # [-C] [--check-only]
42
+ # [-S] [--output-status]
43
+ # [--version] [--copyright] [--help] <var>grammarfile</var>
44
+ #
45
+ # [+filename+]
46
+ # Racc grammar file. Any extention is permitted.
47
+ # [-o+outfile+, --output-file=+outfile+]
48
+ # A filename for output. default is <+filename+>.tab.rb
49
+ # [-O+filename+, --log-file=+filename+]
50
+ # Place logging output in file +filename+.
51
+ # Default log file name is <+filename+>.output.
52
+ # [-e+rubypath+, --executable=+rubypath+]
53
+ # output executable file(mode 755). where +path+ is the Ruby interpreter.
54
+ # [-v, --verbose]
55
+ # verbose mode. create +filename+.output file, like yacc's y.output file.
56
+ # [-g, --debug]
57
+ # add debug code to parser class. To display debuggin information,
58
+ # use this '-g' option and set @yydebug true in parser class.
59
+ # [-E, --embedded]
60
+ # Output parser which doesn't need runtime files (racc/parser.rb).
61
+ # [-C, --check-only]
62
+ # Check syntax of racc grammer file and quit.
63
+ # [-S, --output-status]
64
+ # Print messages time to time while compiling.
65
+ # [-l, --no-line-convert]
66
+ # turns off line number converting.
67
+ # [-c, --line-convert-all]
68
+ # Convert line number of actions, inner, header and footer.
69
+ # [-a, --no-omit-actions]
70
+ # Call all actions, even if an action is empty.
71
+ # [--version]
72
+ # print Racc version and quit.
73
+ # [--copyright]
74
+ # Print copyright and quit.
75
+ # [--help]
76
+ # Print usage and quit.
77
+ #
78
+ # == Generating Parser Using Racc
79
+ #
80
+ # To compile Racc grammar file, simply type:
81
+ #
82
+ # $ racc parse.y
83
+ #
84
+ # This creates Ruby script file "parse.tab.y". The -o option can change the output filename.
85
+ #
86
+ # == Writing A Racc Grammar File
87
+ #
88
+ # If you want your own parser, you have to write a grammar file.
89
+ # A grammar file contains the name of your parser class, grammar for the parser,
90
+ # user code, and anything else.
91
+ # When writing a grammar file, yacc's knowledge is helpful.
92
+ # If you have not used yacc before, Racc is not too difficult.
93
+ #
94
+ # Here's an example Racc grammar file.
95
+ #
96
+ # class Calcparser
97
+ # rule
98
+ # target: exp { print val[0] }
99
+ #
100
+ # exp: exp '+' exp
101
+ # | exp '*' exp
102
+ # | '(' exp ')'
103
+ # | NUMBER
104
+ # end
105
+ #
106
+ # Racc grammar files resemble yacc files.
107
+ # But (of course), this is Ruby code.
108
+ # yacc's $$ is the 'result', $0, $1... is
109
+ # an array called 'val', and $-1, $-2... is an array called '_values'.
110
+ #
111
+ # See the {Grammar File Reference}[rdoc-ref:lib/racc/rdoc/grammar.en.rdoc] for
112
+ # more information on grammar files.
113
+ #
114
+ # == Parser
115
+ #
116
+ # Then you must prepare the parse entry method. There are two types of
117
+ # parse methods in Racc, Racc::Parser#do_parse and Racc::Parser#yyparse
118
+ #
119
+ # Racc::Parser#do_parse is simple.
120
+ #
121
+ # It's yyparse() of yacc, and Racc::Parser#next_token is yylex().
122
+ # This method must returns an array like [TOKENSYMBOL, ITS_VALUE].
123
+ # EOF is [false, false].
124
+ # (TOKENSYMBOL is a Ruby symbol (taken from String#intern) by default.
125
+ # If you want to change this, see the grammar reference.
126
+ #
127
+ # Racc::Parser#yyparse is little complicated, but useful.
128
+ # It does not use Racc::Parser#next_token, instead it gets tokens from any iterator.
129
+ #
130
+ # For example, <code>yyparse(obj, :scan)</code> causes
131
+ # calling +obj#scan+, and you can return tokens by yielding them from +obj#scan+.
132
+ #
133
+ # == Debugging
134
+ #
135
+ # When debugging, "-v" or/and the "-g" option is helpful.
136
+ #
137
+ # "-v" creates verbose log file (.output).
138
+ # "-g" creates a "Verbose Parser".
139
+ # Verbose Parser prints the internal status when parsing.
140
+ # But it's _not_ automatic.
141
+ # You must use -g option and set +@yydebug+ to +true+ in order to get output.
142
+ # -g option only creates the verbose parser.
143
+ #
144
+ # === Racc reported syntax error.
145
+ #
146
+ # Isn't there too many "end"?
147
+ # grammar of racc file is changed in v0.10.
148
+ #
149
+ # Racc does not use '%' mark, while yacc uses huge number of '%' marks..
150
+ #
151
+ # === Racc reported "XXXX conflicts".
152
+ #
153
+ # Try "racc -v xxxx.y".
154
+ # It causes producing racc's internal log file, xxxx.output.
155
+ #
156
+ # === Generated parsers does not work correctly
157
+ #
158
+ # Try "racc -g xxxx.y".
159
+ # This command let racc generate "debugging parser".
160
+ # Then set @yydebug=true in your parser.
161
+ # It produces a working log of your parser.
162
+ #
163
+ # == Re-distributing Racc runtime
164
+ #
165
+ # A parser, which is created by Racc, requires the Racc runtime module;
166
+ # racc/parser.rb.
167
+ #
168
+ # Ruby 1.8.x comes with Racc runtime module,
169
+ # you need NOT distribute Racc runtime files.
170
+ #
171
+ # If you want to include the Racc runtime module with your parser.
172
+ # This can be done by using '-E' option:
173
+ #
174
+ # $ racc -E -omyparser.rb myparser.y
175
+ #
176
+ # This command creates myparser.rb which `includes' Racc runtime.
177
+ # Only you must do is to distribute your parser file (myparser.rb).
178
+ #
179
+ # Note: parser.rb is LGPL, but your parser is not.
180
+ # Your own parser is completely yours.
29
181
  module Racc
30
182
 
31
183
  unless defined?(Racc_No_Extentions)
@@ -35,12 +187,17 @@ module Racc
35
187
  class Parser
36
188
 
37
189
  Racc_Runtime_Version = ::Racc::VERSION
38
- Racc_Runtime_Revision = '$Id: 891566e6b68142589f193e8e7bd3372e1e258373 $'
190
+ Racc_Runtime_Revision = '$Id: a7af944d201a32a63d2536cdd589d8e9910848e0 $'
39
191
 
40
192
  Racc_Runtime_Core_Version_R = ::Racc::VERSION
41
- Racc_Runtime_Core_Revision_R = '$Id: 891566e6b68142589f193e8e7bd3372e1e258373 $'.split[1]
193
+ Racc_Runtime_Core_Revision_R = '$Id: a7af944d201a32a63d2536cdd589d8e9910848e0 $'.split[1]
42
194
  begin
43
- require 'racc/cparse'
195
+ if RUBY_ENGINE == 'jruby'
196
+ require 'racc/cparse-jruby.jar'
197
+ com.headius.racc.Cparse.new.load(JRuby.runtime, false)
198
+ else
199
+ require 'racc/cparse'
200
+ end
44
201
  # Racc_Runtime_Core_Version_C = (defined in extention)
45
202
  Racc_Runtime_Core_Revision_C = Racc_Runtime_Core_Id_C.split[2]
46
203
  unless new.respond_to?(:_racc_do_parse_c, true)
@@ -56,6 +213,8 @@ module Racc
56
213
  Racc_Runtime_Core_Revision = Racc_Runtime_Core_Revision_C # :nodoc:
57
214
  Racc_Runtime_Type = 'c' # :nodoc:
58
215
  rescue LoadError
216
+ puts $!
217
+ puts $!.backtrace
59
218
  Racc_Main_Parsing_Routine = :_racc_do_parse_rb
60
219
  Racc_YY_Parse_Method = :_racc_yyparse_rb
61
220
  Racc_Runtime_Core_Version = Racc_Runtime_Core_Version_R
@@ -169,7 +328,7 @@ module Racc
169
328
  # RECEIVER#METHOD_ID is a method to get next token.
170
329
  # It must 'yield' the token, which format is [TOKEN-SYMBOL, VALUE].
171
330
  def yyparse(recv, mid)
172
- __send__(Racc_YY_Parse_Method, recv, mid, _racc_setup(), true)
331
+ __send__(Racc_YY_Parse_Method, recv, mid, _racc_setup(), false)
173
332
  end
174
333
 
175
334
  def _racc_yyparse_rb(recv, mid, arg, c_debug)