racc 1.4.16 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. checksums.yaml +4 -4
  2. data/README.ja.rdoc +0 -1
  3. data/README.rdoc +8 -11
  4. data/bin/racc +37 -23
  5. data/{rdoc → doc}/en/NEWS.en.rdoc +0 -0
  6. data/{rdoc → doc}/en/grammar.en.rdoc +27 -31
  7. data/doc/en/grammar2.en.rdoc +219 -0
  8. data/{rdoc → doc}/ja/NEWS.ja.rdoc +0 -0
  9. data/{rdoc → doc}/ja/command.ja.html +1 -1
  10. data/{rdoc → doc}/ja/debug.ja.rdoc +0 -0
  11. data/{rdoc → doc}/ja/grammar.ja.rdoc +0 -0
  12. data/{rdoc → doc}/ja/index.ja.html +0 -0
  13. data/{rdoc → doc}/ja/parser.ja.rdoc +0 -0
  14. data/{rdoc → doc}/ja/usage.ja.html +0 -0
  15. data/ext/racc/cparse/cparse.c +19 -17
  16. data/ext/racc/cparse/extconf.rb +2 -1
  17. data/lib/racc/compat.rb +5 -4
  18. data/lib/racc/debugflags.rb +5 -4
  19. data/lib/racc/exception.rb +4 -1
  20. data/lib/racc/grammar.rb +22 -17
  21. data/lib/racc/grammarfileparser.rb +7 -6
  22. data/lib/racc/info.rb +5 -2
  23. data/lib/racc/iset.rb +5 -4
  24. data/lib/racc/logfilegenerator.rb +5 -4
  25. data/lib/racc/parser-text.rb +10 -16
  26. data/lib/racc/parser.rb +10 -16
  27. data/lib/racc/parserfilegenerator.rb +5 -47
  28. data/lib/racc/sourcetext.rb +5 -4
  29. data/lib/racc/state.rb +4 -1
  30. data/lib/racc/statetransitiontable.rb +9 -14
  31. metadata +22 -140
  32. data/DEPENDS +0 -4
  33. data/Manifest.txt +0 -146
  34. data/Rakefile +0 -58
  35. data/bin/racc2y +0 -195
  36. data/bin/y2racc +0 -339
  37. data/ext/racc/com/headius/racc/Cparse.java +0 -849
  38. data/fastcache/extconf.rb +0 -2
  39. data/fastcache/fastcache.c +0 -185
  40. data/lib/racc/pre-setup +0 -13
  41. data/misc/dist.sh +0 -31
  42. data/sample/array.y +0 -67
  43. data/sample/array2.y +0 -59
  44. data/sample/calc-ja.y +0 -66
  45. data/sample/calc.y +0 -65
  46. data/sample/conflict.y +0 -15
  47. data/sample/hash.y +0 -60
  48. data/sample/lalr.y +0 -17
  49. data/sample/lists.y +0 -57
  50. data/sample/syntax.y +0 -46
  51. data/sample/yyerr.y +0 -46
  52. data/setup.rb +0 -1587
  53. data/tasks/doc.rb +0 -12
  54. data/tasks/email.rb +0 -55
  55. data/test/assets/cadenza.y +0 -170
  56. data/test/assets/cast.y +0 -926
  57. data/test/assets/chk.y +0 -126
  58. data/test/assets/conf.y +0 -16
  59. data/test/assets/csspool.y +0 -729
  60. data/test/assets/digraph.y +0 -29
  61. data/test/assets/echk.y +0 -118
  62. data/test/assets/edtf.y +0 -583
  63. data/test/assets/err.y +0 -60
  64. data/test/assets/error_recovery.y +0 -35
  65. data/test/assets/expect.y +0 -7
  66. data/test/assets/firstline.y +0 -4
  67. data/test/assets/huia.y +0 -318
  68. data/test/assets/ichk.y +0 -102
  69. data/test/assets/intp.y +0 -546
  70. data/test/assets/journey.y +0 -47
  71. data/test/assets/liquor.y +0 -313
  72. data/test/assets/machete.y +0 -423
  73. data/test/assets/macruby.y +0 -2197
  74. data/test/assets/mailp.y +0 -437
  75. data/test/assets/mediacloth.y +0 -599
  76. data/test/assets/mof.y +0 -649
  77. data/test/assets/namae.y +0 -302
  78. data/test/assets/nasl.y +0 -626
  79. data/test/assets/newsyn.y +0 -25
  80. data/test/assets/noend.y +0 -4
  81. data/test/assets/nokogiri-css.y +0 -255
  82. data/test/assets/nonass.y +0 -41
  83. data/test/assets/normal.y +0 -27
  84. data/test/assets/norule.y +0 -4
  85. data/test/assets/nullbug1.y +0 -25
  86. data/test/assets/nullbug2.y +0 -15
  87. data/test/assets/opal.y +0 -1807
  88. data/test/assets/opt.y +0 -123
  89. data/test/assets/percent.y +0 -35
  90. data/test/assets/php_serialization.y +0 -98
  91. data/test/assets/recv.y +0 -97
  92. data/test/assets/riml.y +0 -665
  93. data/test/assets/rrconf.y +0 -14
  94. data/test/assets/ruby18.y +0 -1943
  95. data/test/assets/ruby19.y +0 -2174
  96. data/test/assets/ruby20.y +0 -2350
  97. data/test/assets/ruby21.y +0 -2359
  98. data/test/assets/ruby22.y +0 -2381
  99. data/test/assets/scan.y +0 -72
  100. data/test/assets/syntax.y +0 -50
  101. data/test/assets/tp_plus.y +0 -622
  102. data/test/assets/twowaysql.y +0 -278
  103. data/test/assets/unterm.y +0 -5
  104. data/test/assets/useless.y +0 -12
  105. data/test/assets/yyerr.y +0 -46
  106. data/test/bench.y +0 -36
  107. data/test/helper.rb +0 -115
  108. data/test/infini.y +0 -8
  109. data/test/regress/cadenza +0 -796
  110. data/test/regress/cast +0 -3425
  111. data/test/regress/csspool +0 -2318
  112. data/test/regress/edtf +0 -1794
  113. data/test/regress/huia +0 -1392
  114. data/test/regress/journey +0 -222
  115. data/test/regress/liquor +0 -885
  116. data/test/regress/machete +0 -833
  117. data/test/regress/mediacloth +0 -1463
  118. data/test/regress/mof +0 -1368
  119. data/test/regress/namae +0 -634
  120. data/test/regress/nasl +0 -2058
  121. data/test/regress/nokogiri-css +0 -836
  122. data/test/regress/opal +0 -6429
  123. data/test/regress/php_serialization +0 -336
  124. data/test/regress/riml +0 -3297
  125. data/test/regress/ruby18 +0 -6351
  126. data/test/regress/ruby22 +0 -7456
  127. data/test/regress/tp_plus +0 -1933
  128. data/test/regress/twowaysql +0 -556
  129. data/test/scandata/brace +0 -7
  130. data/test/scandata/gvar +0 -1
  131. data/test/scandata/normal +0 -4
  132. data/test/scandata/percent +0 -18
  133. data/test/scandata/slash +0 -10
  134. data/test/src.intp +0 -34
  135. data/test/start.y +0 -20
  136. data/test/test_chk_y.rb +0 -52
  137. data/test/test_grammar_file_parser.rb +0 -15
  138. data/test/test_racc_command.rb +0 -322
  139. data/test/test_scan_y.rb +0 -52
  140. data/test/testscanner.rb +0 -51
  141. data/web/racc.en.rhtml +0 -42
  142. data/web/racc.ja.rhtml +0 -51
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1a97d16998fb78f5a452333cbfd1ea30bda9b21bc28518ae866237f94d0c74d9
4
- data.tar.gz: '031906844664c762e36e62a30b3ca3e0187055a0e809c7746c599abb3a62e29c'
3
+ metadata.gz: c1dc09f1fcbc04e87d099180c64c1566e34c7b1f59c734c60a3760b149bd1a99
4
+ data.tar.gz: b74af200ad861ddad78ff850a15d7f1554c032c6e24e46841b40a212ee620a0f
5
5
  SHA512:
