sfp 0.3.10 → 0.3.11
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/sfp/SfpLangLexer.rb +238 -238
- data/lib/sfp/SfpLangParser.rb +4313 -4530
- data/lib/sfp/Sfplib.rb +7 -0
- data/src/SfpLang.g +14 -45
- metadata +5 -5
data/lib/sfp/Sfplib.rb
CHANGED
@@ -13,6 +13,13 @@ module Sfp
|
|
13
13
|
@conformant = false
|
14
14
|
end
|
15
15
|
|
16
|
+
def finalize
|
17
|
+
@root.keys.each { |k|
|
18
|
+
next if k[0,1] == '_' or !@root[k].is_a?(Hash)
|
19
|
+
@root.delete(k) if @root[k]['_context'] == 'abstract'
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
16
23
|
def next_id
|
17
24
|
nid = "c#{@constraint_next_id}"
|
18
25
|
@constraint_next_id += 1
|
data/src/SfpLang.g
CHANGED
@@ -37,37 +37,19 @@ TODO:
|
|
37
37
|
}
|
38
38
|
|
39
39
|
sfp
|
40
|
-
: {
|
40
|
+
: { self.init }
|
41
41
|
NL*
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
( (object_def | abstract_object | state | constraint_def | class_def | procedure) NL*
|
43
|
+
| include )*
|
44
|
+
{ self.finalize }
|
45
45
|
;
|
46
46
|
|
47
|
-
|
47
|
+
constraint_def
|
48
48
|
: goal_constraint
|
49
49
|
| global_constraint
|
50
50
|
| sometime_constraint
|
51
51
|
;
|
52
52
|
|
53
|
-
/*mmutation
|
54
|
-
: reference equals_op value NL+
|
55
|
-
{
|
56
|
-
path, var = $reference.val.extract
|
57
|
-
parent = @now.at?(path)
|
58
|
-
raise Exception, "#{path} is not a Hash" if not parent.is_a?(Hash)
|
59
|
-
parent[var] = $value.val
|
60
|
-
}
|
61
|
-
| reference equals_op NULL
|
62
|
-
{
|
63
|
-
path, var = $reference.val.extract
|
64
|
-
parent = @now.at?(path)
|
65
|
-
raise Exception, "#{path} is not a Hash" if not parent.is_a?(Hash)
|
66
|
-
parent[var] = self.null_value
|
67
|
-
}
|
68
|
-
;
|
69
|
-
*/
|
70
|
-
|
71
53
|
include
|
72
54
|
: 'include' include_file NL+
|
73
55
|
;
|
@@ -77,11 +59,6 @@ include_file
|
|
77
59
|
{ self.process_file($STRING.text[1,$STRING.text.length-2]) }
|
78
60
|
;
|
79
61
|
|
80
|
-
header
|
81
|
-
: class_def
|
82
|
-
| procedure
|
83
|
-
;
|
84
|
-
|
85
62
|
state
|
86
63
|
: ID 'state' NL*
|
87
64
|
{
|
@@ -97,19 +74,6 @@ state
|
|
97
74
|
{ self.goto_parent(true) }
|
98
75
|
;
|
99
76
|
|
100
|
-
composite
|
101
|
-
: 'composite' ID
|
102
|
-
{
|
103
|
-
@now[$ID.text] = { '_self' => $ID.text,
|
104
|
-
'_context' => 'composite',
|
105
|
-
'_parent' => @now
|
106
|
-
}
|
107
|
-
@now = @now[$ID.text]
|
108
|
-
}
|
109
|
-
'{' NL* ( attribute | constraint )* '}' NL*
|
110
|
-
{ self.goto_parent(true) }
|
111
|
-
;
|
112
|
-
|
113
77
|
class_def
|
114
78
|
: ('class'|'schema') ID
|
115
79
|
{
|
@@ -124,7 +88,7 @@ class_def
|
|
124
88
|
@now['_extends'] = $extends_class.val
|
125
89
|
}
|
126
90
|
)?
|
127
|
-
('{' NL* ( attribute | procedure )* '}')?
|
91
|
+
('{' NL* ( attribute | procedure NL* )* '}')?
|
128
92
|
{
|
129
93
|
if not @now.has_key?('_extends')
|
130
94
|
@now['_extends'] = '$.Object'
|
@@ -221,9 +185,14 @@ object_schemata
|
|
221
185
|
: ',' object_schema
|
222
186
|
;
|
223
187
|
|
224
|
-
|
188
|
+
abstract_object
|
189
|
+
: 'abstract' object_def
|
190
|
+
{ @root[$object_def.id]['_context'] = 'abstract' }
|
191
|
+
;
|
192
|
+
|
193
|
+
object_def returns [id]
|
225
194
|
: { @use_template = false }
|
226
|
-
ID
|
195
|
+
ID { $id = $ID.text }
|
227
196
|
('extends' path
|
228
197
|
{
|
229
198
|
template = @root.at?($path.text)
|
@@ -349,7 +318,7 @@ procedure
|
|
349
318
|
{ @now['_cost'] = $NUMBER.text.to_i }
|
350
319
|
NL+
|
351
320
|
)?
|
352
|
-
conditions? effects '}'
|
321
|
+
conditions? effects '}'
|
353
322
|
{ self.goto_parent() }
|
354
323
|
;
|
355
324
|
|
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.3.
|
4
|
+
version: 0.3.11
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2013-08-13 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
16
|
-
requirement: &
|
16
|
+
requirement: &20563100 !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: *20563100
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: antlr3
|
27
|
-
requirement: &
|
27
|
+
requirement: &20562560 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: 1.9.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *20562560
|
36
36
|
description: A Ruby API and script for SFP language parser
|
37
37
|
email: herry13@gmail.com
|
38
38
|
executables:
|