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,17 +0,0 @@
1
- require 'spec_helper'
2
- module Gisele::Language
3
- describe Grammar, 'spacing' do
4
-
5
- it 'parses all kind of spaces' do
6
- parse(' ', :spacing).should eq(' ')
7
- parse("\t", :spacing).should eq("\t")
8
- parse("\n", :spacing).should eq("\n")
9
- parse(" \t\n", :spacing).should eq(" \t\n")
10
- end
11
-
12
- it 'does not enforces mandatory spacing' do
13
- parse('', :spacing).should eq('')
14
- end
15
-
16
- end
17
- end
@@ -1,35 +0,0 @@
1
- require 'spec_helper'
2
- module Gisele::Language
3
- describe Grammar, 'task_def' do
4
-
5
- it 'parses a simple implicit task definition' do
6
- taskdef = <<-TASKDEF.strip
7
- task Process
8
- Diagnosis
9
- end
10
- TASKDEF
11
- parse(taskdef, :task_def).should eq(taskdef)
12
- end
13
-
14
- it 'allows any statement' do
15
- taskdef = <<-TASKDEF.strip
16
- task Process
17
- while true Diagnosis end
18
- end
19
- TASKDEF
20
- parse(taskdef, :task_def).should eq(taskdef)
21
- end
22
-
23
- it 'supports optional variable definitions in the signature' do
24
- taskdef = <<-TASKDEF.strip
25
- task Process
26
- fluent diagKnown {Diagnosis:start}, {} initially false
27
- trackvar mplus {Diagnosis:end}
28
- Diagnosis
29
- end
30
- TASKDEF
31
- parse(taskdef, :task_def).should eq(taskdef)
32
- end
33
-
34
- end
35
- end
@@ -1,19 +0,0 @@
1
- require 'spec_helper'
2
- module Gisele::Language
3
- describe Grammar,'task_name' do
4
-
5
- it 'parses correct task names' do
6
- parse('A', :task_name).should eq('A')
7
- parse('Diagnosis', :task_name).should eq('Diagnosis')
8
- parse('TaskName', :task_name).should eq('TaskName')
9
- parse('Task_Name', :task_name).should eq('Task_Name')
10
- end
11
-
12
- it 'raises on invalid task names' do
13
- lambda{
14
- parse('not_a_task_name', :task_name)
15
- }.should raise_error(Citrus::ParseError)
16
- end
17
-
18
- end
19
- end
@@ -1,17 +0,0 @@
1
- require 'spec_helper'
2
- module Gisele::Language
3
- describe Grammar, 'task_start_or_end' do
4
-
5
- it 'parses correct event names' do
6
- parse('Task:start', :task_start_or_end).should eq('Task:start')
7
- parse('Task:end', :task_start_or_end).should eq('Task:end')
8
- end
9
-
10
- it 'raises on simple task names' do
11
- lambda{
12
- parse('Task', :task_start_or_end)
13
- }.should raise_error(Citrus::ParseError)
14
- end
15
-
16
- end
17
- end
@@ -1,21 +0,0 @@
1
- require 'spec_helper'
2
- module Gisele::Language
3
- describe Grammar, 'trackvar_def' do
4
-
5
- it 'parses valid tracking variable definitions' do
6
- defn = 'trackvar plateletLow {BloodTest:end}'
7
- parse(defn, :trackvar_def).should eq(defn)
8
- end
9
-
10
- it 'supports an optional initial value' do
11
- defn = 'trackvar plateletLow {BloodTest:end} initially false'
12
- parse(defn, :trackvar_def).should eq(defn)
13
- end
14
-
15
- it 'supports optional obsolete events' do
16
- defn = 'trackvar plateletLow {BloodTest:end}, {Chemotherapy:end}'
17
- parse(defn, :trackvar_def).should eq(defn)
18
- end
19
-
20
- end
21
- end
@@ -1,29 +0,0 @@
1
- require 'spec_helper'
2
- module Gisele::Language
3
- describe Grammar, 'unit' do
4
-
5
- it 'parses a single task definition' do
6
- expr = <<-UNIT.strip
7
- task Task1 end
8
- UNIT
9
- parse(expr, :unit_def).should eq(expr)
10
- end
11
-
12
- it 'accepts multiple task definitions' do
13
- expr = <<-UNIT.strip
14
- task Task1 end
15
- task Task2 end
16
- UNIT
17
- parse(expr, :unit_def).should eq(expr)
18
- end
19
-
20
- it 'allows trailing spaces' do
21
- expr = <<-UNIT
22
- task Task1 end
23
- task Task2 end
24
- UNIT
25
- parse(expr, :unit_def).should eq(expr)
26
- end
27
-
28
- end
29
- end
@@ -1,51 +0,0 @@
1
- require 'spec_helper'
2
- module Gisele::Language
3
- describe Grammar, 'variable_name' do
4
-
5
- RESERVED_WORDS = [
6
- "if",
7
- "else",
8
- "elsif",
9
- "when",
10
- "while",
11
- "seq",
12
- "par",
13
- "task",
14
- "refinement",
15
- "fluent",
16
- "trackvar",
17
- "initially",
18
- "end",
19
- "not",
20
- "or",
21
- "and",
22
- "true",
23
- "false"
24
- ]
25
-
26
- it 'parses correct variable names' do
27
- parse('a', :variable_name).should eq('a')
28
- parse('diagnosis', :variable_name).should eq('diagnosis')
29
- parse('varName', :variable_name).should eq('varName')
30
- end
31
-
32
- it 'does not allow reserved words' do
33
- RESERVED_WORDS.each do |word|
34
- lambda{
35
- parse(word.to_s + " ", :variable_name)
36
- }.should raise_error(Citrus::ParseError)
37
- end
38
- end
39
-
40
- it 'allows a reserved word as prefix' do
41
- parse('ifSomething', :variable_name).should eq('ifSomething')
42
- end
43
-
44
- it 'raises on invalid variable names' do
45
- lambda{
46
- parse('NotAVarName', :variable_name)
47
- }.should raise_error(Citrus::ParseError)
48
- end
49
-
50
- end
51
- end
@@ -1,21 +0,0 @@
1
- require 'spec_helper'
2
- module Gisele::Language
3
- describe Grammar, 'when_clause' do
4
-
5
- it 'parses a single when clause statement' do
6
- expr = 'when goodCond Task'
7
- parse(expr, :when_clause).should eq(expr)
8
- end
9
-
10
- it 'supports a boolean expression' do
11
- expr = 'when not(goodCond and badCond) Task'
12
- parse(expr, :when_clause).should eq(expr)
13
- end
14
-
15
- it 'supports an complex process statement' do
16
- expr = 'when goodCond Task1 par Task2 Task3 end'
17
- parse(expr, :when_clause).should eq(expr)
18
- end
19
-
20
- end
21
- end
@@ -1,11 +0,0 @@
1
- require 'spec_helper'
2
- module Gisele::Language
3
- describe Grammar, 'while_st' do
4
-
5
- it 'parses a single while statement' do
6
- expr = 'while badCond Task end'
7
- parse(expr, :while_st).should eq(expr)
8
- end
9
-
10
- end
11
- end
@@ -1,32 +0,0 @@
1
- require 'spec_helper'
2
- module Gisele::Language::Syntax
3
- describe BoolExpr, "to_ast" do
4
-
5
- it 'is correctly extended by Sexpr' do
6
- ast("true", :bool_expr).should be_a(Gisele::Language::AST::BoolExpr)
7
- end
8
-
9
- it 'returns expected ast on simple expressions' do
10
- expected = \
11
- [:bool_expr, [:bool_and, [:var_ref, "diagKnown"], [:var_ref, "platLow"]]]
12
- ast("diagKnown and platLow", :bool_expr).should eq(expected)
13
- end
14
-
15
- it 'respects priorities' do
16
- expected = [:bool_expr,
17
- [:bool_or, [:bool_and, [:var_ref, "diagKnown"], [:var_ref, "platLow"]], [:var_ref, "platHigh"]]]
18
- ast("diagKnown and platLow or platHigh", :bool_expr).should eq(expected)
19
- end
20
-
21
- it 'supports double negations' do
22
- expected = [:bool_expr, [:bool_not, [:bool_not, [:var_ref, "diagKnown"]]]]
23
- ast("not not(diagKnown)", :bool_expr).should eq(expected)
24
- end
25
-
26
- it 'makes boolean literals explicit' do
27
- ast("true", :bool_expr).should eq([:bool_expr, [:bool_lit, true]])
28
- ast("false", :bool_expr).should eq([:bool_expr, [:bool_lit, false]])
29
- end
30
-
31
- end
32
- end
@@ -1,47 +0,0 @@
1
- require 'spec_helper'
2
- module Gisele::Language::Syntax
3
- describe CaseSt, "to_ast" do
4
-
5
- it 'arranges when clauses as expected' do
6
- expr = <<-CASE_ST.strip
7
- case
8
- when good
9
- Task1
10
- when bad
11
- Task2
12
- end
13
- CASE_ST
14
- when_clause1 = ast("when good Task1", :when_clause)
15
- when_clause2 = ast("when bad Task2", :when_clause)
16
- expected = [:case_st, nil, when_clause1, when_clause2]
17
- ast(expr, :case_st).should eq(expected)
18
- end
19
-
20
- it 'puts the else clause at the end' do
21
- expr = <<-CASE_ST.strip
22
- case
23
- when good
24
- Task1
25
- else
26
- Task2
27
- end
28
- CASE_ST
29
- when_clause = ast("when good Task1", :when_clause)
30
- else_clause = ast("else Task2", :else_clause)
31
- expected = [:case_st, nil, when_clause, else_clause]
32
- ast(expr, :case_st).should eq(expected)
33
- end
34
-
35
- it 'supports an optional variable name' do
36
- expr = <<-CASE_ST.strip
37
- case someVariable
38
- when good
39
- Task1
40
- end
41
- CASE_ST
42
- expected = [:var_ref, "someVariable"]
43
- ast(expr, :case_st)[1].should eq(expected)
44
- end
45
-
46
- end
47
- end
@@ -1,13 +0,0 @@
1
- require 'spec_helper'
2
- module Gisele::Language::Syntax
3
- describe ElseClause, "to_ast" do
4
-
5
- it 'parses as expected' do
6
- expr = "else Task1"
7
- expected = \
8
- [:else_clause, [:task_call_st, "Task1"]]
9
- ast(expr, :else_clause).should eq(expected)
10
- end
11
-
12
- end
13
- end
@@ -1,15 +0,0 @@
1
- require 'spec_helper'
2
- module Gisele::Language::Syntax
3
- describe ElsifClause, "to_ast" do
4
-
5
- it 'parses as expected' do
6
- expr = "elsif goodCond Task1"
7
- expected = \
8
- [:elsif_clause,
9
- [:bool_expr, [:var_ref, "goodCond"]],
10
- [:task_call_st, "Task1"]]
11
- ast(expr, :elsif_clause).should eq(expected)
12
- end
13
-
14
- end
15
- end
@@ -1,24 +0,0 @@
1
- require 'spec_helper'
2
- module Gisele::Language::Syntax
3
- describe EventSet, "to_ast" do
4
-
5
- it 'converts empty lists as expected' do
6
- expr = '{ }'
7
- expected = [:event_set]
8
- ast(expr, :event_set).should eq(expected)
9
- end
10
-
11
- it 'converts singleton lists as expected' do
12
- expr = '{Diagnosis:start}'
13
- expected = [:event_set, "Diagnosis:start"]
14
- ast(expr, :event_set).should eq(expected)
15
- end
16
-
17
- it 'converts non empty lists as expected' do
18
- expr = '{Diagnosis:start, an_event, another_one}'
19
- expected = [:event_set, "Diagnosis:start", "an_event", "another_one"]
20
- ast(expr, :event_set).should eq(expected)
21
- end
22
-
23
- end
24
- end
@@ -1,26 +0,0 @@
1
- require 'spec_helper'
2
- module Gisele::Language::Syntax
3
- describe FluentDef, "to_ast" do
4
-
5
- it 'converts fluent definitions as expected' do
6
- defn = "fluent diagKnown {Diagnosis:start, diagnosis}, {Treatment:end} initially false"
7
- expected = [:fluent_def,
8
- "diagKnown",
9
- [:event_set, "Diagnosis:start", "diagnosis"],
10
- [:event_set, "Treatment:end"],
11
- false]
12
- ast(defn, :fluent_def).should eq(expected)
13
- end
14
-
15
- it 'does not require the initial value' do
16
- defn = "fluent diagKnown {Diagnosis:start, diagnosis}, {Treatment:end}"
17
- expected = [:fluent_def,
18
- "diagKnown",
19
- [:event_set, "Diagnosis:start", "diagnosis"],
20
- [:event_set, "Treatment:end"],
21
- nil]
22
- ast(defn, :fluent_def).should eq(expected)
23
- end
24
-
25
- end
26
- end
@@ -1,39 +0,0 @@
1
- require 'spec_helper'
2
- module Gisele::Language::Syntax
3
- describe IfSt, "to_ast" do
4
-
5
- it 'parses as expected' do
6
- expr = "if goodCond Task1 end"
7
- expected = \
8
- [:if_st,
9
- [:bool_expr, [:var_ref, "goodCond"]],
10
- [:task_call_st, "Task1"]]
11
- ast(expr, :if_st).should eq(expected)
12
- end
13
-
14
- it 'supports a else clause' do
15
- expr = "if goodCond Task1 else Task2 end"
16
- expected = \
17
- [:if_st,
18
- [:bool_expr, [:var_ref, "goodCond"]],
19
- [:task_call_st, "Task1"],
20
- [:else_clause, [:task_call_st, "Task2"]] ]
21
- ast(expr, :if_st).should eq(expected)
22
- end
23
-
24
- it 'supports elsif clauses' do
25
- expr = "if goodCond Task1 elsif otherCond Task2 elsif stillAnother Task3 else Task4 end"
26
- expected = \
27
- [:if_st,
28
- [:bool_expr, [:var_ref, "goodCond"]], [:task_call_st, "Task1"],
29
- [:elsif_clause,
30
- [:bool_expr, [:var_ref, "otherCond"]], [:task_call_st, "Task2"]],
31
- [:elsif_clause,
32
- [:bool_expr, [:var_ref, "stillAnother"]], [:task_call_st, "Task3"]],
33
- [:else_clause,
34
- [:task_call_st, "Task4"]] ]
35
- ast(expr, :if_st).should eq(expected)
36
- end
37
-
38
- end
39
- end
@@ -1,12 +0,0 @@
1
- require 'spec_helper'
2
- module Gisele::Language::Syntax
3
- describe ParSt, "to_ast" do
4
-
5
- it 'parses as expected' do
6
- expr = "par Task1 Task2 end"
7
- expected = [:par_st, [:task_call_st, "Task1"], [:task_call_st, "Task2"]]
8
- ast(expr, :par_st).should eq(expected)
9
- end
10
-
11
- end
12
- end