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,16 +0,0 @@
1
- module Gisele
2
- module Language
3
- module Syntax
4
- module ImplicitSeqSt
5
- include Node
6
-
7
- def _to_ast
8
- front = captures[:explicit_statement].first.to_ast
9
- tail = captures[:st_list].first.value
10
- [:seq_st, front] + tail
11
- end
12
-
13
- end # module ImplicitSeqSt
14
- end # module Syntax
15
- end # module Language
16
- end # module Gisele
@@ -1,40 +0,0 @@
1
- module Gisele
2
- module Language
3
- module Syntax
4
- module Node
5
-
6
- def to_ast
7
- Language::sexpr(value, {:citrus_match => self})
8
- end
9
-
10
- def value
11
- _to_ast
12
- end
13
-
14
- end # module Node
15
- end # module Syntax
16
- end # module Language
17
- end # module Gisele
18
- require_relative 'event_set'
19
- require_relative 'fluent_def'
20
- require_relative 'trackvar_def'
21
- require_relative 'var_ref'
22
- require_relative 'bool_lit'
23
- require_relative 'bool_paren'
24
- require_relative 'bool_not'
25
- require_relative 'bool_and'
26
- require_relative 'bool_or'
27
- require_relative 'bool_expr'
28
- require_relative 'st_list'
29
- require_relative 'implicit_seq_st'
30
- require_relative 'task_call_st'
31
- require_relative 'seq_st'
32
- require_relative 'par_st'
33
- require_relative 'while_st'
34
- require_relative 'if_st'
35
- require_relative 'else_clause'
36
- require_relative 'elsif_clause'
37
- require_relative 'case_st'
38
- require_relative 'when_clause'
39
- require_relative 'task_def'
40
- require_relative 'unit_def'
@@ -1,14 +0,0 @@
1
- module Gisele
2
- module Language
3
- module Syntax
4
- module ParSt
5
- include Node
6
-
7
- def _to_ast
8
- [:par_st] + captures[:st_list].first.value
9
- end
10
-
11
- end # module ParSt
12
- end # module Syntax
13
- end # module Language
14
- end # module Gisele
@@ -1,14 +0,0 @@
1
- module Gisele
2
- module Language
3
- module Syntax
4
- module SeqSt
5
- include Node
6
-
7
- def _to_ast
8
- [:seq_st] + captures[:st_list].first.value
9
- end
10
-
11
- end # module SeqSt
12
- end # module Syntax
13
- end # module Language
14
- end # module Gisele
@@ -1,14 +0,0 @@
1
- module Gisele
2
- module Language
3
- module Syntax
4
- module StList
5
- include Node
6
-
7
- def value
8
- captures[:explicit_statement].map{|x| x.to_ast}
9
- end
10
-
11
- end # module StList
12
- end # module Syntax
13
- end # module Language
14
- end # module Gisele
@@ -1,14 +0,0 @@
1
- module Gisele
2
- module Language
3
- module Syntax
4
- module TaskCallSt
5
- include Node
6
-
7
- def _to_ast
8
- [:task_call_st, strip]
9
- end
10
-
11
- end # module TaskCallSt
12
- end # module Syntax
13
- end # module Language
14
- end # module Gisele
@@ -1,18 +0,0 @@
1
- module Gisele
2
- module Language
3
- module Syntax
4
- module TaskDef
5
- include Node
6
-
7
- def _to_ast
8
- name = captures[:task_name].first.strip
9
- defs = captures[:some_def].map{|x| x.to_ast}
10
- ref = captures[:explicit_statement].map{|x| x.to_ast}.first
11
- ref = [:nop_st] unless ref
12
- [:task_def, name] + defs + [ref]
13
- end
14
-
15
- end # module TaskDef
16
- end # module Syntax
17
- end # module Language
18
- end # module Gisele
@@ -1,19 +0,0 @@
1
- module Gisele
2
- module Language
3
- module Syntax
4
- module TrackvarDef
5
- include Node
6
-
7
- def _to_ast
8
- name = captures[:variable_name].first.strip
9
- init, term = captures[:event_set].map{|x| x.to_ast}
10
- term = [:event_set] unless term
11
- initval = captures[:initially_def].first
12
- initval = (initval && !initval.empty?) ? initval.value : nil
13
- [:trackvar_def, name, init, term, initval]
14
- end
15
-
16
- end # module TrackvarDef
17
- end # module Syntax
18
- end # module Language
19
- end # module Gisele
@@ -1,14 +0,0 @@
1
- module Gisele
2
- module Language
3
- module Syntax
4
- module UnitDef
5
- include Node
6
-
7
- def _to_ast
8
- [:unit_def] + captures[:task_def].map{|x| x.to_ast}
9
- end
10
-
11
- end # module UnitDef
12
- end # module Syntax
13
- end # module Language
14
- end # module Gisele
@@ -1,14 +0,0 @@
1
- module Gisele
2
- module Language
3
- module Syntax
4
- module VarRef
5
- include Node
6
-
7
- def _to_ast
8
- [:var_ref, strip]
9
- end
10
-
11
- end # module VarRef
12
- end # module Syntax
13
- end # module Language
14
- end # module Gisele
@@ -1,16 +0,0 @@
1
- module Gisele
2
- module Language
3
- module Syntax
4
- module WhenClause
5
- include Node
6
-
7
- def _to_ast
8
- cond = captures[:bool_expr].first.to_ast
9
- dost = captures[:process_statement].first.to_ast
10
- [:when_clause, cond, dost]
11
- end
12
-
13
- end # module WhenClause
14
- end # module Syntax
15
- end # module Language
16
- end # module Gisele
@@ -1,16 +0,0 @@
1
- module Gisele
2
- module Language
3
- module Syntax
4
- module WhileSt
5
- include Node
6
-
7
- def _to_ast
8
- cond = captures[:bool_expr].first.to_ast
9
- dost = captures[:process_statement].first.to_ast
10
- [:while_st, cond, dost]
11
- end
12
-
13
- end # module WhileSt
14
- end # module Syntax
15
- end # module Language
16
- end # module Gisele
@@ -1,50 +0,0 @@
1
- require 'spec_helper'
2
- module Gisele::Language::AST
3
- describe BoolExpr, "negate" do
4
-
5
- def sexpr(expr, options = {})
6
- Gisele.sexpr(Gisele.parse(expr, options))
7
- end
8
-
9
- subject{ sexpr(expr, :root => :bool_expr).negate }
10
-
11
- shared_examples_for 'A negated bool_expr' do
12
-
13
- it 'is consistently rewrited' do
14
- (Gisele::Language[:bool_expr] === subject).should be_true
15
- end
16
-
17
- it 'is correctly tagged' do
18
- subject.should be_a(Sexpr)
19
- subject.should be_a(BoolExpr)
20
- end
21
-
22
- it 'has no immediate traceability marker' do
23
- subject.citrus_match.should be_nil
24
- end
25
- end
26
-
27
- describe "on a normal expression" do
28
- let(:expr){ "x and y" }
29
-
30
- it_behaves_like 'A negated bool_expr'
31
-
32
- it "negates as expected" do
33
- expected = sexpr("not(x and y)", :root => :bool_expr)
34
- subject.should eq(expected)
35
- end
36
- end
37
-
38
- describe "on a negated expression" do
39
- let(:expr){ "not(x and y)" }
40
-
41
- it_behaves_like 'A negated bool_expr'
42
-
43
- it "removes the negation" do
44
- expected = sexpr("x and y", :root => :bool_expr)
45
- subject.should eq(expected)
46
- end
47
- end
48
-
49
- end
50
- end
@@ -1,20 +0,0 @@
1
- require 'spec_helper'
2
- module Gisele::Language
3
- describe "the Sexp grammar", "case_st" do
4
-
5
- it 'matches when no variable is specified' do
6
- case_st = \
7
- [:case_st, nil,
8
- [:when_clause, [:bool_expr, [:bool_lit, true]], [:nop_st]] ]
9
- (sexp_grammar[:case_st] === case_st).should be_true
10
- end
11
-
12
- it 'matches when a variable is specified' do
13
- case_st = \
14
- [:case_st, [:var_ref, "varName"],
15
- [:when_clause, [:bool_expr, [:bool_lit, true]], [:nop_st]] ]
16
- (sexp_grammar[:case_st] === case_st).should be_true
17
- end
18
-
19
- end
20
- end
@@ -1,14 +0,0 @@
1
- require 'spec_helper'
2
- module Gisele::Language
3
- describe "the Sexp grammar", "event_set" do
4
-
5
- it 'matches an empty set' do
6
- (sexp_grammar[:event_set] === [:event_set]).should be_true
7
- end
8
-
9
- it 'matches a non empty set' do
10
- (sexp_grammar[:event_set] === [:event_set, "event", "Task:start"]).should be_true
11
- end
12
-
13
- end
14
- end
@@ -1,18 +0,0 @@
1
- require 'spec_helper'
2
- module Gisele::Language
3
- describe "the Sexp grammar", "fluent_def" do
4
-
5
- let(:g){ Gisele::Language }
6
-
7
- it 'matches an fluent with initial value' do
8
- fluent = [:fluent_def, "name", [:event_set, "start"], [:event_set, "stop"], true]
9
- (sexp_grammar[:fluent_def] === fluent).should be_true
10
- end
11
-
12
- it 'matches an fluent without initial value' do
13
- fluent = [:fluent_def, "name", [:event_set, "start"], [:event_set, "stop"], nil]
14
- (sexp_grammar[:fluent_def] === fluent).should be_true
15
- end
16
-
17
- end
18
- end
@@ -1,18 +0,0 @@
1
- require 'spec_helper'
2
- module Gisele::Language
3
- describe "the Sexp grammar", "initially" do
4
-
5
- it 'matches true' do
6
- (sexp_grammar[:initially] === true).should be_true
7
- end
8
-
9
- it 'matches false' do
10
- (sexp_grammar[:initially] === false).should be_true
11
- end
12
-
13
- it 'matches nil' do
14
- (sexp_grammar[:initially] === nil).should be_true
15
- end
16
-
17
- end
18
- end
@@ -1,10 +0,0 @@
1
- require 'spec_helper'
2
- module Gisele::Language
3
- describe "the Sexp grammar", "nop_st" do
4
-
5
- it 'matches [:nop_st]' do
6
- (sexp_grammar[:nop_st] === [:nop_st]).should be_true
7
- end
8
-
9
- end
10
- end
@@ -1,12 +0,0 @@
1
- require 'spec_helper'
2
- module Gisele::Language
3
- describe "the Sexp grammar", "when_clause" do
4
-
5
- it 'matches a valid when clause' do
6
- when_clause = \
7
- [:when_clause, [:bool_expr, [:bool_lit, true]], [:nop_st]]
8
- (sexp_grammar[:when_clause] === when_clause).should be_true
9
- end
10
-
11
- end
12
- end
@@ -1,94 +0,0 @@
1
- require 'spec_helper'
2
- module Gisele::Language
3
- describe ElsifFlattener do
4
-
5
- def ast(source)
6
- Gisele.ast(Gisele.parse(source.strip, :root => :if_st))
7
- end
8
-
9
- def rewrite(ast)
10
- @rewrited = ElsifFlattener.call(ast)
11
- end
12
-
13
- after{
14
- (sexp_grammar[:if_st] === @rewrited).should be_true
15
- }
16
-
17
- it 'rewrites a single if correctly' do
18
- source = ast("if goodCond Task1 end")
19
- rewrite(source).should eq(source)
20
- end
21
-
22
- it 'rewrites a if/else correctly' do
23
- source = ast("if goodCond Task1 else Task2 end")
24
- rewrite(source).should eq(source)
25
- end
26
-
27
- it 'rewrites a if/elsif correctly' do
28
- source = ast("if good Task1 elsif bad Task2 end")
29
- expected = ast("if good Task1 else if bad Task2 end end")
30
- rewrite(source).should eq(expected)
31
- end
32
-
33
- it 'rewrites a if/elsif/else correctly' do
34
- source = ast("if good Task1 elsif bad Task2 else Task3 end")
35
- expected = ast("if good Task1 else if bad Task2 else Task3 end end")
36
- rewrite(source).should eq(expected)
37
- end
38
-
39
- it 'rewrites a if/elsif/elsif/else correctly' do
40
- source = ast(<<-EOF.strip)
41
- if good Task1
42
- elsif bad Task2
43
- elsif none Task3
44
- else Task4
45
- end
46
- EOF
47
- expected = ast(<<-EOF.strip)
48
- if good
49
- Task1
50
- else
51
- if bad
52
- Task2
53
- else
54
- if none
55
- Task3
56
- else
57
- Task4
58
- end
59
- end
60
- end
61
- EOF
62
- rewrite(source).should eq(expected)
63
- end
64
-
65
- it 'recurses by default' do
66
- source = ast(<<-EOF.strip)
67
- if goodCond
68
- Task1
69
- else
70
- if bad
71
- Task2
72
- elsif middle
73
- Task3
74
- end
75
- end
76
- EOF
77
- expected = ast(<<-EOF.strip)
78
- if goodCond
79
- Task1
80
- else
81
- if bad
82
- Task2
83
- else
84
- if middle
85
- Task3
86
- end
87
- end
88
- end
89
- EOF
90
- rewrite(source).should eq(expected)
91
- end
92
-
93
- end
94
- end