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
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require_relative '../container_data/structured_and_oo/function_data'
|
|
2
|
+
require_relative 'function_behavior_{lang}'
|
|
3
|
+
|
|
4
|
+
module Languages
|
|
5
|
+
|
|
6
|
+
module {LANG}
|
|
7
|
+
|
|
8
|
+
# Handling {LANG} global function
|
|
9
|
+
class GlobalFunction{LANG} < Languages::{LANG}::FunctionBehavior{LANG}
|
|
10
|
+
|
|
11
|
+
public
|
|
12
|
+
|
|
13
|
+
# Get {LANG} global function.
|
|
14
|
+
# @see FunctionBehavior{LANG}
|
|
15
|
+
def get_method(pLine, type = 'public')
|
|
16
|
+
# YOUR CODE HERE
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Class
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# {LANG}
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Language
|
|
26
|
+
end
|
data/data/lang_syntax.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require_relative '../language'
|
|
2
2
|
require_relative '../container_data/structured_and_oo/class_data'
|
|
3
|
-
require_relative '../container_data/structured_and_oo/
|
|
3
|
+
require_relative '../container_data/structured_and_oo/file_element_data'
|
|
4
4
|
require_relative 'token_{lang}'
|
|
5
5
|
require_relative 'extern_requirement_{lang}'
|
|
6
6
|
require_relative 'variable_global_{lang}'
|
|
@@ -12,6 +12,10 @@ require_relative 'conditional_{lang}'
|
|
|
12
12
|
require_relative 'repetition_{lang}'
|
|
13
13
|
require_relative 'function_behavior_{lang}'
|
|
14
14
|
require_relative 'attribute_{lang}'
|
|
15
|
+
require_relative 'comment_{lang}'
|
|
16
|
+
require_relative 'method_{lang}'
|
|
17
|
+
require_relative 'aggregation_{lang}'
|
|
18
|
+
require_relative '../metadata'
|
|
15
19
|
|
|
16
20
|
module Languages
|
|
17
21
|
|
|
@@ -29,82 +33,111 @@ module Languages
|
|
|
29
33
|
@classHandler = Languages::{LANG}::Class{LANG}.new
|
|
30
34
|
@attributeHandler = Languages::{LANG}::Attribute{LANG}.new
|
|
31
35
|
@endBlockHandler = Languages::{LANG}::EndBlock{LANG}.new
|
|
32
|
-
@methodHandler = Languages::{LANG}::
|
|
36
|
+
@methodHandler = Languages::{LANG}::Method{LANG}.new
|
|
33
37
|
@constructorHandler = Languages::{LANG}::Constructor{LANG}.new
|
|
34
38
|
@conditionalHandler = Languages::{LANG}::Conditional{LANG}.new
|
|
35
39
|
@repetitionHandler = Languages::{LANG}::Repetition{LANG}.new
|
|
40
|
+
@commentHandler = Languages::{LANG}::Comment{LANG}.new
|
|
41
|
+
@aggregationHandler = Languages::{LANG}::Aggregation{LANG}.new
|
|
42
|
+
@metadata = Languages::Metadata.create
|
|
36
43
|
@visibility = "public"
|
|
37
44
|
end
|
|
38
45
|
|
|
46
|
+
# Analyse source code.
|
|
47
|
+
# @param pPath Path of file to be analysed.
|
|
39
48
|
def analyse_source(pPath)
|
|
40
49
|
@name = File.basename(pPath, ".*")
|
|
41
50
|
@path = File.dirname(pPath)
|
|
42
51
|
analyse_first_step(pPath)
|
|
43
|
-
|
|
52
|
+
analyse_second_step
|
|
44
53
|
end
|
|
45
54
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
55
|
+
private
|
|
56
|
+
|
|
57
|
+
attr_accessor :visibility
|
|
58
|
+
@source
|
|
59
|
+
@flagMultipleLineComment = false
|
|
60
|
+
|
|
61
|
+
# Puts every statement in a single line
|
|
62
|
+
# @param pLine Line of the file to be analysed.
|
|
63
|
+
def handle_semicolon(pLine)
|
|
64
|
+
commentLine = []
|
|
65
|
+
|
|
66
|
+
if pLine =~ /^=begin(.*?)/
|
|
67
|
+
@flagMultipleLineComment = true
|
|
68
|
+
elsif pLine =~ /^=end/
|
|
69
|
+
@flagMultipleLineComment = false
|
|
53
70
|
end
|
|
54
|
-
|
|
55
|
-
@
|
|
56
|
-
|
|
71
|
+
|
|
72
|
+
unless @flagMultipleLineComment == true || pLine =~ /#(.*)/
|
|
73
|
+
return pLine.split(/;/)
|
|
57
74
|
end
|
|
58
|
-
|
|
75
|
+
commentLine << pLine
|
|
59
76
|
end
|
|
60
77
|
|
|
61
|
-
#
|
|
62
|
-
#
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
78
|
+
# First step for analyse code, it is responsible for get only basic
|
|
79
|
+
# informations.
|
|
80
|
+
# @param pPath Path of file to be analysed.
|
|
81
|
+
def analyse_first_step(pPath)
|
|
82
|
+
fileElement = Languages::FileElementData.new(pPath)
|
|
83
|
+
@source = File.open(pPath, "rb")
|
|
84
|
+
@source.each do |line|
|
|
85
|
+
next if line.gsub(/\s+/,"").size == 0
|
|
86
|
+
processedLines = handle_semicolon(line)
|
|
87
|
+
if !processedLines.nil?
|
|
88
|
+
processedLines.each do |line|
|
|
89
|
+
@state.handle_line(line)
|
|
90
|
+
fileElement = @state.execute(fileElement, line)
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
66
94
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
def class_extract
|
|
70
|
-
return @currentClass
|
|
71
|
-
end
|
|
95
|
+
@source.close()
|
|
96
|
+
@fileElements.push(fileElement)
|
|
72
97
|
|
|
73
|
-
# @param source [String]
|
|
74
|
-
def attribute_extract
|
|
75
|
-
return @currentClass.get_attributes
|
|
76
98
|
end
|
|
77
99
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
end
|
|
100
|
+
def analyse_second_step
|
|
101
|
+
sort_all_classes
|
|
102
|
+
sort_all_aggregations
|
|
82
103
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
104
|
+
allActualAggregations = []
|
|
105
|
+
|
|
106
|
+
@metadata.allAggregations.each do |element|
|
|
107
|
+
if binary_search(@metadata.allClasses, element)
|
|
108
|
+
allActualAggregations << element
|
|
109
|
+
end
|
|
110
|
+
end
|
|
86
111
|
|
|
87
|
-
|
|
112
|
+
# TODO: Think how to improve.
|
|
113
|
+
@fileElements.each do |fileElement|
|
|
114
|
+
fileElement.classes.each do |classes|
|
|
115
|
+
classes.aggregations.delete_if do |aggregation|
|
|
116
|
+
unless allActualAggregations.include? aggregation
|
|
117
|
+
true
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
88
122
|
end
|
|
89
123
|
|
|
90
|
-
|
|
124
|
+
# TODO: Move it to utils
|
|
125
|
+
def binary_search(pVector, pElement)
|
|
126
|
+
pVector.bsearch {|obj| pElement.name <=> obj.name}
|
|
127
|
+
end
|
|
91
128
|
|
|
92
|
-
|
|
93
|
-
|
|
129
|
+
# TODO: Move it to utils
|
|
130
|
+
def sort_all_classes
|
|
131
|
+
@metadata.allClasses.sort! {|c1, c2| c1.name <=> c2.name}
|
|
132
|
+
end
|
|
94
133
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
@
|
|
98
|
-
@
|
|
99
|
-
next if line.gsub(/\s+/,"").size == 0
|
|
100
|
-
# Special token for class
|
|
101
|
-
@state.handle_line(line)
|
|
102
|
-
fileElement = @state.execute(fileElement, line)
|
|
103
|
-
end
|
|
104
|
-
@fileElements.push(fileElement)
|
|
134
|
+
# TODO: Move it to utils
|
|
135
|
+
def sort_all_aggregations
|
|
136
|
+
@metadata.allAggregations.sort! {|a1, a2| a1.name <=> a2.name}
|
|
137
|
+
@metadata.allAggregations.uniq! {|a| a.name}
|
|
105
138
|
end
|
|
106
139
|
|
|
107
|
-
#
|
|
140
|
+
# Class
|
|
108
141
|
end
|
|
109
142
|
|
|
110
143
|
# Module
|
data/data/method_lang.rb
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require_relative '../container_data/structured_and_oo/method_data'
|
|
2
|
+
require_relative 'function_behavior_{lang}'
|
|
3
|
+
|
|
4
|
+
module Languages
|
|
5
|
+
|
|
6
|
+
module {LANG}
|
|
7
|
+
|
|
8
|
+
# Handling {LANG} method
|
|
9
|
+
class Method{LANG} < Languages::{LANG}::FunctionBehavior{LANG}
|
|
10
|
+
|
|
11
|
+
public
|
|
12
|
+
|
|
13
|
+
# Get {LANG} method.
|
|
14
|
+
# @see FunctionBehavior{LANG}
|
|
15
|
+
def get_method(pLine, type = 'public')
|
|
16
|
+
# YOUR CODE HERE
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Class
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# {LANG}
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Language
|
|
26
|
+
end
|
|
@@ -10,33 +10,28 @@ module Languages
|
|
|
10
10
|
|
|
11
11
|
public
|
|
12
12
|
|
|
13
|
+
# Get {LANG} module.
|
|
14
|
+
# @see Languages::ModuleNamespace
|
|
13
15
|
def get_module(pLine)
|
|
14
|
-
|
|
15
|
-
return nil unless result
|
|
16
|
-
|
|
17
|
-
result = remove_unnecessary_information(result)
|
|
18
|
-
moduleCaptured = Languages::ModuleNamespaceData.new(result)
|
|
19
|
-
|
|
20
|
-
return moduleCaptured
|
|
16
|
+
# YOUR CODE HERE
|
|
21
17
|
end
|
|
22
18
|
|
|
23
19
|
protected
|
|
24
20
|
|
|
21
|
+
# Override
|
|
25
22
|
def detect_module(pLine)
|
|
26
|
-
|
|
27
|
-
return nil unless pLine =~ regexExpression
|
|
28
|
-
return pLine.scan(regexExpression).join("")
|
|
23
|
+
# YOUR CODE HERE
|
|
29
24
|
end
|
|
30
25
|
|
|
26
|
+
# Override
|
|
31
27
|
def remove_unnecessary_information(pLine)
|
|
32
|
-
|
|
33
|
-
return pLine
|
|
28
|
+
# YOUR CODE HERE
|
|
34
29
|
end
|
|
35
30
|
|
|
36
31
|
# class
|
|
37
32
|
end
|
|
38
33
|
|
|
39
|
-
#
|
|
34
|
+
# module
|
|
40
35
|
end
|
|
41
36
|
|
|
42
37
|
# module
|
data/data/repetition_lang.rb
CHANGED
|
@@ -1,61 +1,48 @@
|
|
|
1
|
-
require_relative '../abstract_container/structured_and_oo/
|
|
2
|
-
require_relative '../
|
|
1
|
+
require_relative '../abstract_container/structured_and_oo/global_tokens'
|
|
2
|
+
require_relative '../abstract_container/structured_and_oo/repetition'
|
|
3
|
+
require_relative '../container_data/structured_and_oo/repetition_data'
|
|
3
4
|
|
|
4
5
|
module Languages
|
|
5
6
|
|
|
6
7
|
module {LANG}
|
|
7
8
|
|
|
9
|
+
# Class responsible for handling {LANG} repetition data structures.
|
|
8
10
|
class Repetition{LANG} < Languages::Repetition
|
|
9
11
|
|
|
10
12
|
public
|
|
11
13
|
|
|
14
|
+
# Get {LANG} repetition structure.
|
|
15
|
+
# @see Languages::Repetition
|
|
12
16
|
def get_repetition(pLine)
|
|
13
|
-
|
|
14
|
-
return nil unless result
|
|
15
|
-
|
|
16
|
-
repetitionCaptured = Languages::RepetitionData.new
|
|
17
|
-
repetitionCaptured.type = repetition_type(pLine)
|
|
18
|
-
|
|
19
|
-
repetitionCaptured.expression = get_expression(result)
|
|
20
|
-
|
|
21
|
-
return repetitionCaptured
|
|
17
|
+
# YOUR CODE HERE
|
|
22
18
|
end
|
|
23
19
|
|
|
24
20
|
protected
|
|
25
21
|
|
|
22
|
+
# Override
|
|
26
23
|
def detect_repetition(pLine)
|
|
27
|
-
|
|
28
|
-
return pLine.scan(regexExp)[0].join("") if regexExp =~ pLine
|
|
29
|
-
|
|
30
|
-
regexExp = /^\s*for\s+(.*)/
|
|
31
|
-
return pLine.scan(regexExp)[0].join("") if regexExp =~ pLine
|
|
32
|
-
|
|
33
|
-
regexExp = /^\s*until\s+(.*)do/
|
|
34
|
-
return pLine.scan(regexExp)[0].join("") if regexExp =~ pLine
|
|
35
|
-
|
|
36
|
-
return nil
|
|
24
|
+
# YOUR CODE HERE
|
|
37
25
|
end
|
|
38
26
|
|
|
27
|
+
# Override
|
|
39
28
|
def repetition_type(pString)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
regexExp = /^\s+for|^for/
|
|
44
|
-
return "FOR" if regexExp =~ pString
|
|
29
|
+
# YOUR CODE HERE
|
|
30
|
+
end
|
|
45
31
|
|
|
46
|
-
|
|
32
|
+
# Override
|
|
33
|
+
def get_expression(pType, pString)
|
|
34
|
+
# YOUR CODE HERE
|
|
47
35
|
end
|
|
48
36
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return rightStrip
|
|
37
|
+
# Override
|
|
38
|
+
def remove_unnecessary_information(pString)
|
|
39
|
+
# YOUR CODE HERE
|
|
53
40
|
end
|
|
54
41
|
|
|
55
42
|
# class
|
|
56
43
|
end
|
|
57
44
|
|
|
58
|
-
#
|
|
45
|
+
# Module
|
|
59
46
|
end
|
|
60
47
|
|
|
61
48
|
# Module
|
data/data/token_lang.rb
CHANGED
|
@@ -1,52 +1,10 @@
|
|
|
1
1
|
module Languages
|
|
2
2
|
|
|
3
|
+
# Module responsible for handling {LANG} syntax.
|
|
3
4
|
module {LANG}
|
|
4
5
|
|
|
5
6
|
# Token types used to identify keywords
|
|
6
|
-
|
|
7
|
-
ATTRIBUTE_TOKEN ||= 2
|
|
8
|
-
DEF_TOKEN ||= 3
|
|
9
|
-
VISIBILITY_TOKEN ||= 4
|
|
10
|
-
END_TOKEN ||= 5 # Code, enclosed in { and }, to run when the program ends.
|
|
11
|
-
IF_TOKEN ||= 6 # Executes code block if true. Closes with end.
|
|
12
|
-
WHILE_TOKEN ||= 7 # Executes the block passed to the method.
|
|
13
|
-
DO_TOKEN ||= 8 # Begins a block and executes code in that block(end)
|
|
14
|
-
BEGIN_TOKEN ||= 9 # Code, enclosed in { and }, to run before the program runs.
|
|
15
|
-
ALIAS_TOKEN ||= 10 # Creates an alias: method, operator, or global variable.
|
|
16
|
-
AND_TOKEN ||= 11 # Logical operator same as && except and has lower precedence.
|
|
17
|
-
BEGIN_DOWN_TOKEN ||= 12 # Begins a code block or group of statements (end).
|
|
18
|
-
BREAK_TOKEN ||= 13 # Terminates a while or until loop or a method.
|
|
19
|
-
CASE_TOKEN ||= 14 # Compares an expression with a matching when clause (end).
|
|
20
|
-
REQUIRE_TOKEN ||= 15 # Extern requirement
|
|
21
|
-
DEFINED_TOKEN ||= 16 # Determines: variable, method, super method, or block.
|
|
22
|
-
ELSE_TOKEN ||= 17 # Executes if previous conditional.
|
|
23
|
-
ELSIF_TOKEN ||= 18 # Executes if previous conditional, in if or elsif.
|
|
24
|
-
ENSURE_TOKEN ||= 19 # Always executes at block termination.
|
|
25
|
-
FALSE_TOKEN ||= 20 # Logical or Boolean false, instance of FalseClass.
|
|
26
|
-
TRUE_TOKEN ||= 21 # Instance of TrueClass.
|
|
27
|
-
FOR_TOKEN ||= 22 # Begins a for loop; used with in.
|
|
28
|
-
MODULE_TOKEN ||= 23 # Defines a module; closes with end.
|
|
29
|
-
NEXT_TOKEN ||= 24 # Jumps before a loop's conditional.
|
|
30
|
-
NIL_TOKEN ||= 25 # Object of NilClass.
|
|
31
|
-
NOT_TOKEN ||= 26 # Logical operator, same as !.
|
|
32
|
-
OR_TOKEN ||= 27 # Logical operator, same as ||.
|
|
33
|
-
REDO_TOKEN ||= 28 # Jumps after a loop's conditional.
|
|
34
|
-
RESCUE_TOKEN ||= 29 # Evaluates an expression after an exception is raised.
|
|
35
|
-
RETRY_TOKEN ||= 30 # Repeats a method call outside of rescue.
|
|
36
|
-
RETURN_TOKEN ||= 31 # Returns a value from a method or block.
|
|
37
|
-
SELF_TOKEN ||= 32 # Current object (invoked by a method).
|
|
38
|
-
SUPER_TOKEN ||= 33 # Calls method of the same name in the superclass.
|
|
39
|
-
THEN_TOKEN ||= 34 # A continuation for if, unless, and when.
|
|
40
|
-
UNDEF_TOKEN ||= 35 # Makes a method in current class undefined.
|
|
41
|
-
UNLESS_TOKEN ||= 36 # Executes code block if conditional statement is false.
|
|
42
|
-
UNTIL_TOKEN ||= 37 # Executes code block while conditional statement is false.
|
|
43
|
-
WHEN_TOKEN ||= 38 # Starts a clause (one or more) under case.
|
|
44
|
-
YIELD_TOKEN ||= 39 # Executes the block passed to the method.
|
|
45
|
-
INTEGER_TOKEN ||= 40
|
|
46
|
-
ARRAY_TOKEN ||= 41
|
|
47
|
-
HASH_TOKEN ||= 42
|
|
48
|
-
OBJECT_TOKEN ||= 43
|
|
49
|
-
CONSTRUCTOR_TOKEN ||= 44
|
|
7
|
+
# YOUR TOKENS HERE
|
|
50
8
|
|
|
51
9
|
# Module
|
|
52
10
|
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require_relative '../abstract_container/structured_and_oo/variable_behaviour'
|
|
2
|
+
|
|
3
|
+
module Languages
|
|
4
|
+
|
|
5
|
+
module {LANG}
|
|
6
|
+
|
|
7
|
+
# Ruby Handling Ruby attributes
|
|
8
|
+
class VariableBehaviour{LANG} < Languages::VariableBehaviour
|
|
9
|
+
|
|
10
|
+
protected
|
|
11
|
+
|
|
12
|
+
# Override
|
|
13
|
+
def remove_unnecessary_information(pString)
|
|
14
|
+
# YOUR CODE HERE
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Override
|
|
18
|
+
def prepare_final_string(pString)
|
|
19
|
+
# YOUR CODE HERE
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Override
|
|
23
|
+
def handle_multiple_declaration_with_comma(pString)
|
|
24
|
+
# YOUR CODE HERE
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Override
|
|
28
|
+
def handle_multiple_declaration_with_equal(pString)
|
|
29
|
+
# YOUR CODE HERE
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Override
|
|
33
|
+
def handle_line_declaration(pString)
|
|
34
|
+
# YOUR CODE HERE
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
#Class
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# {LANG}
|
|
41
|
+
end
|
|
42
|
+
#Language
|
|
43
|
+
end
|