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,83 +0,0 @@
1
- parser:
2
- grammar.citrus
3
- rules:
4
- ### units and tasks
5
- unit_def:
6
- - [task_def+]
7
- task_def:
8
- - [task_name, some_def*, statement]
9
- some_def:
10
- - fluent_def
11
- - trackvar_def
12
- - task_def
13
- ### variables
14
- fluent_def:
15
- - [var_name, event_set, event_set, initially]
16
- trackvar_def:
17
- - [var_name, event_set, event_set, initially]
18
- event_set:
19
- - [event*]
20
- event:
21
- - event_name
22
- - task_event_name
23
- var_ref:
24
- - [var_name]
25
- ### statements
26
- statement:
27
- - if_st
28
- - case_st
29
- - while_st
30
- - seq_st
31
- - par_st
32
- - task_call_st
33
- - nop_st
34
- if_st:
35
- - [bool_expr, statement, elsif_clause*, "else_clause?"]
36
- case_st:
37
- - [[var_ref, ~], when_clause+, "else_clause?"]
38
- while_st:
39
- - [bool_expr, statement]
40
- seq_st:
41
- - [statement+]
42
- par_st:
43
- - [statement+]
44
- task_call_st:
45
- - [task_name]
46
- nop_st:
47
- - []
48
- ### clauses
49
- elsif_clause:
50
- - [bool_expr, statement]
51
- else_clause:
52
- - [statement]
53
- when_clause:
54
- - [bool_expr, statement]
55
- ### boolean expressions
56
- bool_expr:
57
- - [bool_expression]
58
- bool_expression:
59
- - bool_or
60
- - bool_and
61
- - bool_not
62
- - var_ref
63
- - bool_lit
64
- bool_or:
65
- - [bool_expression, bool_expression]
66
- bool_and:
67
- - [bool_expression, bool_expression]
68
- bool_not:
69
- - [bool_expression]
70
- bool_lit:
71
- - [ boolean_literal ]
72
- boolean_literal:
73
- - true
74
- - false
75
- ### terminals
76
- task_name: !ruby/regexp /^[A-Z][A-Za-z0-9_]*$/
77
- var_name: !ruby/regexp /^[a-z][A-Za-z0-9_]*$/
78
- event_name: !ruby/regexp /^[a-z][a-z0-9_]*$/
79
- task_event_name: !ruby/regexp /^[A-Z][A-Za-z0-9_]*:(start|end)$/
80
- initially:
81
- - true
82
- - false
83
- - ~
@@ -1,4 +0,0 @@
1
- require_relative 'processors/scoping_helper'
2
- require_relative 'processors/elsif_flattener'
3
- require_relative 'processors/if_to_case'
4
- require_relative 'processors/sugar_removal'
@@ -1,36 +0,0 @@
1
- module Gisele
2
- module Language
3
- class ElsifFlattener < Sexpr::Rewriter
4
- grammar Language
5
-
6
- def on_if_st(sexpr)
7
- condition, dost, *clauses = sexpr.sexpr_body
8
-
9
- base = [:if_st, condition, dost]
10
- base = sexpr(base, sexpr.tracking_markers)
11
-
12
- clauses.inject base do |cur_if, clause|
13
- rw_clause = apply(clause)
14
- cur_if << rw_clause
15
- rw_clause.last
16
- end
17
-
18
- base
19
- end
20
-
21
- def on_elsif_clause(sexpr)
22
- base = \
23
- [:else_clause,
24
- [:if_st, sexpr[1], apply(sexpr[2])] ]
25
- base = sexpr(base, sexpr.tracking_markers)
26
- end
27
-
28
- def on_else_clause(sexpr)
29
- [:else_clause, apply(sexpr.last)]
30
- end
31
-
32
- alias :on_missing :copy_and_apply
33
-
34
- end # class ElsifFlattener
35
- end # module Language
36
- end # module Gisele
@@ -1,65 +0,0 @@
1
- module Gisele
2
- module Language
3
- class IfToCase < Sexpr::Rewriter
4
- grammar Language
5
-
6
- def on_if_st(sexpr)
7
- condition, dost, *clauses = sexpr.sexpr_body
8
-
9
- # create case_st with same markers as the if_st
10
- when_clause = [:when_clause, condition, apply(dost)]
11
- when_clause = sexpr(when_clause, sexpr.tracking_markers)
12
- base = [:case_st, nil, when_clause]
13
- base = sexpr(base, sexpr.tracking_markers)
14
-
15
- # this is the condition for elsif clauses
16
- @condition = negate(condition.last)
17
-
18
- # make injection now
19
- clauses.inject base do |memo,clause|
20
- memo << apply(clause)
21
- end
22
- end
23
-
24
- def on_elsif_clause(sexpr)
25
- condition, dost, = sexpr.sexpr_body
26
-
27
- # install new conditions for me and next elsif clauses
28
- condition = condition.last
29
- previous = @condition
30
- @condition = [:bool_and, negate(condition), @condition]
31
-
32
- # convert elsif to when and keep the markers
33
- base = \
34
- [:when_clause,
35
- [:bool_expr, [:bool_and, condition, previous]],
36
- apply(dost) ]
37
- sexpr(base, sexpr.tracking_markers)
38
- end
39
-
40
- def on_else_clause(sexpr)
41
- dost, = sexpr.sexpr_body
42
-
43
- # convert else to when and keep the markers
44
- base = \
45
- [:when_clause,
46
- [:bool_expr, @condition],
47
- apply(dost)]
48
- sexpr(base, sexpr.tracking_markers)
49
- end
50
-
51
- alias :on_missing :copy_and_apply
52
-
53
- private
54
-
55
- def negate(cond)
56
- if cond.first == :bool_not
57
- cond.last
58
- else
59
- [:bool_not, cond]
60
- end
61
- end
62
-
63
- end # class IfToCase
64
- end # module Language
65
- end # module Gisele
@@ -1,32 +0,0 @@
1
- module Gisele
2
- module Language
3
- class ScopingHelper < Sexpr::Processor::Helper
4
-
5
- module Methods
6
-
7
- def scope_stack
8
- @scope_stack ||= []
9
- end
10
-
11
- def with_scope(scope)
12
- scope_stack.push(scope)
13
- result = yield
14
- scope_stack.pop
15
- result
16
- end
17
-
18
- end # module Methods
19
-
20
- def on_missing(rw, sexpr)
21
- if sexpr.first.to_s =~ /_def/
22
- rw.with_scope(sexpr) do
23
- yield(rw, sexpr)
24
- end
25
- else
26
- yield(rw, sexpr)
27
- end
28
- end
29
-
30
- end # module ScopingHelper
31
- end # module Language
32
- end # module Gisele
@@ -1,17 +0,0 @@
1
- module Gisele
2
- module Language
3
- class SugarRemoval < Sexpr::Rewriter
4
- grammar Language
5
-
6
- # (elsif ... -> else if ...)
7
- use ElsifFlattener
8
-
9
- def apply(sexpr)
10
- # all is already done by preprocessors so that we can simply return
11
- # the s-expression.
12
- sexpr
13
- end
14
-
15
- end # class SugarRemoval
16
- end # module Language
17
- end # module Gisele
@@ -1,14 +0,0 @@
1
- module Gisele
2
- module Language
3
- module Syntax
4
- module BoolAnd
5
- include Node
6
-
7
- def _to_ast
8
- [:bool_and, left.to_ast, right.to_ast]
9
- end
10
-
11
- end # module BoolAnd
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 BoolExpr
5
- include Node
6
-
7
- def _to_ast
8
- [:bool_expr, captures[:theexpr].first.to_ast]
9
- end
10
-
11
- end # module BoolExpr
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 BoolLit
5
- include Node
6
-
7
- def _to_ast
8
- [:bool_lit, strip == "true"]
9
- end
10
-
11
- end # module BoolLit
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 BoolNot
5
- include Node
6
-
7
- def _to_ast
8
- [:bool_not, captures[:expr].first.to_ast]
9
- end
10
-
11
- end # module BoolParen
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 BoolOr
5
- include Node
6
-
7
- def _to_ast
8
- [:bool_or, left.to_ast, right.to_ast]
9
- end
10
-
11
- end # module BoolOr
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 BoolParen
5
- include Node
6
-
7
- def _to_ast
8
- captures[:expr].first.to_ast
9
- end
10
-
11
- end # module BoolParen
12
- end # module Syntax
13
- end # module Language
14
- end # module Gisele
@@ -1,19 +0,0 @@
1
- module Gisele
2
- module Language
3
- module Syntax
4
- module CaseSt
5
- include Node
6
-
7
- def _to_ast
8
- var = captures[:var_ref].first
9
- var = var.to_ast if var
10
- var = nil if var && var.empty?
11
- whens = captures[:when_clause].map{|x| x.to_ast}
12
- els = captures[:else_clause].map{|x| x.to_ast}
13
- [:case_st, var] + whens + els
14
- end
15
-
16
- end # module CaseSt
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 ElseClause
5
- include Node
6
-
7
- def _to_ast
8
- [:else_clause, captures[:process_statement].first.to_ast]
9
- end
10
-
11
- end # module ElseClause
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 ElsifClause
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
- [:elsif_clause, cond, dost]
11
- end
12
-
13
- end # module ElsifClause
14
- end # module Syntax
15
- end # module Language
16
- end # module Gisele
@@ -1,15 +0,0 @@
1
- module Gisele
2
- module Language
3
- module Syntax
4
- module EventSet
5
- include Node
6
-
7
- def _to_ast
8
- events = (captures[:event] || []).map{|e| e.value}
9
- [:event_set] + events
10
- end
11
-
12
- end # module EventSet
13
- end # module Syntax
14
- end # module Language
15
- end # module Gisele
@@ -1,18 +0,0 @@
1
- module Gisele
2
- module Language
3
- module Syntax
4
- module FluentDef
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
- initval = captures[:initially_def].first
11
- initval = (initval && !initval.empty?) ? initval.value : nil
12
- [:fluent_def, name, init, term, initval]
13
- end
14
-
15
- end # module FluentDef
16
- end # module Syntax
17
- end # module Language
18
- end # module Gisele
@@ -1,18 +0,0 @@
1
- module Gisele
2
- module Language
3
- module Syntax
4
- module IfSt
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
- elsifs = captures[:elsif_clause].map{|x| x.to_ast}
11
- els = captures[:else_clause].map{|x| x.to_ast}
12
- [:if_st, cond, dost] + elsifs + els
13
- end
14
-
15
- end # module IfSt
16
- end # module Syntax
17
- end # module Language
18
- end # module Gisele