gisele 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. data/CHANGELOG.md +5 -1
  2. data/Gemfile +4 -7
  3. data/Gemfile.lock +19 -19
  4. data/Rakefile +0 -4
  5. data/examples/merge/BreastCancer.dot +30 -0
  6. data/examples/merge/BreastCancer.gif +0 -0
  7. data/examples/merge/BreastCancer.gis +17 -0
  8. data/examples/merge/Merge.dot +46 -0
  9. data/examples/merge/Merge.gif +0 -0
  10. data/examples/merge/RectalCancer.dot +22 -0
  11. data/examples/merge/RectalCancer.gif +0 -0
  12. data/examples/merge/RectalCancer.gis +15 -0
  13. data/gisele.gemspec +3 -6
  14. data/gisele.noespec +11 -19
  15. data/lib/gisele.rb +0 -13
  16. data/lib/gisele/loader.rb +2 -3
  17. data/lib/gisele/version.rb +1 -1
  18. data/spec/command/main/gisele_version.stdout +1 -1
  19. data/spec/spec_helper.rb +0 -17
  20. data/tasks/gem.rake +9 -4
  21. metadata +65 -231
  22. data/lib/gisele/language.rb +0 -31
  23. data/lib/gisele/language/ast/bool_and.rb +0 -14
  24. data/lib/gisele/language/ast/bool_expr.rb +0 -22
  25. data/lib/gisele/language/ast/bool_not.rb +0 -14
  26. data/lib/gisele/language/ast/bool_or.rb +0 -14
  27. data/lib/gisele/language/ast/case_st.rb +0 -14
  28. data/lib/gisele/language/ast/else_clause.rb +0 -14
  29. data/lib/gisele/language/ast/elsif_clause.rb +0 -14
  30. data/lib/gisele/language/ast/if_st.rb +0 -14
  31. data/lib/gisele/language/ast/node.rb +0 -35
  32. data/lib/gisele/language/ast/task_call_st.rb +0 -14
  33. data/lib/gisele/language/ast/var_ref.rb +0 -14
  34. data/lib/gisele/language/ast/when_clause.rb +0 -14
  35. data/lib/gisele/language/ast/while_st.rb +0 -14
  36. data/lib/gisele/language/grammar.citrus +0 -236
  37. data/lib/gisele/language/grammar.sexp.yml +0 -83
  38. data/lib/gisele/language/processors.rb +0 -4
  39. data/lib/gisele/language/processors/elsif_flattener.rb +0 -36
  40. data/lib/gisele/language/processors/if_to_case.rb +0 -65
  41. data/lib/gisele/language/processors/scoping_helper.rb +0 -32
  42. data/lib/gisele/language/processors/sugar_removal.rb +0 -17
  43. data/lib/gisele/language/syntax/bool_and.rb +0 -14
  44. data/lib/gisele/language/syntax/bool_expr.rb +0 -14
  45. data/lib/gisele/language/syntax/bool_lit.rb +0 -14
  46. data/lib/gisele/language/syntax/bool_not.rb +0 -14
  47. data/lib/gisele/language/syntax/bool_or.rb +0 -14
  48. data/lib/gisele/language/syntax/bool_paren.rb +0 -14
  49. data/lib/gisele/language/syntax/case_st.rb +0 -19
  50. data/lib/gisele/language/syntax/else_clause.rb +0 -14
  51. data/lib/gisele/language/syntax/elsif_clause.rb +0 -16
  52. data/lib/gisele/language/syntax/event_set.rb +0 -15
  53. data/lib/gisele/language/syntax/fluent_def.rb +0 -18
  54. data/lib/gisele/language/syntax/if_st.rb +0 -18
  55. data/lib/gisele/language/syntax/implicit_seq_st.rb +0 -16
  56. data/lib/gisele/language/syntax/node.rb +0 -40
  57. data/lib/gisele/language/syntax/par_st.rb +0 -14
  58. data/lib/gisele/language/syntax/seq_st.rb +0 -14
  59. data/lib/gisele/language/syntax/st_list.rb +0 -14
  60. data/lib/gisele/language/syntax/task_call_st.rb +0 -14
  61. data/lib/gisele/language/syntax/task_def.rb +0 -18
  62. data/lib/gisele/language/syntax/trackvar_def.rb +0 -19
  63. data/lib/gisele/language/syntax/unit_def.rb +0 -14
  64. data/lib/gisele/language/syntax/var_ref.rb +0 -14
  65. data/lib/gisele/language/syntax/when_clause.rb +0 -16
  66. data/lib/gisele/language/syntax/while_st.rb +0 -16
  67. data/spec/unit/language/ast/test_bool_expr.rb +0 -50
  68. data/spec/unit/language/grammar_sexp/test_case_st.rb +0 -20
  69. data/spec/unit/language/grammar_sexp/test_event_set.rb +0 -14
  70. data/spec/unit/language/grammar_sexp/test_fluent_def.rb +0 -18
  71. data/spec/unit/language/grammar_sexp/test_initially.rb +0 -18
  72. data/spec/unit/language/grammar_sexp/test_nop_st.rb +0 -10
  73. data/spec/unit/language/grammar_sexp/test_when_clause.rb +0 -12
  74. data/spec/unit/language/processors/test_elsif_flattener.rb +0 -94
  75. data/spec/unit/language/processors/test_if_to_case.rb +0 -105
  76. data/spec/unit/language/processors/test_scoping_helper.rb +0 -45
  77. data/spec/unit/language/syntax/grammar/test_bool_expr.rb +0 -34
  78. data/spec/unit/language/syntax/grammar/test_boolean_literal.rb +0 -17
  79. data/spec/unit/language/syntax/grammar/test_case_st.rb +0 -60
  80. data/spec/unit/language/syntax/grammar/test_event.rb +0 -18
  81. data/spec/unit/language/syntax/grammar/test_event_name.rb +0 -21
  82. data/spec/unit/language/syntax/grammar/test_event_set.rb +0 -26
  83. data/spec/unit/language/syntax/grammar/test_fluent_def.rb +0 -21
  84. data/spec/unit/language/syntax/grammar/test_if_st.rb +0 -21
  85. data/spec/unit/language/syntax/grammar/test_par_st.rb +0 -11
  86. data/spec/unit/language/syntax/grammar/test_process_statement.rb +0 -19
  87. data/spec/unit/language/syntax/grammar/test_seq_st.rb +0 -11
  88. data/spec/unit/language/syntax/grammar/test_spaces.rb +0 -19
  89. data/spec/unit/language/syntax/grammar/test_spacing.rb +0 -17
  90. data/spec/unit/language/syntax/grammar/test_task_def.rb +0 -35
  91. data/spec/unit/language/syntax/grammar/test_task_name.rb +0 -19
  92. data/spec/unit/language/syntax/grammar/test_task_start_or_end.rb +0 -17
  93. data/spec/unit/language/syntax/grammar/test_trackvar_def.rb +0 -21
  94. data/spec/unit/language/syntax/grammar/test_unit_def.rb +0 -29
  95. data/spec/unit/language/syntax/grammar/test_variable_name.rb +0 -51
  96. data/spec/unit/language/syntax/grammar/test_when_clause.rb +0 -21
  97. data/spec/unit/language/syntax/grammar/test_while_st.rb +0 -11
  98. data/spec/unit/language/syntax/to_ast/test_bool_expr.rb +0 -32
  99. data/spec/unit/language/syntax/to_ast/test_case_st.rb +0 -47
  100. data/spec/unit/language/syntax/to_ast/test_else_clause.rb +0 -13
  101. data/spec/unit/language/syntax/to_ast/test_elsif_clause.rb +0 -15
  102. data/spec/unit/language/syntax/to_ast/test_event_set.rb +0 -24
  103. data/spec/unit/language/syntax/to_ast/test_fluent_def.rb +0 -26
  104. data/spec/unit/language/syntax/to_ast/test_if_st.rb +0 -39
  105. data/spec/unit/language/syntax/to_ast/test_par_st.rb +0 -12
  106. data/spec/unit/language/syntax/to_ast/test_seq_st.rb +0 -12
  107. data/spec/unit/language/syntax/to_ast/test_task_call_st.rb +0 -10
  108. data/spec/unit/language/syntax/to_ast/test_task_def.rb +0 -44
  109. data/spec/unit/language/syntax/to_ast/test_trackvar_def.rb +0 -26
  110. data/spec/unit/language/syntax/to_ast/test_unit_def.rb +0 -28
  111. data/spec/unit/language/syntax/to_ast/test_var_ref.rb +0 -12
  112. data/spec/unit/language/syntax/to_ast/test_when_clause.rb +0 -15
  113. data/spec/unit/language/syntax/to_ast/test_while_st.rb +0 -24
  114. data/spec/unit/language/test_syntax.rb +0 -51
