cauldron 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. data/Gemfile +6 -0
  2. data/Gemfile.lock +63 -0
  3. data/History.md +5 -0
  4. data/Rakefile +62 -16
  5. data/VERSION +1 -1
  6. data/cauldron.gemspec +463 -0
  7. data/cauldron/lib/cauldron.rb +1 -1
  8. data/features/cauldron_generates_runtime_method.feature +7 -4
  9. data/features/cauldron_generates_single_paramter_methods.feature +25 -0
  10. data/features/cauldron_interactive_start_terminal.feature +17 -0
  11. data/features/cauldron_quit_terminal.feature +9 -0
  12. data/features/cauldron_start_terminal.feature +0 -1
  13. data/features/step_definitions/cauldron_steps.rb +10 -5
  14. data/features/step_definitions/terminal_steps.rb +27 -0
  15. data/features/support/env.rb +2 -0
  16. data/features/support/hooks.rb +15 -0
  17. data/lib/Chain.rb +3 -3
  18. data/lib/Mapping.rb +1 -0
  19. data/lib/PartialChain.rb +253 -0
  20. data/lib/Theory.rb +28 -4
  21. data/lib/UnifiedChain.rb +94 -125
  22. data/lib/cauldron.rb +3 -0
  23. data/lib/cauldron/demos.rb +4 -4
  24. data/lib/cauldron/env.rb +1 -0
  25. data/lib/cauldron/pot.rb +42 -38
  26. data/lib/cauldron/terminal.rb +19 -3
  27. data/lib/cauldron/util/home.rb +21 -0
  28. data/lib/cauldron/util/saver.rb +45 -0
  29. data/lib/core/Container.rb +1 -1
  30. data/lib/core/runtime_method/ActsAsRuntimeMethod.rb +28 -28
  31. data/lib/core/runtime_method/RuntimeMethod.rb +6 -23
  32. data/lib/core/statement/ActsAsStatement.rb +0 -96
  33. data/lib/core/statement/BlockStatement.rb +1 -1
  34. data/lib/core/statement/OpenStatement.rb +1 -1
  35. data/lib/core/statement/Statement.rb +39 -94
  36. data/lib/core/statement/TheoryStatement.rb +1 -1
  37. data/lib/core/syntax/BlockContainer.rb +0 -28
  38. data/lib/core/variable/MethodParameter.rb +1 -1
  39. data/lib/required.rb +2 -14
  40. data/lib/theories.rb +0 -1
  41. data/lib/theory/ActionImplementation.rb +1 -1
  42. data/lib/theory/TheoryAction.rb +2 -2
  43. data/lib/theory/TheoryConnector.rb +11 -14
  44. data/lib/theory/TheoryImplementation.rb +10 -9
  45. data/lib/util/MethodWriter.rb +10 -10
  46. data/sandbox.rb +23 -0
  47. data/spec/cauldron/pot_spec.rb +62 -10
  48. data/spec/cauldron/runtime_method_spec.rb +31 -17
  49. data/spec/cauldron/saver_spec.rb +45 -0
  50. data/spec/cauldron/terminal_spec.rb +10 -1
  51. data/spec/cauldron/theory_spec.rb +4 -4
  52. data/spec/cauldron/unified_chain_spec.rb +38 -0
  53. data/spec/spec_helper.rb +3 -1
  54. data/tasks/development_tasks.rake +4 -0
  55. data/tasks/theory_tasks.rake +16 -20
  56. data/test/fixtures/theories/0/desc +6 -6
  57. data/test/fixtures/theories/0/dump +0 -0
  58. data/test/fixtures/theories/1/desc +7 -7
  59. data/test/fixtures/theories/1/dump +0 -0
  60. data/test/fixtures/theories/10/desc +13 -13
  61. data/test/fixtures/theories/10/dump +0 -0
  62. data/test/fixtures/theories/11/desc +10 -10
  63. data/test/fixtures/theories/11/dump +0 -0
  64. data/test/fixtures/theories/12/desc +9 -9
  65. data/test/fixtures/theories/12/dump +0 -0
  66. data/test/fixtures/theories/13/desc +16 -16
  67. data/test/fixtures/theories/13/dump +0 -0
  68. data/test/fixtures/theories/14/desc +16 -16
  69. data/test/fixtures/theories/14/dump +0 -0
  70. data/test/fixtures/theories/15/desc +10 -10
  71. data/test/fixtures/theories/15/dump +0 -0
  72. data/test/fixtures/theories/16/desc +10 -10
  73. data/test/fixtures/theories/16/dump +0 -0
  74. data/test/fixtures/theories/17/desc +7 -7
  75. data/test/fixtures/theories/17/dump +0 -0
  76. data/test/fixtures/theories/18/desc +7 -7
  77. data/test/fixtures/theories/18/dump +0 -0
  78. data/test/fixtures/theories/19/desc +7 -7
  79. data/test/fixtures/theories/19/dump +0 -0
  80. data/test/fixtures/theories/2/desc +6 -6
  81. data/test/fixtures/theories/2/dump +0 -0
  82. data/test/fixtures/theories/20/desc +13 -13
  83. data/test/fixtures/theories/20/dump +0 -0
  84. data/test/fixtures/theories/3/desc +7 -7
  85. data/test/fixtures/theories/3/dump +0 -0
  86. data/test/fixtures/theories/4/desc +7 -7
  87. data/test/fixtures/theories/4/dump +0 -0
  88. data/test/fixtures/theories/5/desc +6 -6
  89. data/test/fixtures/theories/5/dump +0 -0
  90. data/test/fixtures/theories/6/desc +7 -7
  91. data/test/fixtures/theories/6/dump +0 -0
  92. data/test/fixtures/theories/7/desc +7 -7
  93. data/test/fixtures/theories/7/dump +0 -0
  94. data/test/fixtures/theories/8/desc +7 -7
  95. data/test/fixtures/theories/8/dump +0 -0
  96. data/test/fixtures/theories/9/desc +16 -16
  97. data/test/fixtures/theories/9/dump +0 -0
  98. data/test/fixtures/theory_implementations/0/dump +0 -0
  99. data/test/fixtures/theory_implementations/2/dump +0 -0
  100. data/test/ts_complete.rb +1 -10
  101. data/test/unit/core/runtime_method/tc_realised_runtime_method.rb +1 -0
  102. data/test/unit/core/runtime_method/tc_runtime_method.rb +16 -39
  103. data/test/unit/core/statement/tc_block_statement.rb +3 -3
  104. data/test/unit/core/statement/tc_open_statement.rb +4 -4
  105. data/test/unit/core/statement/tc_statement.rb +2 -147
  106. data/test/unit/core/statement/tc_theory_statement.rb +1 -1
  107. data/test/unit/theory/tc_theory_dependent.rb +3 -3
  108. data/test/unit/theory/tc_theory_result.rb +5 -5
  109. data/test/unit/util/tc_method_validation.rb +45 -45
  110. data/test/unit/util/tc_parser.rb +1 -1
  111. data/test/unit/util/tc_string_to_theory.rb +2 -2
  112. metadata +74 -48
  113. data/lib/ScopeDependencies.rb +0 -8
  114. data/lib/core/statement/StatementDependencies.rb +0 -271
  115. data/lib/core/structure/DeclareNewInstanceStructure.rb +0 -49
  116. data/lib/core/structure/DeclareRuntimeMethodStructure.rb +0 -34
  117. data/lib/core/structure/DeclareVariableAsLiteralStructure.rb +0 -31
  118. data/lib/core/structure/DeclareVariableAsVariableStructure.rb +0 -52
  119. data/lib/core/structure/FixnumAdditionStructure.rb +0 -56
  120. data/lib/core/structure/InstanceCallContainerStructure.rb +0 -50
  121. data/lib/core/structure/InstanceCallStructure.rb +0 -53
  122. data/lib/core/structure/InstanceMethodCallStructure.rb +0 -21
  123. data/lib/core/structure/ReturnStructure.rb +0 -20
  124. data/lib/core/structure/StatementStructure.rb +0 -11
  125. data/test/unit/core/statement/tc_statement_dependencies.rb +0 -147
  126. data/test/unit/core/structure/tc_declare_new_instance_structure.rb +0 -41
  127. data/test/unit/core/structure/tc_declare_variable_as_literal_structure.rb +0 -41
  128. data/test/unit/core/structure/tc_declare_variable_as_variable_structure.rb +0 -66
  129. data/test/unit/core/structure/tc_instance_call_container_structure.rb +0 -41
  130. data/test/unit/core/structure/tc_return_structure.rb +0 -32
  131. data/test/unit/tc_instance_call_structure.rb +0 -35
  132. data/test/unit/tc_statement_structure_2.rb +0 -43