6
- metadata.gz: 178509fe90fa510f9249bfcc87ff99ae08006898213e9cbc6a49d33ba1760a42fef78e6163a6d9a3b01beb5cb36eef186b0b5ff0f761ed26487535bdc5d2bc9c
7
- data.tar.gz: 32f021789662eebc5c11ba74ec99cc04ba7f242427cfa87a28bea5e9070bbc0b76b2beb49c5324a38e9c703aa9803d4db40746c0dc04bb627f666c02e7b3569e
6
+ metadata.gz: 18d137641877399ad7ca6f475405fee151af9975df5f04c894c62ed2cba11835b880da0399a69303f663f772ae2283fdd09ce4dce924463c1df8c739a3e30f29
7
+ data.tar.gz: 5bec7de05bc72b35614140184f4619419b488f878206ed44d5e59405cf55045e90bd1b2eacef0501bd8195f9db035802e2f3e8d569812948cd944097a6f800f6
data/README.ja.rdoc CHANGED
@@ -1,7 +1,6 @@
1
1
  = Racc
2
2
 
3
3
  * http://i.loveruby.net/en/projects/racc/
4
- * http://racc.rubyforge.org/
5
4
 
6
5
  == DESCRIPTION:
7
6
 
data/README.rdoc CHANGED
@@ -1,7 +1,6 @@
1
1
  = Racc
