kuniri 0.0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- 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,29 @@
|
|
1
|
+
module Languages
|
2
|
+
|
3
|
+
# @abstract Aggregation is a container for handling aggregation among classes
|
4
|
+
class Aggregation
|
5
|
+
|
6
|
+
public
|
7
|
+
|
8
|
+
# Verify if line has an aggregation.
|
9
|
+
# @param pLine Line with the potential class.
|
10
|
+
# @return Return an object AggregationData if it find a class in the
|
11
|
+
# line, otherwise return nil.
|
12
|
+
def get_aggregation(pLine)
|
13
|
+
raise NotImplementedError
|
14
|
+
end
|
15
|
+
|
16
|
+
protected
|
17
|
+
|
18
|
+
# Detect if an aggregation exists.
|
19
|
+
# @param pLine Line to inspect.
|
20
|
+
# @return Returns an row string, otherwise returns nil.
|
21
|
+
def detect_aggregation(pLine)
|
22
|
+
raise NotImplementedError
|
23
|
+
end
|
24
|
+
|
25
|
+
# class
|
26
|
+
end
|
27
|
+
|
28
|
+
# module
|
29
|
+
end
|
@@ -26,46 +26,6 @@ module Languages
|
|
26
26
|
raise NotImplementedError
|
27
27
|
end
|
28
28
|
|
29
|
-
# Remove unnecessary information from line. For example, remove
|
30
|
-
# everything into parenthesis or line comment.
|
31
|
-
# @param pString String for remove unnecessary information.
|
32
|
-
# @return If match any unnecessary character defined by the programmer
|
33
|
-
# returns the new string, otherwise return the same string.
|
34
|
-
def remove_unnecessary_information(pString)
|
35
|
-
raise NotImplementedError
|
36
|
-
end
|
37
|
-
|
38
|
-
# Take the string, and do some final changes on the data before save it.
|
39
|
-
# @param pLine Target string to be saved.
|
40
|
-
# @return Returns a final string or array with final attributes.
|
41
|
-
def prepare_final_string(pLine)
|
42
|
-
raise NotImplementedError
|
43
|
-
end
|
44
|
-
|
45
|
-
# Some attributes can be declared in the same line separated only by
|
46
|
-
# comma. Here is the place to handling it!
|
47
|
-
# @param pString String with all attributes separated by comma.
|
48
|
-
# @return Return an array of attributes.
|
49
|
-
def handle_multiple_declaration_with_comma(pString)
|
50
|
-
raise NotImplementedError
|
51
|
-
end
|
52
|
-
|
53
|
-
# Some languages allows do declare and set initial value in the same line
|
54
|
-
# by using equal. This method is responsible for handling this kind of
|
55
|
-
# situation.
|
56
|
-
# @param pString String with multiple declaration of string.
|
57
|
-
# @return Return an array of attributes.
|
58
|
-
def handle_multiple_declaration_with_equal(pString)
|
59
|
-
raise NotImplementedError
|
60
|
-
end
|
61
|
-
|
62
|
-
# Handling the simple case of line declaration
|
63
|
-
# @param pString String with attribute
|
64
|
-
# @return Return an String with the attribute.
|
65
|
-
def handle_line_declaration(pString)
|
66
|
-
raise NotImplementedError
|
67
|
-
end
|
68
|
-
|
69
29
|
# Class
|
70
30
|
end
|
71
31
|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Languages
|
2
|
+
|
3
|
+
# Token types used for standardize assignments.
|
4
|
+
IF_LABEL ||= "IF"
|
5
|
+
ELSE_LABEL ||= "ELSE"
|
6
|
+
ELSIF_LABEL ||= "ELSIF"
|
7
|
+
UNLESS_LABEL ||= "UNLESS"
|
8
|
+
CASE_LABEL ||= "CASE"
|
9
|
+
WHEN_LABEL ||= "WHEN"
|
10
|
+
WHILE_LABEL ||= "WHILE"
|
11
|
+
FOR_LABEL ||= "FOR"
|
12
|
+
DO_WHILE_LABEL ||= "DOWHILE"
|
13
|
+
UNTIL_LABEL ||= "UNTIL"
|
14
|
+
LAMBDA_LABEL ||= "LAMBDA"
|
15
|
+
# Handle nested conditional and loops
|
16
|
+
UP_LEVEL ||= -1
|
17
|
+
DOWN_LEVEL ||= 1
|
18
|
+
KEEP_LEVEL ||= 0
|
19
|
+
|
20
|
+
end
|
@@ -30,8 +30,16 @@ module Languages
|
|
30
30
|
|
31
31
|
# Try to extract the expression.
|
32
32
|
# @param pString String with conditional expression.
|
33
|
+
# @param pType Loop type.
|
33
34
|
# @return Return a partial string.
|
34
|
-
def get_expression(pString)
|
35
|
+
def get_expression(pType, pString)
|
36
|
+
raise NotImplementedError
|
37
|
+
end
|
38
|
+
|
39
|
+
# Take an partial result of string, and remove unnecessary informations.
|
40
|
+
# @param pString Line with string.
|
41
|
+
# @return Return a string without any unnecessary information.
|
42
|
+
def remove_unnecessary_information(pString)
|
35
43
|
raise NotImplementedError
|
36
44
|
end
|
37
45
|
|
@@ -25,41 +25,6 @@ module Languages
|
|
25
25
|
raise NotImplementedError
|
26
26
|
end
|
27
27
|
|
28
|
-
# Remove unnecessary information.
|
29
|
-
# @param pLine String to be improved.
|
30
|
-
# @return Return an partial string, or the same if no work is needed.
|
31
|
-
def remove_unnecessary_information(pLine)
|
32
|
-
raise NotImplementedError
|
33
|
-
end
|
34
|
-
|
35
|
-
# Make some prunes and adjustments in the string.
|
36
|
-
# @param pLine String to be prepared.
|
37
|
-
# @return Return a string.
|
38
|
-
def prepare_final_string(pLine)
|
39
|
-
raise NotImplementedError
|
40
|
-
end
|
41
|
-
|
42
|
-
# Handling multiple line declaration with comma.
|
43
|
-
# @param pString String with multiple declaration with comma.
|
44
|
-
# @return Return a string.
|
45
|
-
def handle_multiple_declaration_with_comma(pString)
|
46
|
-
raise NotImplementedError
|
47
|
-
end
|
48
|
-
|
49
|
-
# Handling multiple declaration with equal.
|
50
|
-
# @param pString String to be handled.
|
51
|
-
# @return Return an array with all variables.
|
52
|
-
def handle_multiple_declaration_with_equal(pString)
|
53
|
-
raise NotImplementedError
|
54
|
-
end
|
55
|
-
|
56
|
-
# Handling simple line declaration.
|
57
|
-
# @param pString String with simple declaration.
|
58
|
-
# @return Return a string.
|
59
|
-
def handle_line_declaration(pString)
|
60
|
-
raise NotImplementedError
|
61
|
-
end
|
62
|
-
|
63
28
|
# class
|
64
29
|
end
|
65
30
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative 'basic_data'
|
2
|
+
|
3
|
+
module Languages
|
4
|
+
|
5
|
+
# Handling aggregations data.
|
6
|
+
class AggregationData < Languages::BasicData
|
7
|
+
|
8
|
+
public
|
9
|
+
|
10
|
+
# Basic initialization of aggregation.
|
11
|
+
# @param pAggregationName Aggregation name for basic initialization.
|
12
|
+
def initialize (pAggregationName)
|
13
|
+
return nil if pAggregationName.nil? or !pAggregationName.is_a? String
|
14
|
+
|
15
|
+
@name = pAggregationName
|
16
|
+
@isInProject = false
|
17
|
+
end
|
18
|
+
|
19
|
+
# Class
|
20
|
+
end
|
21
|
+
|
22
|
+
# Module
|
23
|
+
end
|
@@ -9,8 +9,10 @@ module Languages
|
|
9
9
|
|
10
10
|
# Basic initialization of attribute.
|
11
11
|
# @param pAttribute_name Attribute name for basic initialization.
|
12
|
-
def initialize (
|
13
|
-
|
12
|
+
def initialize (pAttributeName)
|
13
|
+
return nil if pAttributeName.nil? or !pAttributeName.is_a? String
|
14
|
+
|
15
|
+
@name = pAttributeName
|
14
16
|
@visibility = "public"
|
15
17
|
end
|
16
18
|
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require_relative 'basic_data'
|
2
|
+
|
3
|
+
module Languages
|
4
|
+
|
5
|
+
# Class responsible to be an abstraction for conditional and repetition data.
|
6
|
+
class BasicStructure < Languages::BasicData
|
7
|
+
|
8
|
+
public
|
9
|
+
|
10
|
+
attr_accessor :type
|
11
|
+
attr_accessor :expression
|
12
|
+
attr_accessor :level
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
@type = "none"
|
16
|
+
@expression = "empty"
|
17
|
+
@level = 0
|
18
|
+
end
|
19
|
+
|
20
|
+
# class
|
21
|
+
end
|
22
|
+
|
23
|
+
# module
|
24
|
+
end
|
@@ -2,6 +2,7 @@ require_relative 'basic_data'
|
|
2
2
|
require_relative 'attribute_data'
|
3
3
|
require_relative 'method_data'
|
4
4
|
require_relative 'constructor_data'
|
5
|
+
require_relative 'aggregation_data'
|
5
6
|
|
6
7
|
module Languages
|
7
8
|
|
@@ -11,16 +12,19 @@ module Languages
|
|
11
12
|
public
|
12
13
|
|
13
14
|
attr_accessor :inheritances
|
15
|
+
attr_accessor :aggregations
|
14
16
|
attr_reader :attributes
|
15
17
|
attr_reader :methods
|
16
18
|
attr_reader :constructors
|
17
19
|
|
18
20
|
def initialize
|
19
|
-
@inheritances = []
|
21
|
+
@inheritances = []
|
20
22
|
@attributes = []
|
21
23
|
@methods = []
|
22
24
|
@constructors = []
|
25
|
+
@aggregations = []
|
23
26
|
@visibility = "public"
|
27
|
+
@comments = ""
|
24
28
|
end
|
25
29
|
|
26
30
|
# Add attribute to class data, notice the possibility of call this
|
@@ -29,7 +33,7 @@ module Languages
|
|
29
33
|
# is a list of AttributeData.
|
30
34
|
def add_attribute(pAttribute)
|
31
35
|
pAttribute.each do |attributeElement|
|
32
|
-
|
36
|
+
next unless attributeElement.is_a?(Languages::AttributeData)
|
33
37
|
@attributes.push(attributeElement)
|
34
38
|
end
|
35
39
|
end
|
@@ -39,7 +43,7 @@ module Languages
|
|
39
43
|
# @param pMethod It is an object of FunctionData with the method
|
40
44
|
# informations.
|
41
45
|
def add_method(pMethod)
|
42
|
-
return unless pMethod.is_a?(Languages::
|
46
|
+
return nil unless pMethod.is_a?(Languages::MethodData)
|
43
47
|
|
44
48
|
@methods.push(pMethod)
|
45
49
|
end
|
@@ -47,28 +51,18 @@ module Languages
|
|
47
51
|
# Add constructor inside class.
|
48
52
|
# @param pConstructor Object of FunctionData to be added at class.
|
49
53
|
def add_constructor(pConstructor)
|
50
|
-
return unless pConstructor.is_a?(Languages::
|
54
|
+
return nil unless pConstructor.is_a?(Languages::ConstructorData)
|
51
55
|
|
52
56
|
@constructors.push(pConstructor)
|
53
57
|
end
|
54
58
|
|
55
|
-
#
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
def get_attributes
|
61
|
-
@attributes
|
62
|
-
end
|
59
|
+
# Add aggregation inside class.
|
60
|
+
# @param pAggregation Object of AggregationData to be added at class.
|
61
|
+
def add_aggregation(pAggregation)
|
62
|
+
return nil unless pAggregation.is_a?(Languages::AggregationData)
|
63
63
|
|
64
|
-
|
65
|
-
@constructors
|
64
|
+
@aggregations.push(pAggregation)
|
66
65
|
end
|
67
|
-
|
68
|
-
def get_parameters
|
69
|
-
@parameters
|
70
|
-
end
|
71
|
-
|
72
66
|
# Class
|
73
67
|
end
|
74
68
|
|
@@ -1,20 +1,9 @@
|
|
1
|
-
require_relative '
|
1
|
+
require_relative 'basic_structure'
|
2
2
|
|
3
3
|
module Languages
|
4
4
|
|
5
5
|
# Class responsible for handling conditional data
|
6
|
-
class ConditionalData < Languages::
|
7
|
-
|
8
|
-
public
|
9
|
-
|
10
|
-
attr_accessor :type
|
11
|
-
attr_accessor :expression
|
12
|
-
|
13
|
-
def initialize
|
14
|
-
@name = "nothing"
|
15
|
-
@type = "none"
|
16
|
-
@expression = "empty"
|
17
|
-
end
|
6
|
+
class ConditionalData < Languages::BasicStructure
|
18
7
|
|
19
8
|
# class
|
20
9
|
end
|
@@ -7,16 +7,21 @@ module Languages
|
|
7
7
|
|
8
8
|
public
|
9
9
|
|
10
|
-
attr_reader :
|
10
|
+
attr_reader :library
|
11
11
|
|
12
12
|
def initialize(pRequirement)
|
13
|
-
|
13
|
+
return nil if pRequirement.nil? or !pRequirement.is_a? String
|
14
|
+
@library = pRequirement
|
14
15
|
end
|
15
16
|
|
16
|
-
# Set
|
17
|
-
# @param
|
18
|
-
def
|
19
|
-
|
17
|
+
# Set library of extern requirement.
|
18
|
+
# @param pLibrary Library inside the extern requirement.
|
19
|
+
def set_library(pLibrary)
|
20
|
+
if pLibrary.nil? or !pLibrary.is_a? String or pLibrary.empty?
|
21
|
+
return nil
|
22
|
+
end
|
23
|
+
|
24
|
+
@library = pLibrary
|
20
25
|
end
|
21
26
|
|
22
27
|
# Class
|
data/lib/kuniri/language/container_data/structured_and_oo/{file_element.rb → file_element_data.rb}
RENAMED
@@ -7,9 +7,9 @@ require_relative 'class_data'
|
|
7
7
|
|
8
8
|
module Languages
|
9
9
|
|
10
|
-
#
|
10
|
+
# FileElementData is the upper element related with container data, this class
|
11
11
|
# refers to file.
|
12
|
-
class
|
12
|
+
class FileElementData < Languages::BasicData
|
13
13
|
|
14
14
|
public
|
15
15
|
|
@@ -20,6 +20,8 @@ module Languages
|
|
20
20
|
attr_reader :modules
|
21
21
|
|
22
22
|
def initialize(pName)
|
23
|
+
return nil if pName.nil? or !pName.is_a? String
|
24
|
+
|
23
25
|
@global_functions = []
|
24
26
|
@global_variables = []
|
25
27
|
@extern_requirements = []
|
@@ -32,15 +34,15 @@ module Languages
|
|
32
34
|
# Add global function to the file.
|
33
35
|
# @param pFunction An object of FunctionData to be added at the file.
|
34
36
|
def add_global_function(pFunction)
|
35
|
-
return
|
37
|
+
return nil unless pFunction.is_a?(Languages::FunctionData)
|
36
38
|
|
37
39
|
@global_functions.push(pFunction)
|
38
40
|
end
|
39
41
|
|
40
42
|
# Add global variable inside file.
|
41
|
-
# @param pVariable
|
42
|
-
def add_global_variable(pVariable)
|
43
|
-
pVariable.each do |element|
|
43
|
+
# @param pVariable A single VariableGlobalData object or list to be added.
|
44
|
+
def add_global_variable(*pVariable)
|
45
|
+
pVariable.flatten.each do |element|
|
44
46
|
next unless element.is_a?(Languages::VariableGlobalData)
|
45
47
|
@global_variables.push(element)
|
46
48
|
end
|
@@ -49,7 +51,7 @@ module Languages
|
|
49
51
|
# Add extern requirement inside file.
|
50
52
|
# @param pOutside Add an object of ExternRequirementData.
|
51
53
|
def add_extern_requirement(pOutside)
|
52
|
-
return unless pOutside.is_a?(Languages::ExternRequirementData)
|
54
|
+
return nil unless pOutside.is_a?(Languages::ExternRequirementData)
|
53
55
|
|
54
56
|
@extern_requirements.push(pOutside)
|
55
57
|
end
|
@@ -57,7 +59,7 @@ module Languages
|
|
57
59
|
# Add a class inside file.
|
58
60
|
# @param pClass Add an object of ClassData.
|
59
61
|
def add_class(pClass)
|
60
|
-
return unless pClass.is_a?(Languages::ClassData)
|
62
|
+
return nil unless pClass.is_a?(Languages::ClassData)
|
61
63
|
|
62
64
|
@classes.push(pClass)
|
63
65
|
end
|
@@ -65,7 +67,7 @@ module Languages
|
|
65
67
|
# Add a module inside file.
|
66
68
|
# @param pModule Add an object of ModuleNamespaceData
|
67
69
|
def add_modules(pModule)
|
68
|
-
return unless pModule.is_a?(Languages::ModuleNamespaceData)
|
70
|
+
return nil unless pModule.is_a?(Languages::ModuleNamespaceData)
|
69
71
|
|
70
72
|
@modules.push(pModule)
|
71
73
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require_relative 'basic_data'
|
2
2
|
require_relative 'conditional_data'
|
3
3
|
require_relative 'repetition_data'
|
4
|
+
require_relative 'attribute_data'
|
5
|
+
require_relative 'manager_basic_structure_data'
|
4
6
|
|
5
7
|
module Languages
|
6
8
|
|
@@ -10,21 +12,33 @@ module Languages
|
|
10
12
|
public
|
11
13
|
|
12
14
|
attr_reader :parameters
|
13
|
-
attr_reader :conditionals
|
14
|
-
attr_reader :repetitions
|
15
15
|
attr_accessor :type
|
16
|
+
attr_reader :managerCondAndLoop
|
17
|
+
|
18
|
+
METHOD_DATA ||= "METHOD"
|
19
|
+
CONSTRUCTOR_DATA ||= "CONSTRUCTOR"
|
20
|
+
GLOBAL_FUNCTION_DATA ||= "GLOBALFUNCTION"
|
16
21
|
|
17
22
|
def initialize(pFunctionName)
|
23
|
+
return nil if pFunctionName.nil? or !pFunctionName.is_a? String
|
24
|
+
|
18
25
|
@name = pFunctionName
|
19
26
|
@parameters = []
|
20
|
-
@
|
21
|
-
@
|
27
|
+
@visibility = "public"
|
28
|
+
@comments = ""
|
29
|
+
@type = "unknown"
|
30
|
+
@managerCondAndLoop = Languages::ManagerBasicStructureData.new
|
22
31
|
end
|
23
32
|
|
24
33
|
# Add parameters inside function.
|
25
34
|
# @param pValue Add a parameter inside function.
|
35
|
+
# @return if pValue is not String or Hash with more than one element.
|
36
|
+
# return nil.
|
26
37
|
def add_parameters(pValue)
|
27
|
-
|
38
|
+
unless ((pValue.is_a? Hash and pValue.length == 1) or
|
39
|
+
pValue.is_a? String)
|
40
|
+
return nil
|
41
|
+
end
|
28
42
|
@parameters.push(pValue)
|
29
43
|
end
|
30
44
|
|
@@ -32,19 +46,52 @@ module Languages
|
|
32
46
|
# @param pConditional An object of ConditionalData.
|
33
47
|
# @return If pConditional is not an instance of ConditionalData,
|
34
48
|
# return nil.
|
35
|
-
def add_conditional(pConditional)
|
49
|
+
def add_conditional(pConditional, pBehaviour = Languages::KEEP_LEVEL)
|
36
50
|
return nil unless (pConditional.instance_of?Languages::ConditionalData)
|
37
|
-
|
51
|
+
add_with_manager(pConditional, "conditional", pBehaviour)
|
38
52
|
end
|
39
53
|
|
40
54
|
# Add repetition element inside function.
|
41
|
-
# @param pRepetition An object of
|
42
|
-
# @return If pRepetition is not
|
43
|
-
def add_repetition(pRepetition)
|
55
|
+
# @param pRepetition An object of RepetitionData.
|
56
|
+
# @return If pRepetition is not RepetitionData instance return nil.
|
57
|
+
def add_repetition(pRepetition, pBehaviour = Languages::KEEP_LEVEL)
|
44
58
|
return nil unless (pRepetition.instance_of?Languages::RepetitionData)
|
45
|
-
|
59
|
+
add_with_manager(pRepetition, "repetition", pBehaviour)
|
46
60
|
end
|
47
61
|
|
62
|
+
# Copy elements from an object of FunctionAbstract to specific element
|
63
|
+
# @param fromTo Reference from FunctionAbstract
|
64
|
+
def << (fromTo)
|
65
|
+
unless fromTo.is_a?(Languages::FunctionAbstract)
|
66
|
+
return nil
|
67
|
+
end
|
68
|
+
@name = fromTo.name
|
69
|
+
@parameters = fromTo.parameters
|
70
|
+
@managerCondAndLoop = fromTo.managerCondAndLoop
|
71
|
+
@visibility = fromTo.visibility
|
72
|
+
@comments = fromTo.comments
|
73
|
+
@type = @type
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
# Add to a manager conditional or repetition.
|
79
|
+
# @param pElementToAdd Element wish we want to add.
|
80
|
+
# @param pMetaData String with name for of element we want to add.
|
81
|
+
# @param pBehaviour Flag with behaviour.
|
82
|
+
def add_with_manager(pElementToAdd, pMetaData, pBehaviour)
|
83
|
+
case pBehaviour
|
84
|
+
when Languages::KEEP_LEVEL
|
85
|
+
@managerCondAndLoop.send("add_#{pMetaData}", pElementToAdd)
|
86
|
+
when Languages::UP_LEVEL
|
87
|
+
@managerCondAndLoop.up_level
|
88
|
+
@managerCondAndLoop.send("add_#{pMetaData}", pElementToAdd)
|
89
|
+
when Languages::DOWN_LEVEL
|
90
|
+
@managerCondAndLoop.down_level
|
91
|
+
@managerCondAndLoop.send("add_#{pMetaData}", pElementToAdd)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
48
95
|
# class
|
49
96
|
end
|
50
97
|
|