@@ -9,6 +9,14 @@ module Cauldron
9
9
 
10
10
  def initialize(output,auto=true)
11
11
  @output, @cases, @auto = output, [], auto
12
+
13
+ # Create a logger for the user inputs
14
+ #file = File.open('user-input.log', File::WRONLY | File::APPEND)
15
+ file = File.open('user-input.log', 'w+')
16
+ # To create new (and to remove old) logfile, add File::CREAT like;
17
+ # file = open('foo.log', File::WRONLY | File::APPEND | File::CREAT)
18
+ @user_logger = Logger.new(file)
19
+
12
20
  end
13
21
 
14
22
  def start
@@ -26,21 +34,29 @@ module Cauldron
26
34
  @output.puts "input,input,output"
27
35
  @output.puts "For example "
28
36
  @output.puts "'fish','animal'"
29
- @output.puts "'cat','animal'"
30
37
  @output.puts "'carrot','vegtable'"
31
38
  @output.puts "and when you're done just type RUN"
32
-
39
+
33
40
  # Wait for the user's inputs
34
41
  unless @auto
35
42
  loop do
36
43
  submit gets
37
44
  end
38
45
  end
46
+
39
47
  end
40
48
 
41
49
  def submit(input)
50
+
51
+ @user_logger.info input
52
+
42
53
  if input =~ /^RUN$/
