rubymm 0.1.0-java
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/jars/com.google.collect_1.0.0.v201105210816.jar +0 -0
- data/lib/jars/com.google.inject_2.0.0.v201105231817.jar +0 -0
- data/lib/jars/com.ibm.icu_4.4.2.v20110208.jar +0 -0
- data/lib/jars/org.apache.commons.lang_2.4.0.v201005080502.jar +0 -0
- data/lib/jars/org.apache.commons.logging_1.1.1.jar +0 -0
- data/lib/jars/org.apache.log4j_1.2.16.jar +0 -0
- data/lib/jars/org.eclipse.core.runtime.compatibility_3.2.100.v20100505.jar +0 -0
- data/lib/jars/org.eclipse.core.runtime_3.7.0.v20110110.jar +0 -0
- data/lib/rubymm/metamodel.rb +30 -0
- data/lib/rubymm/parser.rb +70 -0
- data/lib/rubymm.rb +7 -0
- metadata +111 -0
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'rgen/metamodel_builder'
|
2
|
+
|
3
|
+
module RubyMM
|
4
|
+
|
5
|
+
class Value < RGen::MetamodelBuilder::MMBase
|
6
|
+
end
|
7
|
+
|
8
|
+
class Block < Value
|
9
|
+
has_many 'contents', Value
|
10
|
+
end
|
11
|
+
|
12
|
+
class Call < Value
|
13
|
+
has_attr 'name', String
|
14
|
+
has_many 'args', Value
|
15
|
+
has_one 'receiver', Value
|
16
|
+
end
|
17
|
+
|
18
|
+
class Def < RGen::MetamodelBuilder::MMBase
|
19
|
+
has_attr 'name', String
|
20
|
+
has_one 'body', Value
|
21
|
+
end
|
22
|
+
|
23
|
+
class Literal < Value
|
24
|
+
end
|
25
|
+
|
26
|
+
class IntLiteral < Literal
|
27
|
+
has_attr 'value', Integer
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'jruby-parser'
|
2
|
+
require 'rubymm/metamodel'
|
3
|
+
require 'java'
|
4
|
+
require 'emf_jruby'
|
5
|
+
|
6
|
+
java_import org.jrubyparser.ast.ArrayNode
|
7
|
+
|
8
|
+
module RubyMM
|
9
|
+
|
10
|
+
def self.parse(code)
|
11
|
+
tree = JRubyParser.parse(code)
|
12
|
+
tree_to_model(tree)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.tree_to_model(tree)
|
16
|
+
unless tree.node_type.name=='ROOTNODE'
|
17
|
+
raise 'Root expected'
|
18
|
+
end
|
19
|
+
node_to_model tree.body
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.node_to_model(node)
|
23
|
+
case node.node_type.name
|
24
|
+
when 'NEWLINENODE'
|
25
|
+
node_to_model node.next_node
|
26
|
+
when 'CALLNODE'
|
27
|
+
model = RubyMM::Call.new
|
28
|
+
model.name = node.name
|
29
|
+
model.receiver = node_to_model node.receiver
|
30
|
+
model.args = args_to_model node.args
|
31
|
+
model
|
32
|
+
when 'DEFNNODE'
|
33
|
+
model = RubyMM::Def.new
|
34
|
+
model.name = node.name
|
35
|
+
#puts "Body #{node_to_model node.body}"
|
36
|
+
model.body = node_to_model node.body
|
37
|
+
model
|
38
|
+
when 'BLOCKNODE'
|
39
|
+
model = RubyMM::Block.new
|
40
|
+
for i in 0..(node.size-1)
|
41
|
+
content_at_i = node_to_model(node.get i)
|
42
|
+
#puts "Adding to contents #{content_at_i}"
|
43
|
+
model.contents = (model.contents << content_at_i)
|
44
|
+
#puts "Contents #{model.contents.class}"
|
45
|
+
end
|
46
|
+
model
|
47
|
+
when 'FIXNUMNODE'
|
48
|
+
model = RubyMM::IntLiteral.new
|
49
|
+
model.value = node.value
|
50
|
+
model
|
51
|
+
else
|
52
|
+
raise "I don't know how to deal with #{node.node_type.name}"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.args_to_model(args_node)
|
57
|
+
args=[]
|
58
|
+
if args_node.is_a? ArrayNode
|
59
|
+
#puts "ARGS #{args_node} #{args_node.size} #{args_node.class}"
|
60
|
+
for i in 0..(args_node.size-1)
|
61
|
+
#puts "DEALING WITH #{i} #{args_node.get i} #{(args_node.get i).class}"
|
62
|
+
args << node_to_model(args_node.get i)
|
63
|
+
end
|
64
|
+
args
|
65
|
+
else
|
66
|
+
raise "I don't know how to deal with #{args_node.class}"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
data/lib/rubymm.rb
ADDED
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rubymm
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.0
|
6
|
+
platform: java
|
7
|
+
authors:
|
8
|
+
- Federico Tomassetti
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-08-04 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: json
|
16
|
+
version_requirements: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: !binary |-
|
21
|
+
MA==
|
22
|
+
none: false
|
23
|
+
requirement: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: !binary |-
|
28
|
+
MA==
|
29
|
+
none: false
|
30
|
+
prerelease: false
|
31
|
+
type: :runtime
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
name: emf_jruby
|
34
|
+
version_requirements: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: !binary |-
|
39
|
+
MA==
|
40
|
+
none: false
|
41
|
+
requirement: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: !binary |-
|
46
|
+
MA==
|
47
|
+
none: false
|
48
|
+
prerelease: false
|
49
|
+
type: :runtime
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: jruby-parser
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: !binary |-
|
57
|
+
MA==
|
58
|
+
none: false
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: !binary |-
|
64
|
+
MA==
|
65
|
+
none: false
|
66
|
+
prerelease: false
|
67
|
+
type: :runtime
|
68
|
+
description: Ruby metamodel and parser producing an EMF model
|
69
|
+
email: f.tomassetti@gmail.com
|
70
|
+
executables: []
|
71
|
+
extensions: []
|
72
|
+
extra_rdoc_files: []
|
73
|
+
files:
|
74
|
+
- "./lib/rubymm.rb"
|
75
|
+
- "./lib/rubymm/metamodel.rb"
|
76
|
+
- "./lib/rubymm/parser.rb"
|
77
|
+
- "./lib/jars/com.google.collect_1.0.0.v201105210816.jar"
|
78
|
+
- "./lib/jars/com.google.inject_2.0.0.v201105231817.jar"
|
79
|
+
- "./lib/jars/com.ibm.icu_4.4.2.v20110208.jar"
|
80
|
+
- "./lib/jars/org.apache.commons.lang_2.4.0.v201005080502.jar"
|
81
|
+
- "./lib/jars/org.apache.commons.logging_1.1.1.jar"
|
82
|
+
- "./lib/jars/org.apache.log4j_1.2.16.jar"
|
83
|
+
- "./lib/jars/org.eclipse.core.runtime.compatibility_3.2.100.v20100505.jar"
|
84
|
+
- "./lib/jars/org.eclipse.core.runtime_3.7.0.v20110110.jar"
|
85
|
+
homepage: http://federico-tomassetti.it
|
86
|
+
licenses: []
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: !binary |-
|
96
|
+
MA==
|
97
|
+
none: false
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: !binary |-
|
103
|
+
MA==
|
104
|
+
none: false
|
105
|
+
requirements: []
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 1.8.24
|
108
|
+
signing_key:
|
109
|
+
specification_version: 3
|
110
|
+
summary: Ruby metamodel and parser
|
111
|
+
test_files: []
|