racc 1.6.2 → 1.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/BSDL +22 -0
- data/COPYING +56 -22
- data/ChangeLog +3 -3
- data/README.ja.rdoc +2 -38
- data/README.rdoc +8 -27
- data/TODO +1 -1
- data/bin/racc +32 -32
- data/doc/en/grammar.en.rdoc +99 -107
- data/doc/en/grammar2.en.rdoc +1 -1
- data/doc/ja/command.ja.html +5 -0
- data/doc/ja/grammar.ja.rdoc +1 -1
- data/doc/ja/parser.ja.rdoc +1 -1
- data/ext/racc/cparse/cparse.c +26 -47
- data/ext/racc/cparse/extconf.rb +3 -4
- data/lib/racc/grammar.rb +82 -9
- data/lib/racc/grammarfileparser.rb +119 -13
- data/lib/racc/info.rb +2 -1
- data/lib/racc/parser-text.rb +18 -11
- data/lib/racc/parser.rb +10 -12
- data/lib/racc/parserfilegenerator.rb +10 -5
- data/lib/racc/state.rb +7 -3
- data/lib/racc/statetransitiontable.rb +1 -1
- data/lib/racc/static.rb +5 -5
- data/lib/racc.rb +6 -6
- metadata +8 -9
- data/doc/en/NEWS.en.rdoc +0 -282
- data/doc/ja/NEWS.ja.rdoc +0 -307
- data/ext/racc/MANIFEST +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69b370f19f8eac7c705b49dd5d6c005a52c07ea1e00198453628d3eb68ac0e74
|
4
|
+
data.tar.gz: abad1bf0e54c19b185f043a9e37517c3fcb0240103e6dfa268ee5a7a5ade62fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
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
|
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
|
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/
|
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
|
-
*
|
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
|
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
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
== DESCRIPTION:
|
6
6
|
|
7
|
-
Racc is
|
7
|
+
Racc is an LALR(1) parser generator.
|
8
8
|
It is written in Ruby itself, and generates Ruby program.
|
9
9
|
|
10
10
|
== Requirement
|
@@ -17,32 +17,6 @@
|
|
17
17
|
|
18
18
|
$ gem install racc
|
19
19
|
|
20
|
-
setup.rb install:
|
21
|
-
|
22
|
-
Type this in the top directory of the extracted archive:
|
23
|
-
|
24
|
-
$ ruby setup.rb config
|
25
|
-
$ ruby setup.rb setup
|
26
|
-
($ su)
|
27
|
-
# ruby setup.rb install
|
28
|
-
|
29
|
-
You can install Racc into your favorite directory by giving
|
30
|
-
options to setup.rb. e.g.
|
31
|
-
|
32
|
-
$ ruby setup.rb config --prefix=/usr
|
33
|
-
|
34
|
-
For details, try "ruby setup.rb --help".
|
35
|
-
|
36
|
-
|
37
|
-
If you don't have C Compiler
|
38
|
-
----------------------------
|
39
|
-
|
40
|
-
You can install Racc without C compilers. Type following
|
41
|
-
command in config phase.
|
42
|
-
|
43
|
-
$ ruby setup.rb config --without-ext
|
44
|
-
|
45
|
-
|
46
20
|
== Testing Racc
|
47
21
|
|
48
22
|
Racc comes with simple calculator. To compile this, on shell:
|
@@ -57,6 +31,13 @@
|
|
57
31
|
For details of Racc, see HTML documents placed under 'doc/en/'
|
58
32
|
and sample grammar files under 'sample/'.
|
59
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]
|
60
41
|
|
61
42
|
== License
|
62
43
|
|
data/TODO
CHANGED
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]
|
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
|
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
|
-
|
98
|
-
Racc::Parser::Racc_Runtime_Core_Version_R)
|
102
|
+
Racc::Parser::Racc_Runtime_Core_Version_R
|
99
103
|
else
|
100
|
-
|
101
|
-
Racc::Parser::Racc_Runtime_Core_Version_C)
|
104
|
+
Racc::Parser::Racc_Runtime_Core_Version_C
|
102
105
|
end
|
103
|
-
exit
|
106
|
+
exit
|
104
107
|
}
|
105
108
|
parser.on('--copyright', 'Prints copyright and quit.') {
|
106
109
|
puts Racc::Copyright
|
107
|
-
exit
|
110
|
+
exit
|
108
111
|
}
|
109
112
|
parser.on('--help', 'Prints this message and quit.') {
|
110
113
|
puts parser.help
|
111
|
-
exit
|
114
|
+
exit
|
112
115
|
}
|
113
116
|
begin
|
114
117
|
parser.parse!
|
115
118
|
rescue OptionParser::ParseError => err
|
116
|
-
|
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
|
-
|
126
|
-
|
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
|
-
|
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
|
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
|
-
|
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 =
|
283
|
+
t1 = ::Process.times.utime
|
284
284
|
result = yield
|
285
|
-
t2 =
|
285
|
+
t2 = ::Process.times.utime
|
286
286
|
@log.push [name, t2 - t1]
|
287
287
|
result
|
288
288
|
else
|