@@ -1,31 +0,0 @@
1
- require 'yaml'
2
- module Gisele
3
-
4
- # Load the Language through Sexpr
5
- Language = Sexpr.load Path.dir/"language/grammar.sexp.yml"
6
-
7
- # Load syntax nodes, abstract syntax nodes, and processors
8
- require_relative 'language/syntax/node'
9
- require_relative 'language/ast/node'
10
- require_relative 'language/processors'
11
-
12
- # Force loading the Citrus parser now
13
- Language.parser.parser
14
-
15
- module Language
16
-
17
- # By default, Sexpr will find for abstract nodes under Language itself. We
18
- # override that behavior here and let it know that the AST module is the
19
- # parent of all ast nodes.
20
- def tagging_reference
21
- AST
22
- end
23
-
24
- # The tagging function (from s-expr kind to AST module) is not complete so far.
25
- # This allows us to at least include the AST:Node module in all s-expressions.
26
- def default_tagging_module
27
- AST::Node
28
- end
29
-
30
- end # module Language
31
- end # module Gisele
@@ -1,14 +0,0 @@
1
- module Gisele
2
- module Language
3
- module AST
4
- module BoolAnd
5
- include Node
6
-
7
- def label
8
- (citrus_match && citrus_match.to_s) || "(#{self[1].label} and #{self[2].label})"
9
- end
10
-
11
- end # module BoolAnd
12
- end # module AST
13
- end # module Language
14
- end # module Gisele
@@ -1,22 +0,0 @@
1
- module Gisele
2
- module Language
3
- module AST
4
- module BoolExpr
5
- include Node
6
-
7
- def label
8
- (citrus_match && citrus_match.to_s) || last.label
9
- end
10
-
11
- def negate
12
- if last.first == :bool_not
13
- Language.sexpr [:bool_expr, last.last]
14
- else
15
- Language.sexpr [ :bool_expr, [:bool_not, last] ]
16
- end
17
- end
18
-
19
- end # module BoolExpr
20
- end # module AST
21
- end # module Language
22
- end # module Gisele
@@ -1,14 +0,0 @@
1
- module Gisele
2
- module Language
3
- module AST
4
- module BoolNot
5
- include Node
6
-
7
- def label
8
- (citrus_match && citrus_match.to_s) || "not(#{last.label})"
9
- end
10
-
11
- end # module BoolNot
12
- end # module AST
13
- end # module Language
14
- end # module Gisele
@@ -1,14 +0,0 @@
1
- module Gisele
2
- module Language
3
- module AST
4
- module BoolOr
5
- include Node
6
-
7
- def label
8
- (citrus_match && citrus_match.to_s) || "(#{self[1].label} or #{self[2].label})"
9
- end
10
-
11
- end # module BoolOr
12
- end # module AST
13
- end # module Language
14
- end # module Gisele
@@ -1,14 +0,0 @@
1
- module Gisele
2
- module Language
3
- module AST
4
- module CaseSt
5
- include Node
6
-
7
- def label
8
- (self[1] && self[1].label) || ""
9
- end
10
-
11
- end # module CaseSt
12
- end # module AST
13
- end # module Language
14
- end # module Gisele
@@ -1,14 +0,0 @@
1
- module Gisele
2
- module Language
3
- module AST
4
- module ElseClause
5
- include Node
6
-
7
- def label
8
- "[else]"
9
- end
10
-
11
- end # module ElseClause
12
- end # module AST
13
- end # module Language
14
- end # module Gisele
@@ -1,14 +0,0 @@
1
- module Gisele
2
- module Language
3
- module AST
4
- module ElsifClause
5
- include Node
6
-
7
- def label
8
- self[1].label
9
- end
10
-
11
- end # module ElsifClause
12
- end # module AST
13
- end # module Language
14
- end # module Gisele
@@ -1,14 +0,0 @@
1
- module Gisele
2
- module Language
3
- module AST
4
- module IfSt
5
- include Node
6
-
7
- def label
8
- self[1].label
9
- end
10
-
11
- end # module IfSt
12
- end # module AST
13
- end # module Language
14
- end # module Gisele
@@ -1,35 +0,0 @@
1
- module Gisele
2
- module Language
3
- module AST
4
- module Node
5
-
6
- def citrus_match
7
- tracking_markers[:citrus_match]
8
- end
9
-
10
- # Returns a label for this AST node
11
- def label
12
- ""
13
- end
14
-
15
- # Checks validity over the definition
16
- def ===(sexp)
17
- Language[rule_name] === sexp
18
- end
19
-
20
- end # module Node
21
- end # module AST
22
- end # module Language
23
- end # module Gisele
24
- require_relative 'task_call_st'
25
- require_relative 'while_st'
26
- require_relative 'if_st'
27
- require_relative 'else_clause'
28
- require_relative 'elsif_clause'
29
- require_relative 'case_st'
30
- require_relative 'when_clause'
31
- require_relative 'bool_expr'
32
- require_relative 'bool_and'
33
- require_relative 'bool_or'
34
- require_relative 'bool_not'
35
- require_relative 'var_ref'
@@ -1,14 +0,0 @@
1
- module Gisele
2
- module Language
3
- module AST
4
- module TaskCallSt
5
- include Node
6
-
7
- def label
8
- last.to_s
9
- end
10
-
11
- end # module TaskCallSt
12
- end # module AST
13
- end # module Language
14
- end # module Gisele
@@ -1,14 +0,0 @@
1
- module Gisele
2
- module Language
3
- module AST
4
- module VarRef
5
- include Node
6
-
7
- def label
8
- last.to_s
9
- end
10
-
11
- end # module BoolNot
12
- end # module AST
13
- end # module Language
14
- end # module Gisele
@@ -1,14 +0,0 @@
1
- module Gisele
2
- module Language
3
- module AST
4
- module WhenClause
5
- include Node
6
-
7
- def label
8
- self[1].label
9
- end
10
-
11
- end # module WhenClause
12
- end # module AST
13
- end # module Language
14
- end # module Gisele
@@ -1,14 +0,0 @@
1
- module Gisele
2
- module Language
3
- module AST
4
- module WhileSt
5
- include Node
6
-
7
- def label
8
- self[1].label
9
- end
10
-
11
- end # module WhileSt
12
- end # module AST
13
- end # module Language
14
- end # module Gisele
@@ -1,236 +0,0 @@
1
- grammar Gisele::Language::Grammar
2
-
3
- ### Units
4
-
5
- rule unit_def
6
- (spacing task_def (spaces task_def)* spacing)
7
- <Gisele::Language::Syntax::UnitDef>
8
- end
9
-
10
- ### Task definitions
11
-
12
- rule task_def
13
- ('task' spaces task_name spaces
14
- (some_def spaces)*
15
- (explicit_statement spaces)?
16
- 'end')
17
- <Gisele::Language::Syntax::TaskDef>
18
- end
19
-
20
- rule some_def
21
- fluent_def | trackvar_def | task_def
22
- end
23
-
24
- ### Process statements
25
-
26
- rule process_statement
27
- implicit_seq_st | explicit_statement
28
- end
29
-
30
- rule implicit_seq_st
31
- (explicit_statement spaces st_list)
32
- <Gisele::Language::Syntax::ImplicitSeqSt>
33
- end
34
-
35
- rule st_list
36
- (explicit_statement (spaces explicit_statement)*)
37
- <Gisele::Language::Syntax::StList>
38
- end
39
-
40
- rule explicit_statement
41
- if_st
42
- | case_st
43
- | while_st
44
- | seq_st
45
- | par_st
46
- | task_call_st
47
- end
48
-
49
- rule case_st
50
- ('case' spaces (var_ref spaces)?
51
- (when_clause spaces)+
52
- (else_clause spaces)?
53
- 'end')
54
- <Gisele::Language::Syntax::CaseSt>
55
- end
56
-
57
- rule when_clause
58
- ('when' spaces bool_expr spaces process_statement)
59
- <Gisele::Language::Syntax::WhenClause>
60
- end
61
-
62
- rule if_st
63
- ('if' spaces bool_expr spaces
64
- process_statement spaces
65
- (elsif_clause spaces)*
66
- (else_clause spaces)?
67
- 'end')
68
- <Gisele::Language::Syntax::IfSt>
69
- end
70
-
71
- rule elsif_clause
72
- ('elsif' spaces bool_expr spaces process_statement)
73
- <Gisele::Language::Syntax::ElsifClause>
74
- end
75
-
76
- rule else_clause
77
- ('else' spaces process_statement)
78
- <Gisele::Language::Syntax::ElseClause>
79
- end
80
-
81
- rule while_st
82
- ('while' spaces bool_expr spaces process_statement spaces 'end')
83
- <Gisele::Language::Syntax::WhileSt>
84
- end
85
-
86
- rule seq_st
87
- ('seq' spaces st_list spaces 'end')
88
- <Gisele::Language::Syntax::SeqSt>
89
- end
90
-
91
- rule par_st
92
- ('par' spaces st_list spaces 'end')
93
- <Gisele::Language::Syntax::ParSt>
94
- end
95
-
96
- rule task_call_st
97
- (task_name)
98
- <Gisele::Language::Syntax::TaskCallSt>
99
- end
100
-
101
- ### Boolean expressions
102
-
103
- rule bool_expr
104
- (spacing theexpr:bool_or)
105
- <Gisele::Language::Syntax::BoolExpr>
106
- end
107
-
108
- rule bool_or
109
- (left:bool_and spaces 'or' spaces right:bool_or)
110
- <Gisele::Language::Syntax::BoolOr>
111
- | bool_and
112
- end
113
-
114
- rule bool_and
115
- (left:bool_not spaces 'and' spaces right:bool_and)
116
- <Gisele::Language::Syntax::BoolAnd>
117
- | bool_not
118
- end
119
-
120
- rule bool_not
121
- ('not' &([ \t\n] | '(') spacing expr:bool_not)
122
- <Gisele::Language::Syntax::BoolNot>
123
- | bool_term
124
- end
125
-
126
- rule bool_term
127
- bool_paren | bool_lit | var_ref
128
- end
129
-
130
- rule bool_paren
131
- ('(' spacing expr:bool_or spacing ')')
132
- <Gisele::Language::Syntax::BoolParen>
133
- end
134
-
135
- rule bool_lit
136
- (boolean_literal)
137
- <Gisele::Language::Syntax::BoolLit>
138
- end
139
-
140
- ### Variables
141
-
142
- rule variable_def
143
- trackvar_def | fluent_def
144
- end
145
-
146
- rule trackvar_def
147
- ('trackvar' spaces variable_name spacing event_set (spacing ',' spacing event_set)? initially_def?)
148
- <Gisele::Language::Syntax::TrackvarDef>
149
- end
150
-
151
- rule fluent_def
152
- ('fluent' spaces variable_name spacing event_set spacing ',' spacing event_set initially_def?)
153
- <Gisele::Language::Syntax::FluentDef>
154
- end
155
-
156
- rule initially_def
157
- (spaces 'initially' spaces lit:boolean_literal){ lit.value }
158
- end
159
-
160
- rule var_ref
161
- (variable_name)
162
- <Gisele::Language::Syntax::VarRef>
163
- end
164
-
165
- ### Events
166
-
167
- rule event_set
168
- ('{' spacing (event (spacing ',' spacing event)*)? spacing '}')
169
- <Gisele::Language::Syntax::EventSet>
170
- end
171
-
172
- rule event
173
- task_start_or_end | event_name
174
- end
175
-
176
- rule task_start_or_end
177
- task_name ':' ('start' | 'end')
178
- end
179
-
180
- ### Names
181
-
182
- rule task_name
183
- [A-Z] [A-Za-z0-9_]*
184
- end
185
-
186
- rule variable_name
187
- !(reserved_word spaces) [a-z] [A-Za-z0-9_]*
188
- end
189
-
190
- rule event_name
191
- !(reserved_word spaces) [a-z] [a-z0-9_]*
192
- end
193
-
194
- ### Literals
195
-
196
- rule boolean_literal
197
- ('true' | 'false'){ strip == "true" }
198
- end
199
-
200
- ### Spacing
201
-
202
- rule comment
203
- "#" (![\n] .)*
204
- end
205
-
206
- rule spaces
207
- (comment | [ \t\n])+
208
- end
209
-
210
- rule spacing
211
- (comment | [ \t\n])*
212
- end
213
-
214
- ### Reserved Words
215
- rule reserved_word
216
- "if"
217
- | "else"
218
- | "elsif"
219
- | "when"
220
- | "while"
221
- | "seq"
222
- | "par"
223
- | "task"
224
- | "refinement"
225
- | "fluent"
226
- | "trackvar"
227
- | "initially"
228
- | "end"
229
- | "not"
230
- | "or"
231
- | "and"
232
- | "true"
233
- | "false"
234
- end
235
-
236
- end