racc 1.6.0 → 1.8.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c1dc09f1fcbc04e87d099180c64c1566e34c7b1f59c734c60a3760b149bd1a99
4
- data.tar.gz: b74af200ad861ddad78ff850a15d7f1554c032c6e24e46841b40a212ee620a0f
3
+ metadata.gz: 69b370f19f8eac7c705b49dd5d6c005a52c07ea1e00198453628d3eb68ac0e74
4
+ data.tar.gz: abad1bf0e54c19b185f043a9e37517c3fcb0240103e6dfa268ee5a7a5ade62fe
5
5
  SHA512:
6
- metadata.gz: 18d137641877399ad7ca6f475405fee151af9975df5f04c894c62ed2cba11835b880da0399a69303f663f772ae2283fdd09ce4dce924463c1df8c739a3e30f29
7
- data.tar.gz: 5bec7de05bc72b35614140184f4619419b488f878206ed44d5e59405cf55045e90bd1b2eacef0501bd8195f9db035802e2f3e8d569812948cd944097a6f800f6
6
+ metadata.gz: 532d1963e4f214b026d6286e8ff357f676467e45d63dc3d4cd46bd48290f66c242f3fc177090109fe9faca73a30f79b1171f17c94e9e59c5796fb6f5448fe59d
7
+ data.tar.gz: d85b06738c817c235aae22521dd2cfda5b7b7b3ca914dc08f554a34d6ed76a665d72e89b46367ca6ae61ba275b44d563cd3bfebe997bae537098165d0e341c78
data/BSDL ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (C) 1993-2013 Yukihiro Matsumoto. All rights reserved.
2
+
3
+ Redistribution and use in source and binary forms, with or without
4
+ modification, are permitted provided that the following conditions
5
+ are met:
6
+ 1. Redistributions of source code must retain the above copyright
7
+ notice, this list of conditions and the following disclaimer.
8
+ 2. Redistributions in binary form must reproduce the above copyright
9
+ notice, this list of conditions and the following disclaimer in the
10
+ documentation and/or other materials provided with the distribution.
11
+
12
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
13
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
16
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
17
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
18
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
19
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
21
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
22
+ SUCH DAMAGE.
data/COPYING CHANGED
@@ -1,22 +1,56 @@
1
- Copyright (C) 2019 Yukihiro Matsumoto. All rights reserved.
2
-
3
- Redistribution and use in source and binary forms, with or without
4
- modification, are permitted provided that the following conditions
5
- are met:
6
- 1. Redistributions of source code must retain the above copyright
7
- notice, this list of conditions and the following disclaimer.
8
- 2. Redistributions in binary form must reproduce the above copyright
9
- notice, this list of conditions and the following disclaimer in the
10
- documentation and/or other materials provided with the distribution.
11
-
12
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
13
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15
- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
16
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
17
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
18
- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
19
- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
21
- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
22
- SUCH DAMAGE.
1
+ Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
2
+ You can redistribute it and/or modify it under either the terms of the
3
+ 2-clause BSDL (see the file BSDL), or the conditions below:
4
+
5
+ 1. You may make and give away verbatim copies of the source form of the
6
+ software without restriction, provided that you duplicate all of the
7
+ original copyright notices and associated disclaimers.
8
+
9
+ 2. You may modify your copy of the software in any way, provided that
10
+ you do at least ONE of the following:
11
+
12
+ a. place your modifications in the Public Domain or otherwise
13
+ make them Freely Available, such as by posting said
14
+ modifications to Usenet or an equivalent medium, or by allowing
15
+ the author to include your modifications in the software.
16
+
17
+ b. use the modified software only within your corporation or
18
+ organization.
19
+
20
+ c. give non-standard binaries non-standard names, with
21
+ instructions on where to get the original software distribution.
22
+
23
+ d. make other distribution arrangements with the author.
24
+
25
+ 3. You may distribute the software in object code or binary form,
26
+ provided that you do at least ONE of the following:
27
+
28
+ a. distribute the binaries and library files of the software,
29
+ together with instructions (in the manual page or equivalent)
30
+ on where to get the original distribution.
31
+
32
+ b. accompany the distribution with the machine-readable source of
33
+ the software.
34
+
35
+ c. give non-standard binaries non-standard names, with
36
+ instructions on where to get the original software distribution.
37
+
38
+ d. make other distribution arrangements with the author.
39
+
40
+ 4. You may modify and include the part of the software into any other
41
+ software (possibly commercial). But some files in the distribution
42
+ are not written by the author, so that they are not under these terms.
43
+
44
+ For the list of those files and their copying conditions, see the
45
+ file LEGAL.
46
+
47
+ 5. The scripts and library files supplied as input to or produced as
48
+ output from the software do not automatically fall under the
49
+ copyright of the software, but belong to whomever generated them,
50
+ and may be sold commercially, and may be aggregated with this
51
+ software.
52
+
53
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
54
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
55
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
56
+ PURPOSE.
data/ChangeLog CHANGED
@@ -253,7 +253,7 @@ Mon Jul 3 04:34:32 2006 Minero Aoki <aamine@loveruby.net>
253
253
 