2
2
 
3
3
  * http://i.loveruby.net/en/projects/racc/
4
- * http://racc.rubyforge.org/
5
4
 
6
5
  == DESCRIPTION:
7
6
 
@@ -16,8 +15,6 @@
16
15
  == Requirement
17
16
 
18
17
  * Ruby 1.8.x or later.
19
- (*) make and C compiler.
20
-
21
18
 
22
19
  == Installation
23
20
 
@@ -36,9 +33,9 @@
36
33
 
37
34
  You can install Racc into your favorite directory by giving
38
35
  options to setup.rb. e.g.
39
-
36
+
40
37
  $ ruby setup.rb config --prefix=/usr
41
-
38
+
42
39
  For details, try "ruby setup.rb --help".
43
40
 
44
41
 
@@ -61,9 +58,9 @@
61
58
 
62
59
  $ ruby calc
63
60
 
64
- ... Does it works?
65
- For details of Racc, see HTML documents placed under 'doc.en/'
66
- and sample grammer files under 'sample/'.
61
+ ... Does it work?
62
+ For details of Racc, see HTML documents placed under 'rdoc/en/'
63
+ and sample grammar files under 'sample/'.
67
64
 
68
65
 
69
66
  == License
@@ -76,9 +73,9 @@
76
73
 
77
74
  == Bug Reports
78
75
 
79
- Any kind of bug reports are welcome.
80
- If you find a bug of Racc, please email me. Your grammer file,
81
- debug output genereted by "racc -g", are helpful.
76
+ Any kind of bug report is welcome.
77
+ If you find a bug of Racc, please email me. Your grammar file,
78
+ debug output generated by "racc -g", are helpful.
82
79
 
83
80
 
84
81
  Minero Aoki
data/bin/racc CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  #
3
- # $Id$
3
+ #
4
4
  #
5
5
  # Copyright (c) 1999-2006 Minero Aoki
6
6
  #
@@ -51,7 +51,7 @@ def main
51
51
  logfilename = path
52
52
  }
53
53
  parser.on('-e', '--executable [RUBYPATH]', 'Makes executable parser.') {|path|
54
- executable = true
54
+ make_executable = true
55
55
  rubypath = (path == 'ruby' ? nil : path)
56
56
  }
57
57
  parser.on('-E', '--embedded', "Embeds Racc runtime in output.") {
@@ -71,10 +71,6 @@ def main
71
71
  'Uses CLASSNAME instead of Racc::Parser.') {|name|
72
72
  superclass = name
73
73
  }
74
- parser.on('--runtime=FEATURE',
75
- "Uses FEATURE instead of 'racc/parser'") {|feat|
76
- runtime = feature
77
- }
78
74
  parser.on('-C', '--check-only', 'Checks syntax and quit immediately.') {|fl|
79
75
  check_only = fl
80
76
  }
@@ -88,24 +84,21 @@ def main
88
84
  debug_flags = Racc::DebugFlags.parse_option_string(flags)
89
85
  }
90
86
  #parser.on('--no-extensions', 'Run Racc without any Ruby extension.') {