43
- @output.puts @pot.brew(@cases).reset_ids!.basic_write
54
+ @output.puts @pot.brew(@cases).reset_ids!.basic_write
55
+ elsif input =~ /^QUIT$/
56
+ # => TODO Include 'bye' output too
57
+ #Process.exit!(true)
58
+ at_exit {0}
59
+ exit
44
60
  else
45
61
  @cases << convert_to_example(separate_values(input))
46
62
  end
@@ -0,0 +1,21 @@
1
+ module Cauldron
2
+
3
+ module Util
4
+
5
+ module Home
6
+
7
+ private
8
+
9
+ # Check that the home directory exists
10
+ def home
11
+ realHome = ["HOME", "HOMEPATH"].detect {|h| ENV[h] != nil}
12
+ if not realHome
13
+ StandardLogger.instance.warning "Couldn't detect a home directory"
14
+ end
15
+ return ENV[realHome]
16
+ end
17
+
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,45 @@
1
+ module Cauldron::Util::Saver
2
+
3
+ def self.save(obj)
4
+ dir_path = FileUtils.mkdir(next_directory).first
5
+ begin
6
+ dump_file_path = File.join(dir_path,'dump')
7
+ dump_file = File.open(dump_file_path,'w+')
8
+ data = Marshal.dump(obj)
9
+ dump_file << data
10
+ return dump_file_path
11
+ ensure
12
+ dump_file.close
13
+ end
14
+ end
15
+
16
+ def self.debug_directory
17
+ # the home directory code is duplicated
18
+ realHome = ["HOME", "HOMEPATH"].detect {|h| ENV[h] != nil}
19
+ if not realHome
20
+ StandardLogger.instance.warning "Couldn't detect a home directory"
21
+ end
22
+ return File.join(ENV[realHome],'cauldron','debug')
23
+ end
24
+
25
+ def self.next_directory
26
+ FileUtils.mkdir(debug_directory) unless File.exists?(debug_directory)
27
+ highest_integer = 0
28
+ Dir.glob(File.join(debug_directory,'*')).each do |filename|
29
+ if filename.match(/(\d+)/)
30
+ highest_integer = $1.to_i if $1.to_i > highest_integer
31
+ end
32
+ end
33
+ return File.join(debug_directory,(highest_integer + 1).to_s)
34
+ end
35
+
36
+ def self.load(id)
37
+ Dir.glob(File.join(debug_directory,'*')).each do |filename|
38
+ if m = filename.match(/(\d+)/) and m[0].to_i == id
39
+ dump_file = File.open(File.join(filename,'dump'),'r')
40
+ return Marshal.load(dump_file.read)
41
+ end
42
+ end
43
+ end
44
+
45
+ end
@@ -30,7 +30,7 @@ class Container
30
30
 
31
31
  def write(tab=0)
32
32
  line = '('
33
- tab.times {line += "\t" }
33
+ tab.times {line += " " }
34
34
  @tokens.each do |code|
35
35
  line += code.write
36
36
  break if code.object_id == @tokens.last.object_id
