rbx-trepanning 0.1.0-universal-rubinius-1.2 → 0.2.1-universal-rubinius-1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +3 -0
- data/.travis.yml +4 -0
- data/ChangeLog +162 -0
- data/Gemfile +16 -0
- data/NEWS +15 -8
- data/README.md +72 -0
- data/Rakefile +16 -13
- data/app/client.rb +15 -4
- data/app/cmd_parse.kpeg +38 -40
- data/app/cmd_parse.rb +25 -20
- data/app/cmd_parser.rb +1030 -1036
- data/app/complete.rb +12 -12
- data/app/default.rb +6 -5
- data/app/display.rb +2 -2
- data/app/frame.rb +17 -4
- data/app/method.rb +11 -10
- data/app/options.rb +21 -22
- data/app/util.rb +17 -10
- data/interface/user.rb +2 -2
- data/io/input.rb +13 -3
- data/lib/trepanning.rb +22 -23
- data/processor.rb +32 -32
- data/processor/command.rb +32 -13
- data/processor/command/backtrace.rb +2 -16
- data/processor/command/base/submgr.rb +22 -14
- data/processor/command/base/subsubcmd.rb +11 -13
- data/processor/command/base/subsubmgr.rb +38 -19
- data/processor/command/disassemble.rb +11 -11
- data/processor/command/help.rb +24 -24
- data/processor/command/shell.rb +17 -17
- data/processor/default.rb +5 -2
- data/processor/frame.rb +37 -0
- data/processor/help.rb +9 -11
- data/processor/load_cmds.rb +53 -40
- data/processor/location.rb +2 -2
- data/processor/mock.rb +8 -9
- data/processor/subcmd.rb +12 -12
- data/rbx-trepanning.gemspec +4 -3
- data/sample/rocky-trepanx-colors.rb +1 -1
- data/test/example/factorial.rb +10 -0
- data/test/functional/fn_helper.rb +8 -7
- data/test/functional/test-break.rb +39 -5
- data/test/functional/test-recursive-bt.rb +105 -0
- data/test/integration/helper.rb +14 -14
- data/test/integration/test-quit.rb +8 -2
- data/test/unit/cmd-helper.rb +2 -2
- data/test/unit/test-base-subcmd.rb +14 -3
- data/test/unit/test-completion.rb +7 -3
- data/test/unit/test-io-tcpserver.rb +10 -5
- data/test/unit/test-proc-validate.rb +4 -4
- metadata +208 -113
- data/README.textile +0 -34
data/app/cmd_parse.kpeg
CHANGED
@@ -1,7 +1,5 @@
|
|
1
|
-
# -*- Ruby -*-
|
2
|
-
|
3
1
|
%% {
|
4
|
-
#####################################################
|
2
|
+
#####################################################
|
5
3
|
# Structure to hold composite method names
|
6
4
|
SymbolEntry = Struct.new(:type, :name, :chain)
|
7
5
|
|
@@ -17,7 +15,7 @@
|
|
17
15
|
List = Struct.new(:position, :num)
|
18
16
|
|
19
17
|
DEFAULT_OPTS = {
|
20
|
-
:debug=>false,
|
18
|
+
:debug=>false,
|
21
19
|
:file_exists_proc => Proc.new{|filename|
|
22
20
|
File.readable?(filename) && !File.directory?(filename)
|
23
21
|
}
|
@@ -34,37 +32,37 @@
|
|
34
32
|
|
35
33
|
upcase_letter = /[A-Z]/
|
36
34
|
downcase_letter = /[a-z]/
|
37
|
-
suffix_letter = /[=!?]/
|
35
|
+
suffix_letter = /[=!?]/
|
38
36
|
letter = upcase_letter
|
39
37
|
| downcase_letter
|
40
38
|
id_symbol = letter | "_" | [0-9]
|
41
39
|
|
42
40
|
|
43
41
|
# An variable or a method identifier
|
44
|
-
# Examples:
|
42
|
+
# Examples:
|
45
43
|
# var1
|
46
|
-
# my_var?
|
44
|
+
# my_var?
|
47
45
|
# But not: Variable or @var
|
48
46
|
vm_identifier = < (downcase_letter | "_") id_symbol* suffix_letter? >
|
49
|
-
{
|
47
|
+
{
|
50
48
|
SymbolEntry.new(:variable, text)
|
51
49
|
}
|
52
50
|
|
53
|
-
# Examples:
|
51
|
+
# Examples:
|
54
52
|
# var1
|
55
|
-
# But not: my_var?, my_var!
|
53
|
+
# But not: my_var?, my_var!
|
56
54
|
variable_identifier = < (downcase_letter | "_") id_symbol* >
|
57
|
-
{
|
55
|
+
{
|
58
56
|
SymbolEntry.new(:variable, text)
|
59
57
|
}
|
60
58
|
|
61
|
-
# Examples:
|
59
|
+
# Examples:
|
62
60
|
# MY_CONSTANT
|
63
61
|
# MyConstant_01
|
64
62
|
# But not:
|
65
63
|
# MyConstant_01?
|
66
64
|
constant_identifier = < upcase_letter id_symbol* >
|
67
|
-
{
|
65
|
+
{
|
68
66
|
SymbolEntry.new(:constant, text)
|
69
67
|
}
|
70
68
|
|
@@ -76,14 +74,14 @@ global_identifier = < "$" (constant_identifier | variable_identifier) >
|
|
76
74
|
SymbolEntry.new(:global, text)
|
77
75
|
}
|
78
76
|
|
79
|
-
# Examples:
|
77
|
+
# Examples:
|
80
78
|
# Foo
|
81
79
|
# foo
|
82
80
|
# But not:
|
83
81
|
# foo!, @foo, Class.foo
|
84
82
|
local_internal_identifier = constant_identifier | variable_identifier
|
85
83
|
|
86
|
-
# Examples:
|
84
|
+
# Examples:
|
87
85
|
# Foo, foo, foo!
|
88
86
|
# foo
|
89
87
|
# But not:
|
@@ -94,29 +92,29 @@ local_identifier = constant_identifier | vm_identifier
|
|
94
92
|
instance_identifier = < '@' local_identifier >
|
95
93
|
{
|
96
94
|
SymbolEntry.new(:instance, text)
|
97
|
-
}
|
95
|
+
}
|
98
96
|
|
99
97
|
|
100
98
|
# Example: @@foo
|
101
99
|
classvar_identifier = ('@@' local_identifier:id )
|
102
100
|
{
|
103
101
|
SymbolEntry.new(:classvar, id)
|
104
|
-
}
|
102
|
+
}
|
105
103
|
|
106
|
-
identifier = global_identifier
|
107
|
-
| instance_identifier
|
108
|
-
| classvar_identifier
|
109
|
-
| local_identifier
|
104
|
+
identifier = global_identifier
|
105
|
+
| instance_identifier
|
106
|
+
| classvar_identifier
|
107
|
+
| local_identifier
|
110
108
|
|
111
109
|
id_separator = < '::'|'.' > { text }
|
112
110
|
|
113
111
|
# Like of class_module_chain *after* the first name. So we don't
|
114
112
|
# allow sigils in the initial id. That is we don't allow:
|
115
|
-
# Class.@name1.@@name2.$name3
|
113
|
+
# Class.@name1.@@name2.$name3
|
116
114
|
# But we do allow final sigils:
|
117
115
|
# class.name!, class.name=
|
118
|
-
internal_class_module_chain =
|
119
|
-
< local_internal_identifier:parent id_separator:sep
|
116
|
+
internal_class_module_chain =
|
117
|
+
< local_internal_identifier:parent id_separator:sep
|
120
118
|
internal_class_module_chain:child >
|
121
119
|
{
|
122
120
|
SymbolEntry.new(parent.type, text, [parent, child, sep])
|
@@ -125,14 +123,14 @@ internal_class_module_chain =
|
|
125
123
|
|
126
124
|
|
127
125
|
# I think strict Ruby rules are that once one goes from :: to .
|
128
|
-
# There is no going back. That is, A.B::C is invalid.
|
129
|
-
#
|
130
|
-
# Also I think method names can't be constants. But such
|
126
|
+
# There is no going back. That is, A.B::C is invalid.
|
127
|
+
#
|
128
|
+
# Also I think method names can't be constants. But such
|
131
129
|
# subtleties we'll handle when we process the final structure.
|
132
130
|
# Examples:
|
133
|
-
# Object, A::B, A.b @@foo.bar, $foo.bar.baz?
|
131
|
+
# Object, A::B, A.b @@foo.bar, $foo.bar.baz?
|
134
132
|
|
135
|
-
class_module_chain =
|
133
|
+
class_module_chain =
|
136
134
|
< identifier:parent id_separator:sep internal_class_module_chain:child >
|
137
135
|
{
|
138
136
|
SymbolEntry.new(parent.type, text, [parent, child, sep])
|
@@ -157,7 +155,7 @@ class_module_chain =
|
|
157
155
|
dbl_seq = < /[^\\"]+/ > { text }
|
158
156
|
dbl_not_quote = (dbl_escapes | dbl_seq)+:ary { ary }
|
159
157
|
dbl_string = "\"" dbl_not_quote:ary "\"" { ary.join }
|
160
|
-
not_space_colon = escapes
|
158
|
+
not_space_colon = escapes
|
161
159
|
| < /[^ \t\n:]/ > { text }
|
162
160
|
not_space_colons = ( not_space_colon )+:ary { ary.join }
|
163
161
|
filename = dbl_string | not_space_colons
|
@@ -174,14 +172,14 @@ vm_offset = '@' integer:int
|
|
174
172
|
# Examples:
|
175
173
|
# @43
|
176
174
|
# 5
|
177
|
-
position =
|
178
|
-
vm_offset
|
179
|
-
| line_number:l {
|
180
|
-
Position.new(nil, nil, :line, l)
|
175
|
+
position =
|
176
|
+
vm_offset
|
177
|
+
| line_number:l {
|
178
|
+
Position.new(nil, nil, :line, l)
|
181
179
|
}
|
182
180
|
|
183
|
-
file_colon_line = file_no_colon:file &{ File.exist?(file) } ':' position:pos {
|
184
|
-
Position.new(:file, file, pos.position_type, pos.position)
|
181
|
+
file_colon_line = file_no_colon:file &{ File.exist?(file) } ':' position:pos {
|
182
|
+
Position.new(:file, file, pos.position_type, pos.position)
|
185
183
|
}
|
186
184
|
|
187
185
|
# Examples:
|
@@ -190,8 +188,8 @@ file_colon_line = file_no_colon:file &{ File.exist?(file) } ':' position:pos {
|
|
190
188
|
# Myclass.fn 5 # line number 5 of fn
|
191
189
|
# Note: Myclass.fn could be either a filename or a method name
|
192
190
|
|
193
|
-
# The below ordering is important.
|
194
|
-
# 1. Numbers can't be method names they are first. If there's a
|
191
|
+
# The below ordering is important.
|
192
|
+
# 1. Numbers can't be method names they are first. If there's a
|
195
193
|
# file with that name, later we'll allow quoting to indicate filename.
|
196
194
|
# 2. filename:position can't also be a method so that's next
|
197
195
|
# 3. It is possible a filename can be a method name, but we
|
@@ -201,8 +199,8 @@ file_colon_line = file_no_colon:file &{ File.exist?(file) } ':' position:pos {
|
|
201
199
|
# without a position, else we would stop early before handling
|
202
200
|
# the position.
|
203
201
|
|
204
|
-
location =
|
205
|
-
position
|
202
|
+
location =
|
203
|
+
position
|
206
204
|
| <filename>:file &{ @file_exists_proc.call(file) } file_pos_sep position:pos {
|
207
205
|
Position.new(:file, file, pos.position_type, pos.position)
|
208
206
|
}
|
data/app/cmd_parse.rb
CHANGED
@@ -1,11 +1,16 @@
|
|
1
1
|
# use_grammar.rb
|
2
2
|
require 'rubygems'
|
3
|
+
require 'redcard/rubinius'
|
3
4
|
require 'require_relative'
|
4
5
|
require_relative 'cmd_parser'
|
5
6
|
|
6
7
|
class Trepan
|
7
8
|
module CmdParser
|
8
9
|
|
10
|
+
def name_fix(name)
|
11
|
+
RedCard.check('1.9') ? name.to_sym : name
|
12
|
+
end
|
13
|
+
|
9
14
|
# Given a KPeg parse object, return the method of that parse or raise a
|
10
15
|
# Name error if we can't find a method. parent_class is the parent class of
|
11
16
|
# the object we've found so far and "binding" is used if we need
|
@@ -27,24 +32,24 @@ class Trepan
|
|
27
32
|
raise NameError, errmsg unless
|
28
33
|
klass.kind_of?(Class) or klass.kind_of?(Module)
|
29
34
|
m = m.chain[1]
|
30
|
-
if klass.instance_methods.member?('binding')
|
35
|
+
if klass.instance_methods.member?(name_fix('binding'))
|
31
36
|
bind = klass.bind
|
32
|
-
elsif klass.private_instance_methods.member?('binding')
|
37
|
+
elsif klass.private_instance_methods.member?(name_fix('binding'))
|
33
38
|
bind = klass.send(:binding)
|
34
39
|
else
|
35
40
|
bind = nil
|
36
41
|
end
|
37
42
|
resolve_method(m, bind, klass)
|
38
|
-
rescue NameError
|
43
|
+
rescue NameError
|
39
44
|
errmsg ||= "Can't resolve constant #{name}"
|
40
45
|
raise NameError, errmsg
|
41
46
|
end
|
42
47
|
else
|
43
|
-
is_class =
|
48
|
+
is_class =
|
44
49
|
begin
|
45
|
-
m.chain && m.chain[0] &&
|
46
|
-
Class == eval("#{m.chain[0].name}.class", bind)
|
47
|
-
rescue
|
50
|
+
m.chain && m.chain[0] &&
|
51
|
+
Class == eval("#{m.chain[0].name}.class", bind)
|
52
|
+
rescue
|
48
53
|
false
|
49
54
|
end
|
50
55
|
if is_class
|
@@ -62,15 +67,15 @@ class Trepan
|
|
62
67
|
parent_obj = eval("#{m.chain[0].name}", bind) if !parent_class && bind
|
63
68
|
end
|
64
69
|
parent = parent_class || parent_obj
|
65
|
-
meth =
|
70
|
+
meth =
|
66
71
|
if parent
|
67
72
|
errmsg << "in #{parent}"
|
68
73
|
lookup_name = m.chain && m.chain[1] ? m.chain[1].name : name
|
69
|
-
if parent.respond_to?('instance_methods') &&
|
70
|
-
parent.instance_methods.member?(lookup_name)
|
71
|
-
parent.instance_method(lookup_name)
|
74
|
+
if parent.respond_to?('instance_methods') &&
|
75
|
+
parent.instance_methods.member?(name_fix(lookup_name))
|
76
|
+
parent.instance_method(name_fix(lookup_name))
|
72
77
|
elsif parent.respond_to?('methods')
|
73
|
-
parent.method(lookup_name)
|
78
|
+
parent.method(name_fix(lookup_name))
|
74
79
|
end
|
75
80
|
elsif m.chain && m.chain[1]
|
76
81
|
eval("#{m.chain[0].name}.method(#{lookup_name.name.inspect})", bind)
|
@@ -95,16 +100,17 @@ class Trepan
|
|
95
100
|
# nil is returned if we can't parse str
|
96
101
|
def meth_for_string(str, start_binding)
|
97
102
|
@cp ? @cp.setup_parser(str) : @cp = CmdParse.new(str)
|
98
|
-
begin
|
103
|
+
begin
|
99
104
|
if @cp._class_module_chain
|
100
105
|
# Did we match all of it?
|
101
106
|
if @cp.result.name == str.strip
|
107
|
+
# require 'trepanning'; debugger
|
102
108
|
meth_for_parse_struct(@cp.result, start_binding)
|
103
109
|
else
|
104
110
|
nil
|
105
111
|
end
|
106
112
|
else
|
107
|
-
# FIXME: change to raise ParseError?
|
113
|
+
# FIXME: change to raise ParseError?
|
108
114
|
nil
|
109
115
|
end
|
110
116
|
rescue NameError
|
@@ -149,7 +155,7 @@ if __FILE__ == $0
|
|
149
155
|
puts "#{name} failed"
|
150
156
|
end
|
151
157
|
end
|
152
|
-
|
158
|
+
|
153
159
|
%w(Object A::B A::B::C A::B::C::D A::B.c A.b.c.d A(5)
|
154
160
|
Rubinius::VariableScope::method_visibility
|
155
161
|
).each do |name|
|
@@ -177,14 +183,14 @@ if __FILE__ == $0
|
|
177
183
|
def testing; 5 end
|
178
184
|
module_function :testing
|
179
185
|
end
|
180
|
-
p meth_for_string('Testing.testing', binding)
|
181
|
-
p meth_for_string('File.basename', binding)
|
186
|
+
p meth_for_string('Testing.testing', binding)
|
187
|
+
p meth_for_string('File.basename', binding)
|
182
188
|
x = File
|
183
189
|
# require_relative '../lib/trepanning'
|
184
190
|
# debugger
|
185
|
-
p meth_for_string('x.basename', binding)
|
191
|
+
p meth_for_string('x.basename', binding)
|
186
192
|
def x.five; 5; end
|
187
|
-
p meth_for_string('x.five', binding)
|
193
|
+
p meth_for_string('x.five', binding)
|
188
194
|
p x.five
|
189
195
|
|
190
196
|
p parse_terminal(:_line_number, '5').result
|
@@ -206,4 +212,3 @@ if __FILE__ == $0
|
|
206
212
|
|
207
213
|
|
208
214
|
end
|
209
|
-
|
data/app/cmd_parser.rb
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
class CmdParse
|
2
|
-
#
|
2
|
+
# :stopdoc:
|
3
|
+
|
4
|
+
# This is distinct from setup_parser so that a standalone parser
|
5
|
+
# can redefine #initialize and still have access to the proper
|
6
|
+
# parser setup code.
|
7
|
+
def initialize(str, debug=false)
|
8
|
+
setup_parser(str, debug)
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
# Prepares for parsing +str+. If you define a custom initialize you must
|
14
|
+
# call this method before #parse
|
3
15
|
def setup_parser(str, debug=false)
|
4
16
|
@string = str
|
5
17
|
@pos = 0
|
@@ -7,21 +19,15 @@ class CmdParse
|
|
7
19
|
@result = nil
|
8
20
|
@failed_rule = nil
|
9
21
|
@failing_rule_offset = -1
|
10
|
-
end
|
11
22
|
|
12
|
-
|
13
|
-
# can redefine #initialize and still have access to the proper
|
14
|
-
# parser setup code.
|
15
|
-
#
|
16
|
-
def initialize(str, debug=false)
|
17
|
-
setup_parser(str, debug)
|
23
|
+
setup_foreign_grammar
|
18
24
|
end
|
19
25
|
|
20
26
|
attr_reader :string
|
21
|
-
attr_reader :
|
22
|
-
attr_accessor :pos
|
27
|
+
attr_reader :failing_rule_offset
|
28
|
+
attr_accessor :result, :pos
|
23
29
|
|
24
|
-
|
30
|
+
|
25
31
|
def current_column(target=pos)
|
26
32
|
if c = string.rindex("\n", target-1)
|
27
33
|
return target - c - 1
|
@@ -49,7 +55,7 @@ class CmdParse
|
|
49
55
|
lines
|
50
56
|
end
|
51
57
|
|
52
|
-
|
58
|
+
|
53
59
|
|
54
60
|
def get_text(start)
|
55
61
|
@string[start..@pos-1]
|
@@ -67,9 +73,13 @@ class CmdParse
|
|
67
73
|
def failure_info
|
68
74
|
l = current_line @failing_rule_offset
|
69
75
|
c = current_column @failing_rule_offset
|
70
|
-
info = self.class::Rules[@failed_rule]
|
71
76
|
|
72
|
-
|
77
|
+
if @failed_rule.kind_of? Symbol
|
78
|
+
info = self.class::Rules[@failed_rule]
|
79
|
+
"line #{l}, column #{c}: failed rule '#{info.name}' = '#{info.rendered}'"
|
80
|
+
else
|
81
|
+
"line #{l}, column #{c}: failed rule '#{@failed_rule}'"
|
82
|
+
end
|
73
83
|
end
|
74
84
|
|
75
85
|
def failure_caret
|
@@ -90,10 +100,14 @@ class CmdParse
|
|
90
100
|
l = current_line @failing_rule_offset
|
91
101
|
c = current_column @failing_rule_offset
|
92
102
|
|
93
|
-
info = self.class::Rules[@failed_rule]
|
94
103
|
char = lines[l-1][c-1, 1]
|
95
104
|
|
96
|
-
|
105
|
+
if @failed_rule.kind_of? Symbol
|
106
|
+
info = self.class::Rules[@failed_rule]
|
107
|
+
"@#{l}:#{c} failed rule '#{info.name}', got '#{char}'"
|
108
|
+
else
|
109
|
+
"@#{l}:#{c} failed rule '#{@failed_rule}', got '#{char}'"
|
110
|
+
end
|
97
111
|
end
|
98
112
|
|
99
113
|
class ParseError < RuntimeError
|
@@ -108,9 +122,15 @@ class CmdParse
|
|
108
122
|
line_no = current_line(error_pos)
|
109
123
|
col_no = current_column(error_pos)
|
110
124
|
|
111
|
-
info = self.class::Rules[@failed_rule]
|
112
125
|
io.puts "On line #{line_no}, column #{col_no}:"
|
113
|
-
|
126
|
+
|
127
|
+
if @failed_rule.kind_of? Symbol
|
128
|
+
info = self.class::Rules[@failed_rule]
|
129
|
+
io.puts "Failed to match '#{info.rendered}' (rule '#{info.name}')"
|
130
|
+
else
|
131
|
+
io.puts "Failed to match rule '#{@failed_rule}'"
|
132
|
+
end
|
133
|
+
|
114
134
|
io.puts "Got: #{string[error_pos,1].inspect}"
|
115
135
|
line = lines[line_no-1]
|
116
136
|
io.puts "=> #{line}"
|
@@ -169,47 +189,102 @@ class CmdParse
|
|
169
189
|
end
|
170
190
|
end
|
171
191
|
|
172
|
-
def parse
|
173
|
-
|
174
|
-
|
192
|
+
def parse(rule=nil)
|
193
|
+
# We invoke the rules indirectly via apply
|
194
|
+
# instead of by just calling them as methods because
|
195
|
+
# if the rules use left recursion, apply needs to
|
196
|
+
# manage that.
|
175
197
|
|
176
|
-
|
177
|
-
|
178
|
-
|
198
|
+
if !rule
|
199
|
+
apply(:_root)
|
200
|
+
else
|
201
|
+
method = rule.gsub("-","_hyphen_")
|
202
|
+
apply :"_#{method}"
|
179
203
|
end
|
180
|
-
|
181
|
-
attr_accessor :detected
|
182
204
|
end
|
183
205
|
|
184
206
|
class MemoEntry
|
185
207
|
def initialize(ans, pos)
|
186
208
|
@ans = ans
|
187
209
|
@pos = pos
|
188
|
-
@uses = 1
|
189
210
|
@result = nil
|
211
|
+
@set = false
|
212
|
+
@left_rec = false
|
190
213
|
end
|
191
214
|
|
192
|
-
attr_reader :ans, :pos, :
|
193
|
-
|
194
|
-
def inc!
|
195
|
-
@uses += 1
|
196
|
-
end
|
215
|
+
attr_reader :ans, :pos, :result, :set
|
216
|
+
attr_accessor :left_rec
|
197
217
|
|
198
218
|
def move!(ans, pos, result)
|
199
219
|
@ans = ans
|
200
220
|
@pos = pos
|
201
221
|
@result = result
|
222
|
+
@set = true
|
223
|
+
@left_rec = false
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
def external_invoke(other, rule, *args)
|
228
|
+
old_pos = @pos
|
229
|
+
old_string = @string
|
230
|
+
|
231
|
+
@pos = other.pos
|
232
|
+
@string = other.string
|
233
|
+
|
234
|
+
begin
|
235
|
+
if val = __send__(rule, *args)
|
236
|
+
other.pos = @pos
|
237
|
+
other.result = @result
|
238
|
+
else
|
239
|
+
other.set_failed_rule "#{self.class}##{rule}"
|
240
|
+
end
|
241
|
+
val
|
242
|
+
ensure
|
243
|
+
@pos = old_pos
|
244
|
+
@string = old_string
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
def apply_with_args(rule, *args)
|
249
|
+
memo_key = [rule, args]
|
250
|
+
if m = @memoizations[memo_key][@pos]
|
251
|
+
@pos = m.pos
|
252
|
+
if !m.set
|
253
|
+
m.left_rec = true
|
254
|
+
return nil
|
255
|
+
end
|
256
|
+
|
257
|
+
@result = m.result
|
258
|
+
|
259
|
+
return m.ans
|
260
|
+
else
|
261
|
+
m = MemoEntry.new(nil, @pos)
|
262
|
+
@memoizations[memo_key][@pos] = m
|
263
|
+
start_pos = @pos
|
264
|
+
|
265
|
+
ans = __send__ rule, *args
|
266
|
+
|
267
|
+
lr = m.left_rec
|
268
|
+
|
269
|
+
m.move! ans, @pos, @result
|
270
|
+
|
271
|
+
# Don't bother trying to grow the left recursion
|
272
|
+
# if it's failing straight away (thus there is no seed)
|
273
|
+
if ans and lr
|
274
|
+
return grow_lr(rule, args, start_pos, m)
|
275
|
+
else
|
276
|
+
return ans
|
277
|
+
end
|
278
|
+
|
279
|
+
return ans
|
202
280
|
end
|
203
281
|
end
|
204
282
|
|
205
283
|
def apply(rule)
|
206
284
|
if m = @memoizations[rule][@pos]
|
207
|
-
m.inc!
|
208
|
-
|
209
|
-
prev = @pos
|
210
285
|
@pos = m.pos
|
211
|
-
if m.
|
212
|
-
m.
|
286
|
+
if !m.set
|
287
|
+
m.left_rec = true
|
213
288
|
return nil
|
214
289
|
end
|
215
290
|
|
@@ -217,19 +292,20 @@ class CmdParse
|
|
217
292
|
|
218
293
|
return m.ans
|
219
294
|
else
|
220
|
-
|
221
|
-
m = MemoEntry.new(lr, @pos)
|
295
|
+
m = MemoEntry.new(nil, @pos)
|
222
296
|
@memoizations[rule][@pos] = m
|
223
297
|
start_pos = @pos
|
224
298
|
|
225
299
|
ans = __send__ rule
|
226
300
|
|
301
|
+
lr = m.left_rec
|
302
|
+
|
227
303
|
m.move! ans, @pos, @result
|
228
304
|
|
229
305
|
# Don't bother trying to grow the left recursion
|
230
306
|
# if it's failing straight away (thus there is no seed)
|
231
|
-
if ans and lr
|
232
|
-
return grow_lr(rule, start_pos, m)
|
307
|
+
if ans and lr
|
308
|
+
return grow_lr(rule, nil, start_pos, m)
|
233
309
|
else
|
234
310
|
return ans
|
235
311
|
end
|
@@ -238,12 +314,16 @@ class CmdParse
|
|
238
314
|
end
|
239
315
|
end
|
240
316
|
|
241
|
-
def grow_lr(rule, start_pos, m)
|
317
|
+
def grow_lr(rule, args, start_pos, m)
|
242
318
|
while true
|
243
319
|
@pos = start_pos
|
244
320
|
@result = m.result
|
245
321
|
|
246
|
-
|
322
|
+
if args
|
323
|
+
ans = __send__ rule, *args
|
324
|
+
else
|
325
|
+
ans = __send__ rule
|
326
|
+
end
|
247
327
|
return nil unless ans
|
248
328
|
|
249
329
|
break if @pos <= m.pos
|
@@ -269,10 +349,11 @@ class CmdParse
|
|
269
349
|
RuleInfo.new(name, rendered)
|
270
350
|
end
|
271
351
|
|
272
|
-
|
352
|
+
|
353
|
+
# :startdoc:
|
273
354
|
|
274
355
|
|
275
|
-
#####################################################
|
356
|
+
#####################################################
|
276
357
|
# Structure to hold composite method names
|
277
358
|
SymbolEntry = Struct.new(:type, :name, :chain)
|
278
359
|
|
@@ -288,7 +369,7 @@ class CmdParse
|
|
288
369
|
List = Struct.new(:position, :num)
|
289
370
|
|
290
371
|
DEFAULT_OPTS = {
|
291
|
-
:debug=>false,
|
372
|
+
:debug=>false,
|
292
373
|
:file_exists_proc => Proc.new{|filename|
|
293
374
|
File.readable?(filename) && !File.directory?(filename)
|
294
375
|
}
|
@@ -302,6 +383,8 @@ class CmdParse
|
|
302
383
|
|
303
384
|
|
304
385
|
|
386
|
+
# :stopdoc:
|
387
|
+
def setup_foreign_grammar; end
|
305
388
|
|
306
389
|
# upcase_letter = /[A-Z]/
|
307
390
|
def _upcase_letter
|
@@ -370,17 +453,17 @@ class CmdParse
|
|
370
453
|
return _tmp
|
371
454
|
end
|
372
455
|
|
373
|
-
# vm_identifier = < (downcase_letter | "_") id_symbol* suffix_letter? > {
|
456
|
+
# vm_identifier = < (downcase_letter | "_") id_symbol* suffix_letter? > { SymbolEntry.new(:variable, text) }
|
374
457
|
def _vm_identifier
|
375
458
|
|
376
459
|
_save = self.pos
|
377
460
|
while true # sequence
|
378
461
|
_text_start = self.pos
|
379
|
-
|
380
|
-
|
462
|
+
|
463
|
+
_save1 = self.pos
|
381
464
|
while true # sequence
|
382
|
-
|
383
|
-
|
465
|
+
|
466
|
+
_save2 = self.pos
|
384
467
|
while true # choice
|
385
468
|
_tmp = apply(:_downcase_letter)
|
386
469
|
break if _tmp
|
@@ -423,7 +506,7 @@ class CmdParse
|
|
423
506
|
self.pos = _save
|
424
507
|
break
|
425
508
|
end
|
426
|
-
@result = begin;
|
509
|
+
@result = begin;
|
427
510
|
SymbolEntry.new(:variable, text)
|
428
511
|
; end
|
429
512
|
_tmp = true
|
@@ -437,17 +520,17 @@ class CmdParse
|
|
437
520
|
return _tmp
|
438
521
|
end
|
439
522
|
|
440
|
-
# variable_identifier = < (downcase_letter | "_") id_symbol* > {
|
523
|
+
# variable_identifier = < (downcase_letter | "_") id_symbol* > { SymbolEntry.new(:variable, text) }
|
441
524
|
def _variable_identifier
|
442
525
|
|
443
526
|
_save = self.pos
|
444
527
|
while true # sequence
|
445
528
|
_text_start = self.pos
|
446
|
-
|
447
|
-
|
529
|
+
|
530
|
+
_save1 = self.pos
|
448
531
|
while true # sequence
|
449
|
-
|
450
|
-
|
532
|
+
|
533
|
+
_save2 = self.pos
|
451
534
|
while true # choice
|
452
535
|
_tmp = apply(:_downcase_letter)
|
453
536
|
break if _tmp
|
@@ -480,7 +563,7 @@ class CmdParse
|
|
480
563
|
self.pos = _save
|
481
564
|
break
|
482
565
|
end
|
483
|
-
@result = begin;
|
566
|
+
@result = begin;
|
484
567
|
SymbolEntry.new(:variable, text)
|
485
568
|
; end
|
486
569
|
_tmp = true
|
@@ -494,14 +577,14 @@ class CmdParse
|
|
494
577
|
return _tmp
|
495
578
|
end
|
496
579
|
|
497
|
-
# constant_identifier = < upcase_letter id_symbol* > {
|
580
|
+
# constant_identifier = < upcase_letter id_symbol* > { SymbolEntry.new(:constant, text) }
|
498
581
|
def _constant_identifier
|
499
582
|
|
500
583
|
_save = self.pos
|
501
584
|
while true # sequence
|
502
585
|
_text_start = self.pos
|
503
|
-
|
504
|
-
|
586
|
+
|
587
|
+
_save1 = self.pos
|
505
588
|
while true # sequence
|
506
589
|
_tmp = apply(:_upcase_letter)
|
507
590
|
unless _tmp
|
@@ -526,7 +609,7 @@ class CmdParse
|
|
526
609
|
self.pos = _save
|
527
610
|
break
|
528
611
|
end
|
529
|
-
@result = begin;
|
612
|
+
@result = begin;
|
530
613
|
SymbolEntry.new(:constant, text)
|
531
614
|
; end
|
532
615
|
_tmp = true
|
@@ -546,16 +629,16 @@ class CmdParse
|
|
546
629
|
_save = self.pos
|
547
630
|
while true # sequence
|
548
631
|
_text_start = self.pos
|
549
|
-
|
550
|
-
|
632
|
+
|
633
|
+
_save1 = self.pos
|
551
634
|
while true # sequence
|
552
635
|
_tmp = match_string("$")
|
553
636
|
unless _tmp
|
554
637
|
self.pos = _save1
|
555
638
|
break
|
556
639
|
end
|
557
|
-
|
558
|
-
|
640
|
+
|
641
|
+
_save2 = self.pos
|
559
642
|
while true # choice
|
560
643
|
_tmp = apply(:_constant_identifier)
|
561
644
|
break if _tmp
|
@@ -579,7 +662,7 @@ class CmdParse
|
|
579
662
|
self.pos = _save
|
580
663
|
break
|
581
664
|
end
|
582
|
-
@result = begin;
|
665
|
+
@result = begin;
|
583
666
|
SymbolEntry.new(:global, text)
|
584
667
|
; end
|
585
668
|
_tmp = true
|
@@ -635,8 +718,8 @@ class CmdParse
|
|
635
718
|
_save = self.pos
|
636
719
|
while true # sequence
|
637
720
|
_text_start = self.pos
|
638
|
-
|
639
|
-
|
721
|
+
|
722
|
+
_save1 = self.pos
|
640
723
|
while true # sequence
|
641
724
|
_tmp = match_string("@")
|
642
725
|
unless _tmp
|
@@ -657,7 +740,7 @@ class CmdParse
|
|
657
740
|
self.pos = _save
|
658
741
|
break
|
659
742
|
end
|
660
|
-
@result = begin;
|
743
|
+
@result = begin;
|
661
744
|
SymbolEntry.new(:instance, text)
|
662
745
|
; end
|
663
746
|
_tmp = true
|
@@ -687,7 +770,7 @@ class CmdParse
|
|
687
770
|
self.pos = _save
|
688
771
|
break
|
689
772
|
end
|
690
|
-
@result = begin;
|
773
|
+
@result = begin;
|
691
774
|
SymbolEntry.new(:classvar, id)
|
692
775
|
; end
|
693
776
|
_tmp = true
|
@@ -731,8 +814,8 @@ class CmdParse
|
|
731
814
|
_save = self.pos
|
732
815
|
while true # sequence
|
733
816
|
_text_start = self.pos
|
734
|
-
|
735
|
-
|
817
|
+
|
818
|
+
_save1 = self.pos
|
736
819
|
while true # choice
|
737
820
|
_tmp = match_string("::")
|
738
821
|
break if _tmp
|
@@ -750,7 +833,7 @@ class CmdParse
|
|
750
833
|
self.pos = _save
|
751
834
|
break
|
752
835
|
end
|
753
|
-
@result = begin;
|
836
|
+
@result = begin; text ; end
|
754
837
|
_tmp = true
|
755
838
|
unless _tmp
|
756
839
|
self.pos = _save
|
@@ -767,12 +850,12 @@ class CmdParse
|
|
767
850
|
|
768
851
|
_save = self.pos
|
769
852
|
while true # choice
|
770
|
-
|
771
|
-
|
853
|
+
|
854
|
+
_save1 = self.pos
|
772
855
|
while true # sequence
|
773
856
|
_text_start = self.pos
|
774
|
-
|
775
|
-
|
857
|
+
|
858
|
+
_save2 = self.pos
|
776
859
|
while true # sequence
|
777
860
|
_tmp = apply(:_local_internal_identifier)
|
778
861
|
parent = @result
|
@@ -801,7 +884,7 @@ class CmdParse
|
|
801
884
|
self.pos = _save1
|
802
885
|
break
|
803
886
|
end
|
804
|
-
@result = begin;
|
887
|
+
@result = begin;
|
805
888
|
SymbolEntry.new(parent.type, text, [parent, child, sep])
|
806
889
|
; end
|
807
890
|
_tmp = true
|
@@ -828,12 +911,12 @@ class CmdParse
|
|
828
911
|
|
829
912
|
_save = self.pos
|
830
913
|
while true # choice
|
831
|
-
|
832
|
-
|
914
|
+
|
915
|
+
_save1 = self.pos
|
833
916
|
while true # sequence
|
834
917
|
_text_start = self.pos
|
835
|
-
|
836
|
-
|
918
|
+
|
919
|
+
_save2 = self.pos
|
837
920
|
while true # sequence
|
838
921
|
_tmp = apply(:_identifier)
|
839
922
|
parent = @result
|
@@ -862,7 +945,7 @@ class CmdParse
|
|
862
945
|
self.pos = _save1
|
863
946
|
break
|
864
947
|
end
|
865
|
-
@result = begin;
|
948
|
+
@result = begin;
|
866
949
|
SymbolEntry.new(parent.type, text, [parent, child, sep])
|
867
950
|
; end
|
868
951
|
_tmp = true
|
@@ -910,83 +993,83 @@ class CmdParse
|
|
910
993
|
|
911
994
|
# dbl_escapes = ("\\\"" { '"' } | "\\n" { "\n" } | "\\t" { "\t" } | "\\\\" { "\\" })
|
912
995
|
def _dbl_escapes
|
913
|
-
|
996
|
+
|
914
997
|
_save = self.pos
|
915
|
-
|
916
|
-
|
917
|
-
_save1 = self.pos
|
918
|
-
while true # sequence
|
919
|
-
_tmp = match_string("\\\"")
|
920
|
-
unless _tmp
|
921
|
-
self.pos = _save1
|
922
|
-
break
|
923
|
-
end
|
924
|
-
@result = begin; '"' ; end
|
925
|
-
_tmp = true
|
926
|
-
unless _tmp
|
927
|
-
self.pos = _save1
|
928
|
-
end
|
929
|
-
break
|
930
|
-
end # end sequence
|
998
|
+
while true # choice
|
931
999
|
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
_tmp = match_string("\\n")
|
938
|
-
unless _tmp
|
939
|
-
self.pos = _save2
|
940
|
-
break
|
941
|
-
end
|
942
|
-
@result = begin; "\n" ; end
|
943
|
-
_tmp = true
|
944
|
-
unless _tmp
|
945
|
-
self.pos = _save2
|
946
|
-
end
|
1000
|
+
_save1 = self.pos
|
1001
|
+
while true # sequence
|
1002
|
+
_tmp = match_string("\\\"")
|
1003
|
+
unless _tmp
|
1004
|
+
self.pos = _save1
|
947
1005
|
break
|
948
|
-
end
|
1006
|
+
end
|
1007
|
+
@result = begin; '"' ; end
|
1008
|
+
_tmp = true
|
1009
|
+
unless _tmp
|
1010
|
+
self.pos = _save1
|
1011
|
+
end
|
1012
|
+
break
|
1013
|
+
end # end sequence
|
949
1014
|
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
break
|
959
|
-
end
|
960
|
-
@result = begin; "\t" ; end
|
961
|
-
_tmp = true
|
962
|
-
unless _tmp
|
963
|
-
self.pos = _save3
|
964
|
-
end
|
1015
|
+
break if _tmp
|
1016
|
+
self.pos = _save
|
1017
|
+
|
1018
|
+
_save2 = self.pos
|
1019
|
+
while true # sequence
|
1020
|
+
_tmp = match_string("\\n")
|
1021
|
+
unless _tmp
|
1022
|
+
self.pos = _save2
|
965
1023
|
break
|
966
|
-
end
|
1024
|
+
end
|
1025
|
+
@result = begin; "\n" ; end
|
1026
|
+
_tmp = true
|
1027
|
+
unless _tmp
|
1028
|
+
self.pos = _save2
|
1029
|
+
end
|
1030
|
+
break
|
1031
|
+
end # end sequence
|
967
1032
|
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
break
|
977
|
-
end
|
978
|
-
@result = begin; "\\" ; end
|
979
|
-
_tmp = true
|
980
|
-
unless _tmp
|
981
|
-
self.pos = _save4
|
982
|
-
end
|
1033
|
+
break if _tmp
|
1034
|
+
self.pos = _save
|
1035
|
+
|
1036
|
+
_save3 = self.pos
|
1037
|
+
while true # sequence
|
1038
|
+
_tmp = match_string("\\t")
|
1039
|
+
unless _tmp
|
1040
|
+
self.pos = _save3
|
983
1041
|
break
|
984
|
-
end
|
1042
|
+
end
|
1043
|
+
@result = begin; "\t" ; end
|
1044
|
+
_tmp = true
|
1045
|
+
unless _tmp
|
1046
|
+
self.pos = _save3
|
1047
|
+
end
|
1048
|
+
break
|
1049
|
+
end # end sequence
|
985
1050
|
|
986
|
-
|
987
|
-
|
1051
|
+
break if _tmp
|
1052
|
+
self.pos = _save
|
1053
|
+
|
1054
|
+
_save4 = self.pos
|
1055
|
+
while true # sequence
|
1056
|
+
_tmp = match_string("\\\\")
|
1057
|
+
unless _tmp
|
1058
|
+
self.pos = _save4
|
1059
|
+
break
|
1060
|
+
end
|
1061
|
+
@result = begin; "\\" ; end
|
1062
|
+
_tmp = true
|
1063
|
+
unless _tmp
|
1064
|
+
self.pos = _save4
|
1065
|
+
end
|
988
1066
|
break
|
989
|
-
end # end
|
1067
|
+
end # end sequence
|
1068
|
+
|
1069
|
+
break if _tmp
|
1070
|
+
self.pos = _save
|
1071
|
+
break
|
1072
|
+
end # end choice
|
990
1073
|
|
991
1074
|
set_failed_rule :_dbl_escapes unless _tmp
|
992
1075
|
return _tmp
|
@@ -994,204 +1077,204 @@ class CmdParse
|
|
994
1077
|
|
995
1078
|
# escapes = ("\\\"" { '"' } | "\\n" { "\n" } | "\\t" { "\t" } | "\\ " { " " } | "\\:" { ":" } | "\\\\" { "\\" })
|
996
1079
|
def _escapes
|
997
|
-
|
1080
|
+
|
998
1081
|
_save = self.pos
|
999
|
-
|
1000
|
-
|
1001
|
-
_save1 = self.pos
|
1002
|
-
while true # sequence
|
1003
|
-
_tmp = match_string("\\\"")
|
1004
|
-
unless _tmp
|
1005
|
-
self.pos = _save1
|
1006
|
-
break
|
1007
|
-
end
|
1008
|
-
@result = begin; '"' ; end
|
1009
|
-
_tmp = true
|
1010
|
-
unless _tmp
|
1011
|
-
self.pos = _save1
|
1012
|
-
end
|
1013
|
-
break
|
1014
|
-
end # end sequence
|
1082
|
+
while true # choice
|
1015
1083
|
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
_tmp = match_string("\\n")
|
1022
|
-
unless _tmp
|
1023
|
-
self.pos = _save2
|
1024
|
-
break
|
1025
|
-
end
|
1026
|
-
@result = begin; "\n" ; end
|
1027
|
-
_tmp = true
|
1028
|
-
unless _tmp
|
1029
|
-
self.pos = _save2
|
1030
|
-
end
|
1084
|
+
_save1 = self.pos
|
1085
|
+
while true # sequence
|
1086
|
+
_tmp = match_string("\\\"")
|
1087
|
+
unless _tmp
|
1088
|
+
self.pos = _save1
|
1031
1089
|
break
|
1032
|
-
end
|
1090
|
+
end
|
1091
|
+
@result = begin; '"' ; end
|
1092
|
+
_tmp = true
|
1093
|
+
unless _tmp
|
1094
|
+
self.pos = _save1
|
1095
|
+
end
|
1096
|
+
break
|
1097
|
+
end # end sequence
|
1033
1098
|
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
_save3 = self.pos
|
1038
|
-
while true # sequence
|
1039
|
-
_tmp = match_string("\\t")
|
1040
|
-
unless _tmp
|
1041
|
-
self.pos = _save3
|
1042
|
-
break
|
1043
|
-
end
|
1044
|
-
@result = begin; "\t" ; end
|
1045
|
-
_tmp = true
|
1046
|
-
unless _tmp
|
1047
|
-
self.pos = _save3
|
1048
|
-
end
|
1049
|
-
break
|
1050
|
-
end # end sequence
|
1099
|
+
break if _tmp
|
1100
|
+
self.pos = _save
|
1051
1101
|
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
_tmp = match_string("\\ ")
|
1058
|
-
unless _tmp
|
1059
|
-
self.pos = _save4
|
1060
|
-
break
|
1061
|
-
end
|
1062
|
-
@result = begin; " " ; end
|
1063
|
-
_tmp = true
|
1064
|
-
unless _tmp
|
1065
|
-
self.pos = _save4
|
1066
|
-
end
|
1102
|
+
_save2 = self.pos
|
1103
|
+
while true # sequence
|
1104
|
+
_tmp = match_string("\\n")
|
1105
|
+
unless _tmp
|
1106
|
+
self.pos = _save2
|
1067
1107
|
break
|
1068
|
-
end
|
1108
|
+
end
|
1109
|
+
@result = begin; "\n" ; end
|
1110
|
+
_tmp = true
|
1111
|
+
unless _tmp
|
1112
|
+
self.pos = _save2
|
1113
|
+
end
|
1114
|
+
break
|
1115
|
+
end # end sequence
|
1069
1116
|
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
_save5 = self.pos
|
1074
|
-
while true # sequence
|
1075
|
-
_tmp = match_string("\\:")
|
1076
|
-
unless _tmp
|
1077
|
-
self.pos = _save5
|
1078
|
-
break
|
1079
|
-
end
|
1080
|
-
@result = begin; ":" ; end
|
1081
|
-
_tmp = true
|
1082
|
-
unless _tmp
|
1083
|
-
self.pos = _save5
|
1084
|
-
end
|
1085
|
-
break
|
1086
|
-
end # end sequence
|
1117
|
+
break if _tmp
|
1118
|
+
self.pos = _save
|
1087
1119
|
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
_tmp = match_string("\\\\")
|
1094
|
-
unless _tmp
|
1095
|
-
self.pos = _save6
|
1096
|
-
break
|
1097
|
-
end
|
1098
|
-
@result = begin; "\\" ; end
|
1099
|
-
_tmp = true
|
1100
|
-
unless _tmp
|
1101
|
-
self.pos = _save6
|
1102
|
-
end
|
1120
|
+
_save3 = self.pos
|
1121
|
+
while true # sequence
|
1122
|
+
_tmp = match_string("\\t")
|
1123
|
+
unless _tmp
|
1124
|
+
self.pos = _save3
|
1103
1125
|
break
|
1104
|
-
end
|
1126
|
+
end
|
1127
|
+
@result = begin; "\t" ; end
|
1128
|
+
_tmp = true
|
1129
|
+
unless _tmp
|
1130
|
+
self.pos = _save3
|
1131
|
+
end
|
1132
|
+
break
|
1133
|
+
end # end sequence
|
1105
1134
|
|
1106
|
-
|
1107
|
-
|
1135
|
+
break if _tmp
|
1136
|
+
self.pos = _save
|
1137
|
+
|
1138
|
+
_save4 = self.pos
|
1139
|
+
while true # sequence
|
1140
|
+
_tmp = match_string("\\ ")
|
1141
|
+
unless _tmp
|
1142
|
+
self.pos = _save4
|
1143
|
+
break
|
1144
|
+
end
|
1145
|
+
@result = begin; " " ; end
|
1146
|
+
_tmp = true
|
1147
|
+
unless _tmp
|
1148
|
+
self.pos = _save4
|
1149
|
+
end
|
1108
1150
|
break
|
1109
|
-
end # end
|
1151
|
+
end # end sequence
|
1110
1152
|
|
1111
|
-
|
1112
|
-
|
1113
|
-
end
|
1153
|
+
break if _tmp
|
1154
|
+
self.pos = _save
|
1114
1155
|
|
1115
|
-
|
1116
|
-
def _dbl_seq
|
1117
|
-
|
1118
|
-
_save = self.pos
|
1156
|
+
_save5 = self.pos
|
1119
1157
|
while true # sequence
|
1120
|
-
|
1121
|
-
_tmp
|
1122
|
-
|
1123
|
-
|
1158
|
+
_tmp = match_string("\\:")
|
1159
|
+
unless _tmp
|
1160
|
+
self.pos = _save5
|
1161
|
+
break
|
1162
|
+
end
|
1163
|
+
@result = begin; ":" ; end
|
1164
|
+
_tmp = true
|
1165
|
+
unless _tmp
|
1166
|
+
self.pos = _save5
|
1124
1167
|
end
|
1168
|
+
break
|
1169
|
+
end # end sequence
|
1170
|
+
|
1171
|
+
break if _tmp
|
1172
|
+
self.pos = _save
|
1173
|
+
|
1174
|
+
_save6 = self.pos
|
1175
|
+
while true # sequence
|
1176
|
+
_tmp = match_string("\\\\")
|
1125
1177
|
unless _tmp
|
1126
|
-
self.pos =
|
1178
|
+
self.pos = _save6
|
1127
1179
|
break
|
1128
1180
|
end
|
1129
|
-
@result = begin;
|
1181
|
+
@result = begin; "\\" ; end
|
1130
1182
|
_tmp = true
|
1131
1183
|
unless _tmp
|
1132
|
-
self.pos =
|
1184
|
+
self.pos = _save6
|
1133
1185
|
end
|
1134
1186
|
break
|
1135
1187
|
end # end sequence
|
1136
1188
|
|
1189
|
+
break if _tmp
|
1190
|
+
self.pos = _save
|
1191
|
+
break
|
1192
|
+
end # end choice
|
1193
|
+
|
1194
|
+
set_failed_rule :_escapes unless _tmp
|
1195
|
+
return _tmp
|
1196
|
+
end
|
1197
|
+
|
1198
|
+
# dbl_seq = < /[^\\"]+/ > { text }
|
1199
|
+
def _dbl_seq
|
1200
|
+
|
1201
|
+
_save = self.pos
|
1202
|
+
while true # sequence
|
1203
|
+
_text_start = self.pos
|
1204
|
+
_tmp = scan(/\A(?-mix:[^\\"]+)/)
|
1205
|
+
if _tmp
|
1206
|
+
text = get_text(_text_start)
|
1207
|
+
end
|
1208
|
+
unless _tmp
|
1209
|
+
self.pos = _save
|
1210
|
+
break
|
1211
|
+
end
|
1212
|
+
@result = begin; text ; end
|
1213
|
+
_tmp = true
|
1214
|
+
unless _tmp
|
1215
|
+
self.pos = _save
|
1216
|
+
end
|
1217
|
+
break
|
1218
|
+
end # end sequence
|
1219
|
+
|
1137
1220
|
set_failed_rule :_dbl_seq unless _tmp
|
1138
1221
|
return _tmp
|
1139
1222
|
end
|
1140
1223
|
|
1141
1224
|
# dbl_not_quote = (dbl_escapes | dbl_seq)+:ary { ary }
|
1142
1225
|
def _dbl_not_quote
|
1143
|
-
|
1226
|
+
|
1144
1227
|
_save = self.pos
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
_save2 = self.pos
|
1150
|
-
while true # choice
|
1151
|
-
_tmp = apply(:_dbl_escapes)
|
1152
|
-
break if _tmp
|
1153
|
-
self.pos = _save2
|
1154
|
-
_tmp = apply(:_dbl_seq)
|
1155
|
-
break if _tmp
|
1156
|
-
self.pos = _save2
|
1157
|
-
break
|
1158
|
-
end # end choice
|
1228
|
+
while true # sequence
|
1229
|
+
_save1 = self.pos
|
1230
|
+
_ary = []
|
1159
1231
|
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1173
|
-
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1183
|
-
ary = @result
|
1184
|
-
unless _tmp
|
1185
|
-
self.pos = _save
|
1232
|
+
_save2 = self.pos
|
1233
|
+
while true # choice
|
1234
|
+
_tmp = apply(:_dbl_escapes)
|
1235
|
+
break if _tmp
|
1236
|
+
self.pos = _save2
|
1237
|
+
_tmp = apply(:_dbl_seq)
|
1238
|
+
break if _tmp
|
1239
|
+
self.pos = _save2
|
1240
|
+
break
|
1241
|
+
end # end choice
|
1242
|
+
|
1243
|
+
if _tmp
|
1244
|
+
_ary << @result
|
1245
|
+
while true
|
1246
|
+
|
1247
|
+
_save3 = self.pos
|
1248
|
+
while true # choice
|
1249
|
+
_tmp = apply(:_dbl_escapes)
|
1250
|
+
break if _tmp
|
1251
|
+
self.pos = _save3
|
1252
|
+
_tmp = apply(:_dbl_seq)
|
1253
|
+
break if _tmp
|
1254
|
+
self.pos = _save3
|
1186
1255
|
break
|
1187
|
-
end
|
1188
|
-
|
1189
|
-
|
1190
|
-
unless _tmp
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1256
|
+
end # end choice
|
1257
|
+
|
1258
|
+
_ary << @result if _tmp
|
1259
|
+
break unless _tmp
|
1260
|
+
end
|
1261
|
+
_tmp = true
|
1262
|
+
@result = _ary
|
1263
|
+
else
|
1264
|
+
self.pos = _save1
|
1265
|
+
end
|
1266
|
+
ary = @result
|
1267
|
+
unless _tmp
|
1268
|
+
self.pos = _save
|
1269
|
+
break
|
1270
|
+
end
|
1271
|
+
@result = begin; ary ; end
|
1272
|
+
_tmp = true
|
1273
|
+
unless _tmp
|
1274
|
+
self.pos = _save
|
1275
|
+
end
|
1276
|
+
break
|
1277
|
+
end # end sequence
|
1195
1278
|
|
1196
1279
|
set_failed_rule :_dbl_not_quote unless _tmp
|
1197
1280
|
return _tmp
|
@@ -1199,32 +1282,32 @@ class CmdParse
|
|
1199
1282
|
|
1200
1283
|
# dbl_string = "\"" dbl_not_quote:ary "\"" { ary.join }
|
1201
1284
|
def _dbl_string
|
1202
|
-
|
1285
|
+
|
1203
1286
|
_save = self.pos
|
1204
|
-
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
1227
|
-
|
1287
|
+
while true # sequence
|
1288
|
+
_tmp = match_string("\"")
|
1289
|
+
unless _tmp
|
1290
|
+
self.pos = _save
|
1291
|
+
break
|
1292
|
+
end
|
1293
|
+
_tmp = apply(:_dbl_not_quote)
|
1294
|
+
ary = @result
|
1295
|
+
unless _tmp
|
1296
|
+
self.pos = _save
|
1297
|
+
break
|
1298
|
+
end
|
1299
|
+
_tmp = match_string("\"")
|
1300
|
+
unless _tmp
|
1301
|
+
self.pos = _save
|
1302
|
+
break
|
1303
|
+
end
|
1304
|
+
@result = begin; ary.join ; end
|
1305
|
+
_tmp = true
|
1306
|
+
unless _tmp
|
1307
|
+
self.pos = _save
|
1308
|
+
end
|
1309
|
+
break
|
1310
|
+
end # end sequence
|
1228
1311
|
|
1229
1312
|
set_failed_rule :_dbl_string unless _tmp
|
1230
1313
|
return _tmp
|
@@ -1232,36 +1315,36 @@ class CmdParse
|
|
1232
1315
|
|
1233
1316
|
# not_space_colon = (escapes | < /[^ \t\n:]/ > { text })
|
1234
1317
|
def _not_space_colon
|
1235
|
-
|
1318
|
+
|
1236
1319
|
_save = self.pos
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1242
|
-
_save1 = self.pos
|
1243
|
-
while true # sequence
|
1244
|
-
_text_start = self.pos
|
1245
|
-
_tmp = scan(/\A(?-mix:[^ \t\n:])/)
|
1246
|
-
if _tmp
|
1247
|
-
text = get_text(_text_start)
|
1248
|
-
end
|
1249
|
-
unless _tmp
|
1250
|
-
self.pos = _save1
|
1251
|
-
break
|
1252
|
-
end
|
1253
|
-
@result = begin; text ; end
|
1254
|
-
_tmp = true
|
1255
|
-
unless _tmp
|
1256
|
-
self.pos = _save1
|
1257
|
-
end
|
1258
|
-
break
|
1259
|
-
end # end sequence
|
1320
|
+
while true # choice
|
1321
|
+
_tmp = apply(:_escapes)
|
1322
|
+
break if _tmp
|
1323
|
+
self.pos = _save
|
1260
1324
|
|
1261
|
-
|
1262
|
-
|
1325
|
+
_save1 = self.pos
|
1326
|
+
while true # sequence
|
1327
|
+
_text_start = self.pos
|
1328
|
+
_tmp = scan(/\A(?-mix:[^ \t\n:])/)
|
1329
|
+
if _tmp
|
1330
|
+
text = get_text(_text_start)
|
1331
|
+
end
|
1332
|
+
unless _tmp
|
1333
|
+
self.pos = _save1
|
1263
1334
|
break
|
1264
|
-
end
|
1335
|
+
end
|
1336
|
+
@result = begin; text ; end
|
1337
|
+
_tmp = true
|
1338
|
+
unless _tmp
|
1339
|
+
self.pos = _save1
|
1340
|
+
end
|
1341
|
+
break
|
1342
|
+
end # end sequence
|
1343
|
+
|
1344
|
+
break if _tmp
|
1345
|
+
self.pos = _save
|
1346
|
+
break
|
1347
|
+
end # end choice
|
1265
1348
|
|
1266
1349
|
set_failed_rule :_not_space_colon unless _tmp
|
1267
1350
|
return _tmp
|
@@ -1269,36 +1352,36 @@ class CmdParse
|
|
1269
1352
|
|
1270
1353
|
# not_space_colons = not_space_colon+:ary { ary.join }
|
1271
1354
|
def _not_space_colons
|
1272
|
-
|
1355
|
+
|
1273
1356
|
_save = self.pos
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1357
|
+
while true # sequence
|
1358
|
+
_save1 = self.pos
|
1359
|
+
_ary = []
|
1360
|
+
_tmp = apply(:_not_space_colon)
|
1361
|
+
if _tmp
|
1362
|
+
_ary << @result
|
1363
|
+
while true
|
1277
1364
|
_tmp = apply(:_not_space_colon)
|
1278
|
-
if _tmp
|
1279
|
-
|
1280
|
-
|
1281
|
-
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1287
|
-
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1291
|
-
|
1292
|
-
|
1293
|
-
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
1298
|
-
self.pos = _save
|
1299
|
-
end
|
1300
|
-
break
|
1301
|
-
end # end sequence
|
1365
|
+
_ary << @result if _tmp
|
1366
|
+
break unless _tmp
|
1367
|
+
end
|
1368
|
+
_tmp = true
|
1369
|
+
@result = _ary
|
1370
|
+
else
|
1371
|
+
self.pos = _save1
|
1372
|
+
end
|
1373
|
+
ary = @result
|
1374
|
+
unless _tmp
|
1375
|
+
self.pos = _save
|
1376
|
+
break
|
1377
|
+
end
|
1378
|
+
@result = begin; ary.join ; end
|
1379
|
+
_tmp = true
|
1380
|
+
unless _tmp
|
1381
|
+
self.pos = _save
|
1382
|
+
end
|
1383
|
+
break
|
1384
|
+
end # end sequence
|
1302
1385
|
|
1303
1386
|
set_failed_rule :_not_space_colons unless _tmp
|
1304
1387
|
return _tmp
|
@@ -1306,17 +1389,17 @@ class CmdParse
|
|
1306
1389
|
|
1307
1390
|
# filename = (dbl_string | not_space_colons)
|
1308
1391
|
def _filename
|
1309
|
-
|
1392
|
+
|
1310
1393
|
_save = self.pos
|
1311
|
-
|
1312
|
-
|
1313
|
-
|
1314
|
-
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1394
|
+
while true # choice
|
1395
|
+
_tmp = apply(:_dbl_string)
|
1396
|
+
break if _tmp
|
1397
|
+
self.pos = _save
|
1398
|
+
_tmp = apply(:_not_space_colons)
|
1399
|
+
break if _tmp
|
1400
|
+
self.pos = _save
|
1401
|
+
break
|
1402
|
+
end # end choice
|
1320
1403
|
|
1321
1404
|
set_failed_rule :_filename unless _tmp
|
1322
1405
|
return _tmp
|
@@ -1324,27 +1407,27 @@ class CmdParse
|
|
1324
1407
|
|
1325
1408
|
# file_pos_sep = (sp+ | ":")
|
1326
1409
|
def _file_pos_sep
|
1327
|
-
|
1410
|
+
|
1328
1411
|
_save = self.pos
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1332
|
-
|
1333
|
-
|
1334
|
-
|
1335
|
-
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1412
|
+
while true # choice
|
1413
|
+
_save1 = self.pos
|
1414
|
+
_tmp = apply(:_sp)
|
1415
|
+
if _tmp
|
1416
|
+
while true
|
1417
|
+
_tmp = apply(:_sp)
|
1418
|
+
break unless _tmp
|
1419
|
+
end
|
1420
|
+
_tmp = true
|
1421
|
+
else
|
1422
|
+
self.pos = _save1
|
1423
|
+
end
|
1424
|
+
break if _tmp
|
1425
|
+
self.pos = _save
|
1426
|
+
_tmp = match_string(":")
|
1427
|
+
break if _tmp
|
1428
|
+
self.pos = _save
|
1429
|
+
break
|
1430
|
+
end # end choice
|
1348
1431
|
|
1349
1432
|
set_failed_rule :_file_pos_sep unless _tmp
|
1350
1433
|
return _tmp
|
@@ -1352,25 +1435,25 @@ class CmdParse
|
|
1352
1435
|
|
1353
1436
|
# integer = < /[0-9]+/ > { text.to_i }
|
1354
1437
|
def _integer
|
1355
|
-
|
1438
|
+
|
1356
1439
|
_save = self.pos
|
1357
|
-
|
1358
|
-
|
1359
|
-
|
1360
|
-
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
1364
|
-
|
1365
|
-
|
1366
|
-
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
|
1372
|
-
|
1373
|
-
|
1440
|
+
while true # sequence
|
1441
|
+
_text_start = self.pos
|
1442
|
+
_tmp = scan(/\A(?-mix:[0-9]+)/)
|
1443
|
+
if _tmp
|
1444
|
+
text = get_text(_text_start)
|
1445
|
+
end
|
1446
|
+
unless _tmp
|
1447
|
+
self.pos = _save
|
1448
|
+
break
|
1449
|
+
end
|
1450
|
+
@result = begin; text.to_i ; end
|
1451
|
+
_tmp = true
|
1452
|
+
unless _tmp
|
1453
|
+
self.pos = _save
|
1454
|
+
end
|
1455
|
+
break
|
1456
|
+
end # end sequence
|
1374
1457
|
|
1375
1458
|
set_failed_rule :_integer unless _tmp
|
1376
1459
|
return _tmp
|
@@ -1378,25 +1461,25 @@ class CmdParse
|
|
1378
1461
|
|
1379
1462
|
# sinteger = < /[+-]?[0-9]+/ > { text.to_i }
|
1380
1463
|
def _sinteger
|
1381
|
-
|
1464
|
+
|
1382
1465
|
_save = self.pos
|
1383
|
-
|
1384
|
-
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
|
1394
|
-
|
1395
|
-
|
1396
|
-
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1466
|
+
while true # sequence
|
1467
|
+
_text_start = self.pos
|
1468
|
+
_tmp = scan(/\A(?-mix:[+-]?[0-9]+)/)
|
1469
|
+
if _tmp
|
1470
|
+
text = get_text(_text_start)
|
1471
|
+
end
|
1472
|
+
unless _tmp
|
1473
|
+
self.pos = _save
|
1474
|
+
break
|
1475
|
+
end
|
1476
|
+
@result = begin; text.to_i ; end
|
1477
|
+
_tmp = true
|
1478
|
+
unless _tmp
|
1479
|
+
self.pos = _save
|
1480
|
+
end
|
1481
|
+
break
|
1482
|
+
end # end sequence
|
1400
1483
|
|
1401
1484
|
set_failed_rule :_sinteger unless _tmp
|
1402
1485
|
return _tmp
|
@@ -1404,115 +1487,115 @@ class CmdParse
|
|
1404
1487
|
|
1405
1488
|
# line_number = integer
|
1406
1489
|
def _line_number
|
1407
|
-
|
1490
|
+
_tmp = apply(:_integer)
|
1408
1491
|
set_failed_rule :_line_number unless _tmp
|
1409
1492
|
return _tmp
|
1410
1493
|
end
|
1411
1494
|
|
1412
1495
|
# vm_offset = "@" integer:int { Position.new(nil, nil, :offset, int) }
|
1413
1496
|
def _vm_offset
|
1414
|
-
|
1497
|
+
|
1415
1498
|
_save = self.pos
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1427
|
-
|
1428
|
-
|
1499
|
+
while true # sequence
|
1500
|
+
_tmp = match_string("@")
|
1501
|
+
unless _tmp
|
1502
|
+
self.pos = _save
|
1503
|
+
break
|
1504
|
+
end
|
1505
|
+
_tmp = apply(:_integer)
|
1506
|
+
int = @result
|
1507
|
+
unless _tmp
|
1508
|
+
self.pos = _save
|
1509
|
+
break
|
1510
|
+
end
|
1511
|
+
@result = begin;
|
1429
1512
|
Position.new(nil, nil, :offset, int)
|
1430
1513
|
; end
|
1431
|
-
|
1432
|
-
|
1433
|
-
|
1434
|
-
|
1435
|
-
|
1436
|
-
|
1514
|
+
_tmp = true
|
1515
|
+
unless _tmp
|
1516
|
+
self.pos = _save
|
1517
|
+
end
|
1518
|
+
break
|
1519
|
+
end # end sequence
|
1437
1520
|
|
1438
1521
|
set_failed_rule :_vm_offset unless _tmp
|
1439
1522
|
return _tmp
|
1440
1523
|
end
|
1441
1524
|
|
1442
|
-
# position = (vm_offset | line_number:l {
|
1525
|
+
# position = (vm_offset | line_number:l { Position.new(nil, nil, :line, l) })
|
1443
1526
|
def _position
|
1444
|
-
|
1527
|
+
|
1445
1528
|
_save = self.pos
|
1446
|
-
|
1447
|
-
|
1448
|
-
|
1449
|
-
|
1450
|
-
|
1451
|
-
|
1452
|
-
|
1453
|
-
|
1454
|
-
|
1455
|
-
|
1456
|
-
|
1457
|
-
|
1458
|
-
|
1459
|
-
|
1460
|
-
Position.new(nil, nil, :line, l)
|
1529
|
+
while true # choice
|
1530
|
+
_tmp = apply(:_vm_offset)
|
1531
|
+
break if _tmp
|
1532
|
+
self.pos = _save
|
1533
|
+
|
1534
|
+
_save1 = self.pos
|
1535
|
+
while true # sequence
|
1536
|
+
_tmp = apply(:_line_number)
|
1537
|
+
l = @result
|
1538
|
+
unless _tmp
|
1539
|
+
self.pos = _save1
|
1540
|
+
break
|
1541
|
+
end
|
1542
|
+
@result = begin;
|
1543
|
+
Position.new(nil, nil, :line, l)
|
1461
1544
|
; end
|
1462
|
-
|
1463
|
-
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
|
1472
|
-
|
1545
|
+
_tmp = true
|
1546
|
+
unless _tmp
|
1547
|
+
self.pos = _save1
|
1548
|
+
end
|
1549
|
+
break
|
1550
|
+
end # end sequence
|
1551
|
+
|
1552
|
+
break if _tmp
|
1553
|
+
self.pos = _save
|
1554
|
+
break
|
1555
|
+
end # end choice
|
1473
1556
|
|
1474
1557
|
set_failed_rule :_position unless _tmp
|
1475
1558
|
return _tmp
|
1476
1559
|
end
|
1477
1560
|
|
1478
|
-
# file_colon_line = file_no_colon:file &{ File.exist?(file) } ":" position:pos {
|
1561
|
+
# file_colon_line = file_no_colon:file &{ File.exist?(file) } ":" position:pos { Position.new(:file, file, pos.position_type, pos.position) }
|
1479
1562
|
def _file_colon_line
|
1480
|
-
|
1563
|
+
|
1481
1564
|
_save = self.pos
|
1482
|
-
|
1483
|
-
|
1484
|
-
|
1485
|
-
|
1486
|
-
|
1487
|
-
|
1488
|
-
|
1489
|
-
|
1490
|
-
|
1491
|
-
|
1492
|
-
|
1493
|
-
|
1494
|
-
|
1495
|
-
|
1496
|
-
|
1497
|
-
|
1498
|
-
|
1499
|
-
|
1500
|
-
|
1501
|
-
|
1502
|
-
|
1503
|
-
|
1504
|
-
|
1505
|
-
|
1506
|
-
|
1507
|
-
|
1508
|
-
Position.new(:file, file, pos.position_type, pos.position)
|
1565
|
+
while true # sequence
|
1566
|
+
_tmp = apply(:_file_no_colon)
|
1567
|
+
file = @result
|
1568
|
+
unless _tmp
|
1569
|
+
self.pos = _save
|
1570
|
+
break
|
1571
|
+
end
|
1572
|
+
_save1 = self.pos
|
1573
|
+
_tmp = begin; File.exist?(file) ; end
|
1574
|
+
self.pos = _save1
|
1575
|
+
unless _tmp
|
1576
|
+
self.pos = _save
|
1577
|
+
break
|
1578
|
+
end
|
1579
|
+
_tmp = match_string(":")
|
1580
|
+
unless _tmp
|
1581
|
+
self.pos = _save
|
1582
|
+
break
|
1583
|
+
end
|
1584
|
+
_tmp = apply(:_position)
|
1585
|
+
pos = @result
|
1586
|
+
unless _tmp
|
1587
|
+
self.pos = _save
|
1588
|
+
break
|
1589
|
+
end
|
1590
|
+
@result = begin;
|
1591
|
+
Position.new(:file, file, pos.position_type, pos.position)
|
1509
1592
|
; end
|
1510
|
-
|
1511
|
-
|
1512
|
-
|
1513
|
-
|
1514
|
-
|
1515
|
-
|
1593
|
+
_tmp = true
|
1594
|
+
unless _tmp
|
1595
|
+
self.pos = _save
|
1596
|
+
end
|
1597
|
+
break
|
1598
|
+
end # end sequence
|
1516
1599
|
|
1517
1600
|
set_failed_rule :_file_colon_line unless _tmp
|
1518
1601
|
return _tmp
|
@@ -1520,154 +1603,154 @@ class CmdParse
|
|
1520
1603
|
|
1521
1604
|
# location = (position | < filename >:file &{ @file_exists_proc.call(file) } file_pos_sep position:pos { Position.new(:file, file, pos.position_type, pos.position) } | < filename >:file &{ @file_exists_proc.call(file) } { Position.new(:file, file, nil, nil) } | class_module_chain?:fn file_pos_sep position:pos { Position.new(:fn, fn, pos.position_type, pos.position) } | class_module_chain?:fn { Position.new(:fn, fn, nil, nil) })
|
1522
1605
|
def _location
|
1523
|
-
|
1606
|
+
|
1524
1607
|
_save = self.pos
|
1525
|
-
|
1526
|
-
|
1527
|
-
|
1528
|
-
|
1529
|
-
|
1530
|
-
|
1531
|
-
|
1532
|
-
|
1533
|
-
|
1534
|
-
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
1550
|
-
|
1551
|
-
|
1552
|
-
|
1553
|
-
|
1554
|
-
|
1555
|
-
|
1556
|
-
|
1557
|
-
|
1558
|
-
|
1559
|
-
|
1560
|
-
|
1608
|
+
while true # choice
|
1609
|
+
_tmp = apply(:_position)
|
1610
|
+
break if _tmp
|
1611
|
+
self.pos = _save
|
1612
|
+
|
1613
|
+
_save1 = self.pos
|
1614
|
+
while true # sequence
|
1615
|
+
_text_start = self.pos
|
1616
|
+
_tmp = apply(:_filename)
|
1617
|
+
if _tmp
|
1618
|
+
text = get_text(_text_start)
|
1619
|
+
end
|
1620
|
+
file = @result
|
1621
|
+
unless _tmp
|
1622
|
+
self.pos = _save1
|
1623
|
+
break
|
1624
|
+
end
|
1625
|
+
_save2 = self.pos
|
1626
|
+
_tmp = begin; @file_exists_proc.call(file) ; end
|
1627
|
+
self.pos = _save2
|
1628
|
+
unless _tmp
|
1629
|
+
self.pos = _save1
|
1630
|
+
break
|
1631
|
+
end
|
1632
|
+
_tmp = apply(:_file_pos_sep)
|
1633
|
+
unless _tmp
|
1634
|
+
self.pos = _save1
|
1635
|
+
break
|
1636
|
+
end
|
1637
|
+
_tmp = apply(:_position)
|
1638
|
+
pos = @result
|
1639
|
+
unless _tmp
|
1640
|
+
self.pos = _save1
|
1641
|
+
break
|
1642
|
+
end
|
1643
|
+
@result = begin;
|
1561
1644
|
Position.new(:file, file, pos.position_type, pos.position)
|
1562
1645
|
; end
|
1563
|
-
|
1564
|
-
|
1565
|
-
|
1566
|
-
|
1567
|
-
|
1568
|
-
|
1569
|
-
|
1570
|
-
|
1571
|
-
|
1572
|
-
|
1573
|
-
|
1574
|
-
|
1575
|
-
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
1581
|
-
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1587
|
-
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
1591
|
-
|
1592
|
-
|
1646
|
+
_tmp = true
|
1647
|
+
unless _tmp
|
1648
|
+
self.pos = _save1
|
1649
|
+
end
|
1650
|
+
break
|
1651
|
+
end # end sequence
|
1652
|
+
|
1653
|
+
break if _tmp
|
1654
|
+
self.pos = _save
|
1655
|
+
|
1656
|
+
_save3 = self.pos
|
1657
|
+
while true # sequence
|
1658
|
+
_text_start = self.pos
|
1659
|
+
_tmp = apply(:_filename)
|
1660
|
+
if _tmp
|
1661
|
+
text = get_text(_text_start)
|
1662
|
+
end
|
1663
|
+
file = @result
|
1664
|
+
unless _tmp
|
1665
|
+
self.pos = _save3
|
1666
|
+
break
|
1667
|
+
end
|
1668
|
+
_save4 = self.pos
|
1669
|
+
_tmp = begin; @file_exists_proc.call(file) ; end
|
1670
|
+
self.pos = _save4
|
1671
|
+
unless _tmp
|
1672
|
+
self.pos = _save3
|
1673
|
+
break
|
1674
|
+
end
|
1675
|
+
@result = begin;
|
1593
1676
|
Position.new(:file, file, nil, nil)
|
1594
1677
|
; end
|
1595
|
-
|
1596
|
-
|
1597
|
-
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
|
1602
|
-
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
1608
|
-
|
1609
|
-
|
1610
|
-
|
1611
|
-
|
1612
|
-
|
1613
|
-
|
1614
|
-
|
1615
|
-
|
1616
|
-
|
1617
|
-
|
1618
|
-
|
1619
|
-
|
1620
|
-
|
1621
|
-
|
1622
|
-
|
1623
|
-
|
1624
|
-
|
1625
|
-
|
1626
|
-
|
1627
|
-
|
1628
|
-
|
1629
|
-
|
1630
|
-
|
1678
|
+
_tmp = true
|
1679
|
+
unless _tmp
|
1680
|
+
self.pos = _save3
|
1681
|
+
end
|
1682
|
+
break
|
1683
|
+
end # end sequence
|
1684
|
+
|
1685
|
+
break if _tmp
|
1686
|
+
self.pos = _save
|
1687
|
+
|
1688
|
+
_save5 = self.pos
|
1689
|
+
while true # sequence
|
1690
|
+
_save6 = self.pos
|
1691
|
+
_tmp = apply(:_class_module_chain)
|
1692
|
+
@result = nil unless _tmp
|
1693
|
+
unless _tmp
|
1694
|
+
_tmp = true
|
1695
|
+
self.pos = _save6
|
1696
|
+
end
|
1697
|
+
fn = @result
|
1698
|
+
unless _tmp
|
1699
|
+
self.pos = _save5
|
1700
|
+
break
|
1701
|
+
end
|
1702
|
+
_tmp = apply(:_file_pos_sep)
|
1703
|
+
unless _tmp
|
1704
|
+
self.pos = _save5
|
1705
|
+
break
|
1706
|
+
end
|
1707
|
+
_tmp = apply(:_position)
|
1708
|
+
pos = @result
|
1709
|
+
unless _tmp
|
1710
|
+
self.pos = _save5
|
1711
|
+
break
|
1712
|
+
end
|
1713
|
+
@result = begin;
|
1631
1714
|
Position.new(:fn, fn, pos.position_type, pos.position)
|
1632
1715
|
; end
|
1633
|
-
|
1634
|
-
|
1635
|
-
|
1636
|
-
|
1637
|
-
|
1638
|
-
|
1639
|
-
|
1640
|
-
|
1641
|
-
|
1642
|
-
|
1643
|
-
|
1644
|
-
|
1645
|
-
|
1646
|
-
|
1647
|
-
|
1648
|
-
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
1653
|
-
|
1654
|
-
|
1655
|
-
|
1656
|
-
|
1657
|
-
|
1716
|
+
_tmp = true
|
1717
|
+
unless _tmp
|
1718
|
+
self.pos = _save5
|
1719
|
+
end
|
1720
|
+
break
|
1721
|
+
end # end sequence
|
1722
|
+
|
1723
|
+
break if _tmp
|
1724
|
+
self.pos = _save
|
1725
|
+
|
1726
|
+
_save7 = self.pos
|
1727
|
+
while true # sequence
|
1728
|
+
_save8 = self.pos
|
1729
|
+
_tmp = apply(:_class_module_chain)
|
1730
|
+
@result = nil unless _tmp
|
1731
|
+
unless _tmp
|
1732
|
+
_tmp = true
|
1733
|
+
self.pos = _save8
|
1734
|
+
end
|
1735
|
+
fn = @result
|
1736
|
+
unless _tmp
|
1737
|
+
self.pos = _save7
|
1738
|
+
break
|
1739
|
+
end
|
1740
|
+
@result = begin;
|
1658
1741
|
Position.new(:fn, fn, nil, nil)
|
1659
1742
|
; end
|
1660
|
-
|
1661
|
-
|
1662
|
-
|
1663
|
-
|
1664
|
-
|
1665
|
-
|
1666
|
-
|
1667
|
-
|
1668
|
-
|
1669
|
-
|
1670
|
-
|
1743
|
+
_tmp = true
|
1744
|
+
unless _tmp
|
1745
|
+
self.pos = _save7
|
1746
|
+
end
|
1747
|
+
break
|
1748
|
+
end # end sequence
|
1749
|
+
|
1750
|
+
break if _tmp
|
1751
|
+
self.pos = _save
|
1752
|
+
break
|
1753
|
+
end # end choice
|
1671
1754
|
|
1672
1755
|
set_failed_rule :_location unless _tmp
|
1673
1756
|
return _tmp
|
@@ -1675,36 +1758,36 @@ class CmdParse
|
|
1675
1758
|
|
1676
1759
|
# if_unless = < ("if" | "unless") > { text }
|
1677
1760
|
def _if_unless
|
1678
|
-
|
1761
|
+
|
1679
1762
|
_save = self.pos
|
1680
|
-
|
1681
|
-
|
1682
|
-
|
1683
|
-
|
1684
|
-
|
1685
|
-
|
1686
|
-
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1691
|
-
|
1692
|
-
|
1693
|
-
|
1694
|
-
|
1695
|
-
|
1696
|
-
|
1697
|
-
|
1698
|
-
|
1699
|
-
|
1700
|
-
|
1701
|
-
|
1702
|
-
|
1703
|
-
|
1704
|
-
|
1705
|
-
|
1706
|
-
|
1707
|
-
|
1763
|
+
while true # sequence
|
1764
|
+
_text_start = self.pos
|
1765
|
+
|
1766
|
+
_save1 = self.pos
|
1767
|
+
while true # choice
|
1768
|
+
_tmp = match_string("if")
|
1769
|
+
break if _tmp
|
1770
|
+
self.pos = _save1
|
1771
|
+
_tmp = match_string("unless")
|
1772
|
+
break if _tmp
|
1773
|
+
self.pos = _save1
|
1774
|
+
break
|
1775
|
+
end # end choice
|
1776
|
+
|
1777
|
+
if _tmp
|
1778
|
+
text = get_text(_text_start)
|
1779
|
+
end
|
1780
|
+
unless _tmp
|
1781
|
+
self.pos = _save
|
1782
|
+
break
|
1783
|
+
end
|
1784
|
+
@result = begin; text ; end
|
1785
|
+
_tmp = true
|
1786
|
+
unless _tmp
|
1787
|
+
self.pos = _save
|
1788
|
+
end
|
1789
|
+
break
|
1790
|
+
end # end sequence
|
1708
1791
|
|
1709
1792
|
set_failed_rule :_if_unless unless _tmp
|
1710
1793
|
return _tmp
|
@@ -1712,25 +1795,25 @@ class CmdParse
|
|
1712
1795
|
|
1713
1796
|
# condition = < /.+/ > { text}
|
1714
1797
|
def _condition
|
1715
|
-
|
1798
|
+
|
1716
1799
|
_save = self.pos
|
1717
|
-
|
1718
|
-
|
1719
|
-
|
1720
|
-
|
1721
|
-
|
1722
|
-
|
1723
|
-
|
1724
|
-
|
1725
|
-
|
1726
|
-
|
1727
|
-
|
1728
|
-
|
1729
|
-
|
1730
|
-
|
1731
|
-
|
1732
|
-
|
1733
|
-
|
1800
|
+
while true # sequence
|
1801
|
+
_text_start = self.pos
|
1802
|
+
_tmp = scan(/\A(?-mix:.+)/)
|
1803
|
+
if _tmp
|
1804
|
+
text = get_text(_text_start)
|
1805
|
+
end
|
1806
|
+
unless _tmp
|
1807
|
+
self.pos = _save
|
1808
|
+
break
|
1809
|
+
end
|
1810
|
+
@result = begin; text; end
|
1811
|
+
_tmp = true
|
1812
|
+
unless _tmp
|
1813
|
+
self.pos = _save
|
1814
|
+
end
|
1815
|
+
break
|
1816
|
+
end # end sequence
|
1734
1817
|
|
1735
1818
|
set_failed_rule :_condition unless _tmp
|
1736
1819
|
return _tmp
|
@@ -1738,24 +1821,24 @@ class CmdParse
|
|
1738
1821
|
|
1739
1822
|
# breakpoint_stmt_no_condition = location:loc { Breakpoint.new(loc, false, 'true') }
|
1740
1823
|
def _breakpoint_stmt_no_condition
|
1741
|
-
|
1824
|
+
|
1742
1825
|
_save = self.pos
|
1743
|
-
|
1744
|
-
|
1745
|
-
|
1746
|
-
|
1747
|
-
|
1748
|
-
|
1749
|
-
|
1750
|
-
|
1826
|
+
while true # sequence
|
1827
|
+
_tmp = apply(:_location)
|
1828
|
+
loc = @result
|
1829
|
+
unless _tmp
|
1830
|
+
self.pos = _save
|
1831
|
+
break
|
1832
|
+
end
|
1833
|
+
@result = begin;
|
1751
1834
|
Breakpoint.new(loc, false, 'true')
|
1752
1835
|
; end
|
1753
|
-
|
1754
|
-
|
1755
|
-
|
1756
|
-
|
1757
|
-
|
1758
|
-
|
1836
|
+
_tmp = true
|
1837
|
+
unless _tmp
|
1838
|
+
self.pos = _save
|
1839
|
+
end
|
1840
|
+
break
|
1841
|
+
end # end sequence
|
1759
1842
|
|
1760
1843
|
set_failed_rule :_breakpoint_stmt_no_condition unless _tmp
|
1761
1844
|
return _tmp
|
@@ -1763,57 +1846,57 @@ class CmdParse
|
|
1763
1846
|
|
1764
1847
|
# breakpoint_stmt = (location:loc - if_unless:iu - condition:cond { Breakpoint.new(loc, iu == 'unless', cond) } | breakpoint_stmt_no_condition)
|
1765
1848
|
def _breakpoint_stmt
|
1766
|
-
|
1849
|
+
|
1767
1850
|
_save = self.pos
|
1768
|
-
|
1769
|
-
|
1770
|
-
|
1771
|
-
|
1772
|
-
|
1773
|
-
|
1774
|
-
|
1775
|
-
|
1776
|
-
|
1777
|
-
|
1778
|
-
|
1779
|
-
|
1780
|
-
|
1781
|
-
|
1782
|
-
|
1783
|
-
|
1784
|
-
|
1785
|
-
|
1786
|
-
|
1787
|
-
|
1788
|
-
|
1789
|
-
|
1790
|
-
|
1791
|
-
|
1792
|
-
|
1793
|
-
|
1794
|
-
|
1795
|
-
|
1796
|
-
|
1797
|
-
|
1798
|
-
|
1799
|
-
|
1800
|
-
|
1851
|
+
while true # choice
|
1852
|
+
|
1853
|
+
_save1 = self.pos
|
1854
|
+
while true # sequence
|
1855
|
+
_tmp = apply(:_location)
|
1856
|
+
loc = @result
|
1857
|
+
unless _tmp
|
1858
|
+
self.pos = _save1
|
1859
|
+
break
|
1860
|
+
end
|
1861
|
+
_tmp = apply(:__hyphen_)
|
1862
|
+
unless _tmp
|
1863
|
+
self.pos = _save1
|
1864
|
+
break
|
1865
|
+
end
|
1866
|
+
_tmp = apply(:_if_unless)
|
1867
|
+
iu = @result
|
1868
|
+
unless _tmp
|
1869
|
+
self.pos = _save1
|
1870
|
+
break
|
1871
|
+
end
|
1872
|
+
_tmp = apply(:__hyphen_)
|
1873
|
+
unless _tmp
|
1874
|
+
self.pos = _save1
|
1875
|
+
break
|
1876
|
+
end
|
1877
|
+
_tmp = apply(:_condition)
|
1878
|
+
cond = @result
|
1879
|
+
unless _tmp
|
1880
|
+
self.pos = _save1
|
1881
|
+
break
|
1882
|
+
end
|
1883
|
+
@result = begin;
|
1801
1884
|
Breakpoint.new(loc, iu == 'unless', cond)
|
1802
1885
|
; end
|
1803
|
-
|
1804
|
-
|
1805
|
-
|
1806
|
-
|
1807
|
-
|
1808
|
-
|
1809
|
-
|
1810
|
-
|
1811
|
-
|
1812
|
-
|
1813
|
-
|
1814
|
-
|
1815
|
-
|
1816
|
-
|
1886
|
+
_tmp = true
|
1887
|
+
unless _tmp
|
1888
|
+
self.pos = _save1
|
1889
|
+
end
|
1890
|
+
break
|
1891
|
+
end # end sequence
|
1892
|
+
|
1893
|
+
break if _tmp
|
1894
|
+
self.pos = _save
|
1895
|
+
_tmp = apply(:_breakpoint_stmt_no_condition)
|
1896
|
+
break if _tmp
|
1897
|
+
self.pos = _save
|
1898
|
+
break
|
1899
|
+
end # end choice
|
1817
1900
|
|
1818
1901
|
set_failed_rule :_breakpoint_stmt unless _tmp
|
1819
1902
|
return _tmp
|
@@ -1821,36 +1904,36 @@ class CmdParse
|
|
1821
1904
|
|
1822
1905
|
# list_special_targets = < ("." | "-") > { text }
|
1823
1906
|
def _list_special_targets
|
1824
|
-
|
1907
|
+
|
1825
1908
|
_save = self.pos
|
1826
|
-
|
1827
|
-
|
1828
|
-
|
1829
|
-
|
1830
|
-
|
1831
|
-
|
1832
|
-
|
1833
|
-
|
1834
|
-
|
1835
|
-
|
1836
|
-
|
1837
|
-
|
1838
|
-
|
1839
|
-
|
1840
|
-
|
1841
|
-
|
1842
|
-
|
1843
|
-
|
1844
|
-
|
1845
|
-
|
1846
|
-
|
1847
|
-
|
1848
|
-
|
1849
|
-
|
1850
|
-
|
1851
|
-
|
1852
|
-
|
1853
|
-
|
1909
|
+
while true # sequence
|
1910
|
+
_text_start = self.pos
|
1911
|
+
|
1912
|
+
_save1 = self.pos
|
1913
|
+
while true # choice
|
1914
|
+
_tmp = match_string(".")
|
1915
|
+
break if _tmp
|
1916
|
+
self.pos = _save1
|
1917
|
+
_tmp = match_string("-")
|
1918
|
+
break if _tmp
|
1919
|
+
self.pos = _save1
|
1920
|
+
break
|
1921
|
+
end # end choice
|
1922
|
+
|
1923
|
+
if _tmp
|
1924
|
+
text = get_text(_text_start)
|
1925
|
+
end
|
1926
|
+
unless _tmp
|
1927
|
+
self.pos = _save
|
1928
|
+
break
|
1929
|
+
end
|
1930
|
+
@result = begin; text ; end
|
1931
|
+
_tmp = true
|
1932
|
+
unless _tmp
|
1933
|
+
self.pos = _save
|
1934
|
+
end
|
1935
|
+
break
|
1936
|
+
end # end sequence
|
1854
1937
|
|
1855
1938
|
set_failed_rule :_list_special_targets unless _tmp
|
1856
1939
|
return _tmp
|
@@ -1858,226 +1941,137 @@ class CmdParse
|
|
1858
1941
|
|
1859
1942
|
# list_stmt = ((list_special_targets | location):loc - sinteger:int? { List.new(loc, int) } | (list_special_targets | location):loc { List.new(loc, nil) })
|
1860
1943
|
def _list_stmt
|
1861
|
-
|
1944
|
+
|
1862
1945
|
_save = self.pos
|
1863
|
-
|
1864
|
-
|
1865
|
-
_save1 = self.pos
|
1866
|
-
while true # sequence
|
1867
|
-
|
1868
|
-
_save2 = self.pos
|
1869
|
-
while true # choice
|
1870
|
-
_tmp = apply(:_list_special_targets)
|
1871
|
-
break if _tmp
|
1872
|
-
self.pos = _save2
|
1873
|
-
_tmp = apply(:_location)
|
1874
|
-
break if _tmp
|
1875
|
-
self.pos = _save2
|
1876
|
-
break
|
1877
|
-
end # end choice
|
1878
|
-
|
1879
|
-
loc = @result
|
1880
|
-
unless _tmp
|
1881
|
-
self.pos = _save1
|
1882
|
-
break
|
1883
|
-
end
|
1884
|
-
_tmp = apply(:__hyphen_)
|
1885
|
-
unless _tmp
|
1886
|
-
self.pos = _save1
|
1887
|
-
break
|
1888
|
-
end
|
1889
|
-
_save3 = self.pos
|
1890
|
-
_tmp = apply(:_sinteger)
|
1891
|
-
int = @result
|
1892
|
-
unless _tmp
|
1893
|
-
_tmp = true
|
1894
|
-
self.pos = _save3
|
1895
|
-
end
|
1896
|
-
unless _tmp
|
1897
|
-
self.pos = _save1
|
1898
|
-
break
|
1899
|
-
end
|
1900
|
-
@result = begin;
|
1901
|
-
List.new(loc, int)
|
1902
|
-
; end
|
1903
|
-
_tmp = true
|
1904
|
-
unless _tmp
|
1905
|
-
self.pos = _save1
|
1906
|
-
end
|
1907
|
-
break
|
1908
|
-
end # end sequence
|
1909
|
-
|
1910
|
-
break if _tmp
|
1911
|
-
self.pos = _save
|
1912
|
-
|
1913
|
-
_save4 = self.pos
|
1914
|
-
while true # sequence
|
1915
|
-
|
1916
|
-
_save5 = self.pos
|
1917
|
-
while true # choice
|
1918
|
-
_tmp = apply(:_list_special_targets)
|
1919
|
-
break if _tmp
|
1920
|
-
self.pos = _save5
|
1921
|
-
_tmp = apply(:_location)
|
1922
|
-
break if _tmp
|
1923
|
-
self.pos = _save5
|
1924
|
-
break
|
1925
|
-
end # end choice
|
1926
|
-
|
1927
|
-
loc = @result
|
1928
|
-
unless _tmp
|
1929
|
-
self.pos = _save4
|
1930
|
-
break
|
1931
|
-
end
|
1932
|
-
@result = begin;
|
1933
|
-
List.new(loc, nil)
|
1934
|
-
; end
|
1935
|
-
_tmp = true
|
1936
|
-
unless _tmp
|
1937
|
-
self.pos = _save4
|
1938
|
-
end
|
1939
|
-
break
|
1940
|
-
end # end sequence
|
1941
|
-
|
1942
|
-
break if _tmp
|
1943
|
-
self.pos = _save
|
1944
|
-
break
|
1945
|
-
end # end choice
|
1946
|
+
while true # choice
|
1946
1947
|
|
1947
|
-
|
1948
|
-
|
1949
|
-
end
|
1948
|
+
_save1 = self.pos
|
1949
|
+
while true # sequence
|
1950
1950
|
|
1951
|
-
|
1952
|
-
|
1953
|
-
|
1954
|
-
|
1955
|
-
|
1956
|
-
|
1957
|
-
|
1958
|
-
|
1959
|
-
|
1960
|
-
|
1961
|
-
|
1962
|
-
|
1963
|
-
|
1964
|
-
|
1965
|
-
|
1966
|
-
|
1967
|
-
|
1968
|
-
|
1969
|
-
|
1970
|
-
|
1971
|
-
|
1972
|
-
|
1973
|
-
|
1974
|
-
|
1975
|
-
|
1976
|
-
|
1977
|
-
|
1978
|
-
|
1979
|
-
|
1980
|
-
|
1981
|
-
|
1982
|
-
|
1983
|
-
|
1984
|
-
unless _tmp
|
1985
|
-
_tmp = true
|
1986
|
-
self.pos = _save3
|
1987
|
-
end
|
1988
|
-
unless _tmp
|
1989
|
-
self.pos = _save1
|
1990
|
-
break
|
1991
|
-
end
|
1992
|
-
@result = begin;
|
1951
|
+
_save2 = self.pos
|
1952
|
+
while true # choice
|
1953
|
+
_tmp = apply(:_list_special_targets)
|
1954
|
+
break if _tmp
|
1955
|
+
self.pos = _save2
|
1956
|
+
_tmp = apply(:_location)
|
1957
|
+
break if _tmp
|
1958
|
+
self.pos = _save2
|
1959
|
+
break
|
1960
|
+
end # end choice
|
1961
|
+
|
1962
|
+
loc = @result
|
1963
|
+
unless _tmp
|
1964
|
+
self.pos = _save1
|
1965
|
+
break
|
1966
|
+
end
|
1967
|
+
_tmp = apply(:__hyphen_)
|
1968
|
+
unless _tmp
|
1969
|
+
self.pos = _save1
|
1970
|
+
break
|
1971
|
+
end
|
1972
|
+
_save3 = self.pos
|
1973
|
+
_tmp = apply(:_sinteger)
|
1974
|
+
int = @result
|
1975
|
+
unless _tmp
|
1976
|
+
_tmp = true
|
1977
|
+
self.pos = _save3
|
1978
|
+
end
|
1979
|
+
unless _tmp
|
1980
|
+
self.pos = _save1
|
1981
|
+
break
|
1982
|
+
end
|
1983
|
+
@result = begin;
|
1993
1984
|
List.new(loc, int)
|
1994
1985
|
; end
|
1995
|
-
|
1996
|
-
|
1997
|
-
|
1998
|
-
|
1999
|
-
|
2000
|
-
|
2001
|
-
|
2002
|
-
|
2003
|
-
|
2004
|
-
|
2005
|
-
|
2006
|
-
|
2007
|
-
|
2008
|
-
|
2009
|
-
|
2010
|
-
|
2011
|
-
|
2012
|
-
|
2013
|
-
|
2014
|
-
|
2015
|
-
|
2016
|
-
|
2017
|
-
|
2018
|
-
|
2019
|
-
|
2020
|
-
|
2021
|
-
|
2022
|
-
|
2023
|
-
|
2024
|
-
|
1986
|
+
_tmp = true
|
1987
|
+
unless _tmp
|
1988
|
+
self.pos = _save1
|
1989
|
+
end
|
1990
|
+
break
|
1991
|
+
end # end sequence
|
1992
|
+
|
1993
|
+
break if _tmp
|
1994
|
+
self.pos = _save
|
1995
|
+
|
1996
|
+
_save4 = self.pos
|
1997
|
+
while true # sequence
|
1998
|
+
|
1999
|
+
_save5 = self.pos
|
2000
|
+
while true # choice
|
2001
|
+
_tmp = apply(:_list_special_targets)
|
2002
|
+
break if _tmp
|
2003
|
+
self.pos = _save5
|
2004
|
+
_tmp = apply(:_location)
|
2005
|
+
break if _tmp
|
2006
|
+
self.pos = _save5
|
2007
|
+
break
|
2008
|
+
end # end choice
|
2009
|
+
|
2010
|
+
loc = @result
|
2011
|
+
unless _tmp
|
2012
|
+
self.pos = _save4
|
2013
|
+
break
|
2014
|
+
end
|
2015
|
+
@result = begin;
|
2025
2016
|
List.new(loc, nil)
|
2026
2017
|
; end
|
2027
|
-
|
2028
|
-
|
2029
|
-
|
2030
|
-
|
2031
|
-
|
2032
|
-
|
2033
|
-
|
2034
|
-
|
2035
|
-
|
2036
|
-
|
2037
|
-
|
2018
|
+
_tmp = true
|
2019
|
+
unless _tmp
|
2020
|
+
self.pos = _save4
|
2021
|
+
end
|
2022
|
+
break
|
2023
|
+
end # end sequence
|
2024
|
+
|
2025
|
+
break if _tmp
|
2026
|
+
self.pos = _save
|
2027
|
+
break
|
2028
|
+
end # end choice
|
2038
2029
|
|
2030
|
+
set_failed_rule :_list_stmt unless _tmp
|
2039
2031
|
return _tmp
|
2040
2032
|
end
|
2041
|
-
end
|
2042
|
-
if __FILE__ == $0
|
2043
|
-
# require 'rubygems'; require_relative '../lib/trepanning';
|
2044
|
-
|
2045
|
-
cp = CmdParse.new('', :debug=>true)
|
2046
|
-
%w(A::B @@classvar abc01! @ivar @ivar.meth
|
2047
|
-
Object A::B::C A::B::C::D A::B.c A.b.c.d).each do |name|
|
2048
|
-
cp.setup_parser(name, true)
|
2049
|
-
# debugger if name == '@ivar.meth'
|
2050
|
-
res = cp._class_module_chain
|
2051
|
-
p res
|
2052
|
-
p cp.string
|
2053
|
-
p cp.result
|
2054
|
-
end
|
2055
|
-
%w(A::B:5 A::B:@5 @@classvar abc01!:10 @ivar).each do |name|
|
2056
|
-
cp.setup_parser(name, true)
|
2057
|
-
res = cp._location
|
2058
|
-
p res
|
2059
|
-
p cp.string
|
2060
|
-
p cp.result
|
2061
|
-
end
|
2062
|
-
# require 'trepanning';
|
2063
|
-
["#{__FILE__}:10", 'A::B 5',
|
2064
|
-
"#{__FILE__} 20"].each do |name|
|
2065
|
-
cp.setup_parser(name, {:debug=>true})
|
2066
|
-
res = cp._location
|
2067
|
-
p res
|
2068
|
-
p cp.string
|
2069
|
-
p cp.result
|
2070
|
-
end
|
2071
2033
|
|
2072
|
-
|
2073
|
-
|
2074
|
-
|
2075
|
-
|
2076
|
-
|
2077
|
-
|
2078
|
-
|
2079
|
-
|
2080
|
-
|
2081
|
-
|
2082
|
-
|
2034
|
+
Rules = {}
|
2035
|
+
Rules[:_upcase_letter] = rule_info("upcase_letter", "/[A-Z]/")
|
2036
|
+
Rules[:_downcase_letter] = rule_info("downcase_letter", "/[a-z]/")
|
2037
|
+
Rules[:_suffix_letter] = rule_info("suffix_letter", "/[=!?]/")
|
2038
|
+
Rules[:_letter] = rule_info("letter", "(upcase_letter | downcase_letter)")
|
2039
|
+
Rules[:_id_symbol] = rule_info("id_symbol", "(letter | \"_\" | [0-9])")
|
2040
|
+
Rules[:_vm_identifier] = rule_info("vm_identifier", "< (downcase_letter | \"_\") id_symbol* suffix_letter? > { SymbolEntry.new(:variable, text) }")
|
2041
|
+
Rules[:_variable_identifier] = rule_info("variable_identifier", "< (downcase_letter | \"_\") id_symbol* > { SymbolEntry.new(:variable, text) }")
|
2042
|
+
Rules[:_constant_identifier] = rule_info("constant_identifier", "< upcase_letter id_symbol* > { SymbolEntry.new(:constant, text) }")
|
2043
|
+
Rules[:_global_identifier] = rule_info("global_identifier", "< \"$\" (constant_identifier | variable_identifier) > { SymbolEntry.new(:global, text) }")
|
2044
|
+
Rules[:_local_internal_identifier] = rule_info("local_internal_identifier", "(constant_identifier | variable_identifier)")
|
2045
|
+
Rules[:_local_identifier] = rule_info("local_identifier", "(constant_identifier | vm_identifier)")
|
2046
|
+
Rules[:_instance_identifier] = rule_info("instance_identifier", "< \"@\" local_identifier > { SymbolEntry.new(:instance, text) }")
|
2047
|
+
Rules[:_classvar_identifier] = rule_info("classvar_identifier", "\"@@\" local_identifier:id { SymbolEntry.new(:classvar, id) }")
|
2048
|
+
Rules[:_identifier] = rule_info("identifier", "(global_identifier | instance_identifier | classvar_identifier | local_identifier)")
|
2049
|
+
Rules[:_id_separator] = rule_info("id_separator", "< (\"::\" | \".\") > { text }")
|
2050
|
+
Rules[:_internal_class_module_chain] = rule_info("internal_class_module_chain", "(< local_internal_identifier:parent id_separator:sep internal_class_module_chain:child > { SymbolEntry.new(parent.type, text, [parent, child, sep]) } | local_identifier)")
|
2051
|
+
Rules[:_class_module_chain] = rule_info("class_module_chain", "(< identifier:parent id_separator:sep internal_class_module_chain:child > { SymbolEntry.new(parent.type, text, [parent, child, sep]) } | identifier)")
|
2052
|
+
Rules[:_sp] = rule_info("sp", "/[ \\t]/")
|
2053
|
+
Rules[:__hyphen_] = rule_info("-", "sp+")
|
2054
|
+
Rules[:_dbl_escapes] = rule_info("dbl_escapes", "(\"\\\\\\\"\" { '\"' } | \"\\\\n\" { \"\\n\" } | \"\\\\t\" { \"\\t\" } | \"\\\\\\\\\" { \"\\\\\" })")
|
2055
|
+
Rules[:_escapes] = rule_info("escapes", "(\"\\\\\\\"\" { '\"' } | \"\\\\n\" { \"\\n\" } | \"\\\\t\" { \"\\t\" } | \"\\\\ \" { \" \" } | \"\\\\:\" { \":\" } | \"\\\\\\\\\" { \"\\\\\" })")
|
2056
|
+
Rules[:_dbl_seq] = rule_info("dbl_seq", "< /[^\\\\\"]+/ > { text }")
|
2057
|
+
Rules[:_dbl_not_quote] = rule_info("dbl_not_quote", "(dbl_escapes | dbl_seq)+:ary { ary }")
|
2058
|
+
Rules[:_dbl_string] = rule_info("dbl_string", "\"\\\"\" dbl_not_quote:ary \"\\\"\" { ary.join }")
|
2059
|
+
Rules[:_not_space_colon] = rule_info("not_space_colon", "(escapes | < /[^ \\t\\n:]/ > { text })")
|
2060
|
+
Rules[:_not_space_colons] = rule_info("not_space_colons", "not_space_colon+:ary { ary.join }")
|
2061
|
+
Rules[:_filename] = rule_info("filename", "(dbl_string | not_space_colons)")
|
2062
|
+
Rules[:_file_pos_sep] = rule_info("file_pos_sep", "(sp+ | \":\")")
|
2063
|
+
Rules[:_integer] = rule_info("integer", "< /[0-9]+/ > { text.to_i }")
|
2064
|
+
Rules[:_sinteger] = rule_info("sinteger", "< /[+-]?[0-9]+/ > { text.to_i }")
|
2065
|
+
Rules[:_line_number] = rule_info("line_number", "integer")
|
2066
|
+
Rules[:_vm_offset] = rule_info("vm_offset", "\"@\" integer:int { Position.new(nil, nil, :offset, int) }")
|
2067
|
+
Rules[:_position] = rule_info("position", "(vm_offset | line_number:l { Position.new(nil, nil, :line, l) })")
|
2068
|
+
Rules[:_file_colon_line] = rule_info("file_colon_line", "file_no_colon:file &{ File.exist?(file) } \":\" position:pos { Position.new(:file, file, pos.position_type, pos.position) }")
|
2069
|
+
Rules[:_location] = rule_info("location", "(position | < filename >:file &{ @file_exists_proc.call(file) } file_pos_sep position:pos { Position.new(:file, file, pos.position_type, pos.position) } | < filename >:file &{ @file_exists_proc.call(file) } { Position.new(:file, file, nil, nil) } | class_module_chain?:fn file_pos_sep position:pos { Position.new(:fn, fn, pos.position_type, pos.position) } | class_module_chain?:fn { Position.new(:fn, fn, nil, nil) })")
|
2070
|
+
Rules[:_if_unless] = rule_info("if_unless", "< (\"if\" | \"unless\") > { text }")
|
2071
|
+
Rules[:_condition] = rule_info("condition", "< /.+/ > { text}")
|
2072
|
+
Rules[:_breakpoint_stmt_no_condition] = rule_info("breakpoint_stmt_no_condition", "location:loc { Breakpoint.new(loc, false, 'true') }")
|
2073
|
+
Rules[:_breakpoint_stmt] = rule_info("breakpoint_stmt", "(location:loc - if_unless:iu - condition:cond { Breakpoint.new(loc, iu == 'unless', cond) } | breakpoint_stmt_no_condition)")
|
2074
|
+
Rules[:_list_special_targets] = rule_info("list_special_targets", "< (\".\" | \"-\") > { text }")
|
2075
|
+
Rules[:_list_stmt] = rule_info("list_stmt", "((list_special_targets | location):loc - sinteger:int? { List.new(loc, int) } | (list_special_targets | location):loc { List.new(loc, nil) })")
|
2076
|
+
# :startdoc:
|
2083
2077
|
end
|