sfp 0.4.4 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/sfp/SfpLangLexer.rb +486 -449
- data/lib/sfp/SfpLangParser.rb +1872 -1793
- data/src/SfpLang.g +38 -26
- metadata +2 -2
data/src/SfpLang.g
CHANGED
@@ -40,10 +40,26 @@ sfp
|
|
40
40
|
: { self.init }
|
41
41
|
NL*
|
42
42
|
( (object_def | abstract_object | state | constraint_def | class_def | procedure) NL*
|
43
|
-
| include
|
43
|
+
| include
|
44
|
+
| placement
|
45
|
+
)*
|
44
46
|
{ self.finalize }
|
45
47
|
;
|
46
48
|
|
49
|
+
placement
|
50
|
+
: '!' path
|
51
|
+
{
|
52
|
+
ref = "$.#{$path.text}"
|
53
|
+
parent, id = ref.pop_ref
|
54
|
+
@now = @root.at?(parent)
|
55
|
+
fail "parent #{parent} is not exist" if not @now.is_a?(Hash)
|
56
|
+
}
|
57
|
+
assignment[id]
|
58
|
+
{
|
59
|
+
@now = @root
|
60
|
+
}
|
61
|
+
;
|
62
|
+
|
47
63
|
constraint_def
|
48
64
|
: goal_constraint
|
49
65
|
| global_constraint
|
@@ -112,9 +128,10 @@ attribute
|
|
112
128
|
@is_final = false
|
113
129
|
@now['_finals'] = [] if !@now.has_key? '_finals'
|
114
130
|
}
|
115
|
-
('final' { @is_final = true })?
|
131
|
+
('final' { @is_final = true })?
|
132
|
+
ID assignment[$ID.text]
|
116
133
|
{
|
117
|
-
@now['_finals'] << $
|
134
|
+
@now['_finals'] << $ID.text if @is_final
|
118
135
|
}
|
119
136
|
| {
|
120
137
|
@is_final = false
|
@@ -123,56 +140,51 @@ attribute
|
|
123
140
|
('final' { @is_final = true })? object_def NL+
|
124
141
|
;
|
125
142
|
|
126
|
-
|
127
|
-
:
|
143
|
+
assignment[id]
|
144
|
+
: equals_op value NL+
|
128
145
|
{
|
129
|
-
if @now.has_key?($
|
130
|
-
@now[$
|
131
|
-
$value.val.each { |v| @now[$
|
146
|
+
if @now.has_key?($id) and @now[$id].is_a?(Hash) and
|
147
|
+
@now[$id].isset and $value.type == 'Set'
|
148
|
+
$value.val.each { |v| @now[$id]['_values'].push(v) }
|
132
149
|
else
|
133
|
-
@now[$
|
150
|
+
@now[$id] = $value.val
|
134
151
|
end
|
135
|
-
$id = $ID.text
|
136
152
|
}
|
137
|
-
|
|
153
|
+
| reference_type NL+
|
138
154
|
{
|
139
|
-
@now[$
|
140
|
-
$id = $ID.text
|
155
|
+
@now[$id] = $reference_type.val
|
141
156
|
}
|
142
|
-
|
|
157
|
+
| set_type NL+
|
143
158
|
{
|
144
|
-
@now[$
|
145
|
-
$id = $ID.text
|
159
|
+
@now[$id] = $set_type.val
|
146
160
|
}
|
147
|
-
|
|
161
|
+
| probability_op set_value NL+
|
148
162
|
{
|
149
163
|
@conformant = true
|
150
|
-
@now[$
|
164
|
+
@now[$id] = { '_self' => $id,
|
151
165
|
'_context' => 'either',
|
152
166
|
'_parent' => @now,
|
153
167
|
'_values' => $set_value.val
|
154
168
|
}
|
155
|
-
$id = $ID.text
|
156
169
|
}
|
157
|
-
|
|
170
|
+
| ':' path NL+
|
158
171
|
{
|
159
172
|
case $path.text
|
160
173
|
when 'String'
|
161
|
-
@now[$
|
174
|
+
@now[$id] = { '_context' => 'any_value',
|
162
175
|
'_isa' => '$.String'
|
163
176
|
}
|
164
177
|
when 'Bool'
|
165
|
-
@now[$
|
178
|
+
@now[$id] = { '_context' => 'any_value',
|
166
179
|
'_isa' => '$.Boolean'
|
167
180
|
}
|
168
181
|
when 'Int'
|
169
|
-
@now[$
|
182
|
+
@now[$id] = { '_context' => 'any_value',
|
170
183
|
'_isa' => '$.Number'
|
171
184
|
}
|
172
185
|
else
|
173
186
|
raise Exception, "Use isa/isref for any non-primitive type (#{$path.text})."
|
174
187
|
end
|
175
|
-
$id = $ID.text
|
176
188
|
}
|
177
189
|
;
|
178
190
|
|
@@ -874,11 +886,11 @@ mutation returns [key, val]
|
|
874
886
|
;
|
875
887
|
|
876
888
|
set_value returns [val]
|
877
|
-
: '('
|
889
|
+
: ('('|'[')
|
878
890
|
{ @set = Array.new }
|
879
891
|
(set_item (',' NL* set_item)*)?
|
880
892
|
{ $val = @set }
|
881
|
-
')'
|
893
|
+
(')'|']')
|
882
894
|
;
|
883
895
|
|
884
896
|
set_item
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sfp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Herry
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: antlr3
|