91
- # Racc.const_set :Racc_No_Extentions, true
87
+ # Racc.const_set :Racc_No_Extensions, true
92
88
  #}
93
89
  parser.on('--version', 'Prints version and quit.') {
94
90
  puts "racc version #{Racc::Version}"
95
91
  exit 0
96
92
  }
97
93
  parser.on('--runtime-version', 'Prints runtime version and quit.') {
98
- printf "racc runtime version %s (rev. %s); %s\n",
94
+ printf "racc runtime version %s; %s\n",
99
95
  Racc::Parser::Racc_Runtime_Version,
100
- Racc::Parser::Racc_Runtime_Revision,
101
96
  if Racc::Parser.racc_runtime_type == 'ruby'
102
- sprintf('ruby core version %s (rev. %s)',
103
- Racc::Parser::Racc_Runtime_Core_Version_R,
104
- Racc::Parser::Racc_Runtime_Core_Revision_R)
97
+ sprintf('ruby core version %s',
98
+ Racc::Parser::Racc_Runtime_Core_Version_R)
105
99
  else
106
- sprintf('c core version %s (rev. %s)',
107
- Racc::Parser::Racc_Runtime_Core_Version_C,
108
- Racc::Parser::Racc_Runtime_Core_Revision_C)
100
+ sprintf('c core version %s',
101
+ Racc::Parser::Racc_Runtime_Core_Version_C)
109
102
  end
110
103
  exit 0
111
104
  }
@@ -187,8 +180,12 @@ def main
187
180
  log_useless states.grammar
188
181
  log_conflict states
189
182
  else
190
- report_useless states.grammar
191
- report_conflict states
183
+ has_useless = report_useless states.grammar
184
+ has_conflicts = report_conflict states
185
+ if has_useless || has_conflicts
186
+ preamble = make_logfile ? 'C' : 'Turn on logging with "-v" and c'
187
+ $stderr.puts %Q{#{preamble}heck ".output" file for details}
188
+ end
192
189
  end
193
190
 
194
191
  profiler.report
@@ -204,13 +201,29 @@ def make_filename(path, suffix)
204
201
  path.sub(/(?:\..*?)?\z/, suffix)
205
202
  end
206
203
 
204
+ LIST_LIMIT = 10
205
+ def report_list(enum, label)
206
+ c = enum.count
207
+ if c > 0
208
+ $stderr.puts "#{c} #{label}:"
209
+ enum.first(LIST_LIMIT).each do |item|
210
+ $stderr.puts " #{yield item}"
211
+ end
212
+ $stderr.puts " ..." if c > LIST_LIMIT
213
+ end
214
+ end
215
+
216
+ # @return [Boolean] if anything was reported
207
217
  def report_conflict(states)
208
218
  if states.should_report_srconflict?
219
+ reported = true
209
220
  $stderr.puts "#{states.n_srconflicts} shift/reduce conflicts"
210
221
  end
211
222
  if states.rrconflict_exist?
223
+ reported = true
212
224
  $stderr.puts "#{states.n_rrconflicts} reduce/reduce conflicts"
213
225
  end
226
+ reported
214
227
  end
215
228
 
216
229
  def log_conflict(states)
@@ -225,16 +238,17 @@ def log_conflict(states)
225
238
  }
226
239
  end
227
240
 
241
+ # @return [Boolean] if anything was reported
228
242
  def report_useless(grammar)
229
- if grammar.useless_nonterminal_exist?
230
- $stderr.puts "#{grammar.n_useless_nonterminals} useless nonterminals"
231
- end
232
- if grammar.useless_rule_exist?
233
- $stderr.puts "#{grammar.n_useless_rules} useless rules"
234
- end
243
+ reported = report_list(grammar.each_useless_nonterminal, 'useless nonterminals', &:to_s)
244
+
245
+ reported ||= report_list(grammar.each_useless_rule, 'useless rules') { |r| "##{r.ident} (#{r.target})" }
246
+
235
247
  if grammar.start.useless?
236
248
  $stderr.puts 'fatal: start symbol does not derive any sentence'
249
+ reported = true
237
250
  end
251
+ reported
238
252
  end
239
253
 
240
254
  def log_useless(grammar)
File without changes
@@ -4,25 +4,24 @@
4
4
 