254
254
  * lib/racc/grammar.rb: class RuleTable -> Grammar.
255
255
 
256
- * lib/racc/grammar.rb: Grammar.new does not acccept a Compiler.
256
+ * lib/racc/grammar.rb: Grammar.new does not accept a Compiler.
257
257
 
258
258
  * lib/racc/grammar.rb: refactoring.
259
259
 
@@ -285,7 +285,7 @@ Mon Jul 3 04:34:32 2006 Minero Aoki <aamine@loveruby.net>
285
285
 
286
286
  * lib/racc/state.rb: class StateTable -> States.
287
287
 
288
- * lib/racc/state.rb: States.new does not acccept a Compiler.
288
+ * lib/racc/state.rb: States.new does not accept a Compiler.
289
289
 
290
290
  * lib/racc/state.rb: refactoring.
291
291
 
@@ -418,7 +418,7 @@ Tue Jul 26 23:37:46 2005 Minero Aoki <aamine@loveruby.net>
418
418
 
419
419
  Sun Jan 2 11:48:19 2005 Minero Aoki <aamine@loveruby.net>
420
420
 
421
- * lib/racc/grammer.rb (once_writer): bug! needs argument.
421
+ * lib/racc/grammar.rb (once_writer): bug! needs argument.
422
422
 
423
423
  Mon Feb 16 16:14:16 2004 Minero Aoki <aamine@loveruby.net>
424
424
 
data/README.ja.rdoc CHANGED
@@ -1,23 +1,15 @@
1
1
  = Racc
2
2
 
3
- * http://i.loveruby.net/en/projects/racc/
3
+ * https://github.com/ruby/racc
4
4
 
5
5
  == DESCRIPTION:
6
6
 
7
7
  Racc は LALR(1) パーサジェネレータです。
8
8
  yacc の Ruby 版に相当します。
9
9
 
10
- NOTE:
11
- Ruby 1.8.0 からは Racc のランタイムが標準添付されているので、
12
- Racc で生成したパーサを安心して配布できます。また Ruby 1.6 系に
13
- 対応させたい場合は racc -E で生成してください。
14
-
15
-
16
10
  == 必要環境
17
11
 
18
- * Ruby 1.8 以降
19
- (*) C コンパイラと make
20
-
12
+ * Ruby 2.5 以降
21
13
 
22
14
  == インストール
23
15
 
@@ -25,34 +17,6 @@
25
17
 
26
18
  $ gem install racc
27
19
 