@@ -91,15 +91,15 @@ module ActsAsRuntimeMethod
91
91
  raise StandardError.new('Incorrect use of write ') if params.kind_of?(Fixnum)
92
92
 
93
93
  line = "\n"
94
- tab.times {|x| line += "\t" }
94
+ tab.times {|x| line += " " }
95
95
  line += "#\n"
96
96
 
97
97
  if params.nil?
98
98
 
99
99
  @usage.each_with_index do |var,i|
100
100
 
101
- tab.times {|x| line += "\t" }
102
- line += "#\t@param\t"
101
+ tab.times {|x| line += " " }
102
+ line += "# @param "
103
103
 
104
104
  # Get a description of the requirements (this can multiple lines)
105
105
  line_prefix = ''
@@ -108,8 +108,8 @@ module ActsAsRuntimeMethod
108
108
  line += line_prefix+l
109
109
 
110
110
  # Assides the first line pre-fix a "# " to the start
111
- (tab-1).times {|x| line += "\t" }
112
- line_prefix = "#\t\t\t"
111
+ (tab-1).times {|x| line += " " }
112
+ line_prefix = "# "
113
113
 
114
114
  end
115
115
 
@@ -118,8 +118,8 @@ module ActsAsRuntimeMethod
118
118
  else
119
119
 
120
120
  params.each_with_index do |var,i|
121
- tab.times {|x| line += "\t" }
122
- line += "#\t@param\t"
121
+ tab.times {|x| line += " " }
122
+ line += "# @param "
123
123
 
124
124
  # Get a description of the requirements (this can multiple lines)
125
125
  line_prefix = ''
@@ -129,8 +129,8 @@ module ActsAsRuntimeMethod
129
129
  line += line_prefix+l
130
130
 
131
131
  # Assides the first line pre-fix a "# " to the start
132
- (tab-1).times {|x| line += "\t" }
133
- line_prefix = "#\t\t\t"
132
+ (tab-1).times {|x| line += " " }
133
+ line_prefix = "# "
134
134
 
135
135
  end
136
136
 
@@ -140,16 +140,16 @@ module ActsAsRuntimeMethod
140
140
 
141
141
  # Add some some additional comment if supplied
142
142
  unless additional_comments.nil?
143
- tab.times {|x| line += "\t" }
143
+ tab.times {|x| line += " " }
144
144
  line += "#"
145
- tab.times {|x| line += "\t" }
145
+ tab.times {|x| line += " " }
146
146
  line += additional_comments+"\n"
147
147
  end
148
148
 
149
- tab.times {|x| line += "\t" }
149
+ tab.times {|x| line += " " }
150
150
  line += "#\n"
151
151
 
152
- tab.times {|x| line += "\t"}
152
+ tab.times {|x| line += " "}
153
153
  line += basic_write(tab)
154
154
 
155
155
  end
@@ -168,7 +168,7 @@ module ActsAsRuntimeMethod
168
168
  end
169
169
 
170
170
  # Close the method
171
- tab.times {|x| line += "\t" }
171
+ tab.times {|x| line += " " }
172
172
  line += "end"+"\n"
173
173
 
174
174
  return line
@@ -185,15 +185,15 @@ module ActsAsRuntimeMethod
185
185
  raise StandardError.new('Incorrect use of write ') if params.kind_of?(Fixnum)
186
186
 
187
187
  line = "\n"
188
- tab.times {|x| line += "\t" }
188
+ tab.times {|x| line += " " }
189
189
  line += "#\n"
190
190
 
191
191
  if params.nil?
192
192
 
193
193
  @usage.each_with_index do |var,i|
194
194
 
195
- tab.times {|x| line += "\t" }
196
- line += "#\t@param\t"
195
+ tab.times {|x| line += " " }
196
+ line += "# @param "
197
197
 
198
198
  # Get a description of the requirements (this can multiple lines)
199
199
  line_prefix = ''
@@ -202,8 +202,8 @@ module ActsAsRuntimeMethod
202
202
  line += line_prefix+l
203
203
 
204
204
  # Assides the first line pre-fix a "# " to the start
205
- (tab-1).times {|x| line += "\t" }
206
- line_prefix = "#\t\t\t"
205
+ (tab-1).times {|x| line += " " }
206
+ line_prefix = "# "
207
207
 
208
208
  end
209
209
 
@@ -212,8 +212,8 @@ module ActsAsRuntimeMethod
212
212
  else
