quanty 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +1 -1
- data/Manifest.txt +1 -0
- data/README.en +6 -5
- data/extconf.rb +1 -1
- data/lib/quanty.rb +4 -4
- data/lib/quanty/.cvsignore +1 -0
- data/lib/quanty/fact.rb +43 -29
- data/lib/quanty/main.rb +8 -3
- data/lib/quanty/parse.rb +382 -335
- data/parse.y +8 -9
- data/quanty-en.rd +49 -43
- data/quanty-ja.rd +44 -38
- data/units.dat +24 -48
- metadata +4 -3
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
data/README.en
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Quanty class for Ruby ver 1.
|
1
|
+
Quanty class for Ruby ver 1.2 by Masahiro Tanaka 2004-02-29
|
2
2
|
|
3
3
|
= Description
|
4
4
|
|
@@ -19,11 +19,13 @@
|
|
19
19
|
make
|
20
20
|
make install
|
21
21
|
|
22
|
-
* If you want Racc binary library
|
22
|
+
* If you use Ruby 1.6 and want Racc binary library
|
23
|
+
(faster than included script but not always necessary),
|
23
24
|
Get Racc from
|
24
25
|
http://www9.xdsl.ne.jp/~aamine/en/index.html
|
25
26
|
and install it.
|
26
|
-
|
27
|
+
|
28
|
+
* Back to quanty directory.
|
27
29
|
Run `make clean', `make' and install it.
|
28
30
|
|
29
31
|
= Usage
|
@@ -35,8 +37,7 @@
|
|
35
37
|
|
36
38
|
= Tested Platform
|
37
39
|
|
38
|
-
* Ruby 1.
|
39
|
-
* Racc 1.3.7
|
40
|
+
* Ruby 1.8.1 (2003-12-25) [i686-linux]
|
40
41
|
|
41
42
|
= License
|
42
43
|
|
data/extconf.rb
CHANGED
@@ -2,7 +2,7 @@ require 'rbconfig'
|
|
2
2
|
include Config
|
3
3
|
|
4
4
|
target = 'quanty'
|
5
|
-
sitedir =
|
5
|
+
sitedir = CONFIG["sitedir"]+"/"+CONFIG["MAJOR"]+"."+CONFIG["MINOR"]
|
6
6
|
|
7
7
|
def install_lib(mfile, dest, dir, files)
|
8
8
|
mfile.printf "\t@$(MKDIR) %s/%s\n", dest, dir
|
data/lib/quanty.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
units.dump
|
data/lib/quanty/fact.rb
CHANGED
@@ -15,16 +15,16 @@ class Quanty
|
|
15
15
|
|
16
16
|
attr_reader :factor
|
17
17
|
|
18
|
-
#
|
18
|
+
# SI units: Fact.new("m",true) => {"m"=>1}
|
19
19
|
# Derivative units: Fact.new("km") => 1000*{"m"=>1}
|
20
|
-
def initialize(key=nil,
|
20
|
+
def initialize(key=nil,si=false)
|
21
21
|
self.default = 0.0
|
22
22
|
@factor = 1.0
|
23
23
|
case key
|
24
24
|
when Numeric
|
25
25
|
@factor = key
|
26
26
|
when String
|
27
|
-
if
|
27
|
+
if si
|
28
28
|
store(key, 1.0)
|
29
29
|
else
|
30
30
|
decomp(key)
|
@@ -51,9 +51,12 @@ class Quanty
|
|
51
51
|
Fact.new(self)
|
52
52
|
end
|
53
53
|
|
54
|
+
attr_writer :factor
|
55
|
+
protected :factor=
|
56
|
+
|
54
57
|
def find_prefix(a,n)
|
55
58
|
Prefix.each{ |key,factor|
|
56
|
-
if /^#{key}-?/
|
59
|
+
if /^#{key}-?/ =~ a && (unit = List[b=$']) && b.size>n
|
57
60
|
#p [a,b,factor]
|
58
61
|
return Fact.new(b).fac!(factor)
|
59
62
|
end
|
@@ -62,13 +65,13 @@ class Quanty
|
|
62
65
|
end
|
63
66
|
|
64
67
|
def decomp(a)
|
65
|
-
if /^([
|
68
|
+
if /^([A-Za-z_]+([A-Za-z_0-9-]+[A-Za-z_])?)$|^[$%'"]'?$/o =~ a
|
66
69
|
#if /^[A-Za-z_0-9$%-]+$/o =~ a
|
67
70
|
unit = List[a] || find_prefix(a,0) ||
|
68
|
-
if a.size>3 && /chs$/
|
71
|
+
if a.size>3 && /chs$/o !~ a && /(.*[a-rt-y])s$/o =~ a
|
69
72
|
b = $1
|
70
73
|
List[b] || find_prefix(b,2) ||
|
71
|
-
if a.size>4 && /(.*s|.*z|.*ch)es$/
|
74
|
+
if a.size>4 && /(.*s|.*z|.*ch)es$/o =~ a
|
72
75
|
b = $1
|
73
76
|
List[b] || find_prefix(b,2)
|
74
77
|
end
|
@@ -128,16 +131,29 @@ class Quanty
|
|
128
131
|
@factor.to_s+"*"+super
|
129
132
|
end
|
130
133
|
|
131
|
-
def
|
134
|
+
def unit
|
132
135
|
a = []
|
133
|
-
each
|
134
|
-
|
135
|
-
|
136
|
-
|
136
|
+
SI.each do |k|
|
137
|
+
v = self[k]
|
138
|
+
if v && v!=0
|
139
|
+
if v != 1
|
140
|
+
v = v.to_i if v%1 == 0
|
141
|
+
k += v.to_s
|
142
|
+
end
|
143
|
+
a.push(k)
|
137
144
|
end
|
138
|
-
|
139
|
-
|
140
|
-
|
145
|
+
end
|
146
|
+
a.join(" ")
|
147
|
+
end
|
148
|
+
|
149
|
+
def to_s
|
150
|
+
@factor.to_s+" "+unit()
|
151
|
+
end
|
152
|
+
|
153
|
+
def to_quanty
|
154
|
+
f = dup
|
155
|
+
f.factor = 1.0
|
156
|
+
Quanty(@factor, unit(), f)
|
141
157
|
end
|
142
158
|
|
143
159
|
def null?
|
@@ -170,25 +186,27 @@ class Quanty
|
|
170
186
|
end
|
171
187
|
|
172
188
|
class << self
|
173
|
-
def mkdump
|
189
|
+
def mkdump(filename)
|
174
190
|
Prefix.clear
|
175
191
|
List.clear
|
192
|
+
SI.clear
|
176
193
|
#s = open("units.succ","w")
|
177
194
|
#f = open("units.fail","w")
|
178
195
|
open("units.dat","r").readlines.each do |str|
|
179
|
-
if /^([
|
196
|
+
if /^([A-Za-z_0-9%$"'-]+)\s+([^#]+)/ =~ str #"
|
180
197
|
name,repr = $1,$2.strip
|
181
198
|
# conversion due to the different rule from GNU units:
|
182
199
|
# A / B C => A / (B C)
|
183
|
-
if /\//
|
184
|
-
pre,suf = $`,$'.strip
|
185
|
-
if /\s/
|
200
|
+
if /\// =~ repr #/
|
201
|
+
pre,suf = $`,$'.strip #`
|
202
|
+
if /\s/ =~ suf
|
186
203
|
repr = pre + ' / (' + suf + ')'
|
187
204
|
end
|
188
205
|
end
|
189
|
-
if repr=="!"
|
206
|
+
if repr=="!" # SI
|
190
207
|
List[name] = Fact.new(name,true).freeze
|
191
|
-
|
208
|
+
SI << name
|
209
|
+
elsif /-$/ =~ name
|
192
210
|
Prefix[name[0..-2]] = Prefix[repr] || (List[repr] || repr).to_f
|
193
211
|
else
|
194
212
|
#p [name,repr]
|
@@ -201,7 +219,7 @@ class Quanty
|
|
201
219
|
end
|
202
220
|
#Prefix.each{|key,val| p [key,val]}
|
203
221
|
#List.each{|key,val| p [key,val]}
|
204
|
-
Marshal.dump( [Prefix, List], open(filename,"w") )
|
222
|
+
Marshal.dump( [Prefix, List, SI], open(filename,"w") )
|
205
223
|
end
|
206
224
|
end
|
207
225
|
|
@@ -209,20 +227,16 @@ class Quanty
|
|
209
227
|
|
210
228
|
|
211
229
|
### Loading unit data ###
|
212
|
-
=begin
|
213
230
|
fn = nil
|
214
231
|
$:.each{ |dir|
|
215
232
|
fn = dir + "/quanty/units.dump"
|
216
233
|
break if FileTest.exist?( fn )
|
217
234
|
fn = nil
|
218
235
|
}
|
219
|
-
=end
|
220
|
-
fn = File.expand_path('units.dump', File.dirname(__FILE__))
|
221
|
-
fn = nil unless FileTest.exist?( fn )
|
222
236
|
if fn
|
223
|
-
Prefix, List = Marshal.load(open(fn,"r"))
|
237
|
+
Prefix, List, SI = Marshal.load(open(fn,"r"))
|
224
238
|
else
|
225
|
-
Prefix, List = {},{}
|
239
|
+
Prefix, List, SI = {},{},[]
|
226
240
|
end
|
227
241
|
|
228
242
|
end # class Quanty
|
data/lib/quanty/main.rb
CHANGED
@@ -87,7 +87,7 @@ class Quanty #< Numeric
|
|
87
87
|
def > (other); @val > adjust(other) end
|
88
88
|
|
89
89
|
def **(n)
|
90
|
-
if /^[A-Za-z_]+&/
|
90
|
+
if /^[A-Za-z_]+&/o =~ @unit
|
91
91
|
unit = @unit+'^'+n.to_s
|
92
92
|
else
|
93
93
|
unit = '('+@unit+')^'+n.to_s+''
|
@@ -102,7 +102,7 @@ class Quanty #< Numeric
|
|
102
102
|
if unit.empty?
|
103
103
|
unit = @unit
|
104
104
|
else
|
105
|
-
if /\A[A-Za-z_]/
|
105
|
+
if /\A[A-Za-z_]/o =~ unit
|
106
106
|
unit = @unit+' '+unit
|
107
107
|
else
|
108
108
|
unit = @unit+' ('+unit+')'
|
@@ -121,7 +121,7 @@ class Quanty #< Numeric
|
|
121
121
|
if unit.empty?
|
122
122
|
unit = @unit
|
123
123
|
else
|
124
|
-
if /\A[A-Za-z_-]+((\^|\*\*)?[0-9.]+)?$/
|
124
|
+
if /\A[A-Za-z_-]+((\^|\*\*)?[0-9.]+)?$/o =~ unit
|
125
125
|
unit = '/ '+unit
|
126
126
|
else
|
127
127
|
unit = '/ ('+unit+')'
|
@@ -138,6 +138,11 @@ class Quanty #< Numeric
|
|
138
138
|
[ Self.new(other), self ]
|
139
139
|
end
|
140
140
|
|
141
|
+
def to_si
|
142
|
+
@fact.to_quanty * @val
|
143
|
+
end
|
144
|
+
alias to_SI :to_si
|
145
|
+
|
141
146
|
def to_f
|
142
147
|
if @fact.null?
|
143
148
|
@val * @fact.factor
|
data/lib/quanty/parse.rb
CHANGED
@@ -1,17 +1,22 @@
|
|
1
1
|
#
|
2
2
|
# DO NOT MODIFY!!!!
|
3
|
-
# This file is automatically generated by
|
4
|
-
# from
|
3
|
+
# This file is automatically generated by racc 1.4.4
|
4
|
+
# from racc grammer file "parse.y".
|
5
|
+
#
|
6
|
+
#
|
7
|
+
# lib/quanty/parse.rb: generated by racc (runtime embedded)
|
5
8
|
#
|
6
9
|
|
7
|
-
###### racc/parser.rb
|
10
|
+
###### racc/parser.rb
|
11
|
+
|
8
12
|
unless $".index 'racc/parser.rb'
|
9
13
|
$".push 'racc/parser.rb'
|
10
|
-
|
11
|
-
|
12
|
-
# $Id$
|
14
|
+
|
15
|
+
self.class.module_eval <<'..end /usr/local/lib/ruby/site_ruby/1.8/racc/parser.rb modeval..idb0d4489999', '/usr/local/lib/ruby/site_ruby/1.8/racc/parser.rb', 1
|
13
16
|
#
|
14
|
-
#
|
17
|
+
# parser.rb
|
18
|
+
#
|
19
|
+
# Copyright (c) 1999-2003 Minero Aoki <aamine@loveruby.net>
|
15
20
|
#
|
16
21
|
# This program is free software.
|
17
22
|
# You can distribute/modify this program under the same terms of ruby.
|
@@ -20,11 +25,14 @@ self.class.module_eval(<<'...end racc/parser.rb/module_eval...', 'racc/parser.rb
|
|
20
25
|
# into a Racc output file, you may use that output file
|
21
26
|
# without restriction.
|
22
27
|
#
|
28
|
+
# $Id: parse.rb,v 1.4 2004/02/29 07:38:29 masa Exp $
|
29
|
+
#
|
23
30
|
|
24
31
|
unless defined?(NotImplementedError)
|
25
32
|
NotImplementedError = NotImplementError
|
26
33
|
end
|
27
34
|
|
35
|
+
|
28
36
|
module Racc
|
29
37
|
class ParseError < StandardError; end
|
30
38
|
end
|
@@ -32,6 +40,7 @@ unless defined?(::ParseError)
|
|
32
40
|
ParseError = Racc::ParseError
|
33
41
|
end
|
34
42
|
|
43
|
+
|
35
44
|
module Racc
|
36
45
|
|
37
46
|
unless defined?(Racc_No_Extentions)
|
@@ -40,15 +49,15 @@ module Racc
|
|
40
49
|
|
41
50
|
class Parser
|
42
51
|
|
43
|
-
Racc_Runtime_Version = '1.4.
|
44
|
-
Racc_Runtime_Revision = '$
|
52
|
+
Racc_Runtime_Version = '1.4.3'
|
53
|
+
Racc_Runtime_Revision = '$Revision: 1.4 $'.split(/\s+/)[1]
|
45
54
|
|
46
|
-
Racc_Runtime_Core_Version_R = '1.4.
|
47
|
-
Racc_Runtime_Core_Revision_R = '$
|
55
|
+
Racc_Runtime_Core_Version_R = '1.4.3'
|
56
|
+
Racc_Runtime_Core_Revision_R = '$Revision: 1.4 $'.split(/\s+/)[1]
|
48
57
|
begin
|
49
58
|
require 'racc/cparse'
|
50
59
|
# Racc_Runtime_Core_Version_C = (defined in extention)
|
51
|
-
Racc_Runtime_Core_Revision_C = Racc_Runtime_Core_Id_C.split[2]
|
60
|
+
Racc_Runtime_Core_Revision_C = Racc_Runtime_Core_Id_C.split(/\s+/)[2]
|
52
61
|
unless new.respond_to?(:_racc_do_parse_c, true)
|
53
62
|
raise LoadError, 'old cparse.so'
|
54
63
|
end
|
@@ -77,9 +86,9 @@ module Racc
|
|
77
86
|
|
78
87
|
def _racc_setup
|
79
88
|
@yydebug = false unless self.class::Racc_debug_parser
|
80
|
-
@yydebug = false unless defined?
|
89
|
+
@yydebug = false unless defined? @yydebug
|
81
90
|
if @yydebug
|
82
|
-
@racc_debug_out = $stderr unless defined?
|
91
|
+
@racc_debug_out = $stderr unless defined? @racc_debug_out
|
83
92
|
@racc_debug_out ||= $stderr
|
84
93
|
end
|
85
94
|
arg = self.class::Racc_arg
|
@@ -101,19 +110,20 @@ module Racc
|
|
101
110
|
@racc_error_status = 0
|
102
111
|
end
|
103
112
|
|
113
|
+
|
104
114
|
###
|
105
115
|
### do_parse
|
106
116
|
###
|
107
117
|
|
108
118
|
def do_parse
|
109
|
-
__send__
|
119
|
+
__send__ Racc_Main_Parsing_Routine, _racc_setup(), false
|
110
120
|
end
|
111
121
|
|
112
122
|
def next_token
|
113
123
|
raise NotImplementedError, "#{self.class}\#next_token is not defined"
|
114
124
|
end
|
115
125
|
|
116
|
-
def _racc_do_parse_rb(arg, in_debug)
|
126
|
+
def _racc_do_parse_rb( arg, in_debug )
|
117
127
|
action_table, action_check, action_default, action_pointer,
|
118
128
|
goto_table, goto_check, goto_default, goto_pointer,
|
119
129
|
nt_base, reduce_table, token_table, shift_n,
|
@@ -124,33 +134,34 @@ module Racc
|
|
124
134
|
nerr = 0
|
125
135
|
|
126
136
|
catch(:racc_end_parse) {
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
137
|
+
while true
|
138
|
+
if i = action_pointer[@racc_state[-1]]
|
139
|
+
if @racc_read_next
|
140
|
+
if @racc_t != 0 # not EOF
|
141
|
+
tok, @racc_val = next_token()
|
142
|
+
unless tok # EOF
|
143
|
+
@racc_t = 0
|
144
|
+
else
|
145
|
+
@racc_t = (token_table[tok] or 1) # error token
|
146
|
+
end
|
147
|
+
racc_read_token(@racc_t, tok, @racc_val) if @yydebug
|
148
|
+
@racc_read_next = false
|
136
149
|
end
|
137
|
-
racc_read_token(@racc_t, tok, @racc_val) if @yydebug
|
138
|
-
@racc_read_next = false
|
139
150
|
end
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
151
|
+
i += @racc_t
|
152
|
+
if i >= 0 and
|
153
|
+
act = action_table[i] and
|
154
|
+
action_check[i] == @racc_state[-1]
|
155
|
+
;
|
156
|
+
else
|
157
|
+
act = action_default[@racc_state[-1]]
|
158
|
+
end
|
159
|
+
else
|
145
160
|
act = action_default[@racc_state[-1]]
|
146
161
|
end
|
147
|
-
|
148
|
-
|
149
|
-
end
|
150
|
-
while act = _racc_evalact(act, arg)
|
151
|
-
;
|
162
|
+
while act = _racc_evalact(act, arg)
|
163
|
+
end
|
152
164
|
end
|
153
|
-
end
|
154
165
|
}
|
155
166
|
end
|
156
167
|
|
@@ -158,26 +169,31 @@ module Racc
|
|
158
169
|
### yyparse
|
159
170
|
###
|
160
171
|
|
161
|
-
def yyparse(recv, mid)
|
162
|
-
__send__
|
172
|
+
def yyparse( recv, mid )
|
173
|
+
__send__ Racc_YY_Parse_Method, recv, mid, _racc_setup(), true
|
163
174
|
end
|
164
175
|
|
165
|
-
def _racc_yyparse_rb(recv, mid, arg, c_debug)
|
176
|
+
def _racc_yyparse_rb( recv, mid, arg, c_debug )
|
166
177
|
action_table, action_check, action_default, action_pointer,
|
167
178
|
goto_table, goto_check, goto_default, goto_pointer,
|
168
179
|
nt_base, reduce_table, token_table, shift_n,
|
169
180
|
reduce_n, use_result, * = arg
|
170
181
|
|
171
182
|
_racc_init_sysvars
|
183
|
+
tok = nil
|
184
|
+
act = nil
|
185
|
+
i = nil
|
172
186
|
nerr = 0
|
173
187
|
|
188
|
+
|
174
189
|
catch(:racc_end_parse) {
|
175
190
|
until i = action_pointer[@racc_state[-1]]
|
176
191
|
while act = _racc_evalact(action_default[@racc_state[-1]], arg)
|
177
|
-
;
|
178
192
|
end
|
179
193
|
end
|
194
|
+
|
180
195
|
recv.__send__(mid) do |tok, val|
|
196
|
+
# $stderr.puts "rd: tok=#{tok}, val=#{val}"
|
181
197
|
unless tok
|
182
198
|
@racc_t = 0
|
183
199
|
else
|
@@ -187,26 +203,35 @@ module Racc
|
|
187
203
|
@racc_read_next = false
|
188
204
|
|
189
205
|
i += @racc_t
|
190
|
-
|
191
|
-
|
192
|
-
|
206
|
+
if i >= 0 and
|
207
|
+
act = action_table[i] and
|
208
|
+
action_check[i] == @racc_state[-1]
|
209
|
+
;
|
210
|
+
# $stderr.puts "01: act=#{act}"
|
211
|
+
else
|
193
212
|
act = action_default[@racc_state[-1]]
|
213
|
+
# $stderr.puts "02: act=#{act}"
|
214
|
+
# $stderr.puts "curstate=#{@racc_state[-1]}"
|
194
215
|
end
|
216
|
+
|
195
217
|
while act = _racc_evalact(act, arg)
|
196
|
-
;
|
197
218
|
end
|
198
219
|
|
199
|
-
while
|
200
|
-
|
201
|
-
@racc_t == 0
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
220
|
+
while not (i = action_pointer[@racc_state[-1]]) or
|
221
|
+
not @racc_read_next or
|
222
|
+
@racc_t == 0 # $
|
223
|
+
if i and i += @racc_t and
|
224
|
+
i >= 0 and
|
225
|
+
act = action_table[i] and
|
226
|
+
action_check[i] == @racc_state[-1]
|
227
|
+
;
|
228
|
+
# $stderr.puts "03: act=#{act}"
|
229
|
+
else
|
230
|
+
# $stderr.puts "04: act=#{act}"
|
206
231
|
act = action_default[@racc_state[-1]]
|
207
232
|
end
|
233
|
+
|
208
234
|
while act = _racc_evalact(act, arg)
|
209
|
-
;
|
210
235
|
end
|
211
236
|
end
|
212
237
|
end
|
@@ -217,23 +242,27 @@ module Racc
|
|
217
242
|
### common
|
218
243
|
###
|
219
244
|
|
220
|
-
def _racc_evalact(act, arg)
|
245
|
+
def _racc_evalact( act, arg )
|
246
|
+
# $stderr.puts "ea: act=#{act}"
|
221
247
|
action_table, action_check, action_default, action_pointer,
|
222
248
|
goto_table, goto_check, goto_default, goto_pointer,
|
223
249
|
nt_base, reduce_table, token_table, shift_n,
|
224
250
|
reduce_n, use_result, * = arg
|
225
|
-
|
251
|
+
nerr = 0 # tmp
|
226
252
|
|
227
253
|
if act > 0 and act < shift_n
|
228
254
|
#
|
229
255
|
# shift
|
230
256
|
#
|
257
|
+
|
231
258
|
if @racc_error_status > 0
|
232
259
|
@racc_error_status -= 1 unless @racc_t == 1 # error token
|
233
260
|
end
|
261
|
+
|
234
262
|
@racc_vstack.push @racc_val
|
235
263
|
@racc_state.push act
|
236
264
|
@racc_read_next = true
|
265
|
+
|
237
266
|
if @yydebug
|
238
267
|
@racc_tstack.push @racc_t
|
239
268
|
racc_shift @racc_t, @racc_tstack, @racc_vstack
|
@@ -243,9 +272,10 @@ module Racc
|
|
243
272
|
#
|
244
273
|
# reduce
|
245
274
|
#
|
275
|
+
|
246
276
|
code = catch(:racc_jump) {
|
247
|
-
|
248
|
-
|
277
|
+
@racc_state.push _racc_do_reduce(arg, act)
|
278
|
+
false
|
249
279
|
}
|
250
280
|
if code
|
251
281
|
case code
|
@@ -255,7 +285,7 @@ module Racc
|
|
255
285
|
when 2 # yyaccept
|
256
286
|
return shift_n
|
257
287
|
else
|
258
|
-
raise '[Racc Bug] unknown jump code'
|
288
|
+
raise RuntimeError, '[Racc Bug] unknown jump code'
|
259
289
|
end
|
260
290
|
end
|
261
291
|
|
@@ -263,6 +293,7 @@ module Racc
|
|
263
293
|
#
|
264
294
|
# accept
|
265
295
|
#
|
296
|
+
|
266
297
|
racc_accept if @yydebug
|
267
298
|
throw :racc_end_parse, @racc_vstack[0]
|
268
299
|
|
@@ -270,6 +301,7 @@ module Racc
|
|
270
301
|
#
|
271
302
|
# error
|
272
303
|
#
|
304
|
+
|
273
305
|
case @racc_error_status
|
274
306
|
when 0
|
275
307
|
unless arg[21] # user_yyerror
|
@@ -284,6 +316,7 @@ module Racc
|
|
284
316
|
end
|
285
317
|
@racc_user_yyerror = false
|
286
318
|
@racc_error_status = 3
|
319
|
+
|
287
320
|
while true
|
288
321
|
if i = action_pointer[@racc_state[-1]]
|
289
322
|
i += 1 # error token
|
@@ -293,7 +326,8 @@ module Racc
|
|
293
326
|
break
|
294
327
|
end
|
295
328
|
end
|
296
|
-
|
329
|
+
|
330
|
+
throw :racc_end_parse, nil if @racc_state.size < 2
|
297
331
|
@racc_state.pop
|
298
332
|
@racc_vstack.pop
|
299
333
|
if @yydebug
|
@@ -301,10 +335,11 @@ module Racc
|
|
301
335
|
racc_e_pop @racc_state, @racc_tstack, @racc_vstack
|
302
336
|
end
|
303
337
|
end
|
338
|
+
|
304
339
|
return act
|
305
340
|
|
306
341
|
else
|
307
|
-
raise "[Racc Bug] unknown action #{act.inspect}"
|
342
|
+
raise RuntimeError, "[Racc Bug] unknown action #{act.inspect}"
|
308
343
|
end
|
309
344
|
|
310
345
|
racc_next_state(@racc_state[-1], @racc_state) if @yydebug
|
@@ -312,7 +347,7 @@ module Racc
|
|
312
347
|
nil
|
313
348
|
end
|
314
349
|
|
315
|
-
def _racc_do_reduce(arg, act)
|
350
|
+
def _racc_do_reduce( arg, act )
|
316
351
|
action_table, action_check, action_default, action_pointer,
|
317
352
|
goto_table, goto_check, goto_default, goto_pointer,
|
318
353
|
nt_base, reduce_table, token_table, shift_n,
|
@@ -353,7 +388,7 @@ module Racc
|
|
353
388
|
goto_default[k1]
|
354
389
|
end
|
355
390
|
|
356
|
-
def on_error(t, val, vstack)
|
391
|
+
def on_error( t, val, vstack )
|
357
392
|
raise ParseError, sprintf("\nparse error on value %s (%s)",
|
358
393
|
val.inspect, token_to_str(t) || '?')
|
359
394
|
end
|
@@ -370,24 +405,23 @@ module Racc
|
|
370
405
|
@racc_error_status = 0
|
371
406
|
end
|
372
407
|
|
373
|
-
|
408
|
+
|
374
409
|
# for debugging output
|
375
|
-
#
|
376
410
|
|
377
|
-
def racc_read_token(t, tok, val)
|
411
|
+
def racc_read_token( t, tok, val )
|
378
412
|
@racc_debug_out.print 'read '
|
379
413
|
@racc_debug_out.print tok.inspect, '(', racc_token2str(t), ') '
|
380
414
|
@racc_debug_out.puts val.inspect
|
381
415
|
@racc_debug_out.puts
|
382
416
|
end
|
383
417
|
|
384
|
-
def racc_shift(tok, tstack, vstack)
|
418
|
+
def racc_shift( tok, tstack, vstack )
|
385
419
|
@racc_debug_out.puts "shift #{racc_token2str tok}"
|
386
420
|
racc_print_stacks tstack, vstack
|
387
421
|
@racc_debug_out.puts
|
388
422
|
end
|
389
423
|
|
390
|
-
def racc_reduce(toks, sim, tstack, vstack)
|
424
|
+
def racc_reduce( toks, sim, tstack, vstack )
|
391
425
|
out = @racc_debug_out
|
392
426
|
out.print 'reduce '
|
393
427
|
if toks.empty?
|
@@ -406,20 +440,20 @@ module Racc
|
|
406
440
|
@racc_debug_out.puts
|
407
441
|
end
|
408
442
|
|
409
|
-
def racc_e_pop(state, tstack, vstack)
|
443
|
+
def racc_e_pop( state, tstack, vstack )
|
410
444
|
@racc_debug_out.puts 'error recovering mode: pop token'
|
411
445
|
racc_print_states state
|
412
446
|
racc_print_stacks tstack, vstack
|
413
447
|
@racc_debug_out.puts
|
414
448
|
end
|
415
449
|
|
416
|
-
def racc_next_state(curstate, state)
|
450
|
+
def racc_next_state( curstate, state )
|
417
451
|
@racc_debug_out.puts "goto #{curstate}"
|
418
452
|
racc_print_states state
|
419
453
|
@racc_debug_out.puts
|
420
454
|
end
|
421
455
|
|
422
|
-
def racc_print_stacks(t, v)
|
456
|
+
def racc_print_stacks( t, v )
|
423
457
|
out = @racc_debug_out
|
424
458
|
out.print ' ['
|
425
459
|
t.each_index do |i|
|
@@ -428,29 +462,28 @@ module Racc
|
|
428
462
|
out.puts ' ]'
|
429
463
|
end
|
430
464
|
|
431
|
-
def racc_print_states(s)
|
465
|
+
def racc_print_states( s )
|
432
466
|
out = @racc_debug_out
|
433
467
|
out.print ' ['
|
434
468
|
s.each {|st| out.print ' ', st }
|
435
469
|
out.puts ' ]'
|
436
470
|
end
|
437
471
|
|
438
|
-
def racc_token2str(tok)
|
472
|
+
def racc_token2str( tok )
|
439
473
|
self.class::Racc_token_to_s_table[tok] or
|
440
|
-
raise "[Racc Bug] can't convert token #{tok} to string"
|
474
|
+
raise RuntimeError, "[Racc Bug] can't convert token #{tok} to string"
|
441
475
|
end
|
442
476
|
|
443
|
-
def token_to_str(t)
|
477
|
+
def token_to_str( t )
|
444
478
|
self.class::Racc_token_to_s_table[t]
|
445
479
|
end
|
446
480
|
|
447
481
|
end
|
448
482
|
|
449
483
|
end
|
484
|
+
..end /usr/local/lib/ruby/site_ruby/1.8/racc/parser.rb modeval..idb0d4489999
|
485
|
+
end # end of racc/parser.rb
|
450
486
|
|
451
|
-
...end racc/parser.rb/module_eval...
|
452
|
-
end
|
453
|
-
###### racc/parser.rb end
|
454
487
|
|
455
488
|
|
456
489
|
# parse.y, quanty/parse.rb
|
@@ -459,9 +492,10 @@ end
|
|
459
492
|
#
|
460
493
|
class Quanty
|
461
494
|
|
495
|
+
|
462
496
|
class Parse < Racc::Parser
|
463
497
|
|
464
|
-
module_eval
|
498
|
+
module_eval <<'..end parse.y modeval..id8dd3e186dd', 'parse.y', 73
|
465
499
|
|
466
500
|
def parse( str )
|
467
501
|
@q = []
|
@@ -469,18 +503,16 @@ module_eval(<<'...end parse.y/module_eval...', 'parse.y', 72)
|
|
469
503
|
while str.size > 0 do
|
470
504
|
#p str
|
471
505
|
case str
|
472
|
-
when /\A[\s\n]+/
|
473
|
-
when /\A\d+\.?\d*([eE][+-]?\d+)?/
|
506
|
+
when /\A[\s\n]+/o
|
507
|
+
when /\A\d+\.?\d*([eE][+-]?\d+)?/o
|
474
508
|
@q.push [:NUMBER, $&.to_f]
|
475
|
-
|
476
|
-
when /\A[A-Za-z_]+ -/u
|
477
|
-
when /\A[A-Za-z_µ]+([A-Za-z_µ0-9-]+[A-Za-z_µ])?/ou
|
509
|
+
when /\A[A-Za-z_]+([A-Za-z_0-9-]+[A-Za-z_])?/o
|
478
510
|
@q.push [:WORD, $&]
|
479
|
-
when /\A[$%'"]'?/
|
511
|
+
when /\A[$%'"]'?/o
|
480
512
|
@q.push [:WORD, $&]
|
481
|
-
when /\A\^|\A\*\*/
|
513
|
+
when /\A\^|\A\*\*/o
|
482
514
|
@q.push [:POW, $&]
|
483
|
-
when /\A./
|
515
|
+
when /\A./o
|
484
516
|
@q.push [$&,$&]
|
485
517
|
end
|
486
518
|
str = $'
|
@@ -494,357 +526,372 @@ module_eval(<<'...end parse.y/module_eval...', 'parse.y', 72)
|
|
494
526
|
@q.shift
|
495
527
|
end
|
496
528
|
|
497
|
-
|
498
|
-
|
529
|
+
..end parse.y modeval..id8dd3e186dd
|
530
|
+
|
531
|
+
##### racc 1.4.4 generates ###
|
532
|
+
|
533
|
+
racc_reduce_table = [
|
534
|
+
0, 0, :racc_error,
|
535
|
+
1, 18, :_reduce_none,
|
536
|
+
0, 18, :_reduce_2,
|
537
|
+
1, 18, :_reduce_3,
|
538
|
+
1, 20, :_reduce_none,
|
539
|
+
2, 20, :_reduce_5,
|
540
|
+
3, 20, :_reduce_6,
|
541
|
+
3, 20, :_reduce_7,
|
542
|
+
3, 20, :_reduce_8,
|
543
|
+
3, 20, :_reduce_9,
|
544
|
+
3, 20, :_reduce_10,
|
545
|
+
3, 20, :_reduce_11,
|
546
|
+
3, 20, :_reduce_12,
|
547
|
+
1, 19, :_reduce_none,
|
548
|
+
2, 19, :_reduce_14,
|
549
|
+
2, 19, :_reduce_15,
|
550
|
+
3, 19, :_reduce_16,
|
551
|
+
1, 21, :_reduce_none,
|
552
|
+
2, 21, :_reduce_18,
|
553
|
+
3, 21, :_reduce_19,
|
554
|
+
3, 21, :_reduce_20,
|
555
|
+
3, 21, :_reduce_21,
|
556
|
+
3, 21, :_reduce_22,
|
557
|
+
3, 21, :_reduce_23,
|
558
|
+
1, 22, :_reduce_none,
|
559
|
+
2, 22, :_reduce_25,
|
560
|
+
3, 22, :_reduce_26,
|
561
|
+
1, 23, :_reduce_27,
|
562
|
+
3, 23, :_reduce_28,
|
563
|
+
3, 23, :_reduce_29 ]
|
564
|
+
|
565
|
+
racc_reduce_n = 30
|
566
|
+
|
567
|
+
racc_shift_n = 54
|
499
568
|
|
500
569
|
racc_action_table = [
|
501
|
-
23, 22, 24, 25, 26, 27, 29, 23,
|
502
|
-
|
503
|
-
|
504
|
-
29,
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
12, 2,
|
509
|
-
|
510
|
-
|
511
|
-
23,
|
512
|
-
nil,
|
513
|
-
12, 2,
|
514
|
-
|
515
|
-
12, 13,
|
516
|
-
13,
|
570
|
+
23, 22, 23, 24, 25, 26, 27, 29, 23, 21,
|
571
|
+
39, 5, 6, 23, 23, 23, 24, 25, 26, 27,
|
572
|
+
29, 34, 21, 23, 5, 6, 24, 25, 26, 27,
|
573
|
+
29, 41, 21, 23, 5, 6, 24, 37, 26, 27,
|
574
|
+
29, 38, 40, 39, 31, 32, 33, nil, 31, 32,
|
575
|
+
33, 21, 14, 5, 6, 21, nil, 5, 6, 12,
|
576
|
+
2, 13, 7, nil, nil, 12, 2, 4, 7, 5,
|
577
|
+
6, 12, 2, 4, 7, 5, 6, 12, 2, 4,
|
578
|
+
7, 5, 6, 12, 2, 4, 23, 5, 6, 23,
|
579
|
+
nil, 26, 27, 29, 26, 27, 29, 23, nil, nil,
|
580
|
+
23, nil, 26, 27, 29, 26, 27, 29, 12, 2,
|
581
|
+
4, nil, 5, 6, 12, 2, 4, 23, 5, 6,
|
582
|
+
24, 37, 26, 12, 2, 4, 23, 5, 6, 24,
|
583
|
+
37, 26, 21, nil, 5, 6, 21, nil, 5, 6,
|
584
|
+
12, 2, 13, 12, 2, 13, 12, 2, 13, 12,
|
585
|
+
2, 13, 12, 2, 13, 12, 2, 13, 12, 2,
|
586
|
+
13, 12, 2, 13 ]
|
517
587
|
|
518
588
|
racc_action_check = [
|
519
|
-
17,
|
520
|
-
17, 17, 19,
|
521
|
-
19,
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
nil,
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
14,
|
589
|
+
17, 8, 42, 17, 17, 17, 17, 17, 43, 17,
|
590
|
+
17, 17, 17, 19, 45, 46, 19, 19, 19, 19,
|
591
|
+
19, 12, 19, 10, 19, 19, 10, 10, 10, 10,
|
592
|
+
10, 22, 10, 35, 10, 10, 35, 35, 35, 35,
|
593
|
+
35, 16, 18, 35, 28, 28, 28, nil, 11, 11,
|
594
|
+
11, 28, 3, 28, 28, 11, nil, 11, 11, 3,
|
595
|
+
3, 3, 21, nil, nil, 21, 21, 21, 6, 21,
|
596
|
+
21, 6, 6, 6, 4, 6, 6, 4, 4, 4,
|
597
|
+
0, 4, 4, 0, 0, 0, 15, 0, 0, 51,
|
598
|
+
nil, 15, 15, 15, 51, 51, 51, 36, nil, nil,
|
599
|
+
53, nil, 36, 36, 36, 53, 53, 53, 33, 33,
|
600
|
+
33, nil, 33, 33, 32, 32, 32, 48, 32, 32,
|
601
|
+
48, 48, 48, 25, 25, 25, 47, 25, 25, 47,
|
602
|
+
47, 47, 31, nil, 31, 31, 7, nil, 7, 7,
|
603
|
+
29, 29, 29, 13, 13, 13, 23, 23, 23, 14,
|
604
|
+
14, 14, 26, 26, 26, 37, 37, 37, 27, 27,
|
605
|
+
27, 24, 24, 24 ]
|
535
606
|
|
536
607
|
racc_action_pointer = [
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
104, 98, nil,
|
541
|
-
nil,
|
542
|
-
|
608
|
+
73, nil, nil, 49, 67, nil, 61, 124, 1, nil,
|
609
|
+
20, 43, 10, 133, 139, 83, 28, -3, 26, 10,
|
610
|
+
nil, 55, 31, 136, 151, 113, 142, 148, 39, 130,
|
611
|
+
nil, 120, 104, 98, nil, 30, 94, 145, nil, nil,
|
612
|
+
nil, nil, -1, 5, nil, 11, 12, 123, 114, nil,
|
613
|
+
nil, 86, nil, 97 ]
|
543
614
|
|
544
615
|
racc_action_default = [
|
545
|
-
-2, -
|
546
|
-
|
547
|
-
-
|
548
|
-
-
|
549
|
-
|
550
|
-
-22, -
|
616
|
+
-2, -17, -4, -24, -30, -27, -30, -30, -30, -1,
|
617
|
+
-3, -13, -30, -30, -30, -25, -30, -30, -30, -30,
|
618
|
+
-15, -30, -30, -30, -30, -30, -30, -30, -14, -30,
|
619
|
+
-18, -30, -30, -30, -5, -30, -26, -30, -28, -12,
|
620
|
+
-29, 54, -11, -10, -16, -9, -8, -6, -7, -19,
|
621
|
+
-20, -22, -21, -23 ]
|
551
622
|
|
552
623
|
racc_goto_table = [
|
553
|
-
8, 15, 17,
|
554
|
-
|
555
|
-
nil,
|
556
|
-
|
624
|
+
10, 28, 8, 15, 17, 9, nil, nil, 28, nil,
|
625
|
+
28, 18, nil, 35, 36, nil, nil, 20, nil, nil,
|
626
|
+
nil, 30, nil, 42, 43, 45, 46, 47, nil, 48,
|
627
|
+
nil, nil, 51, 53, nil, 44, nil, 45, 30, nil,
|
628
|
+
nil, 49, 50, 52 ]
|
557
629
|
|
558
630
|
racc_goto_check = [
|
559
|
-
3, 3, 3, 2,
|
560
|
-
|
561
|
-
nil,
|
562
|
-
3, 3, 5, nil,
|
631
|
+
3, 4, 1, 3, 3, 2, nil, nil, 4, nil,
|
632
|
+
4, 2, nil, 3, 3, nil, nil, 5, nil, nil,
|
633
|
+
nil, 5, nil, 3, 3, 3, 3, 3, nil, 3,
|
634
|
+
nil, nil, 3, 3, nil, 5, nil, 3, 5, nil,
|
635
|
+
nil, 5, 5, 5 ]
|
563
636
|
|
564
637
|
racc_goto_pointer = [
|
565
|
-
nil,
|
638
|
+
nil, 2, 5, 0, -9, 10, nil ]
|
566
639
|
|
567
640
|
racc_goto_default = [
|
568
|
-
nil, nil, 16, 19,
|
569
|
-
|
570
|
-
racc_reduce_table = [
|
571
|
-
0, 0, :racc_error,
|
572
|
-
1, 17, :_reduce_none,
|
573
|
-
0, 17, :_reduce_2,
|
574
|
-
1, 17, :_reduce_3,
|
575
|
-
1, 19, :_reduce_none,
|
576
|
-
2, 19, :_reduce_5,
|
577
|
-
3, 19, :_reduce_6,
|
578
|
-
3, 19, :_reduce_7,
|
579
|
-
3, 19, :_reduce_8,
|
580
|
-
3, 19, :_reduce_9,
|
581
|
-
3, 19, :_reduce_10,
|
582
|
-
3, 19, :_reduce_11,
|
583
|
-
3, 19, :_reduce_12,
|
584
|
-
1, 18, :_reduce_none,
|
585
|
-
2, 18, :_reduce_14,
|
586
|
-
2, 18, :_reduce_15,
|
587
|
-
3, 18, :_reduce_16,
|
588
|
-
1, 20, :_reduce_none,
|
589
|
-
2, 20, :_reduce_18,
|
590
|
-
3, 20, :_reduce_19,
|
591
|
-
3, 20, :_reduce_20,
|
592
|
-
3, 20, :_reduce_21,
|
593
|
-
3, 20, :_reduce_22,
|
594
|
-
1, 21, :_reduce_none,
|
595
|
-
2, 21, :_reduce_24,
|
596
|
-
3, 21, :_reduce_25,
|
597
|
-
1, 22, :_reduce_26,
|
598
|
-
3, 22, :_reduce_27,
|
599
|
-
3, 22, :_reduce_28 ]
|
600
|
-
|
601
|
-
racc_reduce_n = 29
|
602
|
-
|
603
|
-
racc_shift_n = 52
|
641
|
+
nil, nil, 16, 19, 11, 1, 3 ]
|
604
642
|
|
605
643
|
racc_token_table = {
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
racc_nt_base = 16
|
644
|
+
false => 0,
|
645
|
+
Object.new => 1,
|
646
|
+
:UMINUS => 2,
|
647
|
+
:POW => 3,
|
648
|
+
:UPOW => 4,
|
649
|
+
"." => 5,
|
650
|
+
"*" => 6,
|
651
|
+
"/" => 7,
|
652
|
+
"|" => 8,
|
653
|
+
"+" => 9,
|
654
|
+
"-" => 10,
|
655
|
+
:NUMBER => 11,
|
656
|
+
"(" => 12,
|
657
|
+
")" => 13,
|
658
|
+
:WORD => 14,
|
659
|
+
"[" => 15,
|
660
|
+
"]" => 16 }
|
624
661
|
|
625
662
|
racc_use_result_var = true
|
626
663
|
|
664
|
+
racc_nt_base = 17
|
665
|
+
|
627
666
|
Racc_arg = [
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
667
|
+
racc_action_table,
|
668
|
+
racc_action_check,
|
669
|
+
racc_action_default,
|
670
|
+
racc_action_pointer,
|
671
|
+
racc_goto_table,
|
672
|
+
racc_goto_check,
|
673
|
+
racc_goto_default,
|
674
|
+
racc_goto_pointer,
|
675
|
+
racc_nt_base,
|
676
|
+
racc_reduce_table,
|
677
|
+
racc_token_table,
|
678
|
+
racc_shift_n,
|
679
|
+
racc_reduce_n,
|
680
|
+
racc_use_result_var ]
|
642
681
|
|
643
682
|
Racc_token_to_s_table = [
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
683
|
+
'$end',
|
684
|
+
'error',
|
685
|
+
'UMINUS',
|
686
|
+
'POW',
|
687
|
+
'UPOW',
|
688
|
+
'"."',
|
689
|
+
'"*"',
|
690
|
+
'"/"',
|
691
|
+
'"|"',
|
692
|
+
'"+"',
|
693
|
+
'"-"',
|
694
|
+
'NUMBER',
|
695
|
+
'"("',
|
696
|
+
'")"',
|
697
|
+
'WORD',
|
698
|
+
'"["',
|
699
|
+
'"]"',
|
700
|
+
'$start',
|
701
|
+
'target',
|
702
|
+
'val',
|
703
|
+
'num',
|
704
|
+
'seq',
|
705
|
+
'exp',
|
706
|
+
'unit']
|
667
707
|
|
668
708
|
Racc_debug_parser = false
|
669
709
|
|
670
|
-
#####
|
710
|
+
##### racc system variables end #####
|
671
711
|
|
672
|
-
# reduce 0 omitted
|
712
|
+
# reduce 0 omitted
|
673
713
|
|
674
|
-
# reduce 1 omitted
|
714
|
+
# reduce 1 omitted
|
675
715
|
|
676
|
-
module_eval
|
677
|
-
def _reduce_2(val, _values, result)
|
678
|
-
|
679
|
-
|
716
|
+
module_eval <<'.,.,', 'parse.y', 21
|
717
|
+
def _reduce_2( val, _values, result )
|
718
|
+
result = Quanty::Fact.new
|
719
|
+
result
|
680
720
|
end
|
681
721
|
.,.,
|
682
722
|
|
683
|
-
module_eval
|
684
|
-
def _reduce_3(val, _values, result)
|
685
|
-
|
686
|
-
|
723
|
+
module_eval <<'.,.,', 'parse.y', 22
|
724
|
+
def _reduce_3( val, _values, result )
|
725
|
+
result = Quanty::Fact.new(val[0])
|
726
|
+
result
|
687
727
|
end
|
688
728
|
.,.,
|
689
729
|
|
690
|
-
# reduce 4 omitted
|
730
|
+
# reduce 4 omitted
|
691
731
|
|
692
|
-
module_eval
|
693
|
-
def _reduce_5(val, _values, result)
|
694
|
-
|
695
|
-
|
732
|
+
module_eval <<'.,.,', 'parse.y', 26
|
733
|
+
def _reduce_5( val, _values, result )
|
734
|
+
result = -val[1]
|
735
|
+
result
|
696
736
|
end
|
697
737
|
.,.,
|
698
738
|
|
699
|
-
module_eval
|
700
|
-
def _reduce_6(val, _values, result)
|
701
|
-
|
702
|
-
|
739
|
+
module_eval <<'.,.,', 'parse.y', 27
|
740
|
+
def _reduce_6( val, _values, result )
|
741
|
+
result += val[2]
|
742
|
+
result
|
703
743
|
end
|
704
744
|
.,.,
|
705
745
|
|
706
|
-
module_eval
|
707
|
-
def _reduce_7(val, _values, result)
|
708
|
-
|
709
|
-
|
746
|
+
module_eval <<'.,.,', 'parse.y', 28
|
747
|
+
def _reduce_7( val, _values, result )
|
748
|
+
result -= val[2]
|
749
|
+
result
|
710
750
|
end
|
711
751
|
.,.,
|
712
752
|
|
713
|
-
module_eval
|
714
|
-
def _reduce_8(val, _values, result)
|
715
|
-
|
716
|
-
|
753
|
+
module_eval <<'.,.,', 'parse.y', 29
|
754
|
+
def _reduce_8( val, _values, result )
|
755
|
+
result /= val[2]
|
756
|
+
result
|
717
757
|
end
|
718
758
|
.,.,
|
719
759
|
|
720
|
-
module_eval
|
721
|
-
def _reduce_9(val, _values, result)
|
722
|
-
|
723
|
-
|
760
|
+
module_eval <<'.,.,', 'parse.y', 30
|
761
|
+
def _reduce_9( val, _values, result )
|
762
|
+
result /= val[2]
|
763
|
+
result
|
724
764
|
end
|
725
765
|
.,.,
|
726
766
|
|
727
|
-
module_eval
|
728
|
-
def _reduce_10(val, _values, result)
|
729
|
-
|
730
|
-
|
767
|
+
module_eval <<'.,.,', 'parse.y', 31
|
768
|
+
def _reduce_10( val, _values, result )
|
769
|
+
result *= val[2]
|
770
|
+
result
|
731
771
|
end
|
732
772
|
.,.,
|
733
773
|
|
734
|
-
module_eval
|
735
|
-
def _reduce_11(val, _values, result)
|
736
|
-
|
737
|
-
|
774
|
+
module_eval <<'.,.,', 'parse.y', 32
|
775
|
+
def _reduce_11( val, _values, result )
|
776
|
+
result **= val[2]
|
777
|
+
result
|
738
778
|
end
|
739
779
|
.,.,
|
740
780
|
|
741
|
-
module_eval
|
742
|
-
def _reduce_12(val, _values, result)
|
743
|
-
|
744
|
-
|
781
|
+
module_eval <<'.,.,', 'parse.y', 33
|
782
|
+
def _reduce_12( val, _values, result )
|
783
|
+
result = val[1]
|
784
|
+
result
|
745
785
|
end
|
746
786
|
.,.,
|
747
787
|
|
748
|
-
# reduce 13 omitted
|
788
|
+
# reduce 13 omitted
|
749
789
|
|
750
|
-
module_eval
|
751
|
-
def _reduce_14(val, _values, result)
|
752
|
-
|
753
|
-
|
790
|
+
module_eval <<'.,.,', 'parse.y', 37
|
791
|
+
def _reduce_14( val, _values, result )
|
792
|
+
result = val[1].fac!(val[0])
|
793
|
+
result
|
754
794
|
end
|
755
795
|
.,.,
|
756
796
|
|
757
|
-
module_eval
|
758
|
-
def _reduce_15(val, _values, result)
|
759
|
-
|
760
|
-
|
797
|
+
module_eval <<'.,.,', 'parse.y', 38
|
798
|
+
def _reduce_15( val, _values, result )
|
799
|
+
result = val[1].pow!(-1)
|
800
|
+
result
|
761
801
|
end
|
762
802
|
.,.,
|
763
803
|
|
764
|
-
module_eval
|
765
|
-
def _reduce_16(val, _values, result)
|
766
|
-
|
767
|
-
|
804
|
+
module_eval <<'.,.,', 'parse.y', 39
|
805
|
+
def _reduce_16( val, _values, result )
|
806
|
+
result = val[2].pow!(-1).fac!(val[0])
|
807
|
+
result
|
768
808
|
end
|
769
809
|
.,.,
|
770
810
|
|
771
|
-
# reduce 17 omitted
|
811
|
+
# reduce 17 omitted
|
812
|
+
|
813
|
+
module_eval <<'.,.,', 'parse.y', 43
|
814
|
+
def _reduce_18( val, _values, result )
|
815
|
+
result.mul!(val[1])
|
816
|
+
result
|
817
|
+
end
|
818
|
+
.,.,
|
772
819
|
|
773
|
-
module_eval
|
774
|
-
def
|
775
|
-
|
776
|
-
|
820
|
+
module_eval <<'.,.,', 'parse.y', 44
|
821
|
+
def _reduce_19( val, _values, result )
|
822
|
+
result.mul!(val[2])
|
823
|
+
result
|
777
824
|
end
|
778
825
|
.,.,
|
779
826
|
|
780
|
-
module_eval
|
781
|
-
def
|
782
|
-
|
783
|
-
|
827
|
+
module_eval <<'.,.,', 'parse.y', 45
|
828
|
+
def _reduce_20( val, _values, result )
|
829
|
+
result.mul!(val[2])
|
830
|
+
result
|
784
831
|
end
|
785
832
|
.,.,
|
786
833
|
|
787
|
-
module_eval
|
788
|
-
def
|
789
|
-
|
790
|
-
|
834
|
+
module_eval <<'.,.,', 'parse.y', 46
|
835
|
+
def _reduce_21( val, _values, result )
|
836
|
+
result.div!(val[2])
|
837
|
+
result
|
791
838
|
end
|
792
839
|
.,.,
|
793
840
|
|
794
|
-
module_eval
|
795
|
-
def
|
796
|
-
|
797
|
-
|
841
|
+
module_eval <<'.,.,', 'parse.y', 47
|
842
|
+
def _reduce_22( val, _values, result )
|
843
|
+
result.fac!(val[2])
|
844
|
+
result
|
798
845
|
end
|
799
846
|
.,.,
|
800
847
|
|
801
|
-
module_eval
|
802
|
-
def
|
803
|
-
|
804
|
-
|
848
|
+
module_eval <<'.,.,', 'parse.y', 48
|
849
|
+
def _reduce_23( val, _values, result )
|
850
|
+
result.fac!(val[2]**-1)
|
851
|
+
result
|
805
852
|
end
|
806
853
|
.,.,
|
807
854
|
|
808
|
-
# reduce
|
855
|
+
# reduce 24 omitted
|
809
856
|
|
810
|
-
module_eval
|
811
|
-
def
|
812
|
-
|
813
|
-
|
857
|
+
module_eval <<'.,.,', 'parse.y', 52
|
858
|
+
def _reduce_25( val, _values, result )
|
859
|
+
result.pow!(val[1])
|
860
|
+
result
|
814
861
|
end
|
815
862
|
.,.,
|
816
863
|
|
817
|
-
module_eval
|
818
|
-
def
|
819
|
-
|
820
|
-
|
864
|
+
module_eval <<'.,.,', 'parse.y', 53
|
865
|
+
def _reduce_26( val, _values, result )
|
866
|
+
result.pow!(val[2])
|
867
|
+
result
|
821
868
|
end
|
822
869
|
.,.,
|
823
870
|
|
824
|
-
module_eval
|
825
|
-
def
|
826
|
-
|
827
|
-
|
871
|
+
module_eval <<'.,.,', 'parse.y', 56
|
872
|
+
def _reduce_27( val, _values, result )
|
873
|
+
result = Quanty::Fact.new(val[0])
|
874
|
+
result
|
828
875
|
end
|
829
876
|
.,.,
|
830
877
|
|
831
|
-
module_eval
|
832
|
-
def
|
833
|
-
|
834
|
-
|
878
|
+
module_eval <<'.,.,', 'parse.y', 57
|
879
|
+
def _reduce_28( val, _values, result )
|
880
|
+
result = val[1]
|
881
|
+
result
|
835
882
|
end
|
836
883
|
.,.,
|
837
884
|
|
838
|
-
module_eval
|
839
|
-
def
|
840
|
-
|
841
|
-
|
885
|
+
module_eval <<'.,.,', 'parse.y', 58
|
886
|
+
def _reduce_29( val, _values, result )
|
887
|
+
result = val[1]
|
888
|
+
result
|
842
889
|
end
|
843
890
|
.,.,
|
844
891
|
|
845
|
-
def _reduce_none(val, _values, result)
|
846
|
-
|
847
|
-
end
|
892
|
+
def _reduce_none( val, _values, result )
|
893
|
+
result
|
894
|
+
end
|
848
895
|
|
849
896
|
end # class Parse
|
850
897
|
|