28
- setup.rb インストル:
29
-
30
- パッケージのトップディレクトリで次のように入力してください。
31
- ($ は通常ユーザ、# はルートのプロンプトです)
32
-
33
- $ ruby setup.rb config
34
- $ ruby setup.rb setup
35
- ($ su)
36
- # ruby setup.rb install
37
-
38
- これで通常のパスに Racc がインストールされます。自分の好き
39
- なディレクトリにインストールしたいときは、setup.rb config に
40
- 各種オプションをつけて実行してください。オプションのリストは
41
-
42
- $ ruby setup.rb --help
43
-
44
- で見られます。
45
-
46
-
47
- コンパイラがない場合
48
- --------------------
49
-
50
- config を以下のようにすれば、拡張モジュールなしで
51
- インストールできます。
52
-
53
- $ ruby setup.rb config --without-ext
54
-
55
-
56
20
  == テスト
57
21
 
58
22
  sample/ 以下にいくつか Racc の文法ファイルのサンプルが用意
data/README.rdoc CHANGED
@@ -1,20 +1,15 @@
1
1
  = Racc
2
2
 
3
- * http://i.loveruby.net/en/projects/racc/
3
+ * https://github.com/ruby/racc
4
4
 
5
5
  == DESCRIPTION:
6
6
 
7
- Racc is a LALR(1) parser generator.
7
+ Racc is an LALR(1) parser generator.
8
8
  It is written in Ruby itself, and generates Ruby program.
9
9
 
10
- NOTE: Ruby 1.8.x comes with Racc runtime module. You
11
- can run your parsers generated by racc 1.4.x out of the
12
- box.
13
-
14
-
15
10
  == Requirement
16
11
 
17
- * Ruby 1.8.x or later.
12
+ * Ruby 2.5 or later.
18
13
 
19
14
  == Installation
20
15
 
@@ -22,32 +17,6 @@
22
17
 
23
18
  $ gem install racc
24
19
 
25
- setup.rb install:
26
-
27
- Type this in the top directory of the extracted archive:
28
-
29
- $ ruby setup.rb config
30
- $ ruby setup.rb setup
31
- ($ su)
32
- # ruby setup.rb install
33
-
34
- You can install Racc into your favorite directory by giving
35
- options to setup.rb. e.g.
36
-
37
- $ ruby setup.rb config --prefix=/usr
38
-
39
- For details, try "ruby setup.rb --help".
40
-
41
-
42
- If you don't have C Compiler
43
- ----------------------------
44
-
45
- You can install Racc without C compilers. Type following
46
- command in config phase.
47
-
48
- $ ruby setup.rb config --without-ext
49
-
50
-
51
20
  == Testing Racc
52
21
 
53
22
  Racc comes with simple calculator. To compile this, on shell:
@@ -59,9 +28,16 @@
59
28
  $ ruby calc
60
29
 
61
30
  ... Does it work?
62
- For details of Racc, see HTML documents placed under 'rdoc/en/'
31
+ For details of Racc, see HTML documents placed under 'doc/en/'
63
32
  and sample grammar files under 'sample/'.
64
33
 
34
+ == Release flow
35
+
36
+ * Update VERSION number of these files
37
+ * <code>RACC_VERSION</code> in "ext/racc/com/headius/racc/Cparse.java"
38
+ * <code>VERSION</code> in "lib/racc/info.rb"
39
+ * Release as a gem by <code>rake release</code> with CRuby and JRuby because Racc gem provides 2 packages
40
+ * Create new release on {GitHub}[https://github.com/ruby/racc/releases]
65
41
 
66
42
  == License
67
43
 
@@ -74,7 +50,8 @@
74
50
  == Bug Reports
75
51
 
76
52
  Any kind of bug report is welcome.
77
- If you find a bug of Racc, please email me. Your grammar file,
53
+ If you find a bug of Racc, please report an issue at
54
+ https://github.com/ruby/racc/issues. Your grammar file,
78
55
  debug output generated by "racc -g", are helpful.
79
56
 
80
57
 
data/TODO CHANGED
@@ -1,5 +1,5 @@
1
1
  * check 'error' token handling.
2
2
  * interactive transition table monitor.
3
3
  * support backtracking.
4
- * output Ruby extention library?
4
+ * output Ruby extension library?
5
5
  * LL(k)? (But it should not be called Racc)
data/bin/racc CHANGED
@@ -19,6 +19,7 @@ def main
19
19
  make_executable = false
20
20
  rubypath = nil
21
21
  embed_runtime = false
22
+ frozen_strings = false
22
23
  debug_flags = Racc::DebugFlags.new
23
24
  line_convert = true
24
25
  line_convert_all = false
@@ -29,7 +30,7 @@ def main
29
30
  profiler = RaccProfiler.new(false)
30
31
 
31
32
  parser = OptionParser.new
32
- parser.banner = "Usage: #{File.basename($0)} [options] <input>"
33
+ parser.banner = "Usage: #{File.basename($0)} [options] [input]"
33
34
  parser.on('-o', '--output-file=PATH',
34
35
  'output file name [<input>.tab.rb]') {|name|
35
36
  output = name
@@ -57,6 +58,9 @@ def main
57
58
  parser.on('-E', '--embedded', "Embeds Racc runtime in output.") {
58
59
  embed_runtime = true
59
60
  }
61
+ parser.on('-F', '--frozen', "Add frozen_string_literals: true.") {
62
+ frozen_strings = true
63
+ }
60
64
  parser.on('--line-convert-all', 'Converts line numbers of user codes.') {
61
65
  line_convert_all = true
62
66
  }
@@ -88,54 +92,52 @@ def main
88
92
  #}
89
93
  parser.on('--version', 'Prints version and quit.') {
90
94
  puts "racc version #{Racc::Version}"
91
- exit 0
95
+ exit
92
96
  }
93
97
  parser.on('--runtime-version', 'Prints runtime version and quit.') {
94
- printf "racc runtime version %s; %s\n",
98
+ printf "racc runtime version %s; %s core version %s\n",
95
99
  Racc::Parser::Racc_Runtime_Version,
100
+ Racc::Parser.racc_runtime_type,
96
101
  if Racc::Parser.racc_runtime_type == 'ruby'
97
- sprintf('ruby core version %s',
98
- Racc::Parser::Racc_Runtime_Core_Version_R)
102
+ Racc::Parser::Racc_Runtime_Core_Version_R
99
103
  else
100
- sprintf('c core version %s',
101
- Racc::Parser::Racc_Runtime_Core_Version_C)
104
+ Racc::Parser::Racc_Runtime_Core_Version_C
102
105
  end
103
- exit 0
106
+ exit
104
107
  }
105
108
  parser.on('--copyright', 'Prints copyright and quit.') {
106
109
  puts Racc::Copyright
107
- exit 0
110
+ exit
108
111
  }
109
112
  parser.on('--help', 'Prints this message and quit.') {
110
113
  puts parser.help
111
- exit 1
114
+ exit
112
115
  }
113
116
  begin
114
117
  parser.parse!
115
118
  rescue OptionParser::ParseError => err
116
- $stderr.puts err.message
117
- $stderr.puts parser.help
118
- exit 1
119
- end
120
- if ARGV.empty?
121
- $stderr.puts 'no input'
122
- exit 1
119
+ abort [err.message, parser.help].join("\n")
123
120
  end
124
121
  if ARGV.size > 1
125
- $stderr.puts 'too many input'
126
- exit 1
122
+ abort 'too many input'
123
+ end
124
+
125
+ input = ARGV[0] || "stdin"
126
+
127
+ if input == "stdin" && !output then
128
+ abort 'You must specify a path to read or use -o <path> for output.'
127
129
  end
128
- input = ARGV[0]
129
130
 
130
131
  begin
131
132
  $stderr.puts 'Parsing grammar file...' if verbose
132
133
  result = profiler.section('parse') {
133
134
  parser = Racc::GrammarFileParser.new(debug_flags)
134
- parser.parse(File.read(input), File.basename(input))
135
+ content = input == "stdin" ? ARGF.read : File.read(input)
136
+ parser.parse(content, File.basename(input))
135
137
  }
136
138
  if check_only
137
139
  $stderr.puts 'syntax ok'
138
- exit 0
140
+ exit
139
141
  end
140
142
 
141
143
  $stderr.puts 'Generating LALR states...' if verbose
@@ -150,6 +152,7 @@ def main
150
152
 
151
153
  $stderr.puts 'Creating parser file...' if verbose
152
154
  params = result.params.dup
155
+ params.filename = File.basename(input)
153
156
  # Overwrites parameters given by a grammar file with command line options.
154
157
  params.superclass = superclass if superclass
155
158
  params.omit_action_call = true if omit_action_call
@@ -162,6 +165,7 @@ def main
162
165
  params.convert_line = line_convert
163
166
  params.convert_line_all = line_convert_all
164
167
  params.embed_runtime = embed_runtime
168
+ params.frozen_strings = frozen_strings
165
169
  profiler.section('generation') {
166
170
  generator = Racc::ParserFileGenerator.new(states, params)
167
171
  generator.generate_parser_file(output || make_filename(input, '.tab.rb'))
@@ -189,11 +193,13 @@ def main
189
193
  end
190
194
 
191
195
  profiler.report
196
+ if states.should_error_on_expect_mismatch?
197
+ raise Racc::CompileError, "#{states.grammar.n_expected_srconflicts} shift/reduce conflicts are expected but #{states.n_srconflicts} shift/reduce conflicts exist"
198
+ end
192
199
  rescue Racc::Error, Errno::ENOENT, Errno::EPERM => err
193
200
  raise if $DEBUG or debug_flags.any?
194
201
  lineno = err.message.slice(/\A\d+:/).to_s
195
- $stderr.puts "#{File.basename $0}: #{input}:#{lineno} #{err.message.strip}"
196
- exit 1
202
+ abort "#{File.basename $0}: #{input}:#{lineno} #{err.message.strip}"
197
203
  end
198
204
  end
199
205
 
@@ -270,19 +276,13 @@ class RaccProfiler
270
276
  def initialize(really)
271
277
  @really = really
272
278
  @log = []
273
- unless ::Process.respond_to?(:times)
274
- # Ruby 1.6
275
- @class = ::Time
276
- else
277
- @class = ::Process
278
- end
279
279
  end
280
280
 
281
281
  def section(name)
282
282
  if @really
283
- t1 = @class.times.utime
283
+ t1 = ::Process.times.utime
284
284
  result = yield
285
- t2 = @class.times.utime
285
+ t2 = ::Process.times.utime
286
286
  @log.push [name, t2 - t1]
287
287
  result
288
288
  else