5
5
  == Class Block and User Code Block
6
6
 
7
- There's two block on toplevel.
8
- one is 'class' block, another is 'user code' block. 'user code' block MUST
9
- places after 'class' block.
7
+ There are two top-level blocks: the 'class' block, and the 'user code'
8
+ block. The 'user code' block MUST be after the 'class' block.
10
9
 
11
10
  == Comment
12
11
 
13
- You can insert comment about all places. Two style comment can be used,
14
- Ruby style (#.....) and C style (/*......*/) .
12
+ Comments can be added about everywhere. Two comment styles are
13
+ supported: Ruby style (`# ...`) and C style (`/* ... */`).
15
14
 
16
15
  == Class Block
17
16
 
18
17
  The class block is formed like this:
19
18
  --
20
19
  class CLASS_NAME
21
- [precedance table]
22
- [token declearations]
20
+ [precedence table]
21
+ [token declarations]
23
22
  [expected number of S/R conflict]
24
23
  [options]
25
- [semantic value convertion]
24
+ [semantic value conversion]
26
25
  [start rule]
27
26
  rule
28
27
  GRAMMARS
@@ -43,7 +42,7 @@ end
43
42
 
44
43
  == Grammar Block
45
44
 
46
- The grammar block discripts grammar which is able
45
+ The grammar block describes the grammar
47
46
  to be understood by parser. Syntax is:
48
47
  --
49
48
  (token): (token) (token) (token).... (action)
@@ -69,7 +68,7 @@ It is value of result, or returned value by "return" statement.
69
68
  Here is an example of whole grammar block.
70
69
  --
71
70
  rule
72
- goal: definition ruls source { result = val }
71
+ goal: definition rules source { result = val }
73
72
 
74
73
  definition: /* none */ { result = [] }
75
74
  | definition startdesig { result[0] = val[1] }
@@ -96,7 +95,7 @@ An array of value of right-hand side (rhs).
96
95
  A stack of values.
97
96
  DO NOT MODIFY this stack unless you know what you are doing.
98
97
 
99
- == Operator Precedance
98
+ == Operator Precedence
100
99
 
101
100
  This function is equal to '%prec' in yacc.
102
101
  To designate this block:
@@ -128,25 +127,24 @@ rule
128
127
 
129
128
  == expect
130
129
 
131
- Racc has bison's "expect" directive.
130
+ Racc supports Bison's "expect" directive to declare the expected
131
+ number of shift/reduce conflicts.
132
132
  --
133
- # Example
134
-
135
133
  class MyParser
136
134
  rule
137
135
  expect 3
138
136
  :
139
137
  :
140
138
  --
141
- This directive declears "expected" number of shift/reduce conflict.
142
- If "expected" number is equal to real number of conflicts,
143
- racc does not print confliction warning message.
139
+ Then warnings are issued only when the effective number of conflicts differs.
140
+
144
141
 
145
142
  == Declaring Tokens
146
143
 
147
- By declaring tokens, you can avoid many meanless bugs.
148
- If decleared token does not exist/existing token does not decleared,
149
- Racc output warnings. Declearation syntax is:
144
+ Declaring tokens avoids many bugs.
145
+
146
+ Racc outputs warnings for declared tokens that do not exist, or existing tokens not declared.
147
+ The syntax is:
150
148
  --
151
149
  token TOKEN_NAME AND_IS_THIS
152
150
  ALSO_THIS_IS AGAIN_AND_AGAIN THIS_IS_LAST
@@ -174,12 +172,12 @@ You can use 'no_' prefix to invert its meanings.
174
172
 
175
173
  Token symbols are, as default,
176
174
 
177
- * naked token string in racc file (TOK, XFILE, this_is_token, ...)
175
+ * naked token strings in racc file (TOK, XFILE, this_is_token, ...)
178
176
  --> symbol (:TOK, :XFILE, :this_is_token, ...)
179
- * quoted string (':', '.', '(', ...)
177
+ * quoted strings (':', '.', '(', ...)
180
178
  --> same string (':', '.', '(', ...)
181
179
 
182
- You can change this default by "convert" block.
180
+ You can change this default using a "convert" block.
183
181
  Here is an example:
184
182
  --
185
183
  convert
@@ -202,18 +200,19 @@ end
202
200
 
203
201
  == Start Rule
204
202
 
205
- '%start' in yacc. This changes start rule.
203
+ '%start' in yacc. This changes the start symbol.
206
204
  --
207
205
  start real_target
208
206
  --
209
- This statement will not be used forever, I think.
207
+
210
208
 
211
209
  == User Code Block
212
210
 
213
- "User Code Block" is a Ruby source code which is copied to output.
214
- There are three user code block, "header" "inner" and "footer".
211
+ A "User Code Block" is a piece of Ruby source code copied in the output.
212
+ There are three user code blocks, "header" "inner" and "footer".
215
213
 
216
- Format of user code is like this:
214
+ User code blocks are introduced by four '-' at the beginning of a line,
215
+ followed by a single-word name:
217
216
  --
218
217
  ---- header
219
218
  ruby statement
@@ -225,6 +224,3 @@ Format of user code is like this:
225
224
  :
226
225
  :
227
226
  --
228
- If four '-' exist on line head,
229
- racc treat it as beginning of user code block.
230
- A name of user code must be one word.
@@ -0,0 +1,219 @@
1
+ = Racc Grammar File Reference
2
+
3
+ == Global Structure
4
+
5
+ == Class Block and User Code Block
6
+
7
+ There are two blocks on the toplevel. One is the 'class' block, the other is the 'user code'
8
+ block. The 'user code' block MUST be placed after the 'class' block.
9
+
10
+ == Comments
11
+
12
+ You can insert comments about all places. Two styles of comments can be used, Ruby style '#.....' and C style '/\*......*\/'.
13
+
14
+ == Class Block
15
+
16
+ The class block is formed like this:
17
+
18
+ class CLASS_NAME
19
+ [precedence table]
20
+ [token declarations]
21
+ [expected number of S/R conflicts]
22
+ [options]
23
+ [semantic value conversion]
24
+ [start rule]
25
+ rule
26
+ GRAMMARS
27
+
28
+ CLASS_NAME is a name of the parser class. This is the name of the generating parser
29
+ class.
30
+
31
+ If CLASS_NAME includes '::', Racc outputs the module clause. For example, writing
32
+ "class M::C" causes the code below to be created:
33
+
34
+ module M
35
+ class C
36
+ :
37
+ :
38
+ end
39
+ end
40
+
41
+ == Grammar Block
42
+
43
+ The grammar block describes grammar which is able to be understood by the parser.
44
+ Syntax is:
45
+
46
+ (token): (token) (token) (token).... (action)
47
+
48
+ (token): (token) (token) (token).... (action)
49
+ | (token) (token) (token).... (action)
50
+ | (token) (token) (token).... (action)
51
+
52
+ (action) is an action which is executed when its (token)s are found.
53
+ (action) is a ruby code block, which is surrounded by braces:
54
+
55
+ { print val[0]
56
+ puts val[1] }
57
+
58
+ Note that you cannot use '%' string, here document, '%r' regexp in action.
59
+
60
+ Actions can be omitted. When it is omitted, '' (empty string) is used.
61
+
62
+ A return value of action is a value of the left side value ($$). It is the value of the
63
+ result, or the returned value by `return` statement.
64
+
65
+ Here is an example of the whole grammar block.
66
+
67
+ rule
68
+ goal: definition rules source { result = val }
69
+
70
+ definition: /* none */ { result = [] }
71
+ | definition startdesig { result[0] = val[1] }
72
+ | definition
73
+ precrule # this line continues from upper line
74
+ {
75
+ result[1] = val[1]
76
+ }
77
+
78
+ startdesig: START TOKEN
79
+
80
+ You can use the following special local variables in action:
81
+
82
+ * result ($$)
83
+
84
+ The value of the left-hand side (lhs). A default value is val[0].
85
+
86
+ * val ($1,$2,$3...)
87
+
88
+ An array of value of the right-hand side (rhs).
89
+
90
+ * _values (...$-2,$-1,$0)
91
+
92
+ A stack of values. DO NOT MODIFY this stack unless you know what you are doing.
93
+
94
+ == Operator Precedence
95
+
96
+ This function is equal to '%prec' in yacc.
97
+ To designate this block:
98
+
99
+ prechigh
100
+ nonassoc '++'
101
+ left '*' '/'
102
+ left '+' '-'
103
+ right '='
104
+ preclow
105
+
106
+ `right` is yacc's %right, `left` is yacc's %left.
107
+
108
+ `=` + (symbol) means yacc's %prec:
109
+
110
+ prechigh
111
+ nonassoc UMINUS
112
+ left '*' '/'
113
+ left '+' '-'
114
+ preclow
115
+
116
+ rule
117
+ exp: exp '*' exp
118
+ | exp '-' exp
119
+ | '-' exp =UMINUS # equals to "%prec UMINUS"
120
+ :
121
+ :
122
+
123
+ == expect
124
+
125
+ Racc has bison's "expect" directive.
126
+
127
+ # Example
128
+
129
+ class MyParser
130
+ rule
131
+ expect 3
132
+ :
133
+ :
134
+
135
+ This directive declares "expected" number of shift/reduce conflicts. If
136
+ "expected" number is equal to real number of conflicts, Racc does not print
137
+ conflict warning message.
138
+
139
+ == Declaring Tokens
140
+
141
+ By declaring tokens, you can avoid many meaningless bugs. If declared token
142
+ does not exist or existing token does not decleared, Racc output warnings.
143
+ Declaration syntax is:
144
+
145
+ token TOKEN_NAME AND_IS_THIS
146
+ ALSO_THIS_IS AGAIN_AND_AGAIN THIS_IS_LAST
147
+
148
+ == Options
149
+
150
+ You can write options for Racc command in your Racc file.
151
+
152
+ options OPTION OPTION ...
153
+
154
+ Options are:
155
+
156
+ * omit_action_call
157
+
158
+ omits empty action call or not.
159
+
160
+ * result_var
161
+
162
+ uses local variable "result" or not.
163
+
164
+ You can use 'no_' prefix to invert their meanings.
165
+
166
+ == Converting Token Symbol
167
+
168
+ Token symbols are, as default,
169
+
170
+ * naked token string in Racc file (TOK, XFILE, this_is_token, ...)
171
+ --> symbol (:TOK, :XFILE, :this_is_token, ...)
172
+ * quoted string (':', '.', '(', ...)
173
+ --> same string (':', '.', '(', ...)
174
+
175
+ You can change this default by "convert" block.
176
+ Here is an example:
177
+
178
+ convert
179
+ PLUS 'PlusClass' # We use PlusClass for symbol of `PLUS'
180
+ MIN 'MinusClass' # We use MinusClass for symbol of `MIN'
181
+ end
182
+
183
+ We can use almost all ruby value can be used by token symbol,
184
+ except 'false' and 'nil'. These cause unexpected parse error.
185
+
186
+ If you want to use String as token symbol, special care is required.
187
+ For example:
188
+
189
+ convert
190
+ class '"cls"' # in code, "cls"
191
+ PLUS '"plus\n"' # in code, "plus\n"
192
+ MIN "\"minus#{val}\"" # in code, \"minus#{val}\"
193
+ end
194
+
195
+ == Start Rule
196
+
197
+ '%start' in yacc. This changes start rule.
198
+
199
+ start real_target
200
+
201
+ == User Code Block
202
+
203
+ "User Code Block" is a Ruby source code which is copied to output. There are
204
+ three user code blocks, "header" "inner" and "footer".
205
+
206
+ Format of user code is like this:
207
+
208
+ ---- header
209
+ ruby statement
210
+ ruby statement
211
+ ruby statement
212
+
213
+ ---- inner
214
+ ruby statement
215
+ :
216
+ :
217
+
218
+ If four '-' exist on the line head, Racc treats it as the beginning of the
219
+ user code block. The name of the user code block must be one word.
File without changes
@@ -1,7 +1,7 @@
1
1
  <h1>Raccコマンドリファレンス</h1>
2
2
  <p>
3
3
  racc [-o<var>filename</var>] [--output-file=<var>filename</var>]
4
- [-e<var>rubypath</var>] [--embedded=<var>rubypath</var>]
4
+ [-e<var>rubypath</var>] [--executable=<var>rubypath</var>]
5
5
  [-v] [--verbose]
6
6
  [-O<var>filename</var>] [--log-file=<var>filename</var>]
7
7
  [-g] [--debug]
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -605,7 +605,7 @@ parse_main(struct cparse_params *v, VALUE tok, VALUE val, int resume)
605
605
  user_yyerror:
606
606
  if (v->errstatus == 3) {
607
607
  if (v->t == vFINAL_TOKEN) {
608
- v->retval = Qfalse;
608
+ v->retval = Qnil;
609
609
  v->fin = CP_FIN_EOT;
610
610
  return;
611
611
  }
@@ -819,14 +819,16 @@ reduce0(RB_BLOCK_CALL_FUNC_ARGLIST(_, data))
819
819
  void
820
820
  Init_cparse(void)
821
821
  {
822
- #undef rb_intern
823
- #define rb_intern(str) rb_intern_const(str)
822
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
823
+ rb_ext_ractor_safe(true);
824
+ #endif
825
+
824
826
  VALUE Racc, Parser;
825
- ID id_racc = rb_intern("Racc");
827
+ ID id_racc = rb_intern_const("Racc");
826
828
 
827
829
  if (rb_const_defined(rb_cObject, id_racc)) {
828
830
  Racc = rb_const_get(rb_cObject, id_racc);
829
- Parser = rb_const_get_at(Racc, rb_intern("Parser"));
831
+ Parser = rb_const_get_at(Racc, rb_intern_const("Parser"));
830
832
  }
831
833
  else {
832
834
  Racc = rb_define_module("Racc");
@@ -846,16 +848,16 @@ Init_cparse(void)
846
848
 
847
849
  RaccBug = rb_eRuntimeError;
848
850
 
849
- id_yydebug = rb_intern("@yydebug");
850
- id_nexttoken = rb_intern("next_token");
851
- id_onerror = rb_intern("on_error");
852
- id_noreduce = rb_intern("_reduce_none");
853
- id_errstatus = rb_intern("@racc_error_status");
854
-
855
- id_d_shift = rb_intern("racc_shift");
856
- id_d_reduce = rb_intern("racc_reduce");
857
- id_d_accept = rb_intern("racc_accept");
858
- id_d_read_token = rb_intern("racc_read_token");
859
- id_d_next_state = rb_intern("racc_next_state");
860
- id_d_e_pop = rb_intern("racc_e_pop");
851
+ id_yydebug = rb_intern_const("@yydebug");
852
+ id_nexttoken = rb_intern_const("next_token");
853
+ id_onerror = rb_intern_const("on_error");
854
+ id_noreduce = rb_intern_const("_reduce_none");
855
+ id_errstatus = rb_intern_const("@racc_error_status");
856
+
857
+ id_d_shift = rb_intern_const("racc_shift");
858
+ id_d_reduce = rb_intern_const("racc_reduce");
859
+ id_d_accept = rb_intern_const("racc_accept");
860
+ id_d_read_token = rb_intern_const("racc_read_token");
861
+ id_d_next_state = rb_intern_const("racc_next_state");
862
+ id_d_e_pop = rb_intern_const("racc_e_pop");
861
863
  }
@@ -1,8 +1,9 @@
1
1
  # frozen_string_literal: false
2
- # $Id: a9187b5bc40e6adf05e7b6ee5b370b39a3429ecd $
2
+ #
3
3
 
4
4
  require 'mkmf'
5
5
 
6
+ have_func('rb_block_call')
6
7
  have_func('rb_ary_subseq')
7
8
 
8
9
  create_makefile 'racc/cparse'
data/lib/racc/compat.rb CHANGED
@@ -1,13 +1,14 @@
1
+ #--
2
+ #
1
3
  #
2
- # $Id: 14fa1118eb3a23e85265e4f7afe2d5a297d69f9c $
3
4
  #
4
5
  # Copyright (c) 1999-2006 Minero Aoki
5
6
  #
6
7
  # This program is free software.
7
- # You can distribute/modify this program under the terms of
8
- # the GNU LGPL, Lesser General Public License version 2.1.
9
- # For details of the GNU LGPL, see the file "COPYING".
8
+ # You can distribute/modify this program under the same terms of ruby.
9
+ # see the file "COPYING".
10
10
  #
11
+ #++
11
12
 
12
13
  unless Object.method_defined?(:__send)
13
14
  class Object