gisele 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +33 -13
- data/Gemfile +3 -2
- data/Gemfile.lock +6 -3
- data/LICENCE.md +1 -1
- data/README.md +5 -2
- data/Rakefile +0 -8
- data/examples/rectal-cancer-pathway/RectalCancerPathway.gis +1 -1
- data/gisele.gemspec +3 -2
- data/gisele.noespec +4 -3
- data/lib/gisele.rb +11 -7
- data/lib/gisele/command.rb +28 -19
- data/lib/gisele/compiling.rb +2 -0
- data/lib/gisele/compiling/to_glts.rb +125 -0
- data/lib/gisele/compiling/to_graph.rb +160 -0
- data/lib/gisele/compiling/to_graph.yml +20 -0
- data/lib/gisele/language.rb +22 -36
- data/lib/gisele/language/ast/bool_and.rb +1 -1
- data/lib/gisele/language/ast/bool_expr.rb +9 -1
- data/lib/gisele/language/ast/bool_not.rb +1 -1
- data/lib/gisele/language/ast/bool_or.rb +1 -1
- data/lib/gisele/language/ast/case_st.rb +1 -1
- data/lib/gisele/language/ast/else_clause.rb +1 -1
- data/lib/gisele/language/ast/node.rb +4 -66
- data/lib/gisele/language/grammar.citrus +2 -2
- data/lib/gisele/language/grammar.sexp.yml +83 -80
- data/lib/gisele/language/processors.rb +2 -2
- data/lib/gisele/language/processors/elsif_flattener.rb +14 -13
- data/lib/gisele/language/processors/if_to_case.rb +20 -18
- data/lib/gisele/language/processors/scoping_helper.rb +32 -0
- data/lib/gisele/language/processors/sugar_removal.rb +10 -5
- data/lib/gisele/language/syntax/case_st.rb +1 -1
- data/lib/gisele/language/syntax/node.rb +6 -2
- data/lib/gisele/language/syntax/when_clause.rb +1 -1
- data/lib/gisele/loader.rb +2 -1
- data/lib/gisele/version.rb +1 -1
- data/spec/command/main/gisele_glts.cmd +1 -0
- data/spec/command/main/gisele_glts.stdout +85 -0
- data/spec/command/main/gisele_help.stdout +3 -2
- data/spec/spec_helper.rb +2 -3
- data/spec/test_examples.rb +2 -2
- data/spec/unit/compiling/test_to_glts.rb +20 -0
- data/spec/unit/compiling/test_to_graph.rb +19 -0
- data/spec/unit/language/ast/test_bool_expr.rb +50 -0
- data/spec/unit/language/grammar_sexp/test_fluent_def.rb +1 -1
- data/spec/unit/language/processors/test_elsif_flattener.rb +3 -3
- data/spec/unit/language/processors/test_if_to_case.rb +7 -7
- data/spec/unit/language/processors/test_scoping_helper.rb +45 -0
- data/spec/unit/language/syntax/grammar/test_bool_expr.rb +2 -2
- data/spec/unit/language/syntax/grammar/test_boolean_literal.rb +2 -2
- data/spec/unit/language/syntax/grammar/test_case_st.rb +2 -2
- data/spec/unit/language/syntax/grammar/test_event.rb +2 -2
- data/spec/unit/language/syntax/grammar/test_event_name.rb +2 -2
- data/spec/unit/language/syntax/grammar/test_event_set.rb +2 -3
- data/spec/unit/language/syntax/grammar/test_fluent_def.rb +2 -2
- data/spec/unit/language/syntax/grammar/test_if_st.rb +2 -2
- data/spec/unit/language/syntax/grammar/test_par_st.rb +2 -2
- data/spec/unit/language/syntax/grammar/test_process_statement.rb +2 -2
- data/spec/unit/language/syntax/grammar/test_seq_st.rb +2 -2
- data/spec/unit/language/syntax/grammar/test_spaces.rb +2 -2
- data/spec/unit/language/syntax/grammar/test_spacing.rb +2 -3
- data/spec/unit/language/syntax/grammar/test_task_def.rb +2 -2
- data/spec/unit/language/syntax/grammar/test_task_name.rb +2 -2
- data/spec/unit/language/syntax/grammar/test_task_start_or_end.rb +2 -2
- data/spec/unit/language/syntax/grammar/test_trackvar_def.rb +2 -2
- data/spec/unit/language/syntax/grammar/test_unit_def.rb +2 -2
- data/spec/unit/language/syntax/grammar/test_variable_name.rb +24 -3
- data/spec/unit/language/syntax/grammar/test_when_clause.rb +2 -2
- data/spec/unit/language/syntax/grammar/test_while_st.rb +2 -2
- data/spec/unit/language/syntax/to_ast/test_bool_expr.rb +5 -1
- data/spec/unit/language/syntax/to_ast/test_case_st.rb +1 -1
- data/spec/unit/language/syntax/to_ast/test_else_clause.rb +1 -1
- data/spec/unit/language/syntax/to_ast/test_elsif_clause.rb +1 -1
- data/spec/unit/language/syntax/to_ast/test_event_set.rb +1 -1
- data/spec/unit/language/syntax/to_ast/test_fluent_def.rb +1 -1
- data/spec/unit/language/syntax/to_ast/test_if_st.rb +1 -1
- data/spec/unit/language/syntax/to_ast/test_par_st.rb +1 -1
- data/spec/unit/language/syntax/to_ast/test_seq_st.rb +1 -1
- data/spec/unit/language/syntax/to_ast/test_task_call_st.rb +1 -1
- data/spec/unit/language/syntax/to_ast/test_task_def.rb +1 -1
- data/spec/unit/language/syntax/to_ast/test_trackvar_def.rb +1 -1
- data/spec/unit/language/syntax/to_ast/test_unit_def.rb +1 -1
- data/spec/unit/language/syntax/to_ast/test_var_ref.rb +1 -1
- data/spec/unit/language/syntax/to_ast/test_when_clause.rb +1 -1
- data/spec/unit/language/syntax/to_ast/test_while_st.rb +1 -1
- data/spec/unit/language/test_syntax.rb +36 -38
- data/spec/unit/test_gisele.rb +1 -1
- metadata +189 -190
- data/lib/gisele/language/ast.rb +0 -14
- data/lib/gisele/language/ast/helpers.rb +0 -43
- data/lib/gisele/language/ast/unit_def.rb +0 -10
- data/lib/gisele/language/grammar.dot.yml +0 -19
- data/lib/gisele/language/processors/to_graph.rb +0 -146
- data/lib/gisele/language/rewriter.rb +0 -60
- data/lib/gisele/language/rewriter/helper.rb +0 -41
- data/lib/gisele/language/rewriter/scoping.rb +0 -34
- data/lib/gisele/language/rewriter/work_on_nodes.rb +0 -30
- data/lib/gisele/language/syntax.rb +0 -29
- data/spec/unit/language/ast/test_node.rb +0 -82
- data/spec/unit/language/processors/test_to_graph.rb +0 -17
- data/spec/unit/language/rewriter/test_helper.rb +0 -87
- data/spec/unit/language/rewriter/test_scoping.rb +0 -46
- data/spec/unit/language/rewriter/test_work_on_nodes.rb +0 -45
- data/spec/unit/language/test_ast.rb +0 -38
- data/spec/unit/language/test_rewriter.rb +0 -81
- data/spec/unit/test_language.rb +0 -35
@@ -3,11 +3,11 @@ module Gisele::Language
|
|
3
3
|
describe IfToCase do
|
4
4
|
|
5
5
|
def ast(source)
|
6
|
-
|
6
|
+
Gisele.ast(Gisele.parse(source.strip, :root => :if_st))
|
7
7
|
end
|
8
8
|
|
9
9
|
def rewrite(ast)
|
10
|
-
@rewrited = IfToCase.
|
10
|
+
@rewrited = IfToCase.call(ast)
|
11
11
|
end
|
12
12
|
|
13
13
|
after{
|
@@ -90,16 +90,16 @@ module Gisele::Language
|
|
90
90
|
it 'keeps traceability markers on a single if' do
|
91
91
|
if_st = ast("if goodCond Task1 end")
|
92
92
|
rw_st = rewrite(if_st)
|
93
|
-
rw_st.
|
94
|
-
rw_st.last.
|
93
|
+
rw_st.tracking_markers.should eq(if_st.tracking_markers)
|
94
|
+
rw_st.last.tracking_markers.should eq(if_st.tracking_markers)
|
95
95
|
end
|
96
96
|
|
97
97
|
it 'keeps traceability markers when a else if present' do
|
98
98
|
if_st = ast("if goodCond Task1 else Task2 end")
|
99
99
|
rw_st = rewrite(if_st)
|
100
|
-
rw_st.
|
101
|
-
rw_st.last.
|
100
|
+
rw_st.tracking_markers.should eq(if_st.tracking_markers)
|
101
|
+
rw_st.last.tracking_markers.should eq(if_st.last.tracking_markers)
|
102
102
|
end
|
103
103
|
|
104
104
|
end
|
105
|
-
end
|
105
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
module Gisele::Language
|
3
|
+
describe ScopingHelper do
|
4
|
+
|
5
|
+
let(:rw_class) do
|
6
|
+
Class.new(Sexpr::Rewriter) do
|
7
|
+
grammar Gisele::Language
|
8
|
+
helper ScopingHelper
|
9
|
+
|
10
|
+
def on_hello(node)
|
11
|
+
scope_stack.dup
|
12
|
+
end
|
13
|
+
|
14
|
+
def on_missing(node)
|
15
|
+
call(node.sexpr_body.last)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
let(:rw){ rw_class.new }
|
21
|
+
|
22
|
+
it 'installs the methods on the rewriter' do
|
23
|
+
rw.respond_to?(:scope_stack).should be_true
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'does nothing special on non _def nodes' do
|
27
|
+
node = [:hello, "world"]
|
28
|
+
rw.call(node).should eq([])
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'keeps _def nodes as successive scopes' do
|
32
|
+
second = [:task_def, [:hello]]
|
33
|
+
first = [:task_def, second]
|
34
|
+
rw.call(first).should eq([first, second])
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'pops scopes when returning along the stack' do
|
38
|
+
second = [:task_def, [:hello]]
|
39
|
+
first = [:task_def, second]
|
40
|
+
rw.call(first)
|
41
|
+
rw.scope_stack.should eq([])
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
@@ -1,7 +1,28 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
module Gisele::Language
|
2
|
+
module Gisele::Language
|
3
3
|
describe Grammar, 'variable_name' do
|
4
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
|
+
|
5
26
|
it 'parses correct variable names' do
|
6
27
|
parse('a', :variable_name).should eq('a')
|
7
28
|
parse('diagnosis', :variable_name).should eq('diagnosis')
|
@@ -9,7 +30,7 @@ module Gisele::Language::Syntax
|
|
9
30
|
end
|
10
31
|
|
11
32
|
it 'does not allow reserved words' do
|
12
|
-
|
33
|
+
RESERVED_WORDS.each do |word|
|
13
34
|
lambda{
|
14
35
|
parse(word.to_s + " ", :variable_name)
|
15
36
|
}.should raise_error(Citrus::ParseError)
|
@@ -27,4 +48,4 @@ module Gisele::Language::Syntax
|
|
27
48
|
end
|
28
49
|
|
29
50
|
end
|
30
|
-
end
|
51
|
+
end
|
@@ -2,6 +2,10 @@ require 'spec_helper'
|
|
2
2
|
module Gisele::Language::Syntax
|
3
3
|
describe BoolExpr, "to_ast" do
|
4
4
|
|
5
|
+
it 'is correctly extended by Sexpr' do
|
6
|
+
ast("true", :bool_expr).should be_a(Gisele::Language::AST::BoolExpr)
|
7
|
+
end
|
8
|
+
|
5
9
|
it 'returns expected ast on simple expressions' do
|
6
10
|
expected = \
|
7
11
|
[:bool_expr, [:bool_and, [:var_ref, "diagKnown"], [:var_ref, "platLow"]]]
|
@@ -25,4 +29,4 @@ module Gisele::Language::Syntax
|
|
25
29
|
end
|
26
30
|
|
27
31
|
end
|
28
|
-
end
|
32
|
+
end
|