rbx-trepanning 0.2.0-universal-rubinius-2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -0
- data/ChangeLog +2967 -0
- data/LICENSE +25 -0
- data/Makefile +13 -0
- data/NEWS +105 -0
- data/README.textile +34 -0
- data/Rakefile +244 -0
- data/THANKS +14 -0
- data/app/.gitignore +2 -0
- data/app/breakpoint.rb +242 -0
- data/app/brkptmgr.rb +153 -0
- data/app/client.rb +71 -0
- data/app/cmd_parse.kpeg +242 -0
- data/app/cmd_parse.rb +209 -0
- data/app/cmd_parser.rb +2083 -0
- data/app/complete.rb +79 -0
- data/app/condition.rb +22 -0
- data/app/default.rb +71 -0
- data/app/display.rb +186 -0
- data/app/eventbuffer.rb +147 -0
- data/app/file.rb +24 -0
- data/app/frame.rb +120 -0
- data/app/irb.rb +113 -0
- data/app/iseq.rb +188 -0
- data/app/method.rb +178 -0
- data/app/mock.rb +13 -0
- data/app/options.rb +154 -0
- data/app/rbx-llvm.rb +163 -0
- data/app/run.rb +92 -0
- data/app/util.rb +99 -0
- data/app/validate.rb +30 -0
- data/bin/.gitignore +2 -0
- data/bin/trepanx +69 -0
- data/data/.gitignore +2 -0
- data/data/irbrc +41 -0
- data/interface/.gitignore +2 -0
- data/interface/client.rb +84 -0
- data/interface/comcodes.rb +20 -0
- data/interface/script.rb +112 -0
- data/interface/server.rb +147 -0
- data/interface/user.rb +158 -0
- data/interface.rb +109 -0
- data/io/.gitignore +3 -0
- data/io/input.rb +151 -0
- data/io/null_output.rb +46 -0
- data/io/string_array.rb +155 -0
- data/io/tcpclient.rb +129 -0
- data/io/tcpfns.rb +33 -0
- data/io/tcpserver.rb +141 -0
- data/io.rb +148 -0
- data/lib/.gitignore +2 -0
- data/lib/trepanning.rb +467 -0
- data/processor/.gitignore +3 -0
- data/processor/Makefile +7 -0
- data/processor/breakpoint.rb +167 -0
- data/processor/command/.gitignore +2 -0
- data/processor/command/alias.rb +65 -0
- data/processor/command/backtrace.rb +68 -0
- data/processor/command/base/.gitignore +2 -0
- data/processor/command/base/subcmd.rb +226 -0
- data/processor/command/base/submgr.rb +185 -0
- data/processor/command/base/subsubcmd.rb +125 -0
- data/processor/command/base/subsubmgr.rb +196 -0
- data/processor/command/break.rb +78 -0
- data/processor/command/complete.rb +39 -0
- data/processor/command/condition.rb +64 -0
- data/processor/command/continue.rb +61 -0
- data/processor/command/delete.rb +44 -0
- data/processor/command/directory.rb +51 -0
- data/processor/command/disable.rb +71 -0
- data/processor/command/disassemble.rb +180 -0
- data/processor/command/display.rb +84 -0
- data/processor/command/down.rb +54 -0
- data/processor/command/edit.rb +74 -0
- data/processor/command/enable.rb +43 -0
- data/processor/command/eval.rb +93 -0
- data/processor/command/exit.rb +83 -0
- data/processor/command/finish.rb +80 -0
- data/processor/command/frame.rb +93 -0
- data/processor/command/help/.gitignore +1 -0
- data/processor/command/help/README +10 -0
- data/processor/command/help/command.txt +58 -0
- data/processor/command/help/examples.txt +16 -0
- data/processor/command/help/filename.txt +40 -0
- data/processor/command/help/location.txt +37 -0
- data/processor/command/help/suffixes.txt +17 -0
- data/processor/command/help.rb +228 -0
- data/processor/command/info.rb +30 -0
- data/processor/command/info_subcmd/.gitignore +3 -0
- data/processor/command/info_subcmd/breakpoints.rb +103 -0
- data/processor/command/info_subcmd/files.rb +219 -0
- data/processor/command/info_subcmd/frame.rb +68 -0
- data/processor/command/info_subcmd/line.rb +75 -0
- data/processor/command/info_subcmd/locals.rb +22 -0
- data/processor/command/info_subcmd/macro.rb +62 -0
- data/processor/command/info_subcmd/method.rb +71 -0
- data/processor/command/info_subcmd/program.rb +51 -0
- data/processor/command/info_subcmd/ruby.rb +64 -0
- data/processor/command/info_subcmd/source.rb +75 -0
- data/processor/command/info_subcmd/stack.rb +25 -0
- data/processor/command/info_subcmd/variables.rb +35 -0
- data/processor/command/info_subcmd/variables_subcmd/.gitignore +2 -0
- data/processor/command/info_subcmd/variables_subcmd/class.rb +42 -0
- data/processor/command/info_subcmd/variables_subcmd/constant.rb +42 -0
- data/processor/command/info_subcmd/variables_subcmd/globals.rb +69 -0
- data/processor/command/info_subcmd/variables_subcmd/instance.rb +42 -0
- data/processor/command/info_subcmd/variables_subcmd/locals.rb +80 -0
- data/processor/command/kill.rb +79 -0
- data/processor/command/list.rb +234 -0
- data/processor/command/macro.rb +86 -0
- data/processor/command/next.rb +67 -0
- data/processor/command/nexti.rb +59 -0
- data/processor/command/parsetree.rb +51 -0
- data/processor/command/pr.rb +37 -0
- data/processor/command/ps.rb +40 -0
- data/processor/command/restart.rb +60 -0
- data/processor/command/save.rb +58 -0
- data/processor/command/server.rb +72 -0
- data/processor/command/set.rb +47 -0
- data/processor/command/set_subcmd/.gitignore +2 -0
- data/processor/command/set_subcmd/abbrev.rb +25 -0
- data/processor/command/set_subcmd/auto.rb +33 -0
- data/processor/command/set_subcmd/auto_subcmd/.gitignore +2 -0
- data/processor/command/set_subcmd/auto_subcmd/dis.rb +33 -0
- data/processor/command/set_subcmd/auto_subcmd/eval.rb +53 -0
- data/processor/command/set_subcmd/auto_subcmd/irb.rb +33 -0
- data/processor/command/set_subcmd/auto_subcmd/list.rb +33 -0
- data/processor/command/set_subcmd/basename.rb +25 -0
- data/processor/command/set_subcmd/confirm.rb +24 -0
- data/processor/command/set_subcmd/debug.rb +26 -0
- data/processor/command/set_subcmd/debug_subcmd/.gitignore +2 -0
- data/processor/command/set_subcmd/debug_subcmd/dbgr.rb +36 -0
- data/processor/command/set_subcmd/debug_subcmd/skip.rb +23 -0
- data/processor/command/set_subcmd/debug_subcmd/step.rb +23 -0
- data/processor/command/set_subcmd/different.rb +61 -0
- data/processor/command/set_subcmd/hidelevel.rb +62 -0
- data/processor/command/set_subcmd/highlight.rb +39 -0
- data/processor/command/set_subcmd/kernelstep.rb +60 -0
- data/processor/command/set_subcmd/max.rb +26 -0
- data/processor/command/set_subcmd/max_subcmd/.gitignore +2 -0
- data/processor/command/set_subcmd/max_subcmd/list.rb +49 -0
- data/processor/command/set_subcmd/max_subcmd/stack.rb +50 -0
- data/processor/command/set_subcmd/max_subcmd/string.rb +76 -0
- data/processor/command/set_subcmd/max_subcmd/width.rb +49 -0
- data/processor/command/set_subcmd/reload.rb +42 -0
- data/processor/command/set_subcmd/substitute.rb +24 -0
- data/processor/command/set_subcmd/substitute_subcmd/.gitignore +3 -0
- data/processor/command/set_subcmd/substitute_subcmd/path.rb +56 -0
- data/processor/command/set_subcmd/timer.rb +58 -0
- data/processor/command/set_subcmd/trace.rb +37 -0
- data/processor/command/set_subcmd/trace_subcmd/.gitignore +2 -0
- data/processor/command/set_subcmd/trace_subcmd/buffer.rb +42 -0
- data/processor/command/set_subcmd/trace_subcmd/print.rb +41 -0
- data/processor/command/shell.rb +131 -0
- data/processor/command/show.rb +39 -0
- data/processor/command/show_subcmd/.gitignore +3 -0
- data/processor/command/show_subcmd/abbrev.rb +20 -0
- data/processor/command/show_subcmd/aliases.rb +46 -0
- data/processor/command/show_subcmd/args.rb +25 -0
- data/processor/command/show_subcmd/auto.rb +28 -0
- data/processor/command/show_subcmd/auto_subcmd/.gitignore +3 -0
- data/processor/command/show_subcmd/auto_subcmd/dis.rb +37 -0
- data/processor/command/show_subcmd/auto_subcmd/eval.rb +24 -0
- data/processor/command/show_subcmd/auto_subcmd/irb.rb +23 -0
- data/processor/command/show_subcmd/auto_subcmd/list.rb +22 -0
- data/processor/command/show_subcmd/basename.rb +20 -0
- data/processor/command/show_subcmd/confirm.rb +18 -0
- data/processor/command/show_subcmd/debug.rb +26 -0
- data/processor/command/show_subcmd/debug_subcmd/.gitignore +3 -0
- data/processor/command/show_subcmd/debug_subcmd/dbgr.rb +21 -0
- data/processor/command/show_subcmd/debug_subcmd/skip.rb +22 -0
- data/processor/command/show_subcmd/debug_subcmd/step.rb +22 -0
- data/processor/command/show_subcmd/different.rb +26 -0
- data/processor/command/show_subcmd/directories.rb +22 -0
- data/processor/command/show_subcmd/hidelevel.rb +41 -0
- data/processor/command/show_subcmd/highlight.rb +25 -0
- data/processor/command/show_subcmd/kernelstep.rb +34 -0
- data/processor/command/show_subcmd/max.rb +27 -0
- data/processor/command/show_subcmd/max_subcmd/.gitignore +2 -0
- data/processor/command/show_subcmd/max_subcmd/list.rb +38 -0
- data/processor/command/show_subcmd/max_subcmd/stack.rb +36 -0
- data/processor/command/show_subcmd/max_subcmd/string.rb +42 -0
- data/processor/command/show_subcmd/max_subcmd/width.rb +37 -0
- data/processor/command/show_subcmd/reload.rb +18 -0
- data/processor/command/show_subcmd/timer.rb +18 -0
- data/processor/command/show_subcmd/trace.rb +27 -0
- data/processor/command/show_subcmd/trace_subcmd/.gitignore +2 -0
- data/processor/command/show_subcmd/trace_subcmd/buffer.rb +64 -0
- data/processor/command/show_subcmd/trace_subcmd/print.rb +23 -0
- data/processor/command/show_subcmd/version.rb +23 -0
- data/processor/command/source.rb +133 -0
- data/processor/command/step.rb +97 -0
- data/processor/command/tbreak.rb +20 -0
- data/processor/command/unalias.rb +49 -0
- data/processor/command/undisplay.rb +63 -0
- data/processor/command/up.rb +89 -0
- data/processor/command.rb +173 -0
- data/processor/default.rb +64 -0
- data/processor/disassemble.rb +59 -0
- data/processor/display.rb +53 -0
- data/processor/eval.rb +97 -0
- data/processor/eventbuf.rb +101 -0
- data/processor/frame.rb +265 -0
- data/processor/help.rb +94 -0
- data/processor/hook.rb +134 -0
- data/processor/list.rb +123 -0
- data/processor/load_cmds.rb +253 -0
- data/processor/location.rb +228 -0
- data/processor/mock.rb +138 -0
- data/processor/msg.rb +74 -0
- data/processor/running.rb +244 -0
- data/processor/stepping.rb +135 -0
- data/processor/subcmd.rb +136 -0
- data/processor/validate.rb +379 -0
- data/processor/virtual.rb +33 -0
- data/processor.rb +404 -0
- data/rbx-trepanning.gemspec +39 -0
- data/sample/.gitignore +2 -0
- data/sample/list-terminal-colors.rb +139 -0
- data/sample/rocky-dot-trepanxrc +14 -0
- data/sample/rocky-trepanx-colors.rb +46 -0
- data/test/data/.gitignore +1 -0
- data/test/data/enable.right +36 -0
- data/test/data/fname-with-blank.cmd +6 -0
- data/test/data/fname-with-blank.right +6 -0
- data/test/data/inline-call.cmd +6 -0
- data/test/data/inline-call.right +14 -0
- data/test/data/quit-Xdebug.right +3 -0
- data/test/data/quit.cmd +5 -0
- data/test/data/quit.right +3 -0
- data/test/data/quit2.cmd +6 -0
- data/test/data/quit2.right +3 -0
- data/test/example/.gitignore +2 -0
- data/test/example/debugger-stop.rb +16 -0
- data/test/example/factorial.rb +10 -0
- data/test/example/fname with blank.rb +1 -0
- data/test/example/gcd-server.rb +22 -0
- data/test/example/gcd.rb +19 -0
- data/test/example/goto2goto.rb +11 -0
- data/test/example/inline-call.rb +23 -0
- data/test/example/null.rb +1 -0
- data/test/example/thread1.rb +3 -0
- data/test/functional/.gitignore +3 -0
- data/test/functional/fn_helper.rb +112 -0
- data/test/functional/test-break-name.rb +52 -0
- data/test/functional/test-break.rb +85 -0
- data/test/functional/test-eval.rb +115 -0
- data/test/functional/test-finish.rb +70 -0
- data/test/functional/test-fn_helper.rb +43 -0
- data/test/functional/test-list.rb +56 -0
- data/test/functional/test-next-bug.rb +49 -0
- data/test/functional/test-next.rb +101 -0
- data/test/functional/test-recursive-bt.rb +94 -0
- data/test/functional/test-step.rb +272 -0
- data/test/functional/test-step2.rb +35 -0
- data/test/functional/test-tbreak.rb +41 -0
- data/test/integration/.gitignore +3 -0
- data/test/integration/file-diff.rb +89 -0
- data/test/integration/helper.rb +81 -0
- data/test/integration/test-fname-with-blank.rb +16 -0
- data/test/integration/test-inline-call.rb +20 -0
- data/test/integration/test-quit.rb +47 -0
- data/test/unit/.gitignore +3 -0
- data/test/unit/cmd-helper.rb +50 -0
- data/test/unit/mock-helper.rb +10 -0
- data/test/unit/test-app-brkpt.rb +31 -0
- data/test/unit/test-app-brkptmgr.rb +51 -0
- data/test/unit/test-app-cmd_parse.rb +97 -0
- data/test/unit/test-app-cmd_parser.rb +23 -0
- data/test/unit/test-app-complete.rb +39 -0
- data/test/unit/test-app-condition.rb +18 -0
- data/test/unit/test-app-display.rb +22 -0
- data/test/unit/test-app-iseq.rb +64 -0
- data/test/unit/test-app-method.rb +54 -0
- data/test/unit/test-app-options.rb +94 -0
- data/test/unit/test-app-run.rb +14 -0
- data/test/unit/test-app-util.rb +44 -0
- data/test/unit/test-app-validate.rb +18 -0
- data/test/unit/test-base-cmd.rb +45 -0
- data/test/unit/test-base-subcmd.rb +57 -0
- data/test/unit/test-base-submgr.rb +24 -0
- data/test/unit/test-base-subsubcmd.rb +17 -0
- data/test/unit/test-bin-trepanx.rb +48 -0
- data/test/unit/test-cmd-alias.rb +48 -0
- data/test/unit/test-cmd-break.rb +66 -0
- data/test/unit/test-cmd-edit.rb +34 -0
- data/test/unit/test-cmd-exit.rb +27 -0
- data/test/unit/test-cmd-finish.rb +31 -0
- data/test/unit/test-cmd-help.rb +104 -0
- data/test/unit/test-cmd-kill.rb +54 -0
- data/test/unit/test-cmd-parse_list_cmd.rb +36 -0
- data/test/unit/test-cmd-source.rb +34 -0
- data/test/unit/test-cmd-step.rb +29 -0
- data/test/unit/test-command.rb +45 -0
- data/test/unit/test-completion.rb +48 -0
- data/test/unit/test-intf-user.rb +46 -0
- data/test/unit/test-io-input.rb +27 -0
- data/test/unit/test-io-tcp.rb +33 -0
- data/test/unit/test-io-tcpclient.rb +54 -0
- data/test/unit/test-io-tcpfns.rb +17 -0
- data/test/unit/test-io-tcpserver.rb +50 -0
- data/test/unit/test-proc-eval.rb +35 -0
- data/test/unit/test-proc-frame.rb +81 -0
- data/test/unit/test-proc-help.rb +16 -0
- data/test/unit/test-proc-hook.rb +30 -0
- data/test/unit/test-proc-list.rb +55 -0
- data/test/unit/test-proc-load_cmds.rb +51 -0
- data/test/unit/test-proc-location.rb +67 -0
- data/test/unit/test-proc-main.rb +95 -0
- data/test/unit/test-proc-validate.rb +139 -0
- data/test/unit/test-subcmd-help.rb +43 -0
- metadata +545 -0
data/app/cmd_parser.rb
ADDED
@@ -0,0 +1,2083 @@
|
|
1
|
+
class CmdParse
|
2
|
+
# STANDALONE START
|
3
|
+
def setup_parser(str, debug=false)
|
4
|
+
@string = str
|
5
|
+
@pos = 0
|
6
|
+
@memoizations = Hash.new { |h,k| h[k] = {} }
|
7
|
+
@result = nil
|
8
|
+
@failed_rule = nil
|
9
|
+
@failing_rule_offset = -1
|
10
|
+
end
|
11
|
+
|
12
|
+
# This is distinct from setup_parser so that a standalone parser
|
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)
|
18
|
+
end
|
19
|
+
|
20
|
+
attr_reader :string
|
21
|
+
attr_reader :result, :failing_rule_offset
|
22
|
+
attr_accessor :pos
|
23
|
+
|
24
|
+
# STANDALONE START
|
25
|
+
def current_column(target=pos)
|
26
|
+
if c = string.rindex("\n", target-1)
|
27
|
+
return target - c - 1
|
28
|
+
end
|
29
|
+
|
30
|
+
target + 1
|
31
|
+
end
|
32
|
+
|
33
|
+
def current_line(target=pos)
|
34
|
+
cur_offset = 0
|
35
|
+
cur_line = 0
|
36
|
+
|
37
|
+
string.each_line do |line|
|
38
|
+
cur_line += 1
|
39
|
+
cur_offset += line.size
|
40
|
+
return cur_line if cur_offset >= target
|
41
|
+
end
|
42
|
+
|
43
|
+
-1
|
44
|
+
end
|
45
|
+
|
46
|
+
def lines
|
47
|
+
lines = []
|
48
|
+
string.each_line { |l| lines << l }
|
49
|
+
lines
|
50
|
+
end
|
51
|
+
|
52
|
+
#
|
53
|
+
|
54
|
+
def get_text(start)
|
55
|
+
@string[start..@pos-1]
|
56
|
+
end
|
57
|
+
|
58
|
+
def show_pos
|
59
|
+
width = 10
|
60
|
+
if @pos < width
|
61
|
+
"#{@pos} (\"#{@string[0,@pos]}\" @ \"#{@string[@pos,width]}\")"
|
62
|
+
else
|
63
|
+
"#{@pos} (\"... #{@string[@pos - width, width]}\" @ \"#{@string[@pos,width]}\")"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def failure_info
|
68
|
+
l = current_line @failing_rule_offset
|
69
|
+
c = current_column @failing_rule_offset
|
70
|
+
info = self.class::Rules[@failed_rule]
|
71
|
+
|
72
|
+
"line #{l}, column #{c}: failed rule '#{info.name}' = '#{info.rendered}'"
|
73
|
+
end
|
74
|
+
|
75
|
+
def failure_caret
|
76
|
+
l = current_line @failing_rule_offset
|
77
|
+
c = current_column @failing_rule_offset
|
78
|
+
|
79
|
+
line = lines[l-1]
|
80
|
+
"#{line}\n#{' ' * (c - 1)}^"
|
81
|
+
end
|
82
|
+
|
83
|
+
def failure_character
|
84
|
+
l = current_line @failing_rule_offset
|
85
|
+
c = current_column @failing_rule_offset
|
86
|
+
lines[l-1][c-1, 1]
|
87
|
+
end
|
88
|
+
|
89
|
+
def failure_oneline
|
90
|
+
l = current_line @failing_rule_offset
|
91
|
+
c = current_column @failing_rule_offset
|
92
|
+
|
93
|
+
info = self.class::Rules[@failed_rule]
|
94
|
+
char = lines[l-1][c-1, 1]
|
95
|
+
|
96
|
+
"@#{l}:#{c} failed rule '#{info.name}', got '#{char}'"
|
97
|
+
end
|
98
|
+
|
99
|
+
class ParseError < RuntimeError
|
100
|
+
end
|
101
|
+
|
102
|
+
def raise_error
|
103
|
+
raise ParseError, failure_oneline
|
104
|
+
end
|
105
|
+
|
106
|
+
def show_error(io=STDOUT)
|
107
|
+
error_pos = @failing_rule_offset
|
108
|
+
line_no = current_line(error_pos)
|
109
|
+
col_no = current_column(error_pos)
|
110
|
+
|
111
|
+
info = self.class::Rules[@failed_rule]
|
112
|
+
io.puts "On line #{line_no}, column #{col_no}:"
|
113
|
+
io.puts "Failed to match '#{info.rendered}' (rule '#{info.name}')"
|
114
|
+
io.puts "Got: #{string[error_pos,1].inspect}"
|
115
|
+
line = lines[line_no-1]
|
116
|
+
io.puts "=> #{line}"
|
117
|
+
io.print(" " * (col_no + 3))
|
118
|
+
io.puts "^"
|
119
|
+
end
|
120
|
+
|
121
|
+
def set_failed_rule(name)
|
122
|
+
if @pos > @failing_rule_offset
|
123
|
+
@failed_rule = name
|
124
|
+
@failing_rule_offset = @pos
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
attr_reader :failed_rule
|
129
|
+
|
130
|
+
def match_string(str)
|
131
|
+
len = str.size
|
132
|
+
if @string[pos,len] == str
|
133
|
+
@pos += len
|
134
|
+
return str
|
135
|
+
end
|
136
|
+
|
137
|
+
return nil
|
138
|
+
end
|
139
|
+
|
140
|
+
def scan(reg)
|
141
|
+
if m = reg.match(@string[@pos..-1])
|
142
|
+
width = m.end(0)
|
143
|
+
@pos += width
|
144
|
+
return true
|
145
|
+
end
|
146
|
+
|
147
|
+
return nil
|
148
|
+
end
|
149
|
+
|
150
|
+
if "".respond_to? :getbyte
|
151
|
+
def get_byte
|
152
|
+
if @pos >= @string.size
|
153
|
+
return nil
|
154
|
+
end
|
155
|
+
|
156
|
+
s = @string.getbyte @pos
|
157
|
+
@pos += 1
|
158
|
+
s
|
159
|
+
end
|
160
|
+
else
|
161
|
+
def get_byte
|
162
|
+
if @pos >= @string.size
|
163
|
+
return nil
|
164
|
+
end
|
165
|
+
|
166
|
+
s = @string[@pos]
|
167
|
+
@pos += 1
|
168
|
+
s
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
def parse
|
173
|
+
_root ? true : false
|
174
|
+
end
|
175
|
+
|
176
|
+
class LeftRecursive
|
177
|
+
def initialize(detected=false)
|
178
|
+
@detected = detected
|
179
|
+
end
|
180
|
+
|
181
|
+
attr_accessor :detected
|
182
|
+
end
|
183
|
+
|
184
|
+
class MemoEntry
|
185
|
+
def initialize(ans, pos)
|
186
|
+
@ans = ans
|
187
|
+
@pos = pos
|
188
|
+
@uses = 1
|
189
|
+
@result = nil
|
190
|
+
end
|
191
|
+
|
192
|
+
attr_reader :ans, :pos, :uses, :result
|
193
|
+
|
194
|
+
def inc!
|
195
|
+
@uses += 1
|
196
|
+
end
|
197
|
+
|
198
|
+
def move!(ans, pos, result)
|
199
|
+
@ans = ans
|
200
|
+
@pos = pos
|
201
|
+
@result = result
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
def apply(rule)
|
206
|
+
if m = @memoizations[rule][@pos]
|
207
|
+
m.inc!
|
208
|
+
|
209
|
+
prev = @pos
|
210
|
+
@pos = m.pos
|
211
|
+
if m.ans.kind_of? LeftRecursive
|
212
|
+
m.ans.detected = true
|
213
|
+
return nil
|
214
|
+
end
|
215
|
+
|
216
|
+
@result = m.result
|
217
|
+
|
218
|
+
return m.ans
|
219
|
+
else
|
220
|
+
lr = LeftRecursive.new(false)
|
221
|
+
m = MemoEntry.new(lr, @pos)
|
222
|
+
@memoizations[rule][@pos] = m
|
223
|
+
start_pos = @pos
|
224
|
+
|
225
|
+
ans = __send__ rule
|
226
|
+
|
227
|
+
m.move! ans, @pos, @result
|
228
|
+
|
229
|
+
# Don't bother trying to grow the left recursion
|
230
|
+
# if it's failing straight away (thus there is no seed)
|
231
|
+
if ans and lr.detected
|
232
|
+
return grow_lr(rule, start_pos, m)
|
233
|
+
else
|
234
|
+
return ans
|
235
|
+
end
|
236
|
+
|
237
|
+
return ans
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
def grow_lr(rule, start_pos, m)
|
242
|
+
while true
|
243
|
+
@pos = start_pos
|
244
|
+
@result = m.result
|
245
|
+
|
246
|
+
ans = __send__ rule
|
247
|
+
return nil unless ans
|
248
|
+
|
249
|
+
break if @pos <= m.pos
|
250
|
+
|
251
|
+
m.move! ans, @pos, @result
|
252
|
+
end
|
253
|
+
|
254
|
+
@result = m.result
|
255
|
+
@pos = m.pos
|
256
|
+
return m.ans
|
257
|
+
end
|
258
|
+
|
259
|
+
class RuleInfo
|
260
|
+
def initialize(name, rendered)
|
261
|
+
@name = name
|
262
|
+
@rendered = rendered
|
263
|
+
end
|
264
|
+
|
265
|
+
attr_reader :name, :rendered
|
266
|
+
end
|
267
|
+
|
268
|
+
def self.rule_info(name, rendered)
|
269
|
+
RuleInfo.new(name, rendered)
|
270
|
+
end
|
271
|
+
|
272
|
+
#
|
273
|
+
|
274
|
+
|
275
|
+
#####################################################
|
276
|
+
# Structure to hold composite method names
|
277
|
+
SymbolEntry = Struct.new(:type, :name, :chain)
|
278
|
+
|
279
|
+
|
280
|
+
# Structure to hold position information
|
281
|
+
Position = Struct.new(:container_type, :container,
|
282
|
+
:position_type, :position)
|
283
|
+
|
284
|
+
# Structure to hold breakpoint information
|
285
|
+
Breakpoint = Struct.new(:position, :negate, :condition)
|
286
|
+
|
287
|
+
# Structure to hold list information
|
288
|
+
List = Struct.new(:position, :num)
|
289
|
+
|
290
|
+
DEFAULT_OPTS = {
|
291
|
+
:debug=>false,
|
292
|
+
:file_exists_proc => Proc.new{|filename|
|
293
|
+
File.readable?(filename) && !File.directory?(filename)
|
294
|
+
}
|
295
|
+
}
|
296
|
+
def initialize(str, opts={})
|
297
|
+
@opts = DEFAULT_OPTS.merge(opts)
|
298
|
+
setup_parser(str, opts[:debug])
|
299
|
+
@file_exists_proc = @opts[:file_exists_proc]
|
300
|
+
end
|
301
|
+
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
|
306
|
+
# upcase_letter = /[A-Z]/
|
307
|
+
def _upcase_letter
|
308
|
+
_tmp = scan(/\A(?-mix:[A-Z])/)
|
309
|
+
set_failed_rule :_upcase_letter unless _tmp
|
310
|
+
return _tmp
|
311
|
+
end
|
312
|
+
|
313
|
+
# downcase_letter = /[a-z]/
|
314
|
+
def _downcase_letter
|
315
|
+
_tmp = scan(/\A(?-mix:[a-z])/)
|
316
|
+
set_failed_rule :_downcase_letter unless _tmp
|
317
|
+
return _tmp
|
318
|
+
end
|
319
|
+
|
320
|
+
# suffix_letter = /[=!?]/
|
321
|
+
def _suffix_letter
|
322
|
+
_tmp = scan(/\A(?-mix:[=!?])/)
|
323
|
+
set_failed_rule :_suffix_letter unless _tmp
|
324
|
+
return _tmp
|
325
|
+
end
|
326
|
+
|
327
|
+
# letter = (upcase_letter | downcase_letter)
|
328
|
+
def _letter
|
329
|
+
|
330
|
+
_save = self.pos
|
331
|
+
while true # choice
|
332
|
+
_tmp = apply(:_upcase_letter)
|
333
|
+
break if _tmp
|
334
|
+
self.pos = _save
|
335
|
+
_tmp = apply(:_downcase_letter)
|
336
|
+
break if _tmp
|
337
|
+
self.pos = _save
|
338
|
+
break
|
339
|
+
end # end choice
|
340
|
+
|
341
|
+
set_failed_rule :_letter unless _tmp
|
342
|
+
return _tmp
|
343
|
+
end
|
344
|
+
|
345
|
+
# id_symbol = (letter | "_" | [0-9])
|
346
|
+
def _id_symbol
|
347
|
+
|
348
|
+
_save = self.pos
|
349
|
+
while true # choice
|
350
|
+
_tmp = apply(:_letter)
|
351
|
+
break if _tmp
|
352
|
+
self.pos = _save
|
353
|
+
_tmp = match_string("_")
|
354
|
+
break if _tmp
|
355
|
+
self.pos = _save
|
356
|
+
_save1 = self.pos
|
357
|
+
_tmp = get_byte
|
358
|
+
if _tmp
|
359
|
+
unless _tmp >= 48 and _tmp <= 57
|
360
|
+
self.pos = _save1
|
361
|
+
_tmp = nil
|
362
|
+
end
|
363
|
+
end
|
364
|
+
break if _tmp
|
365
|
+
self.pos = _save
|
366
|
+
break
|
367
|
+
end # end choice
|
368
|
+
|
369
|
+
set_failed_rule :_id_symbol unless _tmp
|
370
|
+
return _tmp
|
371
|
+
end
|
372
|
+
|
373
|
+
# vm_identifier = < (downcase_letter | "_") id_symbol* suffix_letter? > { SymbolEntry.new(:variable, text) }
|
374
|
+
def _vm_identifier
|
375
|
+
|
376
|
+
_save = self.pos
|
377
|
+
while true # sequence
|
378
|
+
_text_start = self.pos
|
379
|
+
|
380
|
+
_save1 = self.pos
|
381
|
+
while true # sequence
|
382
|
+
|
383
|
+
_save2 = self.pos
|
384
|
+
while true # choice
|
385
|
+
_tmp = apply(:_downcase_letter)
|
386
|
+
break if _tmp
|
387
|
+
self.pos = _save2
|
388
|
+
_tmp = match_string("_")
|
389
|
+
break if _tmp
|
390
|
+
self.pos = _save2
|
391
|
+
break
|
392
|
+
end # end choice
|
393
|
+
|
394
|
+
unless _tmp
|
395
|
+
self.pos = _save1
|
396
|
+
break
|
397
|
+
end
|
398
|
+
while true
|
399
|
+
_tmp = apply(:_id_symbol)
|
400
|
+
break unless _tmp
|
401
|
+
end
|
402
|
+
_tmp = true
|
403
|
+
unless _tmp
|
404
|
+
self.pos = _save1
|
405
|
+
break
|
406
|
+
end
|
407
|
+
_save4 = self.pos
|
408
|
+
_tmp = apply(:_suffix_letter)
|
409
|
+
unless _tmp
|
410
|
+
_tmp = true
|
411
|
+
self.pos = _save4
|
412
|
+
end
|
413
|
+
unless _tmp
|
414
|
+
self.pos = _save1
|
415
|
+
end
|
416
|
+
break
|
417
|
+
end # end sequence
|
418
|
+
|
419
|
+
if _tmp
|
420
|
+
text = get_text(_text_start)
|
421
|
+
end
|
422
|
+
unless _tmp
|
423
|
+
self.pos = _save
|
424
|
+
break
|
425
|
+
end
|
426
|
+
@result = begin;
|
427
|
+
SymbolEntry.new(:variable, text)
|
428
|
+
; end
|
429
|
+
_tmp = true
|
430
|
+
unless _tmp
|
431
|
+
self.pos = _save
|
432
|
+
end
|
433
|
+
break
|
434
|
+
end # end sequence
|
435
|
+
|
436
|
+
set_failed_rule :_vm_identifier unless _tmp
|
437
|
+
return _tmp
|
438
|
+
end
|
439
|
+
|
440
|
+
# variable_identifier = < (downcase_letter | "_") id_symbol* > { SymbolEntry.new(:variable, text) }
|
441
|
+
def _variable_identifier
|
442
|
+
|
443
|
+
_save = self.pos
|
444
|
+
while true # sequence
|
445
|
+
_text_start = self.pos
|
446
|
+
|
447
|
+
_save1 = self.pos
|
448
|
+
while true # sequence
|
449
|
+
|
450
|
+
_save2 = self.pos
|
451
|
+
while true # choice
|
452
|
+
_tmp = apply(:_downcase_letter)
|
453
|
+
break if _tmp
|
454
|
+
self.pos = _save2
|
455
|
+
_tmp = match_string("_")
|
456
|
+
break if _tmp
|
457
|
+
self.pos = _save2
|
458
|
+
break
|
459
|
+
end # end choice
|
460
|
+
|
461
|
+
unless _tmp
|
462
|
+
self.pos = _save1
|
463
|
+
break
|
464
|
+
end
|
465
|
+
while true
|
466
|
+
_tmp = apply(:_id_symbol)
|
467
|
+
break unless _tmp
|
468
|
+
end
|
469
|
+
_tmp = true
|
470
|
+
unless _tmp
|
471
|
+
self.pos = _save1
|
472
|
+
end
|
473
|
+
break
|
474
|
+
end # end sequence
|
475
|
+
|
476
|
+
if _tmp
|
477
|
+
text = get_text(_text_start)
|
478
|
+
end
|
479
|
+
unless _tmp
|
480
|
+
self.pos = _save
|
481
|
+
break
|
482
|
+
end
|
483
|
+
@result = begin;
|
484
|
+
SymbolEntry.new(:variable, text)
|
485
|
+
; end
|
486
|
+
_tmp = true
|
487
|
+
unless _tmp
|
488
|
+
self.pos = _save
|
489
|
+
end
|
490
|
+
break
|
491
|
+
end # end sequence
|
492
|
+
|
493
|
+
set_failed_rule :_variable_identifier unless _tmp
|
494
|
+
return _tmp
|
495
|
+
end
|
496
|
+
|
497
|
+
# constant_identifier = < upcase_letter id_symbol* > { SymbolEntry.new(:constant, text) }
|
498
|
+
def _constant_identifier
|
499
|
+
|
500
|
+
_save = self.pos
|
501
|
+
while true # sequence
|
502
|
+
_text_start = self.pos
|
503
|
+
|
504
|
+
_save1 = self.pos
|
505
|
+
while true # sequence
|
506
|
+
_tmp = apply(:_upcase_letter)
|
507
|
+
unless _tmp
|
508
|
+
self.pos = _save1
|
509
|
+
break
|
510
|
+
end
|
511
|
+
while true
|
512
|
+
_tmp = apply(:_id_symbol)
|
513
|
+
break unless _tmp
|
514
|
+
end
|
515
|
+
_tmp = true
|
516
|
+
unless _tmp
|
517
|
+
self.pos = _save1
|
518
|
+
end
|
519
|
+
break
|
520
|
+
end # end sequence
|
521
|
+
|
522
|
+
if _tmp
|
523
|
+
text = get_text(_text_start)
|
524
|
+
end
|
525
|
+
unless _tmp
|
526
|
+
self.pos = _save
|
527
|
+
break
|
528
|
+
end
|
529
|
+
@result = begin;
|
530
|
+
SymbolEntry.new(:constant, text)
|
531
|
+
; end
|
532
|
+
_tmp = true
|
533
|
+
unless _tmp
|
534
|
+
self.pos = _save
|
535
|
+
end
|
536
|
+
break
|
537
|
+
end # end sequence
|
538
|
+
|
539
|
+
set_failed_rule :_constant_identifier unless _tmp
|
540
|
+
return _tmp
|
541
|
+
end
|
542
|
+
|
543
|
+
# global_identifier = < "$" (constant_identifier | variable_identifier) > { SymbolEntry.new(:global, text) }
|
544
|
+
def _global_identifier
|
545
|
+
|
546
|
+
_save = self.pos
|
547
|
+
while true # sequence
|
548
|
+
_text_start = self.pos
|
549
|
+
|
550
|
+
_save1 = self.pos
|
551
|
+
while true # sequence
|
552
|
+
_tmp = match_string("$")
|
553
|
+
unless _tmp
|
554
|
+
self.pos = _save1
|
555
|
+
break
|
556
|
+
end
|
557
|
+
|
558
|
+
_save2 = self.pos
|
559
|
+
while true # choice
|
560
|
+
_tmp = apply(:_constant_identifier)
|
561
|
+
break if _tmp
|
562
|
+
self.pos = _save2
|
563
|
+
_tmp = apply(:_variable_identifier)
|
564
|
+
break if _tmp
|
565
|
+
self.pos = _save2
|
566
|
+
break
|
567
|
+
end # end choice
|
568
|
+
|
569
|
+
unless _tmp
|
570
|
+
self.pos = _save1
|
571
|
+
end
|
572
|
+
break
|
573
|
+
end # end sequence
|
574
|
+
|
575
|
+
if _tmp
|
576
|
+
text = get_text(_text_start)
|
577
|
+
end
|
578
|
+
unless _tmp
|
579
|
+
self.pos = _save
|
580
|
+
break
|
581
|
+
end
|
582
|
+
@result = begin;
|
583
|
+
SymbolEntry.new(:global, text)
|
584
|
+
; end
|
585
|
+
_tmp = true
|
586
|
+
unless _tmp
|
587
|
+
self.pos = _save
|
588
|
+
end
|
589
|
+
break
|
590
|
+
end # end sequence
|
591
|
+
|
592
|
+
set_failed_rule :_global_identifier unless _tmp
|
593
|
+
return _tmp
|
594
|
+
end
|
595
|
+
|
596
|
+
# local_internal_identifier = (constant_identifier | variable_identifier)
|
597
|
+
def _local_internal_identifier
|
598
|
+
|
599
|
+
_save = self.pos
|
600
|
+
while true # choice
|
601
|
+
_tmp = apply(:_constant_identifier)
|
602
|
+
break if _tmp
|
603
|
+
self.pos = _save
|
604
|
+
_tmp = apply(:_variable_identifier)
|
605
|
+
break if _tmp
|
606
|
+
self.pos = _save
|
607
|
+
break
|
608
|
+
end # end choice
|
609
|
+
|
610
|
+
set_failed_rule :_local_internal_identifier unless _tmp
|
611
|
+
return _tmp
|
612
|
+
end
|
613
|
+
|
614
|
+
# local_identifier = (constant_identifier | vm_identifier)
|
615
|
+
def _local_identifier
|
616
|
+
|
617
|
+
_save = self.pos
|
618
|
+
while true # choice
|
619
|
+
_tmp = apply(:_constant_identifier)
|
620
|
+
break if _tmp
|
621
|
+
self.pos = _save
|
622
|
+
_tmp = apply(:_vm_identifier)
|
623
|
+
break if _tmp
|
624
|
+
self.pos = _save
|
625
|
+
break
|
626
|
+
end # end choice
|
627
|
+
|
628
|
+
set_failed_rule :_local_identifier unless _tmp
|
629
|
+
return _tmp
|
630
|
+
end
|
631
|
+
|
632
|
+
# instance_identifier = < "@" local_identifier > { SymbolEntry.new(:instance, text) }
|
633
|
+
def _instance_identifier
|
634
|
+
|
635
|
+
_save = self.pos
|
636
|
+
while true # sequence
|
637
|
+
_text_start = self.pos
|
638
|
+
|
639
|
+
_save1 = self.pos
|
640
|
+
while true # sequence
|
641
|
+
_tmp = match_string("@")
|
642
|
+
unless _tmp
|
643
|
+
self.pos = _save1
|
644
|
+
break
|
645
|
+
end
|
646
|
+
_tmp = apply(:_local_identifier)
|
647
|
+
unless _tmp
|
648
|
+
self.pos = _save1
|
649
|
+
end
|
650
|
+
break
|
651
|
+
end # end sequence
|
652
|
+
|
653
|
+
if _tmp
|
654
|
+
text = get_text(_text_start)
|
655
|
+
end
|
656
|
+
unless _tmp
|
657
|
+
self.pos = _save
|
658
|
+
break
|
659
|
+
end
|
660
|
+
@result = begin;
|
661
|
+
SymbolEntry.new(:instance, text)
|
662
|
+
; end
|
663
|
+
_tmp = true
|
664
|
+
unless _tmp
|
665
|
+
self.pos = _save
|
666
|
+
end
|
667
|
+
break
|
668
|
+
end # end sequence
|
669
|
+
|
670
|
+
set_failed_rule :_instance_identifier unless _tmp
|
671
|
+
return _tmp
|
672
|
+
end
|
673
|
+
|
674
|
+
# classvar_identifier = "@@" local_identifier:id { SymbolEntry.new(:classvar, id) }
|
675
|
+
def _classvar_identifier
|
676
|
+
|
677
|
+
_save = self.pos
|
678
|
+
while true # sequence
|
679
|
+
_tmp = match_string("@@")
|
680
|
+
unless _tmp
|
681
|
+
self.pos = _save
|
682
|
+
break
|
683
|
+
end
|
684
|
+
_tmp = apply(:_local_identifier)
|
685
|
+
id = @result
|
686
|
+
unless _tmp
|
687
|
+
self.pos = _save
|
688
|
+
break
|
689
|
+
end
|
690
|
+
@result = begin;
|
691
|
+
SymbolEntry.new(:classvar, id)
|
692
|
+
; end
|
693
|
+
_tmp = true
|
694
|
+
unless _tmp
|
695
|
+
self.pos = _save
|
696
|
+
end
|
697
|
+
break
|
698
|
+
end # end sequence
|
699
|
+
|
700
|
+
set_failed_rule :_classvar_identifier unless _tmp
|
701
|
+
return _tmp
|
702
|
+
end
|
703
|
+
|
704
|
+
# identifier = (global_identifier | instance_identifier | classvar_identifier | local_identifier)
|
705
|
+
def _identifier
|
706
|
+
|
707
|
+
_save = self.pos
|
708
|
+
while true # choice
|
709
|
+
_tmp = apply(:_global_identifier)
|
710
|
+
break if _tmp
|
711
|
+
self.pos = _save
|
712
|
+
_tmp = apply(:_instance_identifier)
|
713
|
+
break if _tmp
|
714
|
+
self.pos = _save
|
715
|
+
_tmp = apply(:_classvar_identifier)
|
716
|
+
break if _tmp
|
717
|
+
self.pos = _save
|
718
|
+
_tmp = apply(:_local_identifier)
|
719
|
+
break if _tmp
|
720
|
+
self.pos = _save
|
721
|
+
break
|
722
|
+
end # end choice
|
723
|
+
|
724
|
+
set_failed_rule :_identifier unless _tmp
|
725
|
+
return _tmp
|
726
|
+
end
|
727
|
+
|
728
|
+
# id_separator = < ("::" | ".") > { text }
|
729
|
+
def _id_separator
|
730
|
+
|
731
|
+
_save = self.pos
|
732
|
+
while true # sequence
|
733
|
+
_text_start = self.pos
|
734
|
+
|
735
|
+
_save1 = self.pos
|
736
|
+
while true # choice
|
737
|
+
_tmp = match_string("::")
|
738
|
+
break if _tmp
|
739
|
+
self.pos = _save1
|
740
|
+
_tmp = match_string(".")
|
741
|
+
break if _tmp
|
742
|
+
self.pos = _save1
|
743
|
+
break
|
744
|
+
end # end choice
|
745
|
+
|
746
|
+
if _tmp
|
747
|
+
text = get_text(_text_start)
|
748
|
+
end
|
749
|
+
unless _tmp
|
750
|
+
self.pos = _save
|
751
|
+
break
|
752
|
+
end
|
753
|
+
@result = begin; text ; end
|
754
|
+
_tmp = true
|
755
|
+
unless _tmp
|
756
|
+
self.pos = _save
|
757
|
+
end
|
758
|
+
break
|
759
|
+
end # end sequence
|
760
|
+
|
761
|
+
set_failed_rule :_id_separator unless _tmp
|
762
|
+
return _tmp
|
763
|
+
end
|
764
|
+
|
765
|
+
# 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)
|
766
|
+
def _internal_class_module_chain
|
767
|
+
|
768
|
+
_save = self.pos
|
769
|
+
while true # choice
|
770
|
+
|
771
|
+
_save1 = self.pos
|
772
|
+
while true # sequence
|
773
|
+
_text_start = self.pos
|
774
|
+
|
775
|
+
_save2 = self.pos
|
776
|
+
while true # sequence
|
777
|
+
_tmp = apply(:_local_internal_identifier)
|
778
|
+
parent = @result
|
779
|
+
unless _tmp
|
780
|
+
self.pos = _save2
|
781
|
+
break
|
782
|
+
end
|
783
|
+
_tmp = apply(:_id_separator)
|
784
|
+
sep = @result
|
785
|
+
unless _tmp
|
786
|
+
self.pos = _save2
|
787
|
+
break
|
788
|
+
end
|
789
|
+
_tmp = apply(:_internal_class_module_chain)
|
790
|
+
child = @result
|
791
|
+
unless _tmp
|
792
|
+
self.pos = _save2
|
793
|
+
end
|
794
|
+
break
|
795
|
+
end # end sequence
|
796
|
+
|
797
|
+
if _tmp
|
798
|
+
text = get_text(_text_start)
|
799
|
+
end
|
800
|
+
unless _tmp
|
801
|
+
self.pos = _save1
|
802
|
+
break
|
803
|
+
end
|
804
|
+
@result = begin;
|
805
|
+
SymbolEntry.new(parent.type, text, [parent, child, sep])
|
806
|
+
; end
|
807
|
+
_tmp = true
|
808
|
+
unless _tmp
|
809
|
+
self.pos = _save1
|
810
|
+
end
|
811
|
+
break
|
812
|
+
end # end sequence
|
813
|
+
|
814
|
+
break if _tmp
|
815
|
+
self.pos = _save
|
816
|
+
_tmp = apply(:_local_identifier)
|
817
|
+
break if _tmp
|
818
|
+
self.pos = _save
|
819
|
+
break
|
820
|
+
end # end choice
|
821
|
+
|
822
|
+
set_failed_rule :_internal_class_module_chain unless _tmp
|
823
|
+
return _tmp
|
824
|
+
end
|
825
|
+
|
826
|
+
# class_module_chain = (< identifier:parent id_separator:sep internal_class_module_chain:child > { SymbolEntry.new(parent.type, text, [parent, child, sep]) } | identifier)
|
827
|
+
def _class_module_chain
|
828
|
+
|
829
|
+
_save = self.pos
|
830
|
+
while true # choice
|
831
|
+
|
832
|
+
_save1 = self.pos
|
833
|
+
while true # sequence
|
834
|
+
_text_start = self.pos
|
835
|
+
|
836
|
+
_save2 = self.pos
|
837
|
+
while true # sequence
|
838
|
+
_tmp = apply(:_identifier)
|
839
|
+
parent = @result
|
840
|
+
unless _tmp
|
841
|
+
self.pos = _save2
|
842
|
+
break
|
843
|
+
end
|
844
|
+
_tmp = apply(:_id_separator)
|
845
|
+
sep = @result
|
846
|
+
unless _tmp
|
847
|
+
self.pos = _save2
|
848
|
+
break
|
849
|
+
end
|
850
|
+
_tmp = apply(:_internal_class_module_chain)
|
851
|
+
child = @result
|
852
|
+
unless _tmp
|
853
|
+
self.pos = _save2
|
854
|
+
end
|
855
|
+
break
|
856
|
+
end # end sequence
|
857
|
+
|
858
|
+
if _tmp
|
859
|
+
text = get_text(_text_start)
|
860
|
+
end
|
861
|
+
unless _tmp
|
862
|
+
self.pos = _save1
|
863
|
+
break
|
864
|
+
end
|
865
|
+
@result = begin;
|
866
|
+
SymbolEntry.new(parent.type, text, [parent, child, sep])
|
867
|
+
; end
|
868
|
+
_tmp = true
|
869
|
+
unless _tmp
|
870
|
+
self.pos = _save1
|
871
|
+
end
|
872
|
+
break
|
873
|
+
end # end sequence
|
874
|
+
|
875
|
+
break if _tmp
|
876
|
+
self.pos = _save
|
877
|
+
_tmp = apply(:_identifier)
|
878
|
+
break if _tmp
|
879
|
+
self.pos = _save
|
880
|
+
break
|
881
|
+
end # end choice
|
882
|
+
|
883
|
+
set_failed_rule :_class_module_chain unless _tmp
|
884
|
+
return _tmp
|
885
|
+
end
|
886
|
+
|
887
|
+
# sp = /[ \t]/
|
888
|
+
def _sp
|
889
|
+
_tmp = scan(/\A(?-mix:[ \t])/)
|
890
|
+
set_failed_rule :_sp unless _tmp
|
891
|
+
return _tmp
|
892
|
+
end
|
893
|
+
|
894
|
+
# - = sp+
|
895
|
+
def __hyphen_
|
896
|
+
_save = self.pos
|
897
|
+
_tmp = apply(:_sp)
|
898
|
+
if _tmp
|
899
|
+
while true
|
900
|
+
_tmp = apply(:_sp)
|
901
|
+
break unless _tmp
|
902
|
+
end
|
903
|
+
_tmp = true
|
904
|
+
else
|
905
|
+
self.pos = _save
|
906
|
+
end
|
907
|
+
set_failed_rule :__hyphen_ unless _tmp
|
908
|
+
return _tmp
|
909
|
+
end
|
910
|
+
|
911
|
+
# dbl_escapes = ("\\\"" { '"' } | "\\n" { "\n" } | "\\t" { "\t" } | "\\\\" { "\\" })
|
912
|
+
def _dbl_escapes
|
913
|
+
|
914
|
+
_save = self.pos
|
915
|
+
while true # choice
|
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
|
931
|
+
|
932
|
+
break if _tmp
|
933
|
+
self.pos = _save
|
934
|
+
|
935
|
+
_save2 = self.pos
|
936
|
+
while true # sequence
|
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
|
947
|
+
break
|
948
|
+
end # end sequence
|
949
|
+
|
950
|
+
break if _tmp
|
951
|
+
self.pos = _save
|
952
|
+
|
953
|
+
_save3 = self.pos
|
954
|
+
while true # sequence
|
955
|
+
_tmp = match_string("\\t")
|
956
|
+
unless _tmp
|
957
|
+
self.pos = _save3
|
958
|
+
break
|
959
|
+
end
|
960
|
+
@result = begin; "\t" ; end
|
961
|
+
_tmp = true
|
962
|
+
unless _tmp
|
963
|
+
self.pos = _save3
|
964
|
+
end
|
965
|
+
break
|
966
|
+
end # end sequence
|
967
|
+
|
968
|
+
break if _tmp
|
969
|
+
self.pos = _save
|
970
|
+
|
971
|
+
_save4 = self.pos
|
972
|
+
while true # sequence
|
973
|
+
_tmp = match_string("\\\\")
|
974
|
+
unless _tmp
|
975
|
+
self.pos = _save4
|
976
|
+
break
|
977
|
+
end
|
978
|
+
@result = begin; "\\" ; end
|
979
|
+
_tmp = true
|
980
|
+
unless _tmp
|
981
|
+
self.pos = _save4
|
982
|
+
end
|
983
|
+
break
|
984
|
+
end # end sequence
|
985
|
+
|
986
|
+
break if _tmp
|
987
|
+
self.pos = _save
|
988
|
+
break
|
989
|
+
end # end choice
|
990
|
+
|
991
|
+
set_failed_rule :_dbl_escapes unless _tmp
|
992
|
+
return _tmp
|
993
|
+
end
|
994
|
+
|
995
|
+
# escapes = ("\\\"" { '"' } | "\\n" { "\n" } | "\\t" { "\t" } | "\\ " { " " } | "\\:" { ":" } | "\\\\" { "\\" })
|
996
|
+
def _escapes
|
997
|
+
|
998
|
+
_save = self.pos
|
999
|
+
while true # choice
|
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
|
1015
|
+
|
1016
|
+
break if _tmp
|
1017
|
+
self.pos = _save
|
1018
|
+
|
1019
|
+
_save2 = self.pos
|
1020
|
+
while true # sequence
|
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
|
1031
|
+
break
|
1032
|
+
end # end sequence
|
1033
|
+
|
1034
|
+
break if _tmp
|
1035
|
+
self.pos = _save
|
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
|
1051
|
+
|
1052
|
+
break if _tmp
|
1053
|
+
self.pos = _save
|
1054
|
+
|
1055
|
+
_save4 = self.pos
|
1056
|
+
while true # sequence
|
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
|
1067
|
+
break
|
1068
|
+
end # end sequence
|
1069
|
+
|
1070
|
+
break if _tmp
|
1071
|
+
self.pos = _save
|
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
|
1087
|
+
|
1088
|
+
break if _tmp
|
1089
|
+
self.pos = _save
|
1090
|
+
|
1091
|
+
_save6 = self.pos
|
1092
|
+
while true # sequence
|
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
|
1103
|
+
break
|
1104
|
+
end # end sequence
|
1105
|
+
|
1106
|
+
break if _tmp
|
1107
|
+
self.pos = _save
|
1108
|
+
break
|
1109
|
+
end # end choice
|
1110
|
+
|
1111
|
+
set_failed_rule :_escapes unless _tmp
|
1112
|
+
return _tmp
|
1113
|
+
end
|
1114
|
+
|
1115
|
+
# dbl_seq = < /[^\\"]+/ > { text }
|
1116
|
+
def _dbl_seq
|
1117
|
+
|
1118
|
+
_save = self.pos
|
1119
|
+
while true # sequence
|
1120
|
+
_text_start = self.pos
|
1121
|
+
_tmp = scan(/\A(?-mix:[^\\"]+)/)
|
1122
|
+
if _tmp
|
1123
|
+
text = get_text(_text_start)
|
1124
|
+
end
|
1125
|
+
unless _tmp
|
1126
|
+
self.pos = _save
|
1127
|
+
break
|
1128
|
+
end
|
1129
|
+
@result = begin; text ; end
|
1130
|
+
_tmp = true
|
1131
|
+
unless _tmp
|
1132
|
+
self.pos = _save
|
1133
|
+
end
|
1134
|
+
break
|
1135
|
+
end # end sequence
|
1136
|
+
|
1137
|
+
set_failed_rule :_dbl_seq unless _tmp
|
1138
|
+
return _tmp
|
1139
|
+
end
|
1140
|
+
|
1141
|
+
# dbl_not_quote = (dbl_escapes | dbl_seq)+:ary { ary }
|
1142
|
+
def _dbl_not_quote
|
1143
|
+
|
1144
|
+
_save = self.pos
|
1145
|
+
while true # sequence
|
1146
|
+
_save1 = self.pos
|
1147
|
+
_ary = []
|
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
|
1159
|
+
|
1160
|
+
if _tmp
|
1161
|
+
_ary << @result
|
1162
|
+
while true
|
1163
|
+
|
1164
|
+
_save3 = self.pos
|
1165
|
+
while true # choice
|
1166
|
+
_tmp = apply(:_dbl_escapes)
|
1167
|
+
break if _tmp
|
1168
|
+
self.pos = _save3
|
1169
|
+
_tmp = apply(:_dbl_seq)
|
1170
|
+
break if _tmp
|
1171
|
+
self.pos = _save3
|
1172
|
+
break
|
1173
|
+
end # end choice
|
1174
|
+
|
1175
|
+
_ary << @result if _tmp
|
1176
|
+
break unless _tmp
|
1177
|
+
end
|
1178
|
+
_tmp = true
|
1179
|
+
@result = _ary
|
1180
|
+
else
|
1181
|
+
self.pos = _save1
|
1182
|
+
end
|
1183
|
+
ary = @result
|
1184
|
+
unless _tmp
|
1185
|
+
self.pos = _save
|
1186
|
+
break
|
1187
|
+
end
|
1188
|
+
@result = begin; ary ; end
|
1189
|
+
_tmp = true
|
1190
|
+
unless _tmp
|
1191
|
+
self.pos = _save
|
1192
|
+
end
|
1193
|
+
break
|
1194
|
+
end # end sequence
|
1195
|
+
|
1196
|
+
set_failed_rule :_dbl_not_quote unless _tmp
|
1197
|
+
return _tmp
|
1198
|
+
end
|
1199
|
+
|
1200
|
+
# dbl_string = "\"" dbl_not_quote:ary "\"" { ary.join }
|
1201
|
+
def _dbl_string
|
1202
|
+
|
1203
|
+
_save = self.pos
|
1204
|
+
while true # sequence
|
1205
|
+
_tmp = match_string("\"")
|
1206
|
+
unless _tmp
|
1207
|
+
self.pos = _save
|
1208
|
+
break
|
1209
|
+
end
|
1210
|
+
_tmp = apply(:_dbl_not_quote)
|
1211
|
+
ary = @result
|
1212
|
+
unless _tmp
|
1213
|
+
self.pos = _save
|
1214
|
+
break
|
1215
|
+
end
|
1216
|
+
_tmp = match_string("\"")
|
1217
|
+
unless _tmp
|
1218
|
+
self.pos = _save
|
1219
|
+
break
|
1220
|
+
end
|
1221
|
+
@result = begin; ary.join ; end
|
1222
|
+
_tmp = true
|
1223
|
+
unless _tmp
|
1224
|
+
self.pos = _save
|
1225
|
+
end
|
1226
|
+
break
|
1227
|
+
end # end sequence
|
1228
|
+
|
1229
|
+
set_failed_rule :_dbl_string unless _tmp
|
1230
|
+
return _tmp
|
1231
|
+
end
|
1232
|
+
|
1233
|
+
# not_space_colon = (escapes | < /[^ \t\n:]/ > { text })
|
1234
|
+
def _not_space_colon
|
1235
|
+
|
1236
|
+
_save = self.pos
|
1237
|
+
while true # choice
|
1238
|
+
_tmp = apply(:_escapes)
|
1239
|
+
break if _tmp
|
1240
|
+
self.pos = _save
|
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
|
1260
|
+
|
1261
|
+
break if _tmp
|
1262
|
+
self.pos = _save
|
1263
|
+
break
|
1264
|
+
end # end choice
|
1265
|
+
|
1266
|
+
set_failed_rule :_not_space_colon unless _tmp
|
1267
|
+
return _tmp
|
1268
|
+
end
|
1269
|
+
|
1270
|
+
# not_space_colons = not_space_colon+:ary { ary.join }
|
1271
|
+
def _not_space_colons
|
1272
|
+
|
1273
|
+
_save = self.pos
|
1274
|
+
while true # sequence
|
1275
|
+
_save1 = self.pos
|
1276
|
+
_ary = []
|
1277
|
+
_tmp = apply(:_not_space_colon)
|
1278
|
+
if _tmp
|
1279
|
+
_ary << @result
|
1280
|
+
while true
|
1281
|
+
_tmp = apply(:_not_space_colon)
|
1282
|
+
_ary << @result if _tmp
|
1283
|
+
break unless _tmp
|
1284
|
+
end
|
1285
|
+
_tmp = true
|
1286
|
+
@result = _ary
|
1287
|
+
else
|
1288
|
+
self.pos = _save1
|
1289
|
+
end
|
1290
|
+
ary = @result
|
1291
|
+
unless _tmp
|
1292
|
+
self.pos = _save
|
1293
|
+
break
|
1294
|
+
end
|
1295
|
+
@result = begin; ary.join ; end
|
1296
|
+
_tmp = true
|
1297
|
+
unless _tmp
|
1298
|
+
self.pos = _save
|
1299
|
+
end
|
1300
|
+
break
|
1301
|
+
end # end sequence
|
1302
|
+
|
1303
|
+
set_failed_rule :_not_space_colons unless _tmp
|
1304
|
+
return _tmp
|
1305
|
+
end
|
1306
|
+
|
1307
|
+
# filename = (dbl_string | not_space_colons)
|
1308
|
+
def _filename
|
1309
|
+
|
1310
|
+
_save = self.pos
|
1311
|
+
while true # choice
|
1312
|
+
_tmp = apply(:_dbl_string)
|
1313
|
+
break if _tmp
|
1314
|
+
self.pos = _save
|
1315
|
+
_tmp = apply(:_not_space_colons)
|
1316
|
+
break if _tmp
|
1317
|
+
self.pos = _save
|
1318
|
+
break
|
1319
|
+
end # end choice
|
1320
|
+
|
1321
|
+
set_failed_rule :_filename unless _tmp
|
1322
|
+
return _tmp
|
1323
|
+
end
|
1324
|
+
|
1325
|
+
# file_pos_sep = (sp+ | ":")
|
1326
|
+
def _file_pos_sep
|
1327
|
+
|
1328
|
+
_save = self.pos
|
1329
|
+
while true # choice
|
1330
|
+
_save1 = self.pos
|
1331
|
+
_tmp = apply(:_sp)
|
1332
|
+
if _tmp
|
1333
|
+
while true
|
1334
|
+
_tmp = apply(:_sp)
|
1335
|
+
break unless _tmp
|
1336
|
+
end
|
1337
|
+
_tmp = true
|
1338
|
+
else
|
1339
|
+
self.pos = _save1
|
1340
|
+
end
|
1341
|
+
break if _tmp
|
1342
|
+
self.pos = _save
|
1343
|
+
_tmp = match_string(":")
|
1344
|
+
break if _tmp
|
1345
|
+
self.pos = _save
|
1346
|
+
break
|
1347
|
+
end # end choice
|
1348
|
+
|
1349
|
+
set_failed_rule :_file_pos_sep unless _tmp
|
1350
|
+
return _tmp
|
1351
|
+
end
|
1352
|
+
|
1353
|
+
# integer = < /[0-9]+/ > { text.to_i }
|
1354
|
+
def _integer
|
1355
|
+
|
1356
|
+
_save = self.pos
|
1357
|
+
while true # sequence
|
1358
|
+
_text_start = self.pos
|
1359
|
+
_tmp = scan(/\A(?-mix:[0-9]+)/)
|
1360
|
+
if _tmp
|
1361
|
+
text = get_text(_text_start)
|
1362
|
+
end
|
1363
|
+
unless _tmp
|
1364
|
+
self.pos = _save
|
1365
|
+
break
|
1366
|
+
end
|
1367
|
+
@result = begin; text.to_i ; end
|
1368
|
+
_tmp = true
|
1369
|
+
unless _tmp
|
1370
|
+
self.pos = _save
|
1371
|
+
end
|
1372
|
+
break
|
1373
|
+
end # end sequence
|
1374
|
+
|
1375
|
+
set_failed_rule :_integer unless _tmp
|
1376
|
+
return _tmp
|
1377
|
+
end
|
1378
|
+
|
1379
|
+
# sinteger = < /[+-]?[0-9]+/ > { text.to_i }
|
1380
|
+
def _sinteger
|
1381
|
+
|
1382
|
+
_save = self.pos
|
1383
|
+
while true # sequence
|
1384
|
+
_text_start = self.pos
|
1385
|
+
_tmp = scan(/\A(?-mix:[+-]?[0-9]+)/)
|
1386
|
+
if _tmp
|
1387
|
+
text = get_text(_text_start)
|
1388
|
+
end
|
1389
|
+
unless _tmp
|
1390
|
+
self.pos = _save
|
1391
|
+
break
|
1392
|
+
end
|
1393
|
+
@result = begin; text.to_i ; end
|
1394
|
+
_tmp = true
|
1395
|
+
unless _tmp
|
1396
|
+
self.pos = _save
|
1397
|
+
end
|
1398
|
+
break
|
1399
|
+
end # end sequence
|
1400
|
+
|
1401
|
+
set_failed_rule :_sinteger unless _tmp
|
1402
|
+
return _tmp
|
1403
|
+
end
|
1404
|
+
|
1405
|
+
# line_number = integer
|
1406
|
+
def _line_number
|
1407
|
+
_tmp = apply(:_integer)
|
1408
|
+
set_failed_rule :_line_number unless _tmp
|
1409
|
+
return _tmp
|
1410
|
+
end
|
1411
|
+
|
1412
|
+
# vm_offset = "@" integer:int { Position.new(nil, nil, :offset, int) }
|
1413
|
+
def _vm_offset
|
1414
|
+
|
1415
|
+
_save = self.pos
|
1416
|
+
while true # sequence
|
1417
|
+
_tmp = match_string("@")
|
1418
|
+
unless _tmp
|
1419
|
+
self.pos = _save
|
1420
|
+
break
|
1421
|
+
end
|
1422
|
+
_tmp = apply(:_integer)
|
1423
|
+
int = @result
|
1424
|
+
unless _tmp
|
1425
|
+
self.pos = _save
|
1426
|
+
break
|
1427
|
+
end
|
1428
|
+
@result = begin;
|
1429
|
+
Position.new(nil, nil, :offset, int)
|
1430
|
+
; end
|
1431
|
+
_tmp = true
|
1432
|
+
unless _tmp
|
1433
|
+
self.pos = _save
|
1434
|
+
end
|
1435
|
+
break
|
1436
|
+
end # end sequence
|
1437
|
+
|
1438
|
+
set_failed_rule :_vm_offset unless _tmp
|
1439
|
+
return _tmp
|
1440
|
+
end
|
1441
|
+
|
1442
|
+
# position = (vm_offset | line_number:l { Position.new(nil, nil, :line, l) })
|
1443
|
+
def _position
|
1444
|
+
|
1445
|
+
_save = self.pos
|
1446
|
+
while true # choice
|
1447
|
+
_tmp = apply(:_vm_offset)
|
1448
|
+
break if _tmp
|
1449
|
+
self.pos = _save
|
1450
|
+
|
1451
|
+
_save1 = self.pos
|
1452
|
+
while true # sequence
|
1453
|
+
_tmp = apply(:_line_number)
|
1454
|
+
l = @result
|
1455
|
+
unless _tmp
|
1456
|
+
self.pos = _save1
|
1457
|
+
break
|
1458
|
+
end
|
1459
|
+
@result = begin;
|
1460
|
+
Position.new(nil, nil, :line, l)
|
1461
|
+
; end
|
1462
|
+
_tmp = true
|
1463
|
+
unless _tmp
|
1464
|
+
self.pos = _save1
|
1465
|
+
end
|
1466
|
+
break
|
1467
|
+
end # end sequence
|
1468
|
+
|
1469
|
+
break if _tmp
|
1470
|
+
self.pos = _save
|
1471
|
+
break
|
1472
|
+
end # end choice
|
1473
|
+
|
1474
|
+
set_failed_rule :_position unless _tmp
|
1475
|
+
return _tmp
|
1476
|
+
end
|
1477
|
+
|
1478
|
+
# file_colon_line = file_no_colon:file &{ File.exist?(file) } ":" position:pos { Position.new(:file, file, pos.position_type, pos.position) }
|
1479
|
+
def _file_colon_line
|
1480
|
+
|
1481
|
+
_save = self.pos
|
1482
|
+
while true # sequence
|
1483
|
+
_tmp = apply(:_file_no_colon)
|
1484
|
+
file = @result
|
1485
|
+
unless _tmp
|
1486
|
+
self.pos = _save
|
1487
|
+
break
|
1488
|
+
end
|
1489
|
+
_save1 = self.pos
|
1490
|
+
_tmp = begin; File.exist?(file) ; end
|
1491
|
+
self.pos = _save1
|
1492
|
+
unless _tmp
|
1493
|
+
self.pos = _save
|
1494
|
+
break
|
1495
|
+
end
|
1496
|
+
_tmp = match_string(":")
|
1497
|
+
unless _tmp
|
1498
|
+
self.pos = _save
|
1499
|
+
break
|
1500
|
+
end
|
1501
|
+
_tmp = apply(:_position)
|
1502
|
+
pos = @result
|
1503
|
+
unless _tmp
|
1504
|
+
self.pos = _save
|
1505
|
+
break
|
1506
|
+
end
|
1507
|
+
@result = begin;
|
1508
|
+
Position.new(:file, file, pos.position_type, pos.position)
|
1509
|
+
; end
|
1510
|
+
_tmp = true
|
1511
|
+
unless _tmp
|
1512
|
+
self.pos = _save
|
1513
|
+
end
|
1514
|
+
break
|
1515
|
+
end # end sequence
|
1516
|
+
|
1517
|
+
set_failed_rule :_file_colon_line unless _tmp
|
1518
|
+
return _tmp
|
1519
|
+
end
|
1520
|
+
|
1521
|
+
# 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
|
+
def _location
|
1523
|
+
|
1524
|
+
_save = self.pos
|
1525
|
+
while true # choice
|
1526
|
+
_tmp = apply(:_position)
|
1527
|
+
break if _tmp
|
1528
|
+
self.pos = _save
|
1529
|
+
|
1530
|
+
_save1 = self.pos
|
1531
|
+
while true # sequence
|
1532
|
+
_text_start = self.pos
|
1533
|
+
_tmp = apply(:_filename)
|
1534
|
+
if _tmp
|
1535
|
+
text = get_text(_text_start)
|
1536
|
+
end
|
1537
|
+
file = @result
|
1538
|
+
unless _tmp
|
1539
|
+
self.pos = _save1
|
1540
|
+
break
|
1541
|
+
end
|
1542
|
+
_save2 = self.pos
|
1543
|
+
_tmp = begin; @file_exists_proc.call(file) ; end
|
1544
|
+
self.pos = _save2
|
1545
|
+
unless _tmp
|
1546
|
+
self.pos = _save1
|
1547
|
+
break
|
1548
|
+
end
|
1549
|
+
_tmp = apply(:_file_pos_sep)
|
1550
|
+
unless _tmp
|
1551
|
+
self.pos = _save1
|
1552
|
+
break
|
1553
|
+
end
|
1554
|
+
_tmp = apply(:_position)
|
1555
|
+
pos = @result
|
1556
|
+
unless _tmp
|
1557
|
+
self.pos = _save1
|
1558
|
+
break
|
1559
|
+
end
|
1560
|
+
@result = begin;
|
1561
|
+
Position.new(:file, file, pos.position_type, pos.position)
|
1562
|
+
; end
|
1563
|
+
_tmp = true
|
1564
|
+
unless _tmp
|
1565
|
+
self.pos = _save1
|
1566
|
+
end
|
1567
|
+
break
|
1568
|
+
end # end sequence
|
1569
|
+
|
1570
|
+
break if _tmp
|
1571
|
+
self.pos = _save
|
1572
|
+
|
1573
|
+
_save3 = self.pos
|
1574
|
+
while true # sequence
|
1575
|
+
_text_start = self.pos
|
1576
|
+
_tmp = apply(:_filename)
|
1577
|
+
if _tmp
|
1578
|
+
text = get_text(_text_start)
|
1579
|
+
end
|
1580
|
+
file = @result
|
1581
|
+
unless _tmp
|
1582
|
+
self.pos = _save3
|
1583
|
+
break
|
1584
|
+
end
|
1585
|
+
_save4 = self.pos
|
1586
|
+
_tmp = begin; @file_exists_proc.call(file) ; end
|
1587
|
+
self.pos = _save4
|
1588
|
+
unless _tmp
|
1589
|
+
self.pos = _save3
|
1590
|
+
break
|
1591
|
+
end
|
1592
|
+
@result = begin;
|
1593
|
+
Position.new(:file, file, nil, nil)
|
1594
|
+
; end
|
1595
|
+
_tmp = true
|
1596
|
+
unless _tmp
|
1597
|
+
self.pos = _save3
|
1598
|
+
end
|
1599
|
+
break
|
1600
|
+
end # end sequence
|
1601
|
+
|
1602
|
+
break if _tmp
|
1603
|
+
self.pos = _save
|
1604
|
+
|
1605
|
+
_save5 = self.pos
|
1606
|
+
while true # sequence
|
1607
|
+
_save6 = self.pos
|
1608
|
+
_tmp = apply(:_class_module_chain)
|
1609
|
+
@result = nil unless _tmp
|
1610
|
+
unless _tmp
|
1611
|
+
_tmp = true
|
1612
|
+
self.pos = _save6
|
1613
|
+
end
|
1614
|
+
fn = @result
|
1615
|
+
unless _tmp
|
1616
|
+
self.pos = _save5
|
1617
|
+
break
|
1618
|
+
end
|
1619
|
+
_tmp = apply(:_file_pos_sep)
|
1620
|
+
unless _tmp
|
1621
|
+
self.pos = _save5
|
1622
|
+
break
|
1623
|
+
end
|
1624
|
+
_tmp = apply(:_position)
|
1625
|
+
pos = @result
|
1626
|
+
unless _tmp
|
1627
|
+
self.pos = _save5
|
1628
|
+
break
|
1629
|
+
end
|
1630
|
+
@result = begin;
|
1631
|
+
Position.new(:fn, fn, pos.position_type, pos.position)
|
1632
|
+
; end
|
1633
|
+
_tmp = true
|
1634
|
+
unless _tmp
|
1635
|
+
self.pos = _save5
|
1636
|
+
end
|
1637
|
+
break
|
1638
|
+
end # end sequence
|
1639
|
+
|
1640
|
+
break if _tmp
|
1641
|
+
self.pos = _save
|
1642
|
+
|
1643
|
+
_save7 = self.pos
|
1644
|
+
while true # sequence
|
1645
|
+
_save8 = self.pos
|
1646
|
+
_tmp = apply(:_class_module_chain)
|
1647
|
+
@result = nil unless _tmp
|
1648
|
+
unless _tmp
|
1649
|
+
_tmp = true
|
1650
|
+
self.pos = _save8
|
1651
|
+
end
|
1652
|
+
fn = @result
|
1653
|
+
unless _tmp
|
1654
|
+
self.pos = _save7
|
1655
|
+
break
|
1656
|
+
end
|
1657
|
+
@result = begin;
|
1658
|
+
Position.new(:fn, fn, nil, nil)
|
1659
|
+
; end
|
1660
|
+
_tmp = true
|
1661
|
+
unless _tmp
|
1662
|
+
self.pos = _save7
|
1663
|
+
end
|
1664
|
+
break
|
1665
|
+
end # end sequence
|
1666
|
+
|
1667
|
+
break if _tmp
|
1668
|
+
self.pos = _save
|
1669
|
+
break
|
1670
|
+
end # end choice
|
1671
|
+
|
1672
|
+
set_failed_rule :_location unless _tmp
|
1673
|
+
return _tmp
|
1674
|
+
end
|
1675
|
+
|
1676
|
+
# if_unless = < ("if" | "unless") > { text }
|
1677
|
+
def _if_unless
|
1678
|
+
|
1679
|
+
_save = self.pos
|
1680
|
+
while true # sequence
|
1681
|
+
_text_start = self.pos
|
1682
|
+
|
1683
|
+
_save1 = self.pos
|
1684
|
+
while true # choice
|
1685
|
+
_tmp = match_string("if")
|
1686
|
+
break if _tmp
|
1687
|
+
self.pos = _save1
|
1688
|
+
_tmp = match_string("unless")
|
1689
|
+
break if _tmp
|
1690
|
+
self.pos = _save1
|
1691
|
+
break
|
1692
|
+
end # end choice
|
1693
|
+
|
1694
|
+
if _tmp
|
1695
|
+
text = get_text(_text_start)
|
1696
|
+
end
|
1697
|
+
unless _tmp
|
1698
|
+
self.pos = _save
|
1699
|
+
break
|
1700
|
+
end
|
1701
|
+
@result = begin; text ; end
|
1702
|
+
_tmp = true
|
1703
|
+
unless _tmp
|
1704
|
+
self.pos = _save
|
1705
|
+
end
|
1706
|
+
break
|
1707
|
+
end # end sequence
|
1708
|
+
|
1709
|
+
set_failed_rule :_if_unless unless _tmp
|
1710
|
+
return _tmp
|
1711
|
+
end
|
1712
|
+
|
1713
|
+
# condition = < /.+/ > { text}
|
1714
|
+
def _condition
|
1715
|
+
|
1716
|
+
_save = self.pos
|
1717
|
+
while true # sequence
|
1718
|
+
_text_start = self.pos
|
1719
|
+
_tmp = scan(/\A(?-mix:.+)/)
|
1720
|
+
if _tmp
|
1721
|
+
text = get_text(_text_start)
|
1722
|
+
end
|
1723
|
+
unless _tmp
|
1724
|
+
self.pos = _save
|
1725
|
+
break
|
1726
|
+
end
|
1727
|
+
@result = begin; text; end
|
1728
|
+
_tmp = true
|
1729
|
+
unless _tmp
|
1730
|
+
self.pos = _save
|
1731
|
+
end
|
1732
|
+
break
|
1733
|
+
end # end sequence
|
1734
|
+
|
1735
|
+
set_failed_rule :_condition unless _tmp
|
1736
|
+
return _tmp
|
1737
|
+
end
|
1738
|
+
|
1739
|
+
# breakpoint_stmt_no_condition = location:loc { Breakpoint.new(loc, false, 'true') }
|
1740
|
+
def _breakpoint_stmt_no_condition
|
1741
|
+
|
1742
|
+
_save = self.pos
|
1743
|
+
while true # sequence
|
1744
|
+
_tmp = apply(:_location)
|
1745
|
+
loc = @result
|
1746
|
+
unless _tmp
|
1747
|
+
self.pos = _save
|
1748
|
+
break
|
1749
|
+
end
|
1750
|
+
@result = begin;
|
1751
|
+
Breakpoint.new(loc, false, 'true')
|
1752
|
+
; end
|
1753
|
+
_tmp = true
|
1754
|
+
unless _tmp
|
1755
|
+
self.pos = _save
|
1756
|
+
end
|
1757
|
+
break
|
1758
|
+
end # end sequence
|
1759
|
+
|
1760
|
+
set_failed_rule :_breakpoint_stmt_no_condition unless _tmp
|
1761
|
+
return _tmp
|
1762
|
+
end
|
1763
|
+
|
1764
|
+
# breakpoint_stmt = (location:loc - if_unless:iu - condition:cond { Breakpoint.new(loc, iu == 'unless', cond) } | breakpoint_stmt_no_condition)
|
1765
|
+
def _breakpoint_stmt
|
1766
|
+
|
1767
|
+
_save = self.pos
|
1768
|
+
while true # choice
|
1769
|
+
|
1770
|
+
_save1 = self.pos
|
1771
|
+
while true # sequence
|
1772
|
+
_tmp = apply(:_location)
|
1773
|
+
loc = @result
|
1774
|
+
unless _tmp
|
1775
|
+
self.pos = _save1
|
1776
|
+
break
|
1777
|
+
end
|
1778
|
+
_tmp = apply(:__hyphen_)
|
1779
|
+
unless _tmp
|
1780
|
+
self.pos = _save1
|
1781
|
+
break
|
1782
|
+
end
|
1783
|
+
_tmp = apply(:_if_unless)
|
1784
|
+
iu = @result
|
1785
|
+
unless _tmp
|
1786
|
+
self.pos = _save1
|
1787
|
+
break
|
1788
|
+
end
|
1789
|
+
_tmp = apply(:__hyphen_)
|
1790
|
+
unless _tmp
|
1791
|
+
self.pos = _save1
|
1792
|
+
break
|
1793
|
+
end
|
1794
|
+
_tmp = apply(:_condition)
|
1795
|
+
cond = @result
|
1796
|
+
unless _tmp
|
1797
|
+
self.pos = _save1
|
1798
|
+
break
|
1799
|
+
end
|
1800
|
+
@result = begin;
|
1801
|
+
Breakpoint.new(loc, iu == 'unless', cond)
|
1802
|
+
; end
|
1803
|
+
_tmp = true
|
1804
|
+
unless _tmp
|
1805
|
+
self.pos = _save1
|
1806
|
+
end
|
1807
|
+
break
|
1808
|
+
end # end sequence
|
1809
|
+
|
1810
|
+
break if _tmp
|
1811
|
+
self.pos = _save
|
1812
|
+
_tmp = apply(:_breakpoint_stmt_no_condition)
|
1813
|
+
break if _tmp
|
1814
|
+
self.pos = _save
|
1815
|
+
break
|
1816
|
+
end # end choice
|
1817
|
+
|
1818
|
+
set_failed_rule :_breakpoint_stmt unless _tmp
|
1819
|
+
return _tmp
|
1820
|
+
end
|
1821
|
+
|
1822
|
+
# list_special_targets = < ("." | "-") > { text }
|
1823
|
+
def _list_special_targets
|
1824
|
+
|
1825
|
+
_save = self.pos
|
1826
|
+
while true # sequence
|
1827
|
+
_text_start = self.pos
|
1828
|
+
|
1829
|
+
_save1 = self.pos
|
1830
|
+
while true # choice
|
1831
|
+
_tmp = match_string(".")
|
1832
|
+
break if _tmp
|
1833
|
+
self.pos = _save1
|
1834
|
+
_tmp = match_string("-")
|
1835
|
+
break if _tmp
|
1836
|
+
self.pos = _save1
|
1837
|
+
break
|
1838
|
+
end # end choice
|
1839
|
+
|
1840
|
+
if _tmp
|
1841
|
+
text = get_text(_text_start)
|
1842
|
+
end
|
1843
|
+
unless _tmp
|
1844
|
+
self.pos = _save
|
1845
|
+
break
|
1846
|
+
end
|
1847
|
+
@result = begin; text ; end
|
1848
|
+
_tmp = true
|
1849
|
+
unless _tmp
|
1850
|
+
self.pos = _save
|
1851
|
+
end
|
1852
|
+
break
|
1853
|
+
end # end sequence
|
1854
|
+
|
1855
|
+
set_failed_rule :_list_special_targets unless _tmp
|
1856
|
+
return _tmp
|
1857
|
+
end
|
1858
|
+
|
1859
|
+
# list_stmt = ((list_special_targets | location):loc - sinteger:int? { List.new(loc, int) } | (list_special_targets | location):loc { List.new(loc, nil) })
|
1860
|
+
def _list_stmt
|
1861
|
+
|
1862
|
+
_save = self.pos
|
1863
|
+
while true # choice
|
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
|
+
|
1947
|
+
set_failed_rule :_list_stmt unless _tmp
|
1948
|
+
return _tmp
|
1949
|
+
end
|
1950
|
+
|
1951
|
+
# list_stmt = ((list_special_targets | location):loc - integer:int? { List.new(loc, int) } | (list_special_targets | location):loc { List.new(loc, nil) })
|
1952
|
+
def _list_stmt
|
1953
|
+
|
1954
|
+
_save = self.pos
|
1955
|
+
while true # choice
|
1956
|
+
|
1957
|
+
_save1 = self.pos
|
1958
|
+
while true # sequence
|
1959
|
+
|
1960
|
+
_save2 = self.pos
|
1961
|
+
while true # choice
|
1962
|
+
_tmp = apply(:_list_special_targets)
|
1963
|
+
break if _tmp
|
1964
|
+
self.pos = _save2
|
1965
|
+
_tmp = apply(:_location)
|
1966
|
+
break if _tmp
|
1967
|
+
self.pos = _save2
|
1968
|
+
break
|
1969
|
+
end # end choice
|
1970
|
+
|
1971
|
+
loc = @result
|
1972
|
+
unless _tmp
|
1973
|
+
self.pos = _save1
|
1974
|
+
break
|
1975
|
+
end
|
1976
|
+
_tmp = apply(:__hyphen_)
|
1977
|
+
unless _tmp
|
1978
|
+
self.pos = _save1
|
1979
|
+
break
|
1980
|
+
end
|
1981
|
+
_save3 = self.pos
|
1982
|
+
_tmp = apply(:_integer)
|
1983
|
+
int = @result
|
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;
|
1993
|
+
List.new(loc, int)
|
1994
|
+
; end
|
1995
|
+
_tmp = true
|
1996
|
+
unless _tmp
|
1997
|
+
self.pos = _save1
|
1998
|
+
end
|
1999
|
+
break
|
2000
|
+
end # end sequence
|
2001
|
+
|
2002
|
+
break if _tmp
|
2003
|
+
self.pos = _save
|
2004
|
+
|
2005
|
+
_save4 = self.pos
|
2006
|
+
while true # sequence
|
2007
|
+
|
2008
|
+
_save5 = self.pos
|
2009
|
+
while true # choice
|
2010
|
+
_tmp = apply(:_list_special_targets)
|
2011
|
+
break if _tmp
|
2012
|
+
self.pos = _save5
|
2013
|
+
_tmp = apply(:_location)
|
2014
|
+
break if _tmp
|
2015
|
+
self.pos = _save5
|
2016
|
+
break
|
2017
|
+
end # end choice
|
2018
|
+
|
2019
|
+
loc = @result
|
2020
|
+
unless _tmp
|
2021
|
+
self.pos = _save4
|
2022
|
+
break
|
2023
|
+
end
|
2024
|
+
@result = begin;
|
2025
|
+
List.new(loc, nil)
|
2026
|
+
; end
|
2027
|
+
_tmp = true
|
2028
|
+
unless _tmp
|
2029
|
+
self.pos = _save4
|
2030
|
+
end
|
2031
|
+
break
|
2032
|
+
end # end sequence
|
2033
|
+
|
2034
|
+
break if _tmp
|
2035
|
+
self.pos = _save
|
2036
|
+
break
|
2037
|
+
end # end choice
|
2038
|
+
|
2039
|
+
return _tmp
|
2040
|
+
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
|
+
|
2072
|
+
['filename', '"this is a filename"',
|
2073
|
+
'this\ is\ another\ filename',
|
2074
|
+
'C\:filename'
|
2075
|
+
].each do |name|
|
2076
|
+
puts '-' * 10
|
2077
|
+
cp.setup_parser(name, {:debug=>true})
|
2078
|
+
res = cp._filename
|
2079
|
+
p res
|
2080
|
+
puts cp.string
|
2081
|
+
puts cp.result
|
2082
|
+
end
|
2083
|
+
end
|