kuniri 0.0.1 → 0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +9 -7
- data/COPYING +160 -656
- data/Gemfile +4 -3
- data/README.md +57 -27
- data/Rakefile +3 -1
- data/bin/kuniri +50 -26
- data/data/aggregation_lang.rb +33 -0
- data/data/attribute_lang.rb +14 -87
- data/data/class_lang.rb +19 -41
- data/data/comment_lang.rb +52 -0
- data/data/conditional_lang.rb +14 -41
- data/data/constructor_lang.rb +4 -12
- data/data/end_block_lang.rb +7 -6
- data/data/extern_requirement_lang.rb +10 -17
- data/data/function_behavior_lang.rb +17 -66
- data/data/global_function_lang.rb +26 -0
- data/data/lang_syntax.rb +82 -49
- data/data/method_lang.rb +26 -0
- data/data/module_namespace_lang.rb +8 -13
- data/data/repetition_lang.rb +19 -32
- data/data/token_lang.rb +2 -44
- data/data/variable_behaviour_lang.rb +43 -0
- data/data/variable_global_lang.rb +13 -72
- data/kuniri.gemspec +4 -4
- data/lib/kuniri/core/configuration/language_available.rb +2 -2
- data/lib/kuniri/core/kuniri.rb +32 -24
- data/lib/kuniri/core/setting.rb +51 -85
- data/lib/kuniri/error/parser_error.rb +9 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/aggregation.rb +29 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/attribute.rb +0 -40
- data/lib/kuniri/language/abstract_container/structured_and_oo/global_tokens.rb +20 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/repetition.rb +9 -1
- data/lib/kuniri/language/abstract_container/structured_and_oo/variable_global.rb +0 -35
- data/lib/kuniri/language/container_data/structured_and_oo/aggregation_data.rb +23 -0
- data/lib/kuniri/language/container_data/structured_and_oo/attribute_data.rb +4 -2
- data/lib/kuniri/language/container_data/structured_and_oo/basic_structure.rb +24 -0
- data/lib/kuniri/language/container_data/structured_and_oo/class_data.rb +13 -19
- data/lib/kuniri/language/container_data/structured_and_oo/conditional_data.rb +2 -13
- data/lib/kuniri/language/container_data/structured_and_oo/constructor_data.rb +2 -0
- data/lib/kuniri/language/container_data/structured_and_oo/extern_requirement_data.rb +11 -6
- data/lib/kuniri/language/container_data/structured_and_oo/{file_element.rb → file_element_data.rb} +11 -9
- data/lib/kuniri/language/container_data/structured_and_oo/function_abstract.rb +58 -11
- data/lib/kuniri/language/container_data/structured_and_oo/function_data.rb +3 -3
- data/lib/kuniri/language/container_data/structured_and_oo/manager_basic_structure_data.rb +55 -0
- data/lib/kuniri/language/container_data/structured_and_oo/method_data.rb +5 -4
- data/lib/kuniri/language/container_data/structured_and_oo/module_namespace_data.rb +3 -1
- data/lib/kuniri/language/container_data/structured_and_oo/repetition_data.rb +2 -13
- data/lib/kuniri/language/container_data/structured_and_oo/variable_global_data.rb +2 -0
- data/lib/kuniri/language/language.rb +37 -11
- data/lib/kuniri/language/metadata.rb +29 -0
- data/lib/kuniri/language/ruby/aggregation_ruby.rb +37 -0
- data/lib/kuniri/language/ruby/attribute_ruby.rb +23 -38
- data/lib/kuniri/language/ruby/class_ruby.rb +2 -10
- data/lib/kuniri/language/ruby/conditional_ruby.rb +20 -6
- data/lib/kuniri/language/ruby/constructor_ruby.rb +5 -7
- data/lib/kuniri/language/ruby/end_block_ruby.rb +1 -1
- data/lib/kuniri/language/ruby/function_behavior_ruby.rb +1 -9
- data/lib/kuniri/language/ruby/global_function_ruby.rb +32 -0
- data/lib/kuniri/language/ruby/method_ruby.rb +33 -0
- data/lib/kuniri/language/ruby/repetition_ruby.rb +60 -14
- data/lib/kuniri/language/ruby/ruby_syntax.rb +76 -49
- data/lib/kuniri/parser/output_factory.rb +29 -0
- data/lib/kuniri/parser/output_format.rb +134 -0
- data/lib/kuniri/parser/parser.rb +3 -7
- data/lib/kuniri/parser/xml_builder_engine.rb +94 -0
- data/lib/kuniri/parser/xml_output_format.rb +143 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/aggregation_state.rb +45 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/attribute_state.rb +0 -1
- data/lib/kuniri/state_machine/OO_structured_fsm/basic_structure_state.rb +182 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/class_state.rb +12 -3
- data/lib/kuniri/state_machine/OO_structured_fsm/conditional_state.rb +11 -68
- data/lib/kuniri/state_machine/OO_structured_fsm/constructor_state.rb +7 -52
- data/lib/kuniri/state_machine/OO_structured_fsm/function_behaviour_state.rb +86 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/include_state.rb +2 -3
- data/lib/kuniri/state_machine/OO_structured_fsm/method_state.rb +8 -50
- data/lib/kuniri/state_machine/OO_structured_fsm/oo_structured_state.rb +6 -1
- data/lib/kuniri/state_machine/OO_structured_fsm/repetition_state.rb +10 -59
- data/lib/kuniri/state_machine/OO_structured_fsm/token_state_machine.rb +4 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/variable_state.rb +0 -1
- data/lib/kuniri/version.rb +1 -1
- data/other/analyseFile.asta +0 -0
- data/spec/core/kuniri_spec.rb +2 -1
- data/spec/core/setting_spec.rb +35 -61
- data/spec/language/abstract_container/aggregation_spec.rb +13 -0
- data/spec/language/abstract_container/extern_requirement_spec.rb +13 -0
- data/spec/language/container_data/structured_and_oo/aggregation_data_spec.rb +29 -0
- data/spec/language/container_data/structured_and_oo/attribute_data_spec.rb +9 -2
- data/spec/language/container_data/structured_and_oo/class_data_spec.rb +1 -46
- data/spec/language/container_data/structured_and_oo/constructor_data_spec.rb +32 -2
- data/spec/language/container_data/structured_and_oo/extern_requirement_data_spec.rb +31 -7
- data/spec/language/container_data/structured_and_oo/{file_element_spec.rb → file_element_data_spec.rb} +21 -5
- data/spec/language/container_data/structured_and_oo/function_abstract_spec.rb +213 -0
- data/spec/language/container_data/structured_and_oo/function_data_spec.rb +31 -2
- data/spec/language/container_data/structured_and_oo/manager_basic_structure_data_spec.rb +150 -0
- data/spec/language/container_data/structured_and_oo/method_data_spec.rb +80 -0
- data/spec/language/container_data/structured_and_oo/module_namespace_spec.rb +7 -1
- data/spec/language/container_data/structured_and_oo/variable_global_data_spec.rb +9 -0
- data/spec/language/language_factory_spec.rb +1 -1
- data/spec/language/language_spec.rb +46 -9
- data/spec/language/ruby/aggregation_ruby_spec.rb +80 -0
- data/spec/language/ruby/class_ruby_spec.rb +66 -6
- data/spec/language/ruby/constructor_ruby_spec.rb +1 -1
- data/spec/language/ruby/end_block_ruby_spec.rb +11 -0
- data/spec/language/ruby/extern_requirement_ruby_spec.rb +59 -0
- data/spec/language/ruby/function_behavior_ruby_spec.rb +54 -2
- data/spec/language/ruby/global_test/.kuniri.yml +4 -0
- data/spec/language/ruby/global_test/complete_class_ruby_spec.rb +161 -0
- data/spec/language/ruby/global_test/conditional/.kuniri.yml +4 -0
- data/spec/language/ruby/global_test/conditional/.kuniri1.yml +4 -0
- data/spec/language/ruby/global_test/conditional/.kuniri2.yml +4 -0
- data/spec/language/ruby/global_test/conditional/.kuniri3.yml +4 -0
- data/spec/language/ruby/global_test/conditional/.kuniri4.yml +4 -0
- data/spec/language/ruby/global_test/conditional/.kuniri5.yml +4 -0
- data/spec/language/ruby/global_test/conditional/.kuniri6.yml +4 -0
- data/spec/language/ruby/global_test/conditional/a_lot_of_conditionals_spec.rb +92 -0
- data/spec/language/ruby/global_test/conditional/constructor_very_mix_conditional_spec.rb +105 -0
- data/spec/language/ruby/global_test/conditional/function_with_conditional_spec.rb +94 -0
- data/spec/language/ruby/global_test/conditional/function_with_nested_conditional_spec.rb +56 -0
- data/spec/language/ruby/global_test/conditional/method_very_mix_conditional_spec.rb +109 -0
- data/spec/language/ruby/global_test/conditional/very_deep_conditional_structure_spec.rb +61 -0
- data/spec/language/ruby/global_test/conditional/very_mix_conditional_spec.rb +105 -0
- data/spec/language/ruby/global_test/conditionalAndRepetition/.kuniri.yml +4 -0
- data/spec/language/ruby/global_test/conditionalAndRepetition/mix_conditional_repetition_spec.rb +57 -0
- data/spec/language/ruby/global_test/repetition/.kuniri.yml +4 -0
- data/spec/language/ruby/global_test/repetition/.kuniri2.yml +4 -0
- data/spec/language/ruby/global_test/repetition/.kuniri3.yml +4 -0
- data/spec/language/ruby/global_test/repetition/.kuniri4.yml +4 -0
- data/spec/language/ruby/global_test/repetition/.kuniri5.yml +4 -0
- data/spec/language/ruby/global_test/repetition/.kuniri6.yml +4 -0
- data/spec/language/ruby/global_test/repetition/.kuniri7.yml +4 -0
- data/spec/language/ruby/global_test/repetition/.kuniri8.yml +4 -0
- data/spec/language/ruby/global_test/repetition/complete_class_integrity.rb +41 -0
- data/spec/language/ruby/global_test/repetition/complete_class_until_loop_spec.rb +42 -0
- data/spec/language/ruby/global_test/repetition/complete_class_while_loop_spec.rb +41 -0
- data/spec/language/ruby/global_test/repetition/complete_class_with_repetition_spec.rb +42 -0
- data/spec/language/ruby/global_test/repetition/constructor_with_mix_repetition_spec.rb +57 -0
- data/spec/language/ruby/global_test/repetition/method_with_mix_repetition_spec.rb +59 -0
- data/spec/language/ruby/global_test/repetition/very_mix_repetition_spec.rb +61 -0
- data/spec/language/ruby/global_test/repetition/very_nested_repetition_spec.rb +65 -0
- data/spec/language/ruby/method_ruby_spec.rb +52 -0
- data/spec/language/ruby/repetition_ruby_spec.rb +175 -8
- data/spec/language/ruby/ruby_syntax_spec.rb +213 -84
- data/spec/parser/output_factory_spec.rb +32 -0
- data/spec/parser/output_format_spec.rb +83 -0
- data/spec/parser/parser_spec.rb +7 -0
- data/spec/parser/xmlSchemaValidate/.kuniri1.yml +3 -0
- data/spec/parser/xmlSchemaValidate/.kuniri2.yml +3 -0
- data/spec/parser/xmlSchemaValidate/.kuniri3.yml +3 -0
- data/spec/parser/xmlSchemaValidate/class_data.xsd +99 -0
- data/spec/parser/xmlSchemaValidate/fullCodeTwo.xsd +119 -0
- data/spec/parser/xmlSchemaValidate/fullCodeWithComments.xsd +146 -0
- data/spec/parser/xmlSchemaValidate/simpleFunction.xsd +25 -0
- data/spec/parser/xmlSchemaValidate/validate_xml_spec.rb +52 -0
- data/spec/parser/xml_builder_engine_spec.rb +258 -0
- data/spec/parser/xml_output_format_spec.rb +274 -0
- data/spec/samples/rubySyntaxParts/aggregation/classAggregation.rb +37 -0
- data/spec/samples/rubySyntaxParts/aggregation/constructorAggregation.rb +36 -0
- data/spec/samples/rubySyntaxParts/aggregation/methodAggregation.rb +36 -0
- data/spec/samples/rubySyntaxParts/aggregation/multipleAggregation.rb +59 -0
- data/spec/samples/rubySyntaxParts/comment/simple_multiple_line_comment_class.rb +7 -0
- data/spec/samples/rubySyntaxParts/comment/simple_single_line_comment_class.rb +2 -1
- data/spec/samples/rubySyntaxParts/conditionalStatment/aLotOfConditionals.rb +42 -0
- data/spec/samples/rubySyntaxParts/conditionalStatment/commonCasesOfConditionals.rb +47 -0
- data/spec/samples/rubySyntaxParts/conditionalStatment/constructorConditional.rb +1 -1
- data/spec/samples/rubySyntaxParts/conditionalStatment/constructorMixConditional.rb +41 -0
- data/spec/samples/rubySyntaxParts/conditionalStatment/methodMixConditional.rb +41 -0
- data/spec/samples/rubySyntaxParts/conditionalStatment/mixConditionalWithRepetition.rb +20 -0
- data/spec/samples/rubySyntaxParts/conditionalStatment/nestedConditional.rb +61 -0
- data/spec/samples/rubySyntaxParts/conditionalStatment/veryDeepConditionalStructure.rb +48 -0
- data/spec/samples/rubySyntaxParts/conditionalStatment/veryMixConditional.rb +37 -0
- data/spec/samples/rubySyntaxParts/fullCode/fullCodeTwo.rb +56 -0
- data/spec/samples/rubySyntaxParts/fullCode/fullCodeWithComments.rb +64 -0
- data/spec/samples/rubySyntaxParts/fullCode/simpleFullCode.rb +9 -1
- data/spec/samples/rubySyntaxParts/method/simpleMethod.rb +2 -0
- data/spec/samples/rubySyntaxParts/repetition/beginWithWhileLoopInClass.rb +10 -0
- data/spec/samples/rubySyntaxParts/repetition/constructorWithMixRepetition.rb +22 -0
- data/spec/samples/rubySyntaxParts/repetition/forLoopInClass.rb +7 -0
- data/spec/samples/rubySyntaxParts/repetition/methodWithMixRepetition.rb +19 -0
- data/spec/samples/rubySyntaxParts/repetition/mixConditionalRepetition.rb +17 -0
- data/spec/samples/rubySyntaxParts/repetition/untilLoopInClass.rb +16 -0
- data/spec/samples/rubySyntaxParts/repetition/veryMixRepetition.rb +28 -0
- data/spec/samples/rubySyntaxParts/repetition/veryNestedRepetition.rb +17 -0
- data/spec/samples/rubySyntaxParts/repetition/whileLoopInClass.rb +12 -0
- data/spec/state_machine/OO_structured_fsm/aggregation_state_spec.rb +67 -0
- data/spec/state_machine/OO_structured_fsm/class_state_spec.rb +15 -0
- data/spec/state_machine/OO_structured_fsm/conditional_state_spec.rb +64 -0
- data/spec/state_machine/OO_structured_fsm/include_state_spec.rb +3 -3
- data/spec/state_machine/OO_structured_fsm/method_state_spec.rb +18 -0
- data/spec/state_machine/OO_structured_fsm/repetition_state_spec.rb +27 -0
- metadata +195 -28
- data/lib/kuniri/core/configuration/monitor_available.rb +0 -13
- data/lib/kuniri/language/abstract_container/structured_and_oo/constructor.rb +0 -52
- data/lib/kuniri/parser/parser_xml.rb +0 -128
- data/spec/language/abstract_container/constructor_spec.rb +0 -13
- data/spec/util/html_logger_spec.rb +0 -31
- data/spec/util/logger_spec.rb +0 -20
- data/spec/util/txt_logger_spec.rb +0 -31
data/data/class_lang.rb
CHANGED
|
@@ -1,71 +1,49 @@
|
|
|
1
|
-
require_relative '../abstract_container/structured_and_oo/class
|
|
2
|
-
require_relative '../container_data/structured_and_oo/class_data
|
|
3
|
-
require_relative '../../util/html_logger'
|
|
1
|
+
require_relative '../abstract_container/structured_and_oo/class'
|
|
2
|
+
require_relative '../container_data/structured_and_oo/class_data'
|
|
4
3
|
require_relative '../../core/setting'
|
|
5
4
|
|
|
6
5
|
module Languages
|
|
7
6
|
|
|
8
7
|
module {LANG}
|
|
9
8
|
|
|
9
|
+
# Class responsible for handling {LANG} classes.
|
|
10
10
|
class Class{LANG} < Languages::Class
|
|
11
11
|
|
|
12
12
|
public
|
|
13
13
|
|
|
14
14
|
def initialize
|
|
15
|
-
|
|
15
|
+
# YOUR CODE HERE
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
+
# Get {LANG} class.
|
|
19
|
+
# @see Languages::Class
|
|
18
20
|
def get_class(pLine)
|
|
19
|
-
|
|
20
|
-
return nil unless result
|
|
21
|
-
|
|
22
|
-
@log.write_log("Info: Detect class")
|
|
23
|
-
|
|
24
|
-
classCaptured = Languages::ClassData.new
|
|
25
|
-
|
|
26
|
-
inheritance = get_inheritance(result)
|
|
27
|
-
classCaptured.inheritances = inheritance if inheritance
|
|
28
|
-
|
|
29
|
-
result = prepare_final_string(result)
|
|
30
|
-
classCaptured.name = result
|
|
31
|
-
|
|
32
|
-
@log.write_log("Debug: Class: #{classCaptured.name}")
|
|
33
|
-
|
|
34
|
-
return classCaptured
|
|
21
|
+
# YOUR CODE HERE
|
|
35
22
|
end
|
|
36
23
|
|
|
37
24
|
protected
|
|
38
25
|
|
|
26
|
+
# Override
|
|
39
27
|
def detect_class(pLine)
|
|
40
|
-
|
|
41
|
-
return nil unless pLine =~ regexExpression
|
|
42
|
-
return pLine.scan(regexExpression)[0].join("")
|
|
28
|
+
# YOUR CODE HERE
|
|
43
29
|
end
|
|
44
30
|
|
|
31
|
+
# Override
|
|
45
32
|
def get_inheritance(pString)
|
|
46
|
-
|
|
47
|
-
partial = pString.scan(/<(.*)/)
|
|
48
|
-
return remove_unnecessary_information(partial)
|
|
49
|
-
end
|
|
50
|
-
return nil
|
|
33
|
+
# YOUR CODE HERE
|
|
51
34
|
end
|
|
52
35
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
def prepare_final_string(pString)
|
|
59
|
-
if pString =~ /\s|</
|
|
60
|
-
partial = pString.gsub(/<.*/,"")
|
|
61
|
-
return remove_unnecessary_information(partial)
|
|
36
|
+
# Override
|
|
37
|
+
def remove_unnecessary_information(pString)
|
|
38
|
+
# YOUR CODE HERE
|
|
62
39
|
end
|
|
63
|
-
return pString
|
|
64
|
-
end
|
|
65
40
|
|
|
66
|
-
|
|
41
|
+
def prepare_final_string(pString)
|
|
42
|
+
# YOUR CODE HERE
|
|
43
|
+
end
|
|
67
44
|
|
|
68
|
-
|
|
45
|
+
private
|
|
46
|
+
# YOU CAN HAVE CODE HERE...
|
|
69
47
|
|
|
70
48
|
# class
|
|
71
49
|
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
require_relative '../abstract_container/structured_and_oo/comment'
|
|
2
|
+
|
|
3
|
+
module Languages
|
|
4
|
+
|
|
5
|
+
module {LANG}
|
|
6
|
+
|
|
7
|
+
# Comment{LANG} is responsible for handling {LANG} comments.
|
|
8
|
+
class Comment{LANG} < Languages::Comment
|
|
9
|
+
|
|
10
|
+
public
|
|
11
|
+
|
|
12
|
+
@flagMultipleLine
|
|
13
|
+
|
|
14
|
+
def initialize
|
|
15
|
+
@flagMultipleLine = false
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# @see Comment
|
|
19
|
+
def get_comment(pLine)
|
|
20
|
+
# YOUR CODE HERE
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# @see Comment
|
|
24
|
+
def is_single_line_comment?(pLine)
|
|
25
|
+
# YOUR CODE HERE
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# @see Comment
|
|
29
|
+
def is_multiple_line_comment?(pLine)
|
|
30
|
+
# YOUR CODE HERE
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# @see Comment
|
|
34
|
+
def is_multiple_line_comment_end?(pLine)
|
|
35
|
+
# YOUR CODE HERE
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
protected
|
|
39
|
+
|
|
40
|
+
# @see Comment
|
|
41
|
+
def prepare_line_comment(pString)
|
|
42
|
+
# YOUR CODE HERE
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# class
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# module
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# module
|
|
52
|
+
end
|
data/data/conditional_lang.rb
CHANGED
|
@@ -1,70 +1,43 @@
|
|
|
1
|
-
require_relative '../abstract_container/structured_and_oo/conditional
|
|
2
|
-
require_relative '../
|
|
1
|
+
require_relative '../abstract_container/structured_and_oo/conditional'
|
|
2
|
+
require_relative '../abstract_container/structured_and_oo/global_tokens'
|
|
3
|
+
require_relative '../container_data/structured_and_oo/conditional_data'
|
|
3
4
|
|
|
4
5
|
module Languages
|
|
5
6
|
|
|
6
7
|
module {LANG}
|
|
7
8
|
|
|
9
|
+
# Class responsible for handling {LANG} conditional statements.
|
|
8
10
|
class Conditional{LANG} < Languages::Conditional
|
|
9
11
|
|
|
10
12
|
public
|
|
11
13
|
|
|
14
|
+
# Get {LANG} conditional.
|
|
15
|
+
# @see Languages::Conditional
|
|
12
16
|
def get_conditional(pLine)
|
|
13
|
-
|
|
14
|
-
return nil unless result
|
|
15
|
-
|
|
16
|
-
conditionalCaptured = Languages::ConditionalData.new
|
|
17
|
-
conditionalCaptured.type = conditional_type(pLine)
|
|
18
|
-
|
|
19
|
-
conditionalCaptured.expression = get_expression(result)
|
|
20
|
-
|
|
21
|
-
return conditionalCaptured
|
|
17
|
+
# YOUR CODE HERE
|
|
22
18
|
end
|
|
23
19
|
|
|
24
20
|
protected
|
|
25
21
|
|
|
22
|
+
# Override.
|
|
26
23
|
def detect_conditional(pLine)
|
|
27
|
-
|
|
28
|
-
return pLine.scan(regexExp)[0].join("") if regexExp =~ pLine
|
|
29
|
-
|
|
30
|
-
regexExp = /^\s*case\s+(.*)/
|
|
31
|
-
return pLine.scan(regexExp)[0].join("") if regexExp =~ pLine
|
|
32
|
-
|
|
33
|
-
regexExp = /^\s*unless\s+(.*)/
|
|
34
|
-
return pLine.scan(regexExp)[0].join("") if regexExp =~ pLine
|
|
35
|
-
|
|
36
|
-
regexExp = /^\s*elsif\s+(.*)/
|
|
37
|
-
return pLine.scan(regexExp)[0].join("") if regexExp =~ pLine
|
|
38
|
-
|
|
39
|
-
return nil
|
|
24
|
+
# YOUR CODE HERE
|
|
40
25
|
end
|
|
41
26
|
|
|
27
|
+
# Override
|
|
42
28
|
def conditional_type(pString)
|
|
43
|
-
|
|
44
|
-
return "IF" if regexExp =~ pString
|
|
45
|
-
|
|
46
|
-
regexExp = /^\s+case|^case/
|
|
47
|
-
return "CASE" if regexExp =~ pString
|
|
48
|
-
|
|
49
|
-
regexExp = /^\s+unless|^unless/
|
|
50
|
-
return "UNLESS" if regexExp =~ pString
|
|
51
|
-
|
|
52
|
-
regexExp = /^\s+elsif|^elsif/
|
|
53
|
-
return "ELSIF" if regexExp =~ pString
|
|
54
|
-
|
|
55
|
-
return nil
|
|
29
|
+
# YOUR CODE HERE
|
|
56
30
|
end
|
|
57
31
|
|
|
32
|
+
# Override
|
|
58
33
|
def get_expression(pString)
|
|
59
|
-
|
|
60
|
-
rightStrip = leftStrip.rstrip
|
|
61
|
-
return rightStrip
|
|
34
|
+
# YOUR CODE HERE
|
|
62
35
|
end
|
|
63
36
|
|
|
64
37
|
# Class
|
|
65
38
|
end
|
|
66
39
|
|
|
67
|
-
#
|
|
40
|
+
# Module
|
|
68
41
|
end
|
|
69
42
|
|
|
70
43
|
# Module
|
data/data/constructor_lang.rb
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
require_relative '../abstract_container/structured_and_oo/constructor'
|
|
2
1
|
require_relative '../container_data/structured_and_oo/constructor_data'
|
|
3
2
|
require_relative 'function_behavior_{lang}'
|
|
4
3
|
|
|
@@ -7,21 +6,14 @@ module Languages
|
|
|
7
6
|
module {LANG}
|
|
8
7
|
|
|
9
8
|
# Handling {LANG} constructor
|
|
10
|
-
class
|
|
9
|
+
class Constructor{LANG} < Languages::{LANG}::FunctionBehavior{LANG}
|
|
11
10
|
|
|
12
11
|
public
|
|
13
12
|
|
|
13
|
+
# Get {LANG} constructor.
|
|
14
|
+
# @see FunctionBehaviorRuby
|
|
14
15
|
def get_constructor(pLine, type = 'public')
|
|
15
|
-
|
|
16
|
-
return nil unless result
|
|
17
|
-
|
|
18
|
-
if result.name =~ /initialize/
|
|
19
|
-
result.type = "CONSTRUCTOR"
|
|
20
|
-
else
|
|
21
|
-
return nil
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
return result
|
|
16
|
+
# YOUR CODE HERE
|
|
25
17
|
end
|
|
26
18
|
|
|
27
19
|
# Class
|
data/data/end_block_lang.rb
CHANGED
|
@@ -4,26 +4,27 @@ module Languages
|
|
|
4
4
|
|
|
5
5
|
module {LANG}
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
# Class responsible for handling {LANG} end of block.
|
|
8
|
+
class EndBlock{LANG} < Languages::EndBlock
|
|
8
9
|
|
|
9
10
|
public
|
|
10
11
|
|
|
12
|
+
# Verify {LANG} end of block.
|
|
13
|
+
# @see EndBlock
|
|
11
14
|
def has_end_of_block?(pLine)
|
|
12
|
-
|
|
15
|
+
# YOUR CODE HERE
|
|
13
16
|
end
|
|
14
17
|
|
|
15
18
|
protected
|
|
16
19
|
|
|
17
20
|
def detect_end(pLine)
|
|
18
|
-
#
|
|
19
|
-
return true if pLine =~ /^\s+end|^end/
|
|
20
|
-
return false
|
|
21
|
+
# YOUR CODE HERE
|
|
21
22
|
end
|
|
22
23
|
|
|
23
24
|
# Class
|
|
24
25
|
end
|
|
25
26
|
|
|
26
|
-
#
|
|
27
|
+
# Module
|
|
27
28
|
end
|
|
28
29
|
|
|
29
30
|
# Module
|
|
@@ -5,41 +5,34 @@ module Languages
|
|
|
5
5
|
|
|
6
6
|
module {LANG}
|
|
7
7
|
|
|
8
|
-
#
|
|
8
|
+
# ExternRequirement Handling extern requirements.
|
|
9
9
|
class ExternRequirement{LANG} < Languages::ExternRequirement
|
|
10
10
|
|
|
11
11
|
public
|
|
12
12
|
|
|
13
|
+
# Get {LANG} requirement.
|
|
14
|
+
# @see ExternRequirement
|
|
13
15
|
def get_requirement(pLine)
|
|
14
|
-
|
|
15
|
-
return nil unless detectExpression
|
|
16
|
-
|
|
17
|
-
detectExpression = remove_unnecessary_information(detectExpression)
|
|
18
|
-
# @requirement = detectExpression
|
|
19
|
-
name = File.basename(detectExpression, ".*")
|
|
20
|
-
externReference = ExternRequirementData.new(name)
|
|
21
|
-
return externReference
|
|
16
|
+
# YOUR CODE HERE
|
|
22
17
|
end
|
|
23
18
|
|
|
24
19
|
protected
|
|
25
20
|
|
|
21
|
+
# Override
|
|
26
22
|
def detect_extern_requirement(pLine)
|
|
27
|
-
|
|
28
|
-
return nil unless pLine =~ regexExpression
|
|
29
|
-
return pLine.scan(regexExpression).join("")
|
|
23
|
+
# YOUR CODE HERE
|
|
30
24
|
end
|
|
31
25
|
|
|
26
|
+
# Override
|
|
32
27
|
def remove_unnecessary_information(pLine)
|
|
33
|
-
|
|
34
|
-
return pLine.gsub!(regexClean, "") if pLine =~ regexClean
|
|
35
|
-
return pLine
|
|
28
|
+
# YOUR CODE HERE
|
|
36
29
|
end
|
|
37
30
|
|
|
38
31
|
# Class
|
|
39
32
|
end
|
|
40
33
|
|
|
41
|
-
#
|
|
34
|
+
# Module
|
|
42
35
|
end
|
|
43
36
|
|
|
44
37
|
# Module
|
|
45
|
-
end
|
|
38
|
+
end
|
|
@@ -6,107 +6,58 @@ module Languages
|
|
|
6
6
|
|
|
7
7
|
module {LANG}
|
|
8
8
|
|
|
9
|
-
# Handling
|
|
9
|
+
# Handling Ruby method
|
|
10
10
|
class FunctionBehavior{LANG} < Languages::FunctionBehavior
|
|
11
11
|
|
|
12
12
|
public
|
|
13
13
|
|
|
14
14
|
def initialize
|
|
15
|
-
|
|
15
|
+
# YOUR CODE HERE
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
+
# Get {LANG} function.
|
|
18
19
|
def get_function(pLine, type = 'globalFunction')
|
|
19
|
-
|
|
20
|
-
return nil unless result
|
|
21
|
-
|
|
22
|
-
@log.write_log("Info: get method")
|
|
23
|
-
|
|
24
|
-
function{LANG} = Languages::FunctionData.new(result)
|
|
25
|
-
|
|
26
|
-
parameters = handling_parameter(pLine)
|
|
27
|
-
if parameters
|
|
28
|
-
parameters.each do |parameter|
|
|
29
|
-
function{LANG}.add_parameters(parameter)
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
@log.write_log("Debug: Method: #{function{LANG}.name}, Parameter:
|
|
34
|
-
#{function{LANG}.parameters}")
|
|
35
|
-
|
|
36
|
-
return function{LANG}
|
|
20
|
+
# YOUR CODE HERE
|
|
37
21
|
end
|
|
38
22
|
|
|
39
23
|
protected
|
|
40
24
|
|
|
25
|
+
# Override
|
|
41
26
|
def detect_function(pLine)
|
|
42
|
-
|
|
43
|
-
return nil unless pLine =~ regexExpression
|
|
44
|
-
return pLine.scan(regexExpression)[0].join("")
|
|
27
|
+
# YOUR CODE HERE
|
|
45
28
|
end
|
|
46
29
|
|
|
30
|
+
# Override
|
|
47
31
|
def handling_default_parameter(pLine)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if pLine =~ /,/
|
|
51
|
-
partialParameters = pLine.split(",")
|
|
52
|
-
else
|
|
53
|
-
partialParameters = [pLine]
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
newList = []
|
|
57
|
-
partialParameters.each do |element|
|
|
58
|
-
if element =~ /=/
|
|
59
|
-
parameter = element.scan(/(\w*)=/).join("")
|
|
60
|
-
value = element.scan(/=(\w*)/).join("")
|
|
61
|
-
defaultParameter = Hash(parameter => value)
|
|
62
|
-
newList.push(defaultParameter)
|
|
63
|
-
next
|
|
64
|
-
end
|
|
65
|
-
newList.push(element)
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
return newList
|
|
69
|
-
|
|
32
|
+
# YOUR CODE HERE
|
|
70
33
|
end
|
|
71
34
|
|
|
35
|
+
# Override
|
|
72
36
|
def remove_unnecessary_information(pLine)
|
|
73
|
-
|
|
74
|
-
return pLine
|
|
37
|
+
# YOUR CODE HERE
|
|
75
38
|
end
|
|
76
39
|
|
|
40
|
+
# Override
|
|
77
41
|
def handling_parameter(pLine)
|
|
78
|
-
#
|
|
79
|
-
if pLine =~ /\(.+\)/
|
|
80
|
-
partial = get_parameters(pLine, /\(.+\)/)
|
|
81
|
-
elsif pLine =~ /def\s+\w+[\s]+(.+)/
|
|
82
|
-
partial = get_parameters(pLine, /def\s+\w+[\s]+(.+)/)
|
|
83
|
-
else
|
|
84
|
-
return nil
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
return handling_default_parameter(partial) if partial =~ /=/
|
|
88
|
-
return split_string_by_comma(partial)
|
|
42
|
+
# YOUR CODE HERE
|
|
89
43
|
end
|
|
90
44
|
|
|
91
45
|
private
|
|
92
46
|
|
|
93
|
-
|
|
94
|
-
|
|
47
|
+
# Override
|
|
95
48
|
def get_parameters(pLine, pRegex)
|
|
96
|
-
|
|
97
|
-
partialParameters = remove_unnecessary_information(partialParameters)
|
|
98
|
-
return partialParameters
|
|
49
|
+
# YOUR CODE HERE
|
|
99
50
|
end
|
|
100
51
|
|
|
52
|
+
# Override
|
|
101
53
|
def split_string_by_comma(pString)
|
|
102
|
-
|
|
103
|
-
return [pString]
|
|
54
|
+
# YOUR CODE HERE
|
|
104
55
|
end
|
|
105
56
|
|
|
106
57
|
# Class
|
|
107
58
|
end
|
|
108
59
|
|
|
109
|
-
# {
|
|
60
|
+
# {Lang}
|
|
110
61
|
end
|
|
111
62
|
|
|
112
63
|
# Language
|