appswarm 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.autotest +124 -0
- data/History.txt +7 -0
- data/Manifest.txt +304 -0
- data/README.txt +373 -0
- data/Rakefile +153 -0
- data/TODO +7 -0
- data/apps/README.txt +17 -0
- data/apps/admin/admin.rb +79 -0
- data/apps/admin/controllers/admin.rb +81 -0
- data/apps/admin/controllers/settings.rb +63 -0
- data/apps/admin/controllers/users.rb +3 -0
- data/apps/admin/features/access.feature +21 -0
- data/apps/admin/features/mountLocal.feature +12 -0
- data/apps/admin/features/settings.feature +68 -0
- data/apps/admin/features/startApps.feature +27 -0
- data/apps/admin/layouts/main.rhtml +10 -0
- data/apps/admin/lib/settings.rb +52 -0
- data/apps/admin/static/admin.css +23 -0
- data/apps/admin/views/_log.rhtml +21 -0
- data/apps/admin/views/index.rhtml +43 -0
- data/apps/admin/views/info.rhtml +7 -0
- data/apps/admin/views/settings.rhtml +9 -0
- data/apps/admin/views/settings/_http_app.rhtml +15 -0
- data/apps/admin/views/settings/_web_server.rhtml +32 -0
- data/apps/admin/views/settings/index.rhtml +3 -0
- data/apps/admin/views/users/index.rhtml +6 -0
- data/apps/application_provider/application_provider.rb +11 -0
- data/apps/blog/blog.rb +27 -0
- data/apps/blog/controllers/blog.rb +29 -0
- data/apps/blog/views/index.rhtml +27 -0
- data/apps/browser_starter/browser_starter.rb +32 -0
- data/apps/crypto/crypto.rb +47 -0
- data/apps/crypto/crypto_rsa.rb +102 -0
- data/apps/crypto/spec/crypto_spec.rb +10 -0
- data/apps/directory_service/directory_service.rb +107 -0
- data/apps/directory_service/net_application.rb +92 -0
- data/apps/directory_service/spec/directory_service_spec.rb +36 -0
- data/apps/directory_service/spec/net_application_spec.rb +3 -0
- data/apps/global_application_interface/global_application.rb +52 -0
- data/apps/global_application_interface/global_application_interface.rb +84 -0
- data/apps/global_application_interface/spec/app_api_spec.rb +5 -0
- data/apps/global_tuple_space/global_tuple_space.rb +27 -0
- data/apps/global_web_proxy/features/session_handling.feature +7 -0
- data/apps/global_web_proxy/global_web_proxy.rb +221 -0
- data/apps/global_web_proxy/proxy/HTTPProxyServer-Dateien/rdoc-style.css +208 -0
- data/apps/global_web_proxy/proxy/HTTPProxyServer.html +566 -0
- data/apps/global_web_proxy/proxy/dnstest.rb +30 -0
- data/apps/global_web_proxy/proxy/proxy.rb +86 -0
- data/apps/global_web_proxy/proxy/wiki.html +267 -0
- data/apps/global_web_proxy/proxy/wiki.rb +115 -0
- data/apps/global_web_proxy/spec/res1 +112 -0
- data/apps/global_web_proxy/spec/res2 +125 -0
- data/apps/global_web_proxy/spec/web_proxy_spec.rb +88 -0
- data/apps/global_web_server/global_web_server.rb +120 -0
- data/apps/global_web_server/global_web_servlet.rb +6 -0
- data/apps/hello_world/controllers/hello_world.rb +11 -0
- data/apps/hello_world/features/show_on_local_web_server.feature +44 -0
- data/apps/hello_world/features/starting_apps.feature +6 -0
- data/apps/hello_world/features/through_global.feature +12 -0
- data/apps/hello_world/hello_world.rb +3 -0
- data/apps/hello_world/views/get.rhtml +10 -0
- data/apps/hello_world/views/index.rhtml +9 -0
- data/apps/hello_world/views/post.rhtml +10 -0
- data/apps/home/controllers/home.rb +11 -0
- data/apps/home/home.rb +12 -0
- data/apps/home/layouts/main.rhtml +16 -0
- data/apps/home/static/Zeichnung.svg +240 -0
- data/apps/home/static/home.css +134 -0
- data/apps/home/static/menu.css +99 -0
- data/apps/home/views/_appInfo.rhtml +22 -0
- data/apps/home/views/_dummy_fill.rhtml +3 -0
- data/apps/home/views/_info.rhtml +6 -0
- data/apps/home/views/_menu.rhtml +17 -0
- data/apps/home/views/index.rhtml +4 -0
- data/apps/home/views/overview.rhtml +2 -0
- data/apps/local_chunk_store/chunk_store.rb +15 -0
- data/apps/local_chunk_store/local_chunk_store.rb +123 -0
- data/apps/local_chunk_store/spec/local_chunk_store_spec.rb +30 -0
- data/apps/local_file_store/app_configuration.rb +78 -0
- data/apps/local_file_store/app_file_store.rb +32 -0
- data/apps/local_file_store/cached_file_store.rb +94 -0
- data/apps/local_file_store/features/testbed_handling_of_directories.feature +20 -0
- data/apps/local_file_store/local_file_store.rb +47 -0
- data/apps/local_file_store/spec/app_configuration_spec.rb +30 -0
- data/apps/local_file_store/spec/local_file_store_spec.rb +54 -0
- data/apps/local_object_storage/lib/cell.rb +29 -0
- data/apps/local_object_storage/lib/cellmgr.rb +57 -0
- data/apps/local_object_storage/lib/index.rb +43 -0
- data/apps/local_object_storage/lib/marshal.rb +96 -0
- data/apps/local_object_storage/lib/pagefile.rb +6 -0
- data/apps/local_object_storage/lib/persistent_object.rb +126 -0
- data/apps/local_object_storage/local_object_storage.rb +148 -0
- data/apps/local_object_storage/spec/local_object_storage_spec.rb +123 -0
- data/apps/local_secure_file_store/local_secure_file_store.rb +64 -0
- data/apps/local_secure_file_store/spec/local_secure_file_store_spec.rb +23 -0
- data/apps/local_tuple_space/local_tuple_space.rb +92 -0
- data/apps/local_tuple_space/spec/tuple_space_spec.rb +25 -0
- data/apps/local_web_server/features/parsing_args.feature +18 -0
- data/apps/local_web_server/local_web_server.rb +166 -0
- data/apps/logger/logger.rb +27 -0
- data/apps/master/master.rb +46 -0
- data/apps/master/spec/master_spec.rb +31 -0
- data/apps/my_spec_spec.rb +15 -0
- data/apps/name_service/name_service.rb +75 -0
- data/apps/name_service/spec/name_service_spec.rb +51 -0
- data/apps/network_discovery/network_discovery.rb +45 -0
- data/apps/network_discovery_localstore/network_discovery_localstore.rb +20 -0
- data/apps/network_discovery_udp/network_discovery_udp.rb +51 -0
- data/apps/network_lookup/network_lookup.rb +61 -0
- data/apps/network_node/abstract_node.rb +104 -0
- data/apps/network_node/drb_node.rb +90 -0
- data/apps/network_node/network_app.rb +9 -0
- data/apps/network_node/network_node.rb +471 -0
- data/apps/network_node/remote_service.rb +45 -0
- data/apps/network_node/secure_node.rb +125 -0
- data/apps/network_node/spec/drb_spec.rb +41 -0
- data/apps/network_node/spec/network_node_spec_not.rb +264 -0
- data/apps/new_network_node/new_network_node.rb +427 -0
- data/apps/new_network_node/spec/new_network_node_spec.rb +186 -0
- data/apps/node_broadcast/node_broadcast.rb +167 -0
- data/apps/node_broadcast/spec/node_broadcast_spec.rb +59 -0
- data/apps/permaspace/permaspace.rb +47 -0
- data/apps/plaindb/lib/btree.rb +38 -0
- data/apps/plaindb/plaindb.rb +199 -0
- data/apps/plaindb/spec/table_write_spec.rb +36 -0
- data/apps/routed_network/routed_network.rb +23 -0
- data/apps/routed_network/spec/routed_network_spec.rb +17 -0
- data/apps/session_manager/session_manager.rb +18 -0
- data/apps/spec_output.html +222 -0
- data/apps/todo/controllers/todo.rb +87 -0
- data/apps/todo/model/comment.rb +10 -0
- data/apps/todo/model/project.rb +20 -0
- data/apps/todo/model/todo.rb +16 -0
- data/apps/todo/model/user.rb +5 -0
- data/apps/todo/todo.rb +21 -0
- data/apps/todo/views/_commentList.rhtml +7 -0
- data/apps/todo/views/_createProject.rhtml +5 -0
- data/apps/todo/views/_partList.rhtml +12 -0
- data/apps/todo/views/_projectList.rhtml +16 -0
- data/apps/todo/views/edit.rhtml +11 -0
- data/apps/todo/views/editPart.rhtml +10 -0
- data/apps/todo/views/index.rhtml +2 -0
- data/apps/todo/views/question.rhtml +4 -0
- data/apps/transparent_network/transparent_network.rb +7 -0
- data/apps/udp_network/big_transfer.rb +97 -0
- data/apps/udp_network/features/information.feature +7 -0
- data/apps/udp_network/message_queue.rb +84 -0
- data/apps/udp_network/network_interface_api.rb +39 -0
- data/apps/udp_network/qos_queue.rb +186 -0
- data/apps/udp_network/simple_api.rb +180 -0
- data/apps/udp_network/spec/big_transfer_spec.rb +0 -0
- data/apps/udp_network/spec/qos_queue_spec.rb +99 -0
- data/apps/udp_network/spec/simple_api_spec.rb +35 -0
- data/apps/udp_network/spec/udp_network_spec.rb +115 -0
- data/apps/udp_network/spec/udp_transceiver_spec.rb +90 -0
- data/apps/udp_network/udp_network.rb +196 -0
- data/apps/udp_network/udp_transceiver.rb +329 -0
- data/apps/wiki/controllers/wiki.rb +56 -0
- data/apps/wiki/features/editing.feature +21 -0
- data/apps/wiki/layouts/main.rhtml +18 -0
- data/apps/wiki/lib/media_wiki_html.rb +35 -0
- data/apps/wiki/lib/wikicreole.rb +2147 -0
- data/apps/wiki/lib/wikicreole.tt +135 -0
- data/apps/wiki/lib/wikitest.rb +158 -0
- data/apps/wiki/lib/wikitest.tt +17 -0
- data/apps/wiki/model/menu.rb +15 -0
- data/apps/wiki/model/page.rb +31 -0
- data/apps/wiki/spec/wiki_creole_spec.rb +20 -0
- data/apps/wiki/spec/wiki_spec.rb +19 -0
- data/apps/wiki/static/Zeichnung.svg +240 -0
- data/apps/wiki/static/home.css +134 -0
- data/apps/wiki/static/mainMenu.css +32 -0
- data/apps/wiki/static/menu.css +99 -0
- data/apps/wiki/views/_mainMenu.rhtml +3 -0
- data/apps/wiki/views/_menu.rhtml +13 -0
- data/apps/wiki/views/edit.rhtml +13 -0
- data/apps/wiki/views/index.rhtml +2 -0
- data/apps/wiki/views/save.rhtml +1 -0
- data/apps/wiki/wiki.rb +17 -0
- data/bin/appswarm +47 -0
- data/cucumber.yml +2 -0
- data/data/PermaspaceApp/AFS_WikiApp_wiki_config +6 -0
- data/data/draft.txt +63 -0
- data/docs/appswarm_motivation.graffle +0 -0
- data/docs/appswarm_pics.graffle/QuickLook/Preview.pdf +0 -0
- data/docs/appswarm_pics.graffle/QuickLook/Thumbnail.tiff +0 -0
- data/docs/appswarm_pics.graffle/data.plist +63494 -0
- data/docs/appswarm_pics.graffle/image1.tiff +0 -0
- data/docs/appswarm_pics.graffle/image2.tif +0 -0
- data/docs/appswarm_pics.graffle/image3.tif +0 -0
- data/docs/appswarm_pics.graffle/image4.tif +0 -0
- data/docs/appswarm_pics.graffle/image5.tiff +0 -0
- data/docs/routing.graffle +0 -0
- data/features/step_definitions/appstart_steps.rb +28 -0
- data/features/step_definitions/cluster_steps.rb +18 -0
- data/features/step_definitions/testbed_steps.rb +64 -0
- data/features/step_definitions/webapp_steps.rb +257 -0
- data/features/support/env.rb +7 -0
- data/lib/appswarm.rb +127 -0
- data/lib/appswarm/README.txt +67 -0
- data/lib/appswarm/app_config.rb +19 -0
- data/lib/appswarm/application.rb +267 -0
- data/lib/appswarm/breaking_mutex.rb +41 -0
- data/lib/appswarm/cluster_funcs.rb +157 -0
- data/lib/appswarm/cross_spectool.rb +153 -0
- data/lib/appswarm/crypt.rb +10 -0
- data/lib/appswarm/crypt/crypto.rb +90 -0
- data/lib/appswarm/crypt/rsa_key +15 -0
- data/lib/appswarm/crypt/rsa_key.pub +5 -0
- data/lib/appswarm/crypt/test.rb +27 -0
- data/lib/appswarm/dir_tool.rb +41 -0
- data/lib/appswarm/event_api.rb +7 -0
- data/lib/appswarm/features_helper.rb +44 -0
- data/lib/appswarm/global_service.rb +38 -0
- data/lib/appswarm/http.rb +1 -0
- data/lib/appswarm/http/http_app.rb +257 -0
- data/lib/appswarm/http/http_controller.rb +267 -0
- data/lib/appswarm/http/http_provider.rb +80 -0
- data/lib/appswarm/http/static/favicon.ico +0 -0
- data/lib/appswarm/http/static/javascript/._prototype.js +0 -0
- data/lib/appswarm/http/static/javascript/prototype.js +2515 -0
- data/lib/appswarm/http/webrick_logger.rb +12 -0
- data/lib/appswarm/net_service.rb +69 -0
- data/lib/appswarm/package.rb +88 -0
- data/lib/appswarm/parallel_each.rb +46 -0
- data/lib/appswarm/protocols/protocol_dice.rb +25 -0
- data/lib/appswarm/proxy_testing.rb +48 -0
- data/lib/appswarm/public_api.rb +35 -0
- data/lib/appswarm/routing/matrix_math.rb +57 -0
- data/lib/appswarm/routing/pca.rb +211 -0
- data/lib/appswarm/routing/routetest.rb +85 -0
- data/lib/appswarm/routing/routing.rb +326 -0
- data/lib/appswarm/routing/spec/nods_spec.rb +23 -0
- data/lib/appswarm/routing/spec/pca_spec.rb +27 -0
- data/lib/appswarm/routing/spec/routing_spec.rb +91 -0
- data/lib/appswarm/secure_con.rb +437 -0
- data/lib/appswarm/secure_connection.rb +79 -0
- data/lib/appswarm/secure_marshal.rb +137 -0
- data/lib/appswarm/service.rb +76 -0
- data/lib/appswarm/simple_marshal.rb +96 -0
- data/lib/appswarm/simple_marshal_parser.rb +1243 -0
- data/lib/appswarm/simple_marshal_parser.tt +158 -0
- data/lib/appswarm/spec/application_spec.rb +50 -0
- data/lib/appswarm/spec/cluster_spec.rb +2 -0
- data/lib/appswarm/spec/hexdist_spec.rb +13 -0
- data/lib/appswarm/spec/http_controller_spec.rb +18 -0
- data/lib/appswarm/spec/main_spec.rb +6 -0
- data/lib/appswarm/spec/parallel_each_spec.rb +30 -0
- data/lib/appswarm/spec/secure_connection_spec.rb +108 -0
- data/lib/appswarm/spec/secure_marshal_spec.rb +93 -0
- data/lib/appswarm/spec/simple_marshal_spec.rb +87 -0
- data/lib/appswarm/spec/tools_spec.rb +13 -0
- data/lib/appswarm/spec/whiteboard_spec.rb +20 -0
- data/lib/appswarm/spec_helper.rb +18 -0
- data/lib/appswarm/test_bed.rb +207 -0
- data/lib/appswarm/tools.rb +284 -0
- data/lib/appswarm/tools/http_tunnel_client.rb +139 -0
- data/lib/appswarm/tools/http_tunnel_common.rb +8 -0
- data/lib/appswarm/tools/http_tunnel_server.rb +78 -0
- data/lib/appswarm/tools/parser/example_data.simple +102 -0
- data/lib/appswarm/tools/parser/match_test.rb +14 -0
- data/lib/appswarm/tools/parser/parser_lib.rb +165 -0
- data/lib/appswarm/tools/parser/parser_test.rb +104 -0
- data/lib/appswarm/tools/parser/spec/parser_spec.rb +44 -0
- data/lib/appswarm/tools/pipes.rb +95 -0
- data/lib/appswarm/tools/spec/tracing_spec.rb +16 -0
- data/lib/appswarm/tools/spec/waiting_queue_spec.rb +15 -0
- data/lib/appswarm/tools/thread_tool.rb +61 -0
- data/lib/appswarm/tools/tracing.rb +84 -0
- data/lib/appswarm/tools/treetop_test.rb +20 -0
- data/lib/appswarm/tools/treetop_test_grammar.rb +114 -0
- data/lib/appswarm/tools/treetop_test_grammar.tt +7 -0
- data/lib/appswarm/tools/waiting_prio_queue.rb +47 -0
- data/lib/appswarm/tools/waiting_queue.rb +34 -0
- data/lib/appswarm/whiteboard.rb +73 -0
- data/nettest.rb +50 -0
- data/packages/README.txt +1 -0
- data/packages/msandbox/data/packages/store/my.txt +1 -0
- data/packages/msandbox/interfaces.rb +172 -0
- data/packages/msandbox/old/defa.rb +3 -0
- data/packages/msandbox/old/test.rb +14 -0
- data/packages/msandbox/old/test2.rb +56 -0
- data/packages/msandbox/package.rb +67 -0
- data/packages/msandbox/packages/store/config.yml +1 -0
- data/packages/msandbox/packages/store/main.rb +27 -0
- data/packages/msandbox/packages/store/myinclude.rb +7 -0
- data/packages/msandbox/packages/store_test/config.yml +1 -0
- data/packages/msandbox/packages/store_test/main.rb +9 -0
- data/packages/msandbox/server.rb +146 -0
- data/packages/msandbox/test.rb +13 -0
- data/packages/msandbox/test2.rb +29 -0
- data/templates/web/appswarm/controllers/appswarm.rb +41 -0
- data/templates/web/appswarm/layouts/main.rhtml +20 -0
- data/templates/web/appswarm/models/asmenu.rb +14 -0
- data/templates/web/appswarm/models/asuser.rb +30 -0
- data/templates/web/appswarm/static/custom.css +15 -0
- data/templates/web/appswarm/static/home.css +134 -0
- data/templates/web/appswarm/static/mainMenu.css +32 -0
- data/templates/web/appswarm/static/menu.css +99 -0
- data/templates/web/appswarm/views/_mainMenu.rhtml +5 -0
- data/templates/web/appswarm/views/_menu.rhtml +13 -0
- data/templates/web/appswarm/views/_userInfo.rhtml +7 -0
- data/templates/web/appswarm/views/login.rhtml +9 -0
- data/tools/checkPort.rb +11 -0
- metadata +379 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
require 'tools.rb'
|
|
2
|
+
|
|
3
|
+
module Secure
|
|
4
|
+
|
|
5
|
+
class Client
|
|
6
|
+
def initialize(socket)
|
|
7
|
+
@socket=socket
|
|
8
|
+
@data=""
|
|
9
|
+
end
|
|
10
|
+
def send(*m)
|
|
11
|
+
|
|
12
|
+
end
|
|
13
|
+
def register(&b)
|
|
14
|
+
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def run
|
|
18
|
+
@thread=Thread.new {
|
|
19
|
+
begin
|
|
20
|
+
loop do
|
|
21
|
+
@data+=@socket.read(1024)
|
|
22
|
+
check
|
|
23
|
end
|
|
24
|
+
rescue Exception=>e
|
|
25
|
+
log e,e.backtrace
|
|
26
|
+
end
|
|
27
|
+
}
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
private
|
|
31
|
+
|
|
32
|
+
def check
|
|
33
|
+
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
class Server
|
|
38
|
+
attr_reader :clients
|
|
39
|
+
def initialize(port,host="localhost")
|
|
40
|
+
@port=port
|
|
41
|
+
@host=host
|
|
42
|
+
addr= Socket.pack_sockaddr_in( @port,@host)
|
|
43
|
+
@server=TCPServer.new(port,addr)
|
|
44
|
+
@clients=[]
|
|
45
|
+
@mainThread=nil
|
|
46
|
+
@mutex=Mutex.new
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def clients
|
|
50
|
+
@mutex.synchronize {
|
|
51
|
+
@clients.dup
|
|
52
|
+
}
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def kill
|
|
56
|
+
@mainThread.kill if @mainThread
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def run
|
|
60
|
+
@mainThread=Thread.new {
|
|
61
|
+
client=@server.accept
|
|
62
|
+
c=Client.new(client)
|
|
63
|
+
@mutex.synchronize {
|
|
64
|
+
@clients<<c
|
|
65
|
+
}
|
|
66
|
+
begin
|
|
67
|
+
c.run
|
|
68
|
+
rescue Exception=>e
|
|
69
|
+
log e
|
|
70
|
+
@mutex.synchronize {
|
|
71
|
+
@clients.delete(c)
|
|
72
|
+
}
|
|
73
|
+
end
|
|
74
|
+
}
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
end
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
require 'tools.rb'
|
|
2
|
+
|
|
3
|
+
module Secure
|
|
4
|
+
module Marshal
|
|
5
|
+
class OutOfData<Exception
|
|
6
|
+
def initialize(data)
|
|
7
|
+
@data=data
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# This is an interal class to keep track of data parsing, so that
|
|
13
|
+
# not too much data is copied from here to there.
|
|
14
|
+
class Data
|
|
15
|
+
def initialize(data)
|
|
16
|
+
@data=data
|
|
17
|
+
@pos=0
|
|
18
|
+
end
|
|
19
|
+
def read(len)
|
|
20
|
+
raise Secure::Marshal::OutOfData.new(@data) if @data.length<@pos+len
|
|
21
|
+
cur=@data[@pos...(@pos+len)]
|
|
22
|
+
@pos+=cur.length
|
|
23
|
+
cur
|
|
24
|
+
end
|
|
25
|
+
def til(str)
|
|
26
|
+
tmp=@data[(@pos..-1)]
|
|
27
|
+
i=tmp.index(str)
|
|
28
|
+
if i.nil?
|
|
29
|
+
raise Secure::Marshal::OutOfData.new(@data)
|
|
30
|
+
end
|
|
31
|
+
cur=tmp[0...i]
|
|
32
|
+
@pos+=cur.length+str.length
|
|
33
|
+
cur
|
|
34
|
+
end
|
|
35
|
+
def str
|
|
36
|
+
@data[@pos..-1]
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
module Marshal
|
|
41
|
+
# this function work pretty much like ruby standard marshaling. But it supports only
|
|
42
|
+
# some small set of types, being some basic-types like symbols, numbers, strings, hashes, arrays and structs.
|
|
43
|
+
# This is good, because you won't be able to pass custom-objects through the network and thus causing
|
|
44
|
+
# security vulnerabilities. You can however create structs with Struct.new(...) and add functions to this
|
|
45
|
+
# struct.
|
|
46
|
+
# The encoding is PHP-serialization-alike, because it's relatively compact but still is halfway human-readable.
|
|
47
|
+
# It may become necessary to create a shorter syntax in the future.
|
|
48
|
+
def self.dump(o)
|
|
49
|
+
case o
|
|
50
|
+
when String
|
|
51
|
+
"s:"+dump(o.length)+o
|
|
52
|
+
when Integer
|
|
53
|
+
"i:"+o.to_s+":"
|
|
54
|
+
when Float
|
|
55
|
+
"f:"+o.to_s+":"
|
|
56
|
+
when Array
|
|
57
|
+
"a:"+dump(o.length)+o.map{|elem|dump(elem)}.join("")
|
|
58
|
+
when NilClass
|
|
59
|
+
"b:n" # nil
|
|
60
|
+
when TrueClass
|
|
61
|
+
"b:t" # true
|
|
62
|
+
when FalseClass
|
|
63
|
+
"b:f"
|
|
64
|
+
when Hash
|
|
65
|
+
"h:"+dump(o.to_a)
|
|
66
|
+
when Symbol
|
|
67
|
+
"y:"+dump(o.to_s)
|
|
68
|
+
else
|
|
69
|
+
if o.respond_to?(:members) and o.respond_to?(:values)
|
|
70
|
+
n=o.class.to_s
|
|
71
|
+
hash={}
|
|
72
|
+
o.members.each{|m|
|
|
73
|
+
hash[m]=o.send(m)
|
|
74
|
+
}
|
|
75
|
+
"o:"+dump(n)+dump(hash)
|
|
76
|
+
else
|
|
77
|
+
raise "Unknown Type to marshal #{o}"
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# load takes either a string or an object of type Secure::Data. It tries to load an object and return it.
|
|
83
|
+
# If no parsable object is found, an OutOfData exception will be raised.
|
|
84
|
+
def self.load(o)
|
|
85
|
+
unless o.is_a?(Data)
|
|
86
|
+
return load(Data.new(o))
|
|
87
|
+
end
|
|
88
|
+
orig=o.str
|
|
89
|
+
bt=o.dup
|
|
90
|
+
result=case o.read(2)[0..0]
|
|
91
|
+
when "b"
|
|
92
|
+
case o.read(1)
|
|
93
|
+
when "n"
|
|
94
|
+
nil
|
|
95
|
+
when "t"
|
|
96
|
+
true
|
|
97
|
+
when "f"
|
|
98
|
+
false
|
|
99
|
+
end
|
|
100
|
+
when "s"
|
|
101
|
+
len=load(o)
|
|
102
|
+
r=o.read(len)
|
|
103
|
+
r
|
|
104
|
+
when "i"
|
|
105
|
+
o.til(":").to_i
|
|
106
|
+
when "f"
|
|
107
|
+
o.til(":").to_f
|
|
108
|
+
when "a"
|
|
109
|
+
len=load(o)
|
|
110
|
+
assert{len.is_a?(Numeric)}
|
|
111
|
+
(0...len).to_a.map{|i|
|
|
112
|
+
load(o)
|
|
113
|
+
}
|
|
114
|
+
when "h"
|
|
115
|
+
a=load(o)
|
|
116
|
+
h={}
|
|
117
|
+
a.each{|p|
|
|
118
|
+
h[p[0]]=p[1]
|
|
119
|
+
}
|
|
120
|
+
h
|
|
121
|
+
when "y"
|
|
122
|
+
load(o).to_sym
|
|
123
|
+
when "o"
|
|
124
|
+
name=load(o)
|
|
125
|
+
hash=load(o)
|
|
126
|
+
klass=getClass(name)
|
|
127
|
+
mo=klass.new
|
|
128
|
+
hash.each{|k,v|
|
|
129
|
+
mo.send(k+"=",v) if mo.members.member?(k) and mo.respond_to?(k+"=")
|
|
130
|
+
}
|
|
131
|
+
mo
|
|
132
|
+
end
|
|
133
|
+
#pp "LOADING: #{orig.inspect} now:#{o.str.inspect} RES:#{result.inspect}"
|
|
134
|
+
result
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
end
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
require 'application.rb'
|
|
2
|
+
|
|
3
|
+
class Service<Application
|
|
4
|
+
|
|
5
|
+
def self.event(name,arity=nil)
|
|
6
|
+
name=name.to_s
|
|
7
|
+
onName="on"+name[0..0].upcase+name[1..-1]
|
|
8
|
+
isName="is"+name[0..0].upcase+name[1..-1]
|
|
9
|
+
|
|
10
|
+
assert{not self.respond_to?(onName)}
|
|
11
|
+
@@eventArity||={}
|
|
12
|
+
if arity
|
|
13
|
+
@@eventArity[name]=arity
|
|
14
|
+
end
|
|
15
|
+
self.module_eval("
|
|
16
|
+
def #{onName}(&block)
|
|
17
|
+
assert{block_given?}
|
|
18
|
+
if @@eventArity[:#{name}]
|
|
19
|
+
assert{@@eventArity[:#{name}]==block.arity}
|
|
20
|
+
end
|
|
21
|
+
@eventReceivers||={}
|
|
22
|
+
@eventReceivers[:#{name}]||=[]
|
|
23
|
+
@eventReceivers[:#{name}] << block
|
|
24
|
+
end
|
|
25
|
+
private
|
|
26
|
+
def #{isName}(*args)
|
|
27
|
+
if @@eventArity[:#{name}]
|
|
28
|
+
assert{@@eventArity[:#{name}]==args.length}
|
|
29
|
+
end
|
|
30
|
+
@eventReceivers||={}
|
|
31
|
+
@eventReceivers[:#{name}]||=[]
|
|
32
|
+
@eventReceivers[:#{name}].each{|b|
|
|
33
|
+
b.call(*args)
|
|
34
|
+
}
|
|
35
|
+
end
|
|
36
|
+
")
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def initialize(cluster,options,name)
|
|
40
|
+
super(cluster,options)
|
|
41
|
+
@name=name
|
|
42
|
+
@cronMutex=Mutex.new
|
|
43
|
+
provides(name)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def cronTime
|
|
47
|
+
@options[:cronTime]||10
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def run
|
|
51
|
+
@threads << Thread.new {
|
|
52
|
+
while not quit?
|
|
53
|
+
begin
|
|
54
|
+
runCron
|
|
55
|
+
rescue Object=>e
|
|
56
|
+
log e
|
|
57
|
+
log e.backtrace if e.is_a?(Exception)
|
|
58
|
+
end
|
|
59
|
+
sleep(cronTime)
|
|
60
|
+
end
|
|
61
|
+
}
|
|
62
|
+
end
|
|
63
|
+
def stop
|
|
64
|
+
super
|
|
65
|
+
end
|
|
66
|
+
def runCron
|
|
67
|
+
@cronMutex.synchronize {
|
|
68
|
+
cron
|
|
69
|
+
}
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def cron
|
|
73
|
+
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
#require 'treetop'
|
|
2
|
+
#require File.expand_path("../simple_marshal_parser.rb",__FILE__)
|
|
3
|
+
require File.expand_path("../tools/parser/parser_test.rb",__FILE__)
|
|
4
|
+
|
|
5
|
+
require 'time'
|
|
6
|
+
|
|
7
|
+
module Simple
|
|
8
|
+
module Marshal
|
|
9
|
+
INDENT=" "
|
|
10
|
+
def self.dump(data)
|
|
11
|
+
case data
|
|
12
|
+
when String
|
|
13
|
+
"\""+data.gsub("\\"){"\\\\"}.gsub("\"","\\\"").gsub("\n","\\n")+"\""
|
|
14
|
+
when Numeric
|
|
15
|
+
data.to_s
|
|
16
|
+
when Array
|
|
17
|
+
"[\n"+data.map{|d|INDENT+dump(d)}.join(",\n")+"\n]"
|
|
18
|
+
when Hash
|
|
19
|
+
"{\n"+INDENT+data.map{|k,v|dump(k)+" => "+dump(v)}.join(",\n").gsub("\n","\n"+INDENT)+"\n}"
|
|
20
|
+
when Symbol
|
|
21
|
+
":"+data.to_s
|
|
22
|
+
when NilClass
|
|
23
|
+
"nil"
|
|
24
|
+
when FalseClass
|
|
25
|
+
"false"
|
|
26
|
+
when TrueClass
|
|
27
|
+
"true"
|
|
28
|
+
else
|
|
29
|
+
o=data
|
|
30
|
+
hash=nil
|
|
31
|
+
n=o.class.to_s
|
|
32
|
+
case o
|
|
33
|
+
when Time
|
|
34
|
+
hash={:data=>o.to_s}
|
|
35
|
+
end
|
|
36
|
+
if o.respond_to?(:members) and o.respond_to?(:values)
|
|
37
|
+
hash={}
|
|
38
|
+
o.members.each{|m|
|
|
39
|
+
hash[m.to_sym]=o.send(m)
|
|
40
|
+
}
|
|
41
|
+
end
|
|
42
|
+
if hash
|
|
43
|
+
"("+n+"\n"+hash.map{|k,v|INDENT+dump(k)+" => "+dump(v)}.join(",\n")+"\n)"
|
|
44
|
+
else
|
|
45
|
+
raise "Unknown Type to marshal #{data} #{data.class}"
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
Buf=Struct.new(:str,:pos)
|
|
51
|
+
|
|
52
|
+
class Buf
|
|
53
|
+
def buf
|
|
54
|
+
str[pos..-1]
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def self.load(str)
|
|
60
|
+
if false
|
|
61
|
+
@@parser||=nil
|
|
62
|
+
unless @@parser
|
|
63
|
+
|
|
64
|
+
Treetop. load File.expand_path("../simple_marshal_parser.tt",__FILE__)
|
|
65
|
+
@@parser=true
|
|
66
|
+
end
|
|
67
|
+
kcode=$KCODE
|
|
68
|
+
parser = SimpleMarshalParser.new
|
|
69
|
+
result = parser.parse(str)
|
|
70
|
+
#pp result
|
|
71
|
+
$KCODE=kcode
|
|
72
|
+
if result
|
|
73
|
+
pp "GOT RESULT"
|
|
74
|
+
return result.sload
|
|
75
|
+
else
|
|
76
|
+
nil
|
|
77
|
+
end
|
|
78
|
+
else
|
|
79
|
+
@@parser||=nil
|
|
80
|
+
unless @@parser
|
|
81
|
+
|
|
82
|
+
#Treetop.load File.expand_path("../simple_marshal_parser.tt",__FILE__)
|
|
83
|
+
@@parser=true
|
|
84
|
+
end
|
|
85
|
+
parser = SimpleMarshalParser #.new
|
|
86
|
+
result = parser.parse(str)
|
|
87
|
+
if result
|
|
88
|
+
#pp "GOT RESULT"
|
|
89
|
+
return result.convert
|
|
90
|
+
else
|
|
91
|
+
nil
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
@@ -0,0 +1,1243 @@
|
|
|
1
|
+
module SimpleMarshal
|
|
2
|
+
include Treetop::Runtime
|
|
3
|
+
|
|
4
|
+
def root
|
|
5
|
+
@root || :Elements
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
module Elements0
|
|
9
|
+
def Fill
|
|
10
|
+
elements[0]
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def e
|
|
14
|
+
elements[1]
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def Fill
|
|
18
|
+
elements[2]
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
module Elements1
|
|
23
|
+
def sload
|
|
24
|
+
e.sload
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def _nt_Elements
|
|
29
|
+
start_index = index
|
|
30
|
+
if node_cache[:Elements].has_key?(index)
|
|
31
|
+
cached = node_cache[:Elements][index]
|
|
32
|
+
@index = cached.interval.end if cached
|
|
33
|
+
return cached
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
i0, s0 = index, []
|
|
37
|
+
r1 = _nt_Fill
|
|
38
|
+
s0 << r1
|
|
39
|
+
if r1
|
|
40
|
+
r2 = _nt_Element
|
|
41
|
+
s0 << r2
|
|
42
|
+
if r2
|
|
43
|
+
r3 = _nt_Fill
|
|
44
|
+
s0 << r3
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
if s0.last
|
|
48
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
|
49
|
+
r0.extend(Elements0)
|
|
50
|
+
r0.extend(Elements1)
|
|
51
|
+
else
|
|
52
|
+
self.index = i0
|
|
53
|
+
r0 = nil
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
node_cache[:Elements][start_index] = r0
|
|
57
|
+
|
|
58
|
+
return r0
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
module Element0
|
|
62
|
+
def Fill
|
|
63
|
+
elements[0]
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def e
|
|
67
|
+
elements[1]
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def Fill
|
|
71
|
+
elements[2]
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
module Element1
|
|
76
|
+
def sload
|
|
77
|
+
e.sload
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def _nt_Element
|
|
82
|
+
start_index = index
|
|
83
|
+
if node_cache[:Element].has_key?(index)
|
|
84
|
+
cached = node_cache[:Element][index]
|
|
85
|
+
@index = cached.interval.end if cached
|
|
86
|
+
return cached
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
i0, s0 = index, []
|
|
90
|
+
r1 = _nt_Fill
|
|
91
|
+
s0 << r1
|
|
92
|
+
if r1
|
|
93
|
+
r2 = _nt_RElement
|
|
94
|
+
s0 << r2
|
|
95
|
+
if r2
|
|
96
|
+
r3 = _nt_Fill
|
|
97
|
+
s0 << r3
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
if s0.last
|
|
101
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
|
102
|
+
r0.extend(Element0)
|
|
103
|
+
r0.extend(Element1)
|
|
104
|
+
else
|
|
105
|
+
self.index = i0
|
|
106
|
+
r0 = nil
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
node_cache[:Element][start_index] = r0
|
|
110
|
+
|
|
111
|
+
return r0
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def _nt_RElement
|
|
115
|
+
start_index = index
|
|
116
|
+
if node_cache[:RElement].has_key?(index)
|
|
117
|
+
cached = node_cache[:RElement][index]
|
|
118
|
+
@index = cached.interval.end if cached
|
|
119
|
+
return cached
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
i0 = index
|
|
123
|
+
r1 = _nt_Struct
|
|
124
|
+
if r1
|
|
125
|
+
r0 = r1
|
|
126
|
+
else
|
|
127
|
+
r2 = _nt_Hash
|
|
128
|
+
if r2
|
|
129
|
+
r0 = r2
|
|
130
|
+
else
|
|
131
|
+
r3 = _nt_Symbol
|
|
132
|
+
if r3
|
|
133
|
+
r0 = r3
|
|
134
|
+
else
|
|
135
|
+
r4 = _nt_String
|
|
136
|
+
if r4
|
|
137
|
+
r0 = r4
|
|
138
|
+
else
|
|
139
|
+
r5 = _nt_Array
|
|
140
|
+
if r5
|
|
141
|
+
r0 = r5
|
|
142
|
+
else
|
|
143
|
+
r6 = _nt_Boolean
|
|
144
|
+
if r6
|
|
145
|
+
r0 = r6
|
|
146
|
+
else
|
|
147
|
+
r7 = _nt_Nil
|
|
148
|
+
if r7
|
|
149
|
+
r0 = r7
|
|
150
|
+
else
|
|
151
|
+
r8 = _nt_Number
|
|
152
|
+
if r8
|
|
153
|
+
r0 = r8
|
|
154
|
+
else
|
|
155
|
+
self.index = i0
|
|
156
|
+
r0 = nil
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
node_cache[:RElement][start_index] = r0
|
|
167
|
+
|
|
168
|
+
return r0
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
module Symbol0
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
module Symbol1
|
|
175
|
+
def name
|
|
176
|
+
elements[1]
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
module Symbol2
|
|
181
|
+
def sload
|
|
182
|
+
name.text_value.to_sym
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
def _nt_Symbol
|
|
187
|
+
start_index = index
|
|
188
|
+
if node_cache[:Symbol].has_key?(index)
|
|
189
|
+
cached = node_cache[:Symbol][index]
|
|
190
|
+
@index = cached.interval.end if cached
|
|
191
|
+
return cached
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
i0, s0 = index, []
|
|
195
|
+
if input.index(':', index) == index
|
|
196
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
|
197
|
+
@index += 1
|
|
198
|
+
else
|
|
199
|
+
terminal_parse_failure(':')
|
|
200
|
+
r1 = nil
|
|
201
|
+
end
|
|
202
|
+
s0 << r1
|
|
203
|
+
if r1
|
|
204
|
+
i2, s2 = index, []
|
|
205
|
+
if input.index(Regexp.new('[_a-zA-Z]'), index) == index
|
|
206
|
+
r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
|
207
|
+
@index += 1
|
|
208
|
+
else
|
|
209
|
+
r3 = nil
|
|
210
|
+
end
|
|
211
|
+
s2 << r3
|
|
212
|
+
if r3
|
|
213
|
+
s4, i4 = [], index
|
|
214
|
+
loop do
|
|
215
|
+
if input.index(Regexp.new('[0-9a-zA-Z_]'), index) == index
|
|
216
|
+
r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
|
217
|
+
@index += 1
|
|
218
|
+
else
|
|
219
|
+
r5 = nil
|
|
220
|
+
end
|
|
221
|
+
if r5
|
|
222
|
+
s4 << r5
|
|
223
|
+
else
|
|
224
|
+
break
|
|
225
|
+
end
|
|
226
|
+
end
|
|
227
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
|
228
|
+
s2 << r4
|
|
229
|
+
end
|
|
230
|
+
if s2.last
|
|
231
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
|
232
|
+
r2.extend(Symbol0)
|
|
233
|
+
else
|
|
234
|
+
self.index = i2
|
|
235
|
+
r2 = nil
|
|
236
|
+
end
|
|
237
|
+
s0 << r2
|
|
238
|
+
end
|
|
239
|
+
if s0.last
|
|
240
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
|
241
|
+
r0.extend(Symbol1)
|
|
242
|
+
r0.extend(Symbol2)
|
|
243
|
+
else
|
|
244
|
+
self.index = i0
|
|
245
|
+
r0 = nil
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
node_cache[:Symbol][start_index] = r0
|
|
249
|
+
|
|
250
|
+
return r0
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
module Boolean0
|
|
254
|
+
def sload
|
|
255
|
+
true
|
|
256
|
+
end
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
module Boolean1
|
|
260
|
+
def sload
|
|
261
|
+
false
|
|
262
|
+
end
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
def _nt_Boolean
|
|
266
|
+
start_index = index
|
|
267
|
+
if node_cache[:Boolean].has_key?(index)
|
|
268
|
+
cached = node_cache[:Boolean][index]
|
|
269
|
+
@index = cached.interval.end if cached
|
|
270
|
+
return cached
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
i0 = index
|
|
274
|
+
if input.index('true', index) == index
|
|
275
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + 4))
|
|
276
|
+
r1.extend(Boolean0)
|
|
277
|
+
@index += 4
|
|
278
|
+
else
|
|
279
|
+
terminal_parse_failure('true')
|
|
280
|
+
r1 = nil
|
|
281
|
+
end
|
|
282
|
+
if r1
|
|
283
|
+
r0 = r1
|
|
284
|
+
else
|
|
285
|
+
if input.index('false', index) == index
|
|
286
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + 5))
|
|
287
|
+
r2.extend(Boolean1)
|
|
288
|
+
@index += 5
|
|
289
|
+
else
|
|
290
|
+
terminal_parse_failure('false')
|
|
291
|
+
r2 = nil
|
|
292
|
+
end
|
|
293
|
+
if r2
|
|
294
|
+
r0 = r2
|
|
295
|
+
else
|
|
296
|
+
self.index = i0
|
|
297
|
+
r0 = nil
|
|
298
|
+
end
|
|
299
|
+
end
|
|
300
|
+
|
|
301
|
+
node_cache[:Boolean][start_index] = r0
|
|
302
|
+
|
|
303
|
+
return r0
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
module Nil0
|
|
307
|
+
def sload
|
|
308
|
+
nil
|
|
309
|
+
end
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
def _nt_Nil
|
|
313
|
+
start_index = index
|
|
314
|
+
if node_cache[:Nil].has_key?(index)
|
|
315
|
+
cached = node_cache[:Nil][index]
|
|
316
|
+
@index = cached.interval.end if cached
|
|
317
|
+
return cached
|
|
318
|
+
end
|
|
319
|
+
|
|
320
|
+
if input.index('nil', index) == index
|
|
321
|
+
r0 = instantiate_node(SyntaxNode,input, index...(index + 3))
|
|
322
|
+
r0.extend(Nil0)
|
|
323
|
+
@index += 3
|
|
324
|
+
else
|
|
325
|
+
terminal_parse_failure('nil')
|
|
326
|
+
r0 = nil
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
node_cache[:Nil][start_index] = r0
|
|
330
|
+
|
|
331
|
+
return r0
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
module Hash0
|
|
335
|
+
def Fill
|
|
336
|
+
elements[1]
|
|
337
|
+
end
|
|
338
|
+
|
|
339
|
+
end
|
|
340
|
+
|
|
341
|
+
module Hash1
|
|
342
|
+
def sload
|
|
343
|
+
{}
|
|
344
|
+
end
|
|
345
|
+
end
|
|
346
|
+
|
|
347
|
+
module Hash2
|
|
348
|
+
def l
|
|
349
|
+
elements[1]
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
end
|
|
353
|
+
|
|
354
|
+
module Hash3
|
|
355
|
+
def sload
|
|
356
|
+
l.sload
|
|
357
|
+
end
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
def _nt_Hash
|
|
361
|
+
start_index = index
|
|
362
|
+
if node_cache[:Hash].has_key?(index)
|
|
363
|
+
cached = node_cache[:Hash][index]
|
|
364
|
+
@index = cached.interval.end if cached
|
|
365
|
+
return cached
|
|
366
|
+
end
|
|
367
|
+
|
|
368
|
+
i0 = index
|
|
369
|
+
i1, s1 = index, []
|
|
370
|
+
if input.index('{', index) == index
|
|
371
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
|
372
|
+
@index += 1
|
|
373
|
+
else
|
|
374
|
+
terminal_parse_failure('{')
|
|
375
|
+
r2 = nil
|
|
376
|
+
end
|
|
377
|
+
s1 << r2
|
|
378
|
+
if r2
|
|
379
|
+
r3 = _nt_Fill
|
|
380
|
+
s1 << r3
|
|
381
|
+
if r3
|
|
382
|
+
if input.index('}', index) == index
|
|
383
|
+
r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
|
384
|
+
@index += 1
|
|
385
|
+
else
|
|
386
|
+
terminal_parse_failure('}')
|
|
387
|
+
r4 = nil
|
|
388
|
+
end
|
|
389
|
+
s1 << r4
|
|
390
|
+
end
|
|
391
|
+
end
|
|
392
|
+
if s1.last
|
|
393
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
|
394
|
+
r1.extend(Hash0)
|
|
395
|
+
r1.extend(Hash1)
|
|
396
|
+
else
|
|
397
|
+
self.index = i1
|
|
398
|
+
r1 = nil
|
|
399
|
+
end
|
|
400
|
+
if r1
|
|
401
|
+
r0 = r1
|
|
402
|
+
else
|
|
403
|
+
i5, s5 = index, []
|
|
404
|
+
if input.index('{', index) == index
|
|
405
|
+
r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
|
406
|
+
@index += 1
|
|
407
|
+
else
|
|
408
|
+
terminal_parse_failure('{')
|
|
409
|
+
r6 = nil
|
|
410
|
+
end
|
|
411
|
+
s5 << r6
|
|
412
|
+
if r6
|
|
413
|
+
r7 = _nt_HashList
|
|
414
|
+
s5 << r7
|
|
415
|
+
if r7
|
|
416
|
+
if input.index('}', index) == index
|
|
417
|
+
r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
|
418
|
+
@index += 1
|
|
419
|
+
else
|
|
420
|
+
terminal_parse_failure('}')
|
|
421
|
+
r8 = nil
|
|
422
|
+
end
|
|
423
|
+
s5 << r8
|
|
424
|
+
end
|
|
425
|
+
end
|
|
426
|
+
if s5.last
|
|
427
|
+
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
|
428
|
+
r5.extend(Hash2)
|
|
429
|
+
r5.extend(Hash3)
|
|
430
|
+
else
|
|
431
|
+
self.index = i5
|
|
432
|
+
r5 = nil
|
|
433
|
+
end
|
|
434
|
+
if r5
|
|
435
|
+
r0 = r5
|
|
436
|
+
else
|
|
437
|
+
self.index = i0
|
|
438
|
+
r0 = nil
|
|
439
|
+
end
|
|
440
|
+
end
|
|
441
|
+
|
|
442
|
+
node_cache[:Hash][start_index] = r0
|
|
443
|
+
|
|
444
|
+
return r0
|
|
445
|
+
end
|
|
446
|
+
|
|
447
|
+
module HashList0
|
|
448
|
+
def ek
|
|
449
|
+
elements[1]
|
|
450
|
+
end
|
|
451
|
+
|
|
452
|
+
def ev
|
|
453
|
+
elements[3]
|
|
454
|
+
end
|
|
455
|
+
end
|
|
456
|
+
|
|
457
|
+
module HashList1
|
|
458
|
+
def k
|
|
459
|
+
elements[0]
|
|
460
|
+
end
|
|
461
|
+
|
|
462
|
+
def v
|
|
463
|
+
elements[2]
|
|
464
|
+
end
|
|
465
|
+
|
|
466
|
+
def mein_rest
|
|
467
|
+
elements[3]
|
|
468
|
+
end
|
|
469
|
+
end
|
|
470
|
+
|
|
471
|
+
module HashList2
|
|
472
|
+
def sload
|
|
473
|
+
h={}
|
|
474
|
+
h[k.sload]=v.sload
|
|
475
|
+
mein_rest.elements.each{|x|
|
|
476
|
+
h[x.ek.sload]=x.ev.sload
|
|
477
|
+
}
|
|
478
|
+
h
|
|
479
|
+
end
|
|
480
|
+
end
|
|
481
|
+
|
|
482
|
+
def _nt_HashList
|
|
483
|
+
start_index = index
|
|
484
|
+
if node_cache[:HashList].has_key?(index)
|
|
485
|
+
cached = node_cache[:HashList][index]
|
|
486
|
+
@index = cached.interval.end if cached
|
|
487
|
+
return cached
|
|
488
|
+
end
|
|
489
|
+
|
|
490
|
+
i0, s0 = index, []
|
|
491
|
+
r1 = _nt_Element
|
|
492
|
+
s0 << r1
|
|
493
|
+
if r1
|
|
494
|
+
if input.index('=>', index) == index
|
|
495
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
|
496
|
+
@index += 2
|
|
497
|
+
else
|
|
498
|
+
terminal_parse_failure('=>')
|
|
499
|
+
r2 = nil
|
|
500
|
+
end
|
|
501
|
+
s0 << r2
|
|
502
|
+
if r2
|
|
503
|
+
r3 = _nt_Element
|
|
504
|
+
s0 << r3
|
|
505
|
+
if r3
|
|
506
|
+
s4, i4 = [], index
|
|
507
|
+
loop do
|
|
508
|
+
i5, s5 = index, []
|
|
509
|
+
if input.index(',', index) == index
|
|
510
|
+
r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
|
511
|
+
@index += 1
|
|
512
|
+
else
|
|
513
|
+
terminal_parse_failure(',')
|
|
514
|
+
r6 = nil
|
|
515
|
+
end
|
|
516
|
+
s5 << r6
|
|
517
|
+
if r6
|
|
518
|
+
r7 = _nt_Element
|
|
519
|
+
s5 << r7
|
|
520
|
+
if r7
|
|
521
|
+
if input.index('=>', index) == index
|
|
522
|
+
r8 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
|
523
|
+
@index += 2
|
|
524
|
+
else
|
|
525
|
+
terminal_parse_failure('=>')
|
|
526
|
+
r8 = nil
|
|
527
|
+
end
|
|
528
|
+
s5 << r8
|
|
529
|
+
if r8
|
|
530
|
+
r9 = _nt_Element
|
|
531
|
+
s5 << r9
|
|
532
|
+
end
|
|
533
|
+
end
|
|
534
|
+
end
|
|
535
|
+
if s5.last
|
|
536
|
+
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
|
537
|
+
r5.extend(HashList0)
|
|
538
|
+
else
|
|
539
|
+
self.index = i5
|
|
540
|
+
r5 = nil
|
|
541
|
+
end
|
|
542
|
+
if r5
|
|
543
|
+
s4 << r5
|
|
544
|
+
else
|
|
545
|
+
break
|
|
546
|
+
end
|
|
547
|
+
end
|
|
548
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
|
549
|
+
s0 << r4
|
|
550
|
+
end
|
|
551
|
+
end
|
|
552
|
+
end
|
|
553
|
+
if s0.last
|
|
554
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
|
555
|
+
r0.extend(HashList1)
|
|
556
|
+
r0.extend(HashList2)
|
|
557
|
+
else
|
|
558
|
+
self.index = i0
|
|
559
|
+
r0 = nil
|
|
560
|
+
end
|
|
561
|
+
|
|
562
|
+
node_cache[:HashList][start_index] = r0
|
|
563
|
+
|
|
564
|
+
return r0
|
|
565
|
+
end
|
|
566
|
+
|
|
567
|
+
module Number0
|
|
568
|
+
end
|
|
569
|
+
|
|
570
|
+
module Number1
|
|
571
|
+
end
|
|
572
|
+
|
|
573
|
+
module Number2
|
|
574
|
+
def sload
|
|
575
|
+
s=text_value
|
|
576
|
+
if s=~/\./
|
|
577
|
+
return s.to_f
|
|
578
|
+
else
|
|
579
|
+
return s.to_i
|
|
580
|
+
end
|
|
581
|
+
end
|
|
582
|
+
end
|
|
583
|
+
|
|
584
|
+
def _nt_Number
|
|
585
|
+
start_index = index
|
|
586
|
+
if node_cache[:Number].has_key?(index)
|
|
587
|
+
cached = node_cache[:Number][index]
|
|
588
|
+
@index = cached.interval.end if cached
|
|
589
|
+
return cached
|
|
590
|
+
end
|
|
591
|
+
|
|
592
|
+
i0, s0 = index, []
|
|
593
|
+
if input.index('-', index) == index
|
|
594
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
|
595
|
+
@index += 1
|
|
596
|
+
else
|
|
597
|
+
terminal_parse_failure('-')
|
|
598
|
+
r2 = nil
|
|
599
|
+
end
|
|
600
|
+
if r2
|
|
601
|
+
r1 = r2
|
|
602
|
+
else
|
|
603
|
+
r1 = instantiate_node(SyntaxNode,input, index...index)
|
|
604
|
+
end
|
|
605
|
+
s0 << r1
|
|
606
|
+
if r1
|
|
607
|
+
s3, i3 = [], index
|
|
608
|
+
loop do
|
|
609
|
+
if input.index(Regexp.new('[0-9]'), index) == index
|
|
610
|
+
r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
|
611
|
+
@index += 1
|
|
612
|
+
else
|
|
613
|
+
r4 = nil
|
|
614
|
+
end
|
|
615
|
+
if r4
|
|
616
|
+
s3 << r4
|
|
617
|
+
else
|
|
618
|
+
break
|
|
619
|
+
end
|
|
620
|
+
end
|
|
621
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
|
622
|
+
s0 << r3
|
|
623
|
+
if r3
|
|
624
|
+
i6, s6 = index, []
|
|
625
|
+
if input.index('.', index) == index
|
|
626
|
+
r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
|
627
|
+
@index += 1
|
|
628
|
+
else
|
|
629
|
+
terminal_parse_failure('.')
|
|
630
|
+
r7 = nil
|
|
631
|
+
end
|
|
632
|
+
s6 << r7
|
|
633
|
+
if r7
|
|
634
|
+
s8, i8 = [], index
|
|
635
|
+
loop do
|
|
636
|
+
if input.index(Regexp.new('[0-9]'), index) == index
|
|
637
|
+
r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
|
638
|
+
@index += 1
|
|
639
|
+
else
|
|
640
|
+
r9 = nil
|
|
641
|
+
end
|
|
642
|
+
if r9
|
|
643
|
+
s8 << r9
|
|
644
|
+
else
|
|
645
|
+
break
|
|
646
|
+
end
|
|
647
|
+
end
|
|
648
|
+
r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
|
|
649
|
+
s6 << r8
|
|
650
|
+
end
|
|
651
|
+
if s6.last
|
|
652
|
+
r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
|
|
653
|
+
r6.extend(Number0)
|
|
654
|
+
else
|
|
655
|
+
self.index = i6
|
|
656
|
+
r6 = nil
|
|
657
|
+
end
|
|
658
|
+
if r6
|
|
659
|
+
r5 = r6
|
|
660
|
+
else
|
|
661
|
+
r5 = instantiate_node(SyntaxNode,input, index...index)
|
|
662
|
+
end
|
|
663
|
+
s0 << r5
|
|
664
|
+
end
|
|
665
|
+
end
|
|
666
|
+
if s0.last
|
|
667
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
|
668
|
+
r0.extend(Number1)
|
|
669
|
+
r0.extend(Number2)
|
|
670
|
+
else
|
|
671
|
+
self.index = i0
|
|
672
|
+
r0 = nil
|
|
673
|
+
end
|
|
674
|
+
|
|
675
|
+
node_cache[:Number][start_index] = r0
|
|
676
|
+
|
|
677
|
+
return r0
|
|
678
|
+
end
|
|
679
|
+
|
|
680
|
+
module String0
|
|
681
|
+
end
|
|
682
|
+
|
|
683
|
+
module String1
|
|
684
|
+
end
|
|
685
|
+
|
|
686
|
+
module String2
|
|
687
|
+
def sload
|
|
688
|
+
#pp "TV:",text_value
|
|
689
|
+
text_value[1..-2].gsub("\\n","\n").gsub("\\\"","\"").gsub("\\\\","\\")
|
|
690
|
+
end
|
|
691
|
+
end
|
|
692
|
+
|
|
693
|
+
def _nt_String
|
|
694
|
+
start_index = index
|
|
695
|
+
if node_cache[:String].has_key?(index)
|
|
696
|
+
cached = node_cache[:String][index]
|
|
697
|
+
@index = cached.interval.end if cached
|
|
698
|
+
return cached
|
|
699
|
+
end
|
|
700
|
+
|
|
701
|
+
i0, s0 = index, []
|
|
702
|
+
if input.index('"', index) == index
|
|
703
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
|
704
|
+
@index += 1
|
|
705
|
+
else
|
|
706
|
+
terminal_parse_failure('"')
|
|
707
|
+
r1 = nil
|
|
708
|
+
end
|
|
709
|
+
s0 << r1
|
|
710
|
+
if r1
|
|
711
|
+
s2, i2 = [], index
|
|
712
|
+
loop do
|
|
713
|
+
i3 = index
|
|
714
|
+
i4, s4 = index, []
|
|
715
|
+
if input.index('\\', index) == index
|
|
716
|
+
r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
|
717
|
+
@index += 1
|
|
718
|
+
else
|
|
719
|
+
terminal_parse_failure('\\')
|
|
720
|
+
r5 = nil
|
|
721
|
+
end
|
|
722
|
+
s4 << r5
|
|
723
|
+
if r5
|
|
724
|
+
if index < input_length
|
|
725
|
+
r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
|
726
|
+
@index += 1
|
|
727
|
+
else
|
|
728
|
+
terminal_parse_failure("any character")
|
|
729
|
+
r6 = nil
|
|
730
|
+
end
|
|
731
|
+
s4 << r6
|
|
732
|
+
end
|
|
733
|
+
if s4.last
|
|
734
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
|
735
|
+
r4.extend(String0)
|
|
736
|
+
else
|
|
737
|
+
self.index = i4
|
|
738
|
+
r4 = nil
|
|
739
|
+
end
|
|
740
|
+
if r4
|
|
741
|
+
r3 = r4
|
|
742
|
+
else
|
|
743
|
+
if input.index(Regexp.new('[^"\\\\]'), index) == index
|
|
744
|
+
r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
|
745
|
+
@index += 1
|
|
746
|
+
else
|
|
747
|
+
r7 = nil
|
|
748
|
+
end
|
|
749
|
+
if r7
|
|
750
|
+
r3 = r7
|
|
751
|
+
else
|
|
752
|
+
self.index = i3
|
|
753
|
+
r3 = nil
|
|
754
|
+
end
|
|
755
|
+
end
|
|
756
|
+
if r3
|
|
757
|
+
s2 << r3
|
|
758
|
+
else
|
|
759
|
+
break
|
|
760
|
+
end
|
|
761
|
+
end
|
|
762
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
|
763
|
+
s0 << r2
|
|
764
|
+
if r2
|
|
765
|
+
if input.index('"', index) == index
|
|
766
|
+
r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
|
767
|
+
@index += 1
|
|
768
|
+
else
|
|
769
|
+
terminal_parse_failure('"')
|
|
770
|
+
r8 = nil
|
|
771
|
+
end
|
|
772
|
+
s0 << r8
|
|
773
|
+
end
|
|
774
|
+
end
|
|
775
|
+
if s0.last
|
|
776
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
|
777
|
+
r0.extend(String1)
|
|
778
|
+
r0.extend(String2)
|
|
779
|
+
else
|
|
780
|
+
self.index = i0
|
|
781
|
+
r0 = nil
|
|
782
|
+
end
|
|
783
|
+
|
|
784
|
+
node_cache[:String][start_index] = r0
|
|
785
|
+
|
|
786
|
+
return r0
|
|
787
|
+
end
|
|
788
|
+
|
|
789
|
+
def _nt_Fill
|
|
790
|
+
start_index = index
|
|
791
|
+
if node_cache[:Fill].has_key?(index)
|
|
792
|
+
cached = node_cache[:Fill][index]
|
|
793
|
+
@index = cached.interval.end if cached
|
|
794
|
+
return cached
|
|
795
|
+
end
|
|
796
|
+
|
|
797
|
+
r0 = _nt_Whitespaces
|
|
798
|
+
|
|
799
|
+
node_cache[:Fill][start_index] = r0
|
|
800
|
+
|
|
801
|
+
return r0
|
|
802
|
+
end
|
|
803
|
+
|
|
804
|
+
def _nt_Whitespaces
|
|
805
|
+
start_index = index
|
|
806
|
+
if node_cache[:Whitespaces].has_key?(index)
|
|
807
|
+
cached = node_cache[:Whitespaces][index]
|
|
808
|
+
@index = cached.interval.end if cached
|
|
809
|
+
return cached
|
|
810
|
+
end
|
|
811
|
+
|
|
812
|
+
s0, i0 = [], index
|
|
813
|
+
loop do
|
|
814
|
+
r1 = _nt_Whitespace
|
|
815
|
+
if r1
|
|
816
|
+
s0 << r1
|
|
817
|
+
else
|
|
818
|
+
break
|
|
819
|
+
end
|
|
820
|
+
end
|
|
821
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
|
822
|
+
|
|
823
|
+
node_cache[:Whitespaces][start_index] = r0
|
|
824
|
+
|
|
825
|
+
return r0
|
|
826
|
+
end
|
|
827
|
+
|
|
828
|
+
def _nt_Whitespace
|
|
829
|
+
start_index = index
|
|
830
|
+
if node_cache[:Whitespace].has_key?(index)
|
|
831
|
+
cached = node_cache[:Whitespace][index]
|
|
832
|
+
@index = cached.interval.end if cached
|
|
833
|
+
return cached
|
|
834
|
+
end
|
|
835
|
+
|
|
836
|
+
i0 = index
|
|
837
|
+
if input.index(' ', index) == index
|
|
838
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
|
839
|
+
@index += 1
|
|
840
|
+
else
|
|
841
|
+
terminal_parse_failure(' ')
|
|
842
|
+
r1 = nil
|
|
843
|
+
end
|
|
844
|
+
if r1
|
|
845
|
+
r0 = r1
|
|
846
|
+
else
|
|
847
|
+
if input.index("\n", index) == index
|
|
848
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
|
849
|
+
@index += 1
|
|
850
|
+
else
|
|
851
|
+
terminal_parse_failure("\n")
|
|
852
|
+
r2 = nil
|
|
853
|
+
end
|
|
854
|
+
if r2
|
|
855
|
+
r0 = r2
|
|
856
|
+
else
|
|
857
|
+
if input.index("\t", index) == index
|
|
858
|
+
r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
|
859
|
+
@index += 1
|
|
860
|
+
else
|
|
861
|
+
terminal_parse_failure("\t")
|
|
862
|
+
r3 = nil
|
|
863
|
+
end
|
|
864
|
+
if r3
|
|
865
|
+
r0 = r3
|
|
866
|
+
else
|
|
867
|
+
self.index = i0
|
|
868
|
+
r0 = nil
|
|
869
|
+
end
|
|
870
|
+
end
|
|
871
|
+
end
|
|
872
|
+
|
|
873
|
+
node_cache[:Whitespace][start_index] = r0
|
|
874
|
+
|
|
875
|
+
return r0
|
|
876
|
+
end
|
|
877
|
+
|
|
878
|
+
module Array0
|
|
879
|
+
def Fill
|
|
880
|
+
elements[1]
|
|
881
|
+
end
|
|
882
|
+
|
|
883
|
+
end
|
|
884
|
+
|
|
885
|
+
module Array1
|
|
886
|
+
def sload
|
|
887
|
+
[]
|
|
888
|
+
end
|
|
889
|
+
end
|
|
890
|
+
|
|
891
|
+
module Array2
|
|
892
|
+
def e
|
|
893
|
+
elements[1]
|
|
894
|
+
end
|
|
895
|
+
|
|
896
|
+
end
|
|
897
|
+
|
|
898
|
+
module Array3
|
|
899
|
+
|
|
900
|
+
def sload
|
|
901
|
+
e.sload
|
|
902
|
+
end
|
|
903
|
+
end
|
|
904
|
+
|
|
905
|
+
def _nt_Array
|
|
906
|
+
start_index = index
|
|
907
|
+
if node_cache[:Array].has_key?(index)
|
|
908
|
+
cached = node_cache[:Array][index]
|
|
909
|
+
@index = cached.interval.end if cached
|
|
910
|
+
return cached
|
|
911
|
+
end
|
|
912
|
+
|
|
913
|
+
i0 = index
|
|
914
|
+
i1, s1 = index, []
|
|
915
|
+
if input.index('[', index) == index
|
|
916
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
|
917
|
+
@index += 1
|
|
918
|
+
else
|
|
919
|
+
terminal_parse_failure('[')
|
|
920
|
+
r2 = nil
|
|
921
|
+
end
|
|
922
|
+
s1 << r2
|
|
923
|
+
if r2
|
|
924
|
+
r3 = _nt_Fill
|
|
925
|
+
s1 << r3
|
|
926
|
+
if r3
|
|
927
|
+
if input.index(']', index) == index
|
|
928
|
+
r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
|
929
|
+
@index += 1
|
|
930
|
+
else
|
|
931
|
+
terminal_parse_failure(']')
|
|
932
|
+
r4 = nil
|
|
933
|
+
end
|
|
934
|
+
s1 << r4
|
|
935
|
+
end
|
|
936
|
+
end
|
|
937
|
+
if s1.last
|
|
938
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
|
939
|
+
r1.extend(Array0)
|
|
940
|
+
r1.extend(Array1)
|
|
941
|
+
else
|
|
942
|
+
self.index = i1
|
|
943
|
+
r1 = nil
|
|
944
|
+
end
|
|
945
|
+
if r1
|
|
946
|
+
r0 = r1
|
|
947
|
+
else
|
|
948
|
+
i5, s5 = index, []
|
|
949
|
+
if input.index('[', index) == index
|
|
950
|
+
r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
|
951
|
+
@index += 1
|
|
952
|
+
else
|
|
953
|
+
terminal_parse_failure('[')
|
|
954
|
+
r6 = nil
|
|
955
|
+
end
|
|
956
|
+
s5 << r6
|
|
957
|
+
if r6
|
|
958
|
+
r7 = _nt_ElementList
|
|
959
|
+
s5 << r7
|
|
960
|
+
if r7
|
|
961
|
+
if input.index(']', index) == index
|
|
962
|
+
r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
|
963
|
+
@index += 1
|
|
964
|
+
else
|
|
965
|
+
terminal_parse_failure(']')
|
|
966
|
+
r8 = nil
|
|
967
|
+
end
|
|
968
|
+
s5 << r8
|
|
969
|
+
end
|
|
970
|
+
end
|
|
971
|
+
if s5.last
|
|
972
|
+
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
|
973
|
+
r5.extend(Array2)
|
|
974
|
+
r5.extend(Array3)
|
|
975
|
+
else
|
|
976
|
+
self.index = i5
|
|
977
|
+
r5 = nil
|
|
978
|
+
end
|
|
979
|
+
if r5
|
|
980
|
+
r0 = r5
|
|
981
|
+
else
|
|
982
|
+
self.index = i0
|
|
983
|
+
r0 = nil
|
|
984
|
+
end
|
|
985
|
+
end
|
|
986
|
+
|
|
987
|
+
node_cache[:Array][start_index] = r0
|
|
988
|
+
|
|
989
|
+
return r0
|
|
990
|
+
end
|
|
991
|
+
|
|
992
|
+
module ElementList0
|
|
993
|
+
def el
|
|
994
|
+
elements[1]
|
|
995
|
+
end
|
|
996
|
+
end
|
|
997
|
+
|
|
998
|
+
module ElementList1
|
|
999
|
+
def e
|
|
1000
|
+
elements[0]
|
|
1001
|
+
end
|
|
1002
|
+
|
|
1003
|
+
def mein_rest
|
|
1004
|
+
elements[1]
|
|
1005
|
+
end
|
|
1006
|
+
end
|
|
1007
|
+
|
|
1008
|
+
module ElementList2
|
|
1009
|
+
def sload
|
|
1010
|
+
[e.sload]+mein_rest.elements.map{|x|x.el.sload}
|
|
1011
|
+
end
|
|
1012
|
+
end
|
|
1013
|
+
|
|
1014
|
+
def _nt_ElementList
|
|
1015
|
+
start_index = index
|
|
1016
|
+
if node_cache[:ElementList].has_key?(index)
|
|
1017
|
+
cached = node_cache[:ElementList][index]
|
|
1018
|
+
@index = cached.interval.end if cached
|
|
1019
|
+
return cached
|
|
1020
|
+
end
|
|
1021
|
+
|
|
1022
|
+
i0, s0 = index, []
|
|
1023
|
+
r1 = _nt_Element
|
|
1024
|
+
s0 << r1
|
|
1025
|
+
if r1
|
|
1026
|
+
s2, i2 = [], index
|
|
1027
|
+
loop do
|
|
1028
|
+
i3, s3 = index, []
|
|
1029
|
+
if input.index(',', index) == index
|
|
1030
|
+
r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
|
1031
|
+
@index += 1
|
|
1032
|
+
else
|
|
1033
|
+
terminal_parse_failure(',')
|
|
1034
|
+
r4 = nil
|
|
1035
|
+
end
|
|
1036
|
+
s3 << r4
|
|
1037
|
+
if r4
|
|
1038
|
+
r5 = _nt_Element
|
|
1039
|
+
s3 << r5
|
|
1040
|
+
end
|
|
1041
|
+
if s3.last
|
|
1042
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
|
1043
|
+
r3.extend(ElementList0)
|
|
1044
|
+
else
|
|
1045
|
+
self.index = i3
|
|
1046
|
+
r3 = nil
|
|
1047
|
+
end
|
|
1048
|
+
if r3
|
|
1049
|
+
s2 << r3
|
|
1050
|
+
else
|
|
1051
|
+
break
|
|
1052
|
+
end
|
|
1053
|
+
end
|
|
1054
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
|
1055
|
+
s0 << r2
|
|
1056
|
+
end
|
|
1057
|
+
if s0.last
|
|
1058
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
|
1059
|
+
r0.extend(ElementList1)
|
|
1060
|
+
r0.extend(ElementList2)
|
|
1061
|
+
else
|
|
1062
|
+
self.index = i0
|
|
1063
|
+
r0 = nil
|
|
1064
|
+
end
|
|
1065
|
+
|
|
1066
|
+
node_cache[:ElementList][start_index] = r0
|
|
1067
|
+
|
|
1068
|
+
return r0
|
|
1069
|
+
end
|
|
1070
|
+
|
|
1071
|
+
module StructName0
|
|
1072
|
+
end
|
|
1073
|
+
|
|
1074
|
+
def _nt_StructName
|
|
1075
|
+
start_index = index
|
|
1076
|
+
if node_cache[:StructName].has_key?(index)
|
|
1077
|
+
cached = node_cache[:StructName][index]
|
|
1078
|
+
@index = cached.interval.end if cached
|
|
1079
|
+
return cached
|
|
1080
|
+
end
|
|
1081
|
+
|
|
1082
|
+
i0, s0 = index, []
|
|
1083
|
+
if input.index(Regexp.new('[A-Z]'), index) == index
|
|
1084
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
|
1085
|
+
@index += 1
|
|
1086
|
+
else
|
|
1087
|
+
r1 = nil
|
|
1088
|
+
end
|
|
1089
|
+
s0 << r1
|
|
1090
|
+
if r1
|
|
1091
|
+
s2, i2 = [], index
|
|
1092
|
+
loop do
|
|
1093
|
+
if input.index(Regexp.new('[A-Za-z0-9_:]'), index) == index
|
|
1094
|
+
r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
|
1095
|
+
@index += 1
|
|
1096
|
+
else
|
|
1097
|
+
r3 = nil
|
|
1098
|
+
end
|
|
1099
|
+
if r3
|
|
1100
|
+
s2 << r3
|
|
1101
|
+
else
|
|
1102
|
+
break
|
|
1103
|
+
end
|
|
1104
|
+
end
|
|
1105
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
|
1106
|
+
s0 << r2
|
|
1107
|
+
end
|
|
1108
|
+
if s0.last
|
|
1109
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
|
1110
|
+
r0.extend(StructName0)
|
|
1111
|
+
else
|
|
1112
|
+
self.index = i0
|
|
1113
|
+
r0 = nil
|
|
1114
|
+
end
|
|
1115
|
+
|
|
1116
|
+
node_cache[:StructName][start_index] = r0
|
|
1117
|
+
|
|
1118
|
+
return r0
|
|
1119
|
+
end
|
|
1120
|
+
|
|
1121
|
+
def _nt_Any
|
|
1122
|
+
start_index = index
|
|
1123
|
+
if node_cache[:Any].has_key?(index)
|
|
1124
|
+
cached = node_cache[:Any][index]
|
|
1125
|
+
@index = cached.interval.end if cached
|
|
1126
|
+
return cached
|
|
1127
|
+
end
|
|
1128
|
+
|
|
1129
|
+
s0, i0 = [], index
|
|
1130
|
+
loop do
|
|
1131
|
+
if index < input_length
|
|
1132
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
|
1133
|
+
@index += 1
|
|
1134
|
+
else
|
|
1135
|
+
terminal_parse_failure("any character")
|
|
1136
|
+
r1 = nil
|
|
1137
|
+
end
|
|
1138
|
+
if r1
|
|
1139
|
+
s0 << r1
|
|
1140
|
+
else
|
|
1141
|
+
break
|
|
1142
|
+
end
|
|
1143
|
+
end
|
|
1144
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
|
1145
|
+
|
|
1146
|
+
node_cache[:Any][start_index] = r0
|
|
1147
|
+
|
|
1148
|
+
return r0
|
|
1149
|
+
end
|
|
1150
|
+
|
|
1151
|
+
module Struct0
|
|
1152
|
+
def name
|
|
1153
|
+
elements[1]
|
|
1154
|
+
end
|
|
1155
|
+
|
|
1156
|
+
def Whitespace
|
|
1157
|
+
elements[2]
|
|
1158
|
+
end
|
|
1159
|
+
|
|
1160
|
+
def l
|
|
1161
|
+
elements[3]
|
|
1162
|
+
end
|
|
1163
|
+
|
|
1164
|
+
end
|
|
1165
|
+
|
|
1166
|
+
module Struct1
|
|
1167
|
+
|
|
1168
|
+
def sload
|
|
1169
|
+
klass=getClass(name.text_value)
|
|
1170
|
+
mo=nil
|
|
1171
|
+
hash=l.sload
|
|
1172
|
+
if klass==Time
|
|
1173
|
+
mo=Time.parse(hash[:data])
|
|
1174
|
+
else
|
|
1175
|
+
mo=klass.new
|
|
1176
|
+
hash.each{|k,v|
|
|
1177
|
+
k=k.to_s
|
|
1178
|
+
mo.send(k+"=",v) if mo.members.member?(k) and mo.respond_to?(k+"=")
|
|
1179
|
+
}
|
|
1180
|
+
end
|
|
1181
|
+
mo
|
|
1182
|
+
|
|
1183
|
+
end
|
|
1184
|
+
end
|
|
1185
|
+
|
|
1186
|
+
def _nt_Struct
|
|
1187
|
+
start_index = index
|
|
1188
|
+
if node_cache[:Struct].has_key?(index)
|
|
1189
|
+
cached = node_cache[:Struct][index]
|
|
1190
|
+
@index = cached.interval.end if cached
|
|
1191
|
+
return cached
|
|
1192
|
+
end
|
|
1193
|
+
|
|
1194
|
+
i0, s0 = index, []
|
|
1195
|
+
if input.index('(', index) == index
|
|
1196
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
|
1197
|
+
@index += 1
|
|
1198
|
+
else
|
|
1199
|
+
terminal_parse_failure('(')
|
|
1200
|
+
r1 = nil
|
|
1201
|
+
end
|
|
1202
|
+
s0 << r1
|
|
1203
|
+
if r1
|
|
1204
|
+
r2 = _nt_StructName
|
|
1205
|
+
s0 << r2
|
|
1206
|
+
if r2
|
|
1207
|
+
r3 = _nt_Whitespace
|
|
1208
|
+
s0 << r3
|
|
1209
|
+
if r3
|
|
1210
|
+
r4 = _nt_HashList
|
|
1211
|
+
s0 << r4
|
|
1212
|
+
if r4
|
|
1213
|
+
if input.index(')', index) == index
|
|
1214
|
+
r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
|
1215
|
+
@index += 1
|
|
1216
|
+
else
|
|
1217
|
+
terminal_parse_failure(')')
|
|
1218
|
+
r5 = nil
|
|
1219
|
+
end
|
|
1220
|
+
s0 << r5
|
|
1221
|
+
end
|
|
1222
|
+
end
|
|
1223
|
+
end
|
|
1224
|
+
end
|
|
1225
|
+
if s0.last
|
|
1226
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
|
1227
|
+
r0.extend(Struct0)
|
|
1228
|
+
r0.extend(Struct1)
|
|
1229
|
+
else
|
|
1230
|
+
self.index = i0
|
|
1231
|
+
r0 = nil
|
|
1232
|
+
end
|
|
1233
|
+
|
|
1234
|
+
node_cache[:Struct][start_index] = r0
|
|
1235
|
+
|
|
1236
|
+
return r0
|
|
1237
|
+
end
|
|
1238
|
+
|
|
1239
|
+
end
|
|
1240
|
+
|
|
1241
|
+
class SimpleMarshalParser < Treetop::Runtime::CompiledParser
|
|
1242
|
+
include SimpleMarshal
|
|
1243
|
+
end
|