213
213
 
214
214
  params.each_with_index do |var,i|
215
- tab.times {|x| line += "\t" }
216
- line += "#\t@param\t"
215
+ tab.times {|x| line += " " }
216
+ line += "# @param "
217
217
 
218
218
  # Get a description of the requirements (this can multiple lines)
219
219
  line_prefix = ''
@@ -223,8 +223,8 @@ module ActsAsRuntimeMethod
223
223
  line += line_prefix+l
224
224
 
225
225
  # Assides the first line pre-fix a "# " to the start
226
- (tab-1).times {|x| line += "\t" }
227
- line_prefix = "#\t\t\t"
226
+ (tab-1).times {|x| line += " " }
227
+ line_prefix = "# "
228
228
 
229
229
  end
230
230
 
@@ -234,16 +234,16 @@ module ActsAsRuntimeMethod
234
234
 
235
235
  # Add some some additional comment if supplied
236
236
  unless additional_comments.nil?
237
- tab.times {|x| line += "\t" }
237
+ tab.times {|x| line += " " }
238
238
  line += "#"
239
- tab.times {|x| line += "\t" }
239
+ tab.times {|x| line += " " }
240
240
  line += additional_comments+"\n"
241
241
  end
242
242
 
243
- tab.times {|x| line += "\t" }
243
+ tab.times {|x| line += " " }
244
244
  line += "#\n"
245
245
 
246
- tab.times {|x| line += "\t"}
246
+ tab.times {|x| line += " "}
247
247
  line += 'def '+method_name
248
248
 
249
249
  #line += write_params(@parameters)
@@ -257,7 +257,7 @@ module ActsAsRuntimeMethod
257
257
  line += "\n" if self.empty?
258
258
 
259
259
  # Close the method
260
- tab.times {|x| line += "\t" }
260
+ tab.times {|x| line += " " }
261
261
  line += "end"+"\n"
262
262
 
263
263
  return line
@@ -1,4 +1,3 @@
1
- require "set"
2
1
  # This class represents the code of a method generated at runitme
3
2
  #
4
3
  # This a variation on code set that contains usage and a return
@@ -68,21 +67,6 @@ class RuntimeMethod < StatementGroup
68
67
  @method_id = id
69
68
  end
70
69
 
71
- # Returns a declaration instance for this particular runtime
72
- # method. The declaration doesn't contain any of the internally
73
- # generated statements.
74
- #
75
- # TODO Write tests on this with more variables and statements
76
- #
77
- def to_declaration
78
- return VariableDeclaration.new(
79
- self.class.to_s,
80
- @usage.to_declaration,
81
- @method_return.to_declaration,
82
- *self.collect {|x| x.to_declaration}
83
- )
84
- end
85
-
86
70
  def reset_ids!
87
71
  copied_method = copy
88
72
  copied_method.method_id = '0'
@@ -391,8 +375,6 @@ class RuntimeMethod < StatementGroup
391
375
  # Returns a describtion of the method and the variables
392
376
  # within it.
393
377
  #
394
- # TODO Write test for this method
395
- #
396
378
  def describe
397
379
  line = write+"\n"
398
380
  available_variables.each do |var|
@@ -661,7 +643,8 @@ class RuntimeMethod < StatementGroup
661
643
  if x.kind_of?(Statement)
662
644
 
663
645
  # Update the ids of the variables used in the statement to use the ids of the method usage
664
- duplicated_statement = x.exchange_variables(id_conversion)
646
+ #duplicated_statement = x.exchange_variables(id_conversion)
647
+ duplicated_statement = x.copy
665
648
  variable_values = abstract_variables_for_tracking(duplicated_statement)
666
649
  copied.push(duplicated_statement)
