sfp 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +7 -1
- data/bin/solver/linux/downward +0 -0
- data/lib/sfp/SfpLangLexer.rb +318 -256
- data/lib/sfp/SfpLangParser.rb +4471 -4230
- data/sfp.gemspec +4 -4
- data/src/SfpLang.g +47 -21
- data/src/build.sh +2 -2
- data/test/s.sfp +14 -0
- metadata +9 -8
data/sfp.gemspec
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'sfp'
|
3
|
-
s.version = '0.1.
|
3
|
+
s.version = '0.1.1'
|
4
4
|
s.date = '2013-04-20'
|
5
5
|
s.summary = 'SFP Parser and Planner'
|
6
|
-
s.description = 'A Ruby gem that provides a Ruby
|
7
|
-
'It also provides a
|
8
|
-
'
|
6
|
+
s.description = 'A Ruby gem that provides a Ruby API to SFP language parser and ' +
|
7
|
+
'SFP planner. It also provides a planner sript to solve a planning problem ' +
|
8
|
+
'written in SFP language.'
|
9
9
|
s.authors = ['Herry']
|
10
10
|
s.email = 'herry13@gmail.com'
|
11
11
|
|
data/src/SfpLang.g
CHANGED
@@ -8,8 +8,7 @@ options {
|
|
8
8
|
@headers {
|
9
9
|
=begin
|
10
10
|
Depends:
|
11
|
-
-
|
12
|
-
- ext.rb
|
11
|
+
- Sfplib.rb
|
13
12
|
|
14
13
|
Features:
|
15
14
|
- reference
|
@@ -41,7 +40,25 @@ sfp
|
|
41
40
|
: { self.init }
|
42
41
|
NL* include* header*
|
43
42
|
{ self.expand_classes }
|
44
|
-
(
|
43
|
+
(mmutation | object_def NL* | state | constraint | goal_constraint | composite)*
|
44
|
+
;
|
45
|
+
|
46
|
+
|
47
|
+
mmutation
|
48
|
+
: reference equals_op value NL+
|
49
|
+
{
|
50
|
+
path, var = $reference.val.extract
|
51
|
+
parent = @now.at?(path)
|
52
|
+
raise Exception, "#{path} is not a Hash" if not parent.is_a?(Hash)
|
53
|
+
parent[var] = $value.val
|
54
|
+
}
|
55
|
+
| reference equals_op NULL
|
56
|
+
{
|
57
|
+
path, var = $reference.val.extract
|
58
|
+
parent = @now.at?(path)
|
59
|
+
raise Exception, "#{path} is not a Hash" if not parent.is_a?(Hash)
|
60
|
+
parent[var] = self.null_value
|
61
|
+
}
|
45
62
|
;
|
46
63
|
|
47
64
|
include
|
@@ -59,7 +76,7 @@ header
|
|
59
76
|
;
|
60
77
|
|
61
78
|
state
|
62
|
-
: ID
|
79
|
+
: ID 'state'
|
63
80
|
{
|
64
81
|
@now[$ID.text] = { '_self' => $ID.text,
|
65
82
|
'_context' => 'state',
|
@@ -91,7 +108,7 @@ class_definition
|
|
91
108
|
{
|
92
109
|
@now[$ID.text] = { '_self' => $ID.text,
|
93
110
|
'_context' => 'class',
|
94
|
-
'_parent' => @now
|
111
|
+
'_parent' => @now,
|
95
112
|
}
|
96
113
|
@now = @now[$ID.text]
|
97
114
|
}
|
@@ -101,7 +118,13 @@ class_definition
|
|
101
118
|
}
|
102
119
|
)?
|
103
120
|
('{' NL* ( attribute | procedure )* '}')? NL*
|
104
|
-
{
|
121
|
+
{
|
122
|
+
if not @now.has_key?('_extends')
|
123
|
+
@now['_extends'] = '$.Object'
|
124
|
+
@now['_super'] = ['$.Object']
|
125
|
+
end
|
126
|
+
self.goto_parent()
|
127
|
+
}
|
105
128
|
;
|
106
129
|
|
107
130
|
extends_class returns [val]
|
@@ -163,11 +186,10 @@ object_def
|
|
163
186
|
total = $NUMBER.to_s.to_i
|
164
187
|
@arrays[obj.ref] = total
|
165
188
|
for i in 0..(total-1)
|
166
|
-
id = obj['_self'] +
|
189
|
+
id = obj['_self'] + '[' + i.to_s + ']'
|
167
190
|
@now[id] = deep_clone(obj)
|
168
191
|
@now[id]['_self'] = id
|
169
192
|
@now[id]['_classes'] = obj['_classes']
|
170
|
-
#puts 'is_array: ' + $ID.text + '[' + i.to_s + ']'
|
171
193
|
end
|
172
194
|
@now.delete(obj['_self'])
|
173
195
|
else
|
@@ -212,7 +234,7 @@ operator
|
|
212
234
|
'_parent' => @now,
|
213
235
|
'_cost' => 1,
|
214
236
|
'_condition' => { '_context' => 'constraint' },
|
215
|
-
'_effect' => { '_context' => '
|
237
|
+
'_effect' => { '_context' => 'effect' }
|
216
238
|
}
|
217
239
|
@now = @now[$ID.text]
|
218
240
|
}
|
@@ -231,7 +253,7 @@ op_param
|
|
231
253
|
;
|
232
254
|
|
233
255
|
op_conditions
|
234
|
-
: 'conditions' '{' NL*
|
256
|
+
: ('conditions' | 'condition') '{' NL*
|
235
257
|
{
|
236
258
|
@now['_condition']['_parent'] = @now
|
237
259
|
@now = @now['_condition']
|
@@ -265,7 +287,7 @@ procedure
|
|
265
287
|
'_parent' => @now,
|
266
288
|
'_cost' => 1,
|
267
289
|
'_condition' => { '_context' => 'constraint', '_type' => 'and' },
|
268
|
-
'_effect' => { '_context' => '
|
290
|
+
'_effect' => { '_context' => 'effect', '_type' => 'and' }
|
269
291
|
}
|
270
292
|
@now = @now[$ID.text]
|
271
293
|
}
|
@@ -302,7 +324,7 @@ parameter
|
|
302
324
|
;
|
303
325
|
|
304
326
|
conditions
|
305
|
-
: 'conditions'
|
327
|
+
: ('conditions' | 'condition')
|
306
328
|
{
|
307
329
|
@now['_condition']['_parent'] = @now
|
308
330
|
@now = @now['_condition']
|
@@ -313,15 +335,19 @@ conditions
|
|
313
335
|
;
|
314
336
|
|
315
337
|
effects
|
316
|
-
: 'effects'
|
338
|
+
: ('effects' | 'effect')
|
317
339
|
{
|
318
340
|
@now['_effect']['_parent'] = @now
|
319
341
|
@now = @now['_effect']
|
342
|
+
@in_effects = true
|
320
343
|
}
|
321
344
|
'{' NL*
|
322
|
-
|
345
|
+
effect_body
|
323
346
|
'}' NL+
|
324
|
-
{
|
347
|
+
{
|
348
|
+
self.goto_parent()
|
349
|
+
@in_effects = false
|
350
|
+
}
|
325
351
|
;
|
326
352
|
|
327
353
|
goal_constraint
|
@@ -711,10 +737,10 @@ conditional_constraint_then_part
|
|
711
737
|
{ self.goto_parent() }
|
712
738
|
;
|
713
739
|
|
714
|
-
|
740
|
+
effect_body
|
715
741
|
: (
|
716
|
-
(
|
717
|
-
{ @now[$
|
742
|
+
( mutation
|
743
|
+
{ @now[$mutation.key] = $mutation.val }
|
718
744
|
| mutation_iterator
|
719
745
|
)
|
720
746
|
NL+)*
|
@@ -731,14 +757,14 @@ mutation_iterator
|
|
731
757
|
}
|
732
758
|
@now = @now[id]
|
733
759
|
}
|
734
|
-
(
|
735
|
-
{ @now[$
|
760
|
+
(mutation
|
761
|
+
{ @now[$mutation.key] = $mutation.val }
|
736
762
|
NL+)*
|
737
763
|
'}'
|
738
764
|
{ self.goto_parent() }
|
739
765
|
;
|
740
766
|
|
741
|
-
|
767
|
+
mutation returns [key, val]
|
742
768
|
: reference equals_op value
|
743
769
|
{
|
744
770
|
$key = $reference.val
|
data/src/build.sh
CHANGED
data/test/s.sfp
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sfp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2013-04-20 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
16
|
-
requirement: &
|
16
|
+
requirement: &8708440 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.7.5
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *8708440
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: antlr3
|
27
|
-
requirement: &
|
27
|
+
requirement: &8707420 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,9 @@ dependencies:
|
|
32
32
|
version: 1.8.12
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
36
|
-
description: A Ruby gem that provides a Ruby
|
37
|
-
provides a
|
38
|
-
written in SFP language.
|
35
|
+
version_requirements: *8707420
|
36
|
+
description: A Ruby gem that provides a Ruby API to SFP language parser and SFP planner.
|
37
|
+
It also provides a planner sript to solve a planning problem written in SFP language.
|
39
38
|
email: herry13@gmail.com
|
40
39
|
executables:
|
41
40
|
- sfp
|
@@ -67,6 +66,7 @@ files:
|
|
67
66
|
- test/cloud1.sfp
|
68
67
|
- test/cloud2.sfp
|
69
68
|
- test/cloud3.sfp
|
69
|
+
- test/s.sfp
|
70
70
|
- test/service-classes.sfp
|
71
71
|
- test/service1.sfp
|
72
72
|
- test/service3.sfp
|
@@ -107,6 +107,7 @@ test_files:
|
|
107
107
|
- test/cloud1.sfp
|
108
108
|
- test/cloud2.sfp
|
109
109
|
- test/cloud3.sfp
|
110
|
+
- test/s.sfp
|
110
111
|
- test/service-classes.sfp
|
111
112
|
- test/service1.sfp
|
112
113
|
- test/service3.sfp
|