gisele 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +5 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +31 -0
- data/LICENCE.md +22 -0
- data/Manifest.txt +16 -0
- data/README.md +30 -0
- data/Rakefile +23 -0
- data/bin/gisele +8 -0
- data/examples/meeting-scheduler/MeetingScheduling.gis +73 -0
- data/gisele.gemspec +191 -0
- data/gisele.noespec +36 -0
- data/lib/gisele/command.rb +63 -0
- data/lib/gisele/language/grammar.citrus +246 -0
- data/lib/gisele/language/parser.rb +30 -0
- data/lib/gisele/language.rb +6 -0
- data/lib/gisele/loader.rb +4 -0
- data/lib/gisele/version.rb +14 -0
- data/lib/gisele.rb +14 -0
- data/spec/command/main/gisele_ast_ruby.cmd +1 -0
- data/spec/command/main/gisele_ast_ruby.stdout +44 -0
- data/spec/command/main/gisele_help.cmd +1 -0
- data/spec/command/main/gisele_help.stdout +22 -0
- data/spec/command/main/gisele_version.cmd +1 -0
- data/spec/command/main/gisele_version.stdout +2 -0
- data/spec/command/test_command.rb +27 -0
- data/spec/fixtures/tasks/simple.ast +15 -0
- data/spec/fixtures/tasks/simple.gis +9 -0
- data/spec/spec_helper.rb +29 -0
- data/spec/test_examples.rb +14 -0
- data/spec/unit/language/test_ast.rb +264 -0
- data/spec/unit/language/test_grammar.rb +329 -0
- data/spec/unit/language/test_parser.rb +27 -0
- data/spec/unit/test_gisele.rb +8 -0
- data/tasks/debug_mail.rake +75 -0
- data/tasks/debug_mail.txt +13 -0
- data/tasks/gem.rake +68 -0
- data/tasks/spec_test.rake +71 -0
- data/tasks/unit_test.rake +76 -0
- data/tasks/yard.rake +51 -0
- metadata +196 -0
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
|
3
|
+
group :runtime do
|
4
|
+
gem "citrus", "~> 2.4"
|
5
|
+
gem "epath", "~> 0.0.1"
|
6
|
+
gem "quickl", "~> 0.4.3"
|
7
|
+
gem "awesome_print", "~> 1.0"
|
8
|
+
end
|
9
|
+
|
10
|
+
group :development do
|
11
|
+
gem "rake", "~> 0.9.2"
|
12
|
+
gem "bundler", "~> 1.0"
|
13
|
+
gem "rspec", "~> 2.8.0"
|
14
|
+
gem "wlang", "~> 0.10.2"
|
15
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
awesome_print (1.0.2)
|
5
|
+
citrus (2.4.1)
|
6
|
+
diff-lcs (1.1.3)
|
7
|
+
epath (0.0.1)
|
8
|
+
quickl (0.4.3)
|
9
|
+
rake (0.9.2.2)
|
10
|
+
rspec (2.8.0)
|
11
|
+
rspec-core (~> 2.8.0)
|
12
|
+
rspec-expectations (~> 2.8.0)
|
13
|
+
rspec-mocks (~> 2.8.0)
|
14
|
+
rspec-core (2.8.0)
|
15
|
+
rspec-expectations (2.8.0)
|
16
|
+
diff-lcs (~> 1.1.2)
|
17
|
+
rspec-mocks (2.8.0)
|
18
|
+
wlang (0.10.2)
|
19
|
+
|
20
|
+
PLATFORMS
|
21
|
+
ruby
|
22
|
+
|
23
|
+
DEPENDENCIES
|
24
|
+
awesome_print (~> 1.0)
|
25
|
+
bundler (~> 1.0)
|
26
|
+
citrus (~> 2.4)
|
27
|
+
epath (~> 0.0.1)
|
28
|
+
quickl (~> 0.4.3)
|
29
|
+
rake (~> 0.9.2)
|
30
|
+
rspec (~> 2.8.0)
|
31
|
+
wlang (~> 0.10.2)
|
data/LICENCE.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# The MIT Licence
|
2
|
+
|
3
|
+
Copyright (c) 2012 - The University of Louvain
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest.txt
ADDED
data/README.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# Gisele
|
2
|
+
|
3
|
+
Gisele is a Process Analyzer Toolset
|
4
|
+
|
5
|
+
## Description
|
6
|
+
|
7
|
+
This is the process modeling and analysis toolset developed during the Gisele and
|
8
|
+
PIPAS research projects held at the University of Louvain in 2008-2012.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
This project requires an installation of ruby >= 1.9.2. Then,
|
13
|
+
|
14
|
+
gem install gisele
|
15
|
+
gisele --help
|
16
|
+
|
17
|
+
For contributors (UCLouvain students, in particular), please consider the following
|
18
|
+
scenario:
|
19
|
+
|
20
|
+
gem install bundler --pre
|
21
|
+
git clone https://blambeau@github.com/blambeau/gisele.git # or your own fork
|
22
|
+
cd gisele
|
23
|
+
bundle install
|
24
|
+
rake test # please report any test failure on github
|
25
|
+
bundle exec ./bin/gisele --help
|
26
|
+
|
27
|
+
## Contributing
|
28
|
+
|
29
|
+
Gisele is distributed under a MIT license. The common github workflow (fork/pull request)
|
30
|
+
applies. Please take contact with Bernard Lambeau with any question.
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
begin
|
2
|
+
gem "bundler", "~> 1.0"
|
3
|
+
require "bundler/setup"
|
4
|
+
rescue LoadError => ex
|
5
|
+
puts ex.message
|
6
|
+
abort "Bundler failed to load, (did you run 'gem install bundler' ?)"
|
7
|
+
end
|
8
|
+
|
9
|
+
# Dynamically load the gem spec
|
10
|
+
$gemspec_file = File.expand_path('../gisele.gemspec', __FILE__)
|
11
|
+
$gemspec = Kernel.eval(File.read($gemspec_file))
|
12
|
+
|
13
|
+
# We run tests by default
|
14
|
+
task :default => :test
|
15
|
+
|
16
|
+
#
|
17
|
+
# Install all tasks found in tasks folder
|
18
|
+
#
|
19
|
+
# See .rake files there for complete documentation.
|
20
|
+
#
|
21
|
+
Dir["tasks/*.rake"].each do |taskfile|
|
22
|
+
load taskfile
|
23
|
+
end
|
data/bin/gisele
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
#
|
2
|
+
# This is a Gisele process for the Meeting Scheduler example, similar to what can be found
|
3
|
+
# in [Lam11]. The main difference between this model and the one defined there is the use
|
4
|
+
# of tracking variables. Tracking variables are introduced and explained in [Dam11].
|
5
|
+
#
|
6
|
+
# The Meeting Scheduler examplar [Fea97]
|
7
|
+
#
|
8
|
+
# A meeting initiator issues a meeting request, specifying the expected participants and
|
9
|
+
# the date range within which the meeting should take place. The scheduler then sends an
|
10
|
+
# electronic invitation to each participant, requesting them to provide their date
|
11
|
+
# constraints.
|
12
|
+
#
|
13
|
+
# A date conflict occurs when no date can be found that fits all participant constraints.
|
14
|
+
# In such case, the initiator may extend the date range or request some participants to
|
15
|
+
# weaken their constraints; a new scheduling cycle is then required. Otherwise, the
|
16
|
+
# meeting is planned at a date meeting all constraints.
|
17
|
+
#
|
18
|
+
# A soft goal requires meetings to be scheduled as quickly as possible once initiated;
|
19
|
+
# another one requires interactions with participants to be minimized. In the simplified
|
20
|
+
# version considered here, only two scheduling cycles are allowed; the meeting is planned
|
21
|
+
# after that. In such case, we will assume that the best date is chosen so as to maximize
|
22
|
+
# the number of participants attending. We also ignore features like meeting cancellations,
|
23
|
+
# meeting locations, etc.
|
24
|
+
#
|
25
|
+
# References
|
26
|
+
#
|
27
|
+
# * [Dam11] Christophe Damas, Analyzing Multi-View Models of Software Systems, PhD thesis,
|
28
|
+
# University of Louvain, November 2011
|
29
|
+
# * [Fea97] M.S. Feather, S. Fickas, A. Finkelstein and A. van Lamsweerde, Requirements and
|
30
|
+
# Specification Exemplars, Automated Software Engineering, 1997
|
31
|
+
# * [Lam11] Bernard Lambeau, Synthesizing Multi-View Models of Software Systems, PhD thesis,
|
32
|
+
# University of Louvain, November 2011
|
33
|
+
#
|
34
|
+
task MeetingScheduling
|
35
|
+
|
36
|
+
# This fluent encodes the occurence of a second cycle, becoming true when constraints
|
37
|
+
# have been weakened or the date range extended.
|
38
|
+
fluent secondCycle
|
39
|
+
{WeakenConstraints:end, ExtendDateRange:end},
|
40
|
+
{InitiateMeeting:end}
|
41
|
+
initially false
|
42
|
+
|
43
|
+
# A date conflict may only occur when constraints are acquired or weakened. Being a tracking
|
44
|
+
# variable and not fluent, we do not know the exact value of this variable when these tasks
|
45
|
+
# occur.
|
46
|
+
trackvar dateConflict
|
47
|
+
{AcquireConstraints:end, WeakenConstraints:end}
|
48
|
+
initially false
|
49
|
+
|
50
|
+
# The arbitrator decides to resolve a conflict during the Arbitrate task. The following
|
51
|
+
# definition does not capture the precise value of the variable but only that the value
|
52
|
+
# can only change during Arbitrate.
|
53
|
+
trackvar resolveByWeakening
|
54
|
+
{Arbitrate:end}
|
55
|
+
initially false
|
56
|
+
|
57
|
+
# This is the task refinement
|
58
|
+
refinement
|
59
|
+
InitiateMeeting
|
60
|
+
AcquireConstraints
|
61
|
+
while dateConflict and not(secondCycle)
|
62
|
+
Arbitrate
|
63
|
+
if resolveByWeakening
|
64
|
+
WeakenConstraints
|
65
|
+
else
|
66
|
+
ExtendDateRange
|
67
|
+
AcquireConstraints
|
68
|
+
end
|
69
|
+
end
|
70
|
+
ScheduleMeeting
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
data/gisele.gemspec
ADDED
@@ -0,0 +1,191 @@
|
|
1
|
+
# We require your library, mainly to have access to the VERSION number.
|
2
|
+
# Feel free to set $version manually.
|
3
|
+
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
|
4
|
+
require "gisele/version"
|
5
|
+
$version = Gisele::Version.to_s
|
6
|
+
|
7
|
+
#
|
8
|
+
# This is your Gem specification. Default values are provided so that your library
|
9
|
+
# should be correctly packaged given what you have described in the .noespec file.
|
10
|
+
#
|
11
|
+
Gem::Specification.new do |s|
|
12
|
+
|
13
|
+
################################################################### ABOUT YOUR GEM
|
14
|
+
|
15
|
+
# Gem name (required)
|
16
|
+
s.name = "gisele"
|
17
|
+
|
18
|
+
# Gem version (required)
|
19
|
+
s.version = $version
|
20
|
+
|
21
|
+
# A short summary of this gem
|
22
|
+
#
|
23
|
+
# This is displayed in `gem list -d`.
|
24
|
+
s.summary = "Gisele is a Process Analyzer Toolset"
|
25
|
+
|
26
|
+
# A long description of this gem (required)
|
27
|
+
#
|
28
|
+
# The description should be more detailed than the summary. For example,
|
29
|
+
# you might wish to copy the entire README into the description.
|
30
|
+
s.description = "This is a fresh-new implementation of the process analysis techniques\ndeveloped in the Gisele and PIPAS research projects at UCLouvain"
|
31
|
+
|
32
|
+
# The URL of this gem home page (optional)
|
33
|
+
s.homepage = "https://github.com/blambeau/gisele"
|
34
|
+
|
35
|
+
# Gem publication date (required but auto)
|
36
|
+
#
|
37
|
+
# Today is automatically used by default, uncomment only if
|
38
|
+
# you know what you do!
|
39
|
+
#
|
40
|
+
# s.date = Time.now.strftime('%Y-%m-%d')
|
41
|
+
|
42
|
+
# The license(s) for the library. Each license must be a short name, no
|
43
|
+
# more than 64 characters.
|
44
|
+
#
|
45
|
+
# s.licences = %w{}
|
46
|
+
|
47
|
+
# The rubyforge project this gem lives under (optional)
|
48
|
+
#
|
49
|
+
# s.rubyforge_project = nil
|
50
|
+
|
51
|
+
################################################################### ABOUT THE AUTHORS
|
52
|
+
|
53
|
+
# The list of author names who wrote this gem.
|
54
|
+
#
|
55
|
+
# If you are providing multiple authors and multiple emails they should be
|
56
|
+
# in the same order.
|
57
|
+
#
|
58
|
+
s.authors = ["Bernard Lambeau"]
|
59
|
+
|
60
|
+
# Contact emails for this gem
|
61
|
+
#
|
62
|
+
# If you are providing multiple authors and multiple emails they should be
|
63
|
+
# in the same order.
|
64
|
+
#
|
65
|
+
# NOTE: Somewhat strangly this attribute is always singular!
|
66
|
+
# Don't replace by s.emails = ...
|
67
|
+
s.email = ["blambeau@gmail.com"]
|
68
|
+
|
69
|
+
################################################################### PATHS, FILES, BINARIES
|
70
|
+
|
71
|
+
# Paths in the gem to add to $LOAD_PATH when this gem is
|
72
|
+
# activated (required).
|
73
|
+
#
|
74
|
+
# The default 'lib' is typically sufficient.
|
75
|
+
s.require_paths = ["lib"]
|
76
|
+
|
77
|
+
# Files included in this gem.
|
78
|
+
#
|
79
|
+
# By default, we take all files included in the Manifest.txt file on root
|
80
|
+
# of the project. Entries of the manifest are interpreted as Dir[...]
|
81
|
+
# patterns so that lazy people may use wilcards like lib/**/*
|
82
|
+
#
|
83
|
+
here = File.expand_path(File.dirname(__FILE__))
|
84
|
+
s.files = File.readlines(File.join(here, 'Manifest.txt')).
|
85
|
+
inject([]){|files, pattern| files + Dir[File.join(here, pattern.strip)]}.
|
86
|
+
collect{|x| x[(1+here.size)..-1]}
|
87
|
+
|
88
|
+
# Test files included in this gem.
|
89
|
+
#
|
90
|
+
s.test_files = Dir["test/**/*"] + Dir["spec/**/*"]
|
91
|
+
|
92
|
+
# The path in the gem for executable scripts (optional)
|
93
|
+
#
|
94
|
+
s.bindir = "bin"
|
95
|
+
|
96
|
+
# Executables included in the gem.
|
97
|
+
#
|
98
|
+
s.executables = (Dir["bin/*"]).collect{|f| File.basename(f)}
|
99
|
+
|
100
|
+
################################################################### REQUIREMENTS & INSTALL
|
101
|
+
# Remember the gem version requirements operators and schemes:
|
102
|
+
# = Equals version
|
103
|
+
# != Not equal to version
|
104
|
+
# > Greater than version
|
105
|
+
# < Less than version
|
106
|
+
# >= Greater than or equal to
|
107
|
+
# <= Less than or equal to
|
108
|
+
# ~> Approximately greater than
|
109
|
+
#
|
110
|
+
# Don't forget to have a look at http://lmgtfy.com/?q=Ruby+Versioning+Policies
|
111
|
+
# for setting your gem version.
|
112
|
+
#
|
113
|
+
# For your requirements to other gems, remember that
|
114
|
+
# ">= 2.2.0" (optimistic: specify minimal version)
|
115
|
+
# ">= 2.2.0", "< 3.0" (pessimistic: not greater than the next major)
|
116
|
+
# "~> 2.2" (shortcut for ">= 2.2.0", "< 3.0")
|
117
|
+
# "~> 2.2.0" (shortcut for ">= 2.2.0", "< 2.3.0")
|
118
|
+
#
|
119
|
+
|
120
|
+
#
|
121
|
+
# One call to add_dependency('gem_name', 'gem version requirement') for each
|
122
|
+
# runtime dependency. These gems will be installed with your gem.
|
123
|
+
# One call to add_development_dependency('gem_name', 'gem version requirement')
|
124
|
+
# for each development dependency. These gems are required for developers
|
125
|
+
#
|
126
|
+
s.add_development_dependency("rake", "~> 0.9.2")
|
127
|
+
s.add_development_dependency("bundler", "~> 1.0")
|
128
|
+
s.add_development_dependency("rspec", "~> 2.8.0")
|
129
|
+
s.add_development_dependency("wlang", "~> 0.10.2")
|
130
|
+
s.add_dependency("citrus", "~> 2.4")
|
131
|
+
s.add_dependency("epath", "~> 0.0.1")
|
132
|
+
s.add_dependency("quickl", "~> 0.4.3")
|
133
|
+
s.add_dependency("awesome_print", "~> 1.0")
|
134
|
+
|
135
|
+
# The version of ruby required by this gem
|
136
|
+
#
|
137
|
+
# Uncomment and set this if your gem requires specific ruby versions.
|
138
|
+
#
|
139
|
+
# s.required_ruby_version = ">= 0"
|
140
|
+
|
141
|
+
# The RubyGems version required by this gem
|
142
|
+
#
|
143
|
+
# s.required_rubygems_version = ">= 0"
|
144
|
+
|
145
|
+
# The platform this gem runs on. See Gem::Platform for details.
|
146
|
+
#
|
147
|
+
# s.platform = nil
|
148
|
+
|
149
|
+
# Extensions to build when installing the gem.
|
150
|
+
#
|
151
|
+
# Valid types of extensions are extconf.rb files, configure scripts
|
152
|
+
# and rakefiles or mkrf_conf files.
|
153
|
+
#
|
154
|
+
s.extensions = []
|
155
|
+
|
156
|
+
# External (to RubyGems) requirements that must be met for this gem to work.
|
157
|
+
# It’s simply information for the user.
|
158
|
+
#
|
159
|
+
s.requirements = nil
|
160
|
+
|
161
|
+
# A message that gets displayed after the gem is installed
|
162
|
+
#
|
163
|
+
# Uncomment and set this if you want to say something to the user
|
164
|
+
# after gem installation
|
165
|
+
#
|
166
|
+
s.post_install_message = nil
|
167
|
+
|
168
|
+
################################################################### SECURITY
|
169
|
+
|
170
|
+
# The key used to sign this gem. See Gem::Security for details.
|
171
|
+
#
|
172
|
+
# s.signing_key = nil
|
173
|
+
|
174
|
+
# The certificate chain used to sign this gem. See Gem::Security for
|
175
|
+
# details.
|
176
|
+
#
|
177
|
+
# s.cert_chain = []
|
178
|
+
|
179
|
+
################################################################### RDOC
|
180
|
+
|
181
|
+
# An ARGV style array of options to RDoc
|
182
|
+
#
|
183
|
+
# See 'rdoc --help' about this
|
184
|
+
#
|
185
|
+
s.rdoc_options = []
|
186
|
+
|
187
|
+
# Extra files to add to RDoc such as README
|
188
|
+
#
|
189
|
+
s.extra_rdoc_files = Dir["README.md"] + Dir["CHANGELOG.md"] + Dir["LICENCE.md"]
|
190
|
+
|
191
|
+
end
|
data/gisele.noespec
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
template-info:
|
2
|
+
name: "ruby"
|
3
|
+
version: 1.7.0
|
4
|
+
links:
|
5
|
+
source: https://github.com/blambeau/noe
|
6
|
+
manifest:
|
7
|
+
spec/test___lower__.rb:
|
8
|
+
ignore: true
|
9
|
+
variables:
|
10
|
+
lower:
|
11
|
+
gisele
|
12
|
+
upper:
|
13
|
+
Gisele
|
14
|
+
version:
|
15
|
+
0.0.1
|
16
|
+
summary: |-
|
17
|
+
Gisele is a Process Analyzer Toolset
|
18
|
+
description: |-
|
19
|
+
This is a fresh-new implementation of the process analysis techniques
|
20
|
+
developed in the Gisele and PIPAS research projects at UCLouvain
|
21
|
+
|
22
|
+
# Authors of the project (- {name: Bob, email: bob@gmail.com}, ...)
|
23
|
+
authors:
|
24
|
+
- {name: Bernard Lambeau, email: blambeau@gmail.com}
|
25
|
+
links:
|
26
|
+
- https://github.com/blambeau/gisele
|
27
|
+
dependencies:
|
28
|
+
- {name: citrus, version: "~> 2.4", groups: [runtime]}
|
29
|
+
- {name: epath, version: "~> 0.0.1", groups: [runtime]}
|
30
|
+
- {name: quickl, version: "~> 0.4.3", groups: [runtime]}
|
31
|
+
- {name: awesome_print, version: "~> 1.0", groups: [runtime]}
|
32
|
+
#
|
33
|
+
- {name: rake, version: "~> 0.9.2", groups: [development]}
|
34
|
+
- {name: bundler, version: "~> 1.0", groups: [development]}
|
35
|
+
- {name: rspec, version: "~> 2.8.0", groups: [development]}
|
36
|
+
- {name: wlang, version: "~> 0.10.2", groups: [development]}
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'gisele'
|
2
|
+
module Gisele
|
3
|
+
#
|
4
|
+
# Gisele - A Process Analyzer Toolset
|
5
|
+
#
|
6
|
+
# SYNOPSIS
|
7
|
+
# gisele [--version] [--help]
|
8
|
+
# gisele [--ast] PROCESS_FILE
|
9
|
+
#
|
10
|
+
# OPTIONS
|
11
|
+
# #{summarized_options}
|
12
|
+
#
|
13
|
+
# DESCRIPTION
|
14
|
+
# The Gisele process analyzer toolset provides tools and technique to model and analyze
|
15
|
+
# complex process models such as care processes.
|
16
|
+
#
|
17
|
+
# When --ast is used, the command parses a process file and prints its Abstract Syntax
|
18
|
+
# Tree (AST) on standard output. By default, this option prints the AST for manual
|
19
|
+
# debugging, that is with colors and extra information. Use --ast=ruby to get a ruby
|
20
|
+
# array for automatic processing.
|
21
|
+
#
|
22
|
+
class Gisele::Command < Quickl::Command(__FILE__, __LINE__)
|
23
|
+
|
24
|
+
# Install options
|
25
|
+
options do |opt|
|
26
|
+
@ast = nil
|
27
|
+
opt.on('--ast=[MODE]', 'Prints the process abstract syntax tree (debug,ruby)') do |value|
|
28
|
+
@ast = (value || "debug").to_sym
|
29
|
+
end
|
30
|
+
opt.on_tail('--help', "Show this help message") do
|
31
|
+
raise Quickl::Help
|
32
|
+
end
|
33
|
+
opt.on_tail('--version', 'Show version and exit') do
|
34
|
+
raise Quickl::Exit, "gisele #{Gisele::VERSION} (c) The University of Louvain"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def execute(args)
|
39
|
+
raise Quickl::Help unless args.size == 1
|
40
|
+
|
41
|
+
unless (file = Path(args.first)).exist?
|
42
|
+
raise Quickl::IOAccessError, "File does not exists: #{file}"
|
43
|
+
end
|
44
|
+
|
45
|
+
parsed = Gisele::Language::Parser.parse(file)
|
46
|
+
print_ast(parsed, @ast) if @ast
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def print_ast(ast, option)
|
52
|
+
require 'awesome_print'
|
53
|
+
options = case option
|
54
|
+
when :ruby
|
55
|
+
{index: false, plain: true}
|
56
|
+
else
|
57
|
+
{}
|
58
|
+
end
|
59
|
+
ap ast, options
|
60
|
+
end
|
61
|
+
|
62
|
+
end # class Command
|
63
|
+
end # module Gisele
|