667
650
  copied.push(
@@ -738,13 +721,12 @@ class RuntimeMethod < StatementGroup
738
721
  # array of literal values.
739
722
  #
740
723
  def realise2(params,additional_methods=[])
741
-
724
+
742
725
  # TEMP
743
726
  if(params.any? {|x| x.kind_of?(Variable)})
744
727
  raise StandardError.new('Currently only literal values can be realised')
745
728
  end
746
729
 
747
- # TODO Is KnownVariable a better name than LiteralVariable
748
730
  # Convert the passed paramters into literal variables with the appropriate ids
749
731
  unless usage.length == params.length
750
732
  raise StandardError.new('This method expects '+usage.length.to_s+' param(s) but '+params.length.to_s+' were passed')
@@ -772,13 +754,14 @@ class RuntimeMethod < StatementGroup
772
754
  # Go through each statement and substitue any of the variables
773
755
  # for those in the history object
774
756
  self.each do |x|
757
+
775
758
  if x.realised?
776
759
  realised_runtime_method.push(x)
777
760
  next
778
761
  end
779
762
 
780
763
  # Handle nested and single statements differently
781
- if(x.kind_of?(Statement))
764
+ if(x.kind_of?(Statement))
782
765
  realised_statement = x.realise2(past)
783
766
  realised_runtime_method.push(realised_statement)
784
767
  elsif(x.kind_of?(BlockStatement))
@@ -811,7 +794,7 @@ class RuntimeMethod < StatementGroup
811
794
 
812
795
  realised_runtime_method.close
813
796
  return realised_runtime_method
814
-
797
+
815
798
  end
816
799
 
817
800
  def cauldron_method_calls
@@ -3,16 +3,6 @@
3
3
  #
4
4
  module ActsAsStatement
5
5
 
6
- # TODO I think I should start to fade out statement_type - I should start by finding calls where it
7
- # is needed.
8
- def statement_type
9
- if @statement_type.nil?
10
- @statement_type = identify_statement_type
11
- end
12
- raise UnknownStatementType.new('No statement type has been defined for this statement "'+self.write+'" ['+self.class.to_s+']') if @statement_type.nil?
13
- return @statement_type
14
- end
15
-
16
6
  # Returns true if the statement (treated as an array) has all the
17
7
  # same classes as the array supplied.
18
8
  #
@@ -25,92 +15,6 @@ module ActsAsStatement
25
15
  return false unless x.instance_of?(y)
26
16
  end
27
17
  return true
28
- end
29
-
30
- protected
31
-
32
- # Attempts to identify the type of statement this is by its contents.
33
- #
34
- def identify_statement_type
35
- case self.length
36
- when 0
37
- return StatementStructure::BLANK_STATEMENT
38
- when 1
39
- return StatementStructure::IF_STATEMENT if first.kind_of?(If)
40
- #return StatementStructure::USAGE_STATEMENT if self.classes_match?(InstanceCallContainer)
41
- if self.classes_match?(InstanceCallContainer)
42
- if first.method_call.destructive?
43
- return StatementStructure::MODIFYING_STATEMENT
44
- else
45
- return StatementStructure::USAGE_STATEMENT
46
- end
47
- end
48
- # TODO Not sure if this should be a usage_statement
49
- return StatementStructure::USAGE_STATEMENT if self.classes_match?(DefCall)
50
-
51
- when 2
52
- return StatementStructure::RETURN_STATEMENT if first.kind_of?(Return)
53
- when 3
54
- # TODO This should distinguish between modifying statements e.g. chop! and push
55
- # var = var.chop
56
- return StatementStructure::DECLARATION_STATEMENT if self.classes_match?(Unknown,Equal,InstanceCallContainer)
57
- return StatementStructure::DECLARATION_STATEMENT if self.classes_match?(Unknown,Equal,ClassMethodCallContainer)
58
- # TODO Is there a difference between a Literal and a LiteralDeclaration
59
- return StatementStructure::DECLARATION_STATEMENT if self.classes_match?(Unknown,Equal,Literal)
60
- return StatementStructure::DECLARATION_STATEMENT if self.classes_match?(Unknown,Equal,StringVariable)
61
- return StatementStructure::DECLARATION_STATEMENT if self.classes_match?(Unknown,Equal,ArrayVariable)
62
- return StatementStructure::DECLARATION_STATEMENT if self.classes_match?(Unknown,Equal,FixnumVariable)
63
- return StatementStructure::DECLARATION_STATEMENT if self.classes_match?(Unknown,Equal,StatementVariable)
64
- return StatementStructure::DECLARATION_STATEMENT if self.classes_match?(Unknown,Equal,RuntimeMethodParameter)
65
- return StatementStructure::DECLARATION_STATEMENT if self.classes_match?(Unknown,Equal,LiteralDeclaration)
66
- return StatementStructure::DECLARATION_STATEMENT if self.classes_match?(Unknown,Equal,NilVariable)
67
- return StatementStructure::DECLARATION_STATEMENT if self.classes_match?(Unknown,Equal,DefCall)
68
- return StatementStructure::DECLARATION_STATEMENT if self.classes_match?(Unknown,Equal,Fixnum)
69
- return StatementStructure::DECLARATION_STATEMENT if self.classes_match?(Unknown,Equal,UnknownVariable)
70
- return StatementStructure::DECLARATION_STATEMENT if self.classes_match?(StringVariable,Equal,Literal)
71
- return StatementStructure::DECLARATION_STATEMENT if self.classes_match?(StringVariable,Equal,LiteralDeclaration)
72
- return StatementStructure::DECLARATION_STATEMENT if self.classes_match?(StringVariable,Equal,DefCall)
73
- return StatementStructure::DECLARATION_STATEMENT if self.classes_match?(StringVariable,Equal,ArrayAccess)
74
- return StatementStructure::DECLARATION_STATEMENT if self.classes_match?(FixnumVariable,Equal,InstanceCallContainer)
75
- return StatementStructure::DECLARATION_STATEMENT if self.classes_match?(FixnumVariable,Equal,Literal)
76
- return StatementStructure::DECLARATION_STATEMENT if self.classes_match?(FixnumVariable,Equal,DefCall)
77
- return StatementStructure::DECLARATION_STATEMENT if self.classes_match?(ArrayVariable,Equal,Literal)
78
- return StatementStructure::DECLARATION_STATEMENT if self.classes_match?(ArrayVariable,Equal,DefCall)
79
- return StatementStructure::DECLARATION_STATEMENT if self.classes_match?(StatementVariable,Equal,DefCall)
80
- return StatementStructure::DECLARATION_STATEMENT if self.classes_match?(VariableContainer,Equal,Literal)
81
- # TODO I don't know if this should be possible/allowed
82
- return StatementStructure::DECLARATION_STATEMENT if self.classes_match?(Unknown,Equal,Unknown)
83
- # TODO I'm not sure whether ArrayAccess should be USAGE_STATEMENT
84
- return StatementStructure::DECLARATION_STATEMENT if self.classes_match?(Unknown,Equal,ArrayAccess)
85
- return StatementStructure::DECLARATION_STATEMENT if self.classes_match?(StringVariable,Equal,InstanceCallContainer)
86
- return StatementStructure::DECLARATION_STATEMENT if self.classes_match?(MethodUsageVariable,Equal,ClassMethodCallContainer)
87
- return StatementStructure::DECLARATION_STATEMENT if self.classes_match?(StatementVariable,Equal,ClassMethodCallContainer)
88
- return StatementStructure::DECLARATION_STATEMENT if self.classes_match?(RuntimeMethodParameter,Equal,DefCall)
89
- return StatementStructure::DECLARATION_STATEMENT if self.classes_match?(UnknownVariable,Equal,InstanceCallContainer)
90
- return StatementStructure::DECLARATION_STATEMENT if self.classes_match?(RuntimeMethodParameter,Equal,ClassMethodCallContainer)
91
- when 5
92
- if self.classes_match?(Unknown,Equal,Unknown,Addition,Unknown)
93
- return StatementStructure::DECLARATION_STATEMENT
94
- end
95
- if self.classes_match?(Unknown,Equal,Unknown,Subtract,Unknown)
96
- return StatementStructure::DECLARATION_STATEMENT
97
- end
98
- if self.classes_match?(Unknown,Equal,FixnumVariable,Addition,FixnumVariable)
99
- return StatementStructure::DECLARATION_STATEMENT
100
- end
101
- if self.classes_match?(Unknown,Equal,InstanceCallContainer,Addition,InstanceCallContainer )
102
- return StatementStructure::DECLARATION_STATEMENT
103
- end
104
- if self.classes_match?(Unknown,Equal,MethodParameter,Addition,MethodParameter )
105
- return StatementStructure::DECLARATION_STATEMENT
106
- end
107
- return StatementStructure::DECLARATION_STATEMENT if self.classes_match?(Unknown,Equal,StringVariable,Addition,StringVariable)
108
- # TODO I don't know if I want this classed as a declaration statement since it might be replacing the
109
- # value of a variable.
110
- return StatementStructure::DECLARATION_STATEMENT if self.classes_match?(FixnumVariable,Equal,FixnumVariable,Addition,FixnumVariable)
111
- end
112
-
113
- raise StandardError.new('Unable to determine statement type for "'+self.write+'"'+self.inject('') {|x,y| x += y.class.to_s+' : ' })
114
18
  end
115
19
 
116
20
  end