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,29 @@
|
|
|
1
|
+
require_relative '../error/language_error'
|
|
2
|
+
require_relative 'xml_output_format'
|
|
3
|
+
|
|
4
|
+
module Parser
|
|
5
|
+
|
|
6
|
+
# Simple factory to create output objects.
|
|
7
|
+
class OutputFactory
|
|
8
|
+
|
|
9
|
+
public
|
|
10
|
+
|
|
11
|
+
# Handling the output tyoe.
|
|
12
|
+
# @param pType [String] Type of object
|
|
13
|
+
# @return Return an object of output.
|
|
14
|
+
def get_output(pType)
|
|
15
|
+
pType.downcase!
|
|
16
|
+
|
|
17
|
+
if pType == "xml"
|
|
18
|
+
return XMLOutputFormat.new
|
|
19
|
+
end
|
|
20
|
+
if pType == "yml"
|
|
21
|
+
raise Error::ParserError
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Class
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Module
|
|
29
|
+
end
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
require 'fileutils'
|
|
2
|
+
|
|
3
|
+
require_relative '../core/setting'
|
|
4
|
+
|
|
5
|
+
module Parser
|
|
6
|
+
|
|
7
|
+
class OutputFormat
|
|
8
|
+
|
|
9
|
+
public
|
|
10
|
+
|
|
11
|
+
attr_accessor :outputEngine
|
|
12
|
+
attr_accessor :parserPath
|
|
13
|
+
attr_accessor :extension
|
|
14
|
+
|
|
15
|
+
# Set path to save the output.
|
|
16
|
+
# @param pPath Output path.
|
|
17
|
+
def set_path(pPath)
|
|
18
|
+
@parserPath = pPath
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Go through all the data, and generate the output
|
|
22
|
+
# @param pParser
|
|
23
|
+
# @return
|
|
24
|
+
def create_all_data(pParser)
|
|
25
|
+
return nil unless pParser
|
|
26
|
+
|
|
27
|
+
saveElementTo = "./"
|
|
28
|
+
wrapper = self
|
|
29
|
+
|
|
30
|
+
# Go through each file
|
|
31
|
+
pParser.fileLanguage.each do |listOfFile|
|
|
32
|
+
# Inspect each element
|
|
33
|
+
listOfFile.fileElements.each do |singleElement|
|
|
34
|
+
@outputEngine.kuniri do
|
|
35
|
+
if (singleElement.extern_requirements.length() > 0)
|
|
36
|
+
wrapper.extern_requirement_generate(
|
|
37
|
+
singleElement.extern_requirements)
|
|
38
|
+
end
|
|
39
|
+
if (singleElement.modules.length() > 0)
|
|
40
|
+
wrapper.module_generate(singleElement.modules)
|
|
41
|
+
end
|
|
42
|
+
#if (singleElement.global_variables.length() > 0)
|
|
43
|
+
# wrapper.global_variable_generate(
|
|
44
|
+
# singleElement.global_variables)
|
|
45
|
+
#end
|
|
46
|
+
if (singleElement.global_functions.length() > 0)
|
|
47
|
+
singleElement.global_functions.each do |globalFunction|
|
|
48
|
+
wrapper.function_behaviour_generate("functionData",
|
|
49
|
+
globalFunction)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
if (singleElement.classes.length() > 0)
|
|
53
|
+
wrapper.class_generate(singleElement.classes)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
saveElementTo = singleElement.name
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
write_file(saveElementTo, listOfFile.name)
|
|
60
|
+
@outputEngine.reset_engine
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def class_generate(pClass)
|
|
66
|
+
raise NotImplementedError
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def inheritance_generate(pInheritance)
|
|
70
|
+
raise NotImplementedError
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def parameters_generate(pParameters)
|
|
74
|
+
raise NotImplementedError
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def attribute_generate(pAttribute)
|
|
78
|
+
raise NotImplementedError
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def function_behaviour_generate(pElementName, pFunction)
|
|
82
|
+
raise NotImplementedError
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def global_variable_generate(pGlobalVariable)
|
|
86
|
+
raise NotImplementedError
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def extern_requirement_generate(pRequire)
|
|
90
|
+
raise NotImplementedError
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def basic_structure_generate(pManager)
|
|
94
|
+
raise NotImplementedError
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def module_generate(pModule)
|
|
98
|
+
raise NotImplementedError
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def comment_generate(pComment)
|
|
102
|
+
raise NotImplementedError
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def aggregation_generate(pAggregation)
|
|
106
|
+
raise NotImplementedError
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
private
|
|
110
|
+
|
|
111
|
+
def write_file(pSaveTo, pFileName)
|
|
112
|
+
info = Kuniri::Setting.create
|
|
113
|
+
unless File.file?(info.configurationInfo[:source])
|
|
114
|
+
outputDir = File.join(@parserPath, File.dirname(pSaveTo))
|
|
115
|
+
unless Dir.exists? outputDir
|
|
116
|
+
FileUtils.mkdir_p(File.join(@parserPath,
|
|
117
|
+
File.dirname(pSaveTo)))
|
|
118
|
+
end
|
|
119
|
+
# TODO: Extension should be flexible
|
|
120
|
+
destination = File.join(outputDir, pFileName + ".xml")
|
|
121
|
+
else
|
|
122
|
+
destination = @parserPath
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
File.open(destination, "w") do |file|
|
|
126
|
+
file.write(@outputEngine.to_xml)
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
# class
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# module
|
|
134
|
+
end
|
data/lib/kuniri/parser/parser.rb
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
require_relative '../language/language_factory'
|
|
2
|
-
require_relative '../util/html_logger'
|
|
3
|
-
require_relative '../util/html_logger'
|
|
4
2
|
|
|
5
3
|
# Module responsible for keeping the parser handler
|
|
6
4
|
module Parser
|
|
@@ -12,19 +10,19 @@ module Parser
|
|
|
12
10
|
|
|
13
11
|
attr_accessor :language
|
|
14
12
|
attr_reader :fileLanguage
|
|
13
|
+
attr_reader :filesPath
|
|
15
14
|
|
|
16
15
|
def initialize(pFilesPath, pLanguage = "ruby")
|
|
17
16
|
@filesPath = pFilesPath
|
|
18
17
|
@fileLanguage = []
|
|
19
|
-
@log = @settings = Kuniri::Setting.create.log
|
|
20
18
|
@factory = Languages::LanguageFactory.new
|
|
21
19
|
@language = pLanguage
|
|
22
20
|
end
|
|
23
21
|
|
|
24
22
|
# Start parse in the project.
|
|
25
23
|
def start_parser
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
raise Error::ConfigurationFileError if(@filesPath.empty?)
|
|
25
|
+
|
|
28
26
|
@filesPath.each do |file|
|
|
29
27
|
language = @factory.get_language(@language)
|
|
30
28
|
language.analyse_source(file)
|
|
@@ -34,8 +32,6 @@ module Parser
|
|
|
34
32
|
|
|
35
33
|
private
|
|
36
34
|
|
|
37
|
-
@filesPath
|
|
38
|
-
@log
|
|
39
35
|
@factory
|
|
40
36
|
|
|
41
37
|
# class
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
module Parser
|
|
2
|
+
|
|
3
|
+
class XMLBuilderEngine
|
|
4
|
+
|
|
5
|
+
attr_reader :tag
|
|
6
|
+
attr_reader :betweenTag
|
|
7
|
+
attr_reader :ident
|
|
8
|
+
attr_accessor :identIncrement
|
|
9
|
+
|
|
10
|
+
public
|
|
11
|
+
|
|
12
|
+
def initialize(pBaseSpaceIdent = 2)
|
|
13
|
+
set_default(pBaseSpaceIdent)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def to_xml
|
|
17
|
+
return @tag
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def reset_engine
|
|
21
|
+
@tag = nil
|
|
22
|
+
set_default
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def set_default(pBaseSpaceIdent = 2)
|
|
26
|
+
@tag = '<?xml version="1.0" encoding="UTF-8"?>'
|
|
27
|
+
@baseSpaceIdentation = pBaseSpaceIdent
|
|
28
|
+
@content = ''
|
|
29
|
+
@ident = ''
|
|
30
|
+
@identIncrement = ' ' * pBaseSpaceIdent
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
private
|
|
34
|
+
|
|
35
|
+
def method_missing(pTagName, *pTagParameters, &pBlock)
|
|
36
|
+
@tag += "\n" unless @tag.strip == ''
|
|
37
|
+
currentTagName = "#{@ident}<#{pTagName.to_s}"
|
|
38
|
+
@tag << currentTagName
|
|
39
|
+
if pTagParameters.size > 0 and pTagParameters[0].is_a? Hash
|
|
40
|
+
handleArguments(pTagParameters)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
if block_given?
|
|
44
|
+
@tag << ">\n"
|
|
45
|
+
incrementIdentation
|
|
46
|
+
result = instance_eval(&pBlock)
|
|
47
|
+
if result != '' && result.is_a?(String)
|
|
48
|
+
updateTag(result)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
decrementIdent
|
|
52
|
+
@tag << "#{@ident}</#{pTagName.to_s}>\n"
|
|
53
|
+
@tag.squeeze!("\n")
|
|
54
|
+
else
|
|
55
|
+
@tag << "/>\n"
|
|
56
|
+
end
|
|
57
|
+
@content = ''
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def updateTag(pNewContent)
|
|
61
|
+
@content = "\n#{@ident}" + pNewContent + "\n"
|
|
62
|
+
@tag << @content
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def handleArguments(pTagParameters)
|
|
66
|
+
pTagParameters[0].each do |key, value|
|
|
67
|
+
stringValue = handleSpecialCharactersXml(value.to_s)
|
|
68
|
+
@tag << " #{key.to_s}=\"#{stringValue}\""
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def handleSpecialCharactersXml(pString)
|
|
73
|
+
if pString.count('"') > 0 || pString.count("&") > 0 ||
|
|
74
|
+
pString.count('>') > 0 || pString.count('<') > 0
|
|
75
|
+
pString = pString.gsub('"', "'")
|
|
76
|
+
.gsub('&', '&')
|
|
77
|
+
.gsub('>', '>')
|
|
78
|
+
.gsub('<', '<')
|
|
79
|
+
end
|
|
80
|
+
return pString
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def incrementIdentation
|
|
84
|
+
@ident += @identIncrement
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def decrementIdent
|
|
88
|
+
if @ident.size > 0
|
|
89
|
+
@ident = @ident[0...(@ident.size - @baseSpaceIdentation)]
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
end
|
|
94
|
+
end
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
require_relative 'output_format'
|
|
2
|
+
require_relative 'xml_builder_engine'
|
|
3
|
+
|
|
4
|
+
module Parser
|
|
5
|
+
|
|
6
|
+
class XMLOutputFormat < OutputFormat
|
|
7
|
+
|
|
8
|
+
public
|
|
9
|
+
|
|
10
|
+
def initialize(pPath = "outputKuniri/")
|
|
11
|
+
@outputEngine = XMLBuilderEngine.new
|
|
12
|
+
set_path(pPath)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# @see OutputFormat
|
|
16
|
+
def class_generate(pClass)
|
|
17
|
+
# We use it because of the block below.
|
|
18
|
+
wrapper = self
|
|
19
|
+
pClass.each do |singleClass|
|
|
20
|
+
@outputEngine.classData :name => singleClass.name,
|
|
21
|
+
:visibility => singleClass.visibility do
|
|
22
|
+
wrapper.comment_generate(singleClass)
|
|
23
|
+
|
|
24
|
+
unless singleClass.aggregations.empty?
|
|
25
|
+
wrapper.aggregation_generate(singleClass.aggregations)
|
|
26
|
+
end
|
|
27
|
+
singleClass.inheritances.each do |singleInheritance|
|
|
28
|
+
wrapper.inheritance_generate(singleInheritance)
|
|
29
|
+
end
|
|
30
|
+
unless singleClass.attributes.empty?
|
|
31
|
+
wrapper.attribute_generate(singleClass.attributes)
|
|
32
|
+
end
|
|
33
|
+
singleClass.constructors.each do |singleConstructor|
|
|
34
|
+
wrapper.function_behaviour_generate("constructorData",
|
|
35
|
+
singleConstructor)
|
|
36
|
+
end
|
|
37
|
+
singleClass.methods.each do |singleMethod|
|
|
38
|
+
wrapper.function_behaviour_generate("methodData" , singleMethod)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# @see OutputFormat
|
|
45
|
+
def function_behaviour_generate(pElementName, pFunction)
|
|
46
|
+
wrapper = self
|
|
47
|
+
@outputEngine.send(pElementName, {:name => pFunction.name,
|
|
48
|
+
:visibility => pFunction.visibility}) do
|
|
49
|
+
wrapper.comment_generate(pFunction)
|
|
50
|
+
|
|
51
|
+
pFunction.parameters.each do |parameter|
|
|
52
|
+
wrapper.parameters_generate(parameter)
|
|
53
|
+
end
|
|
54
|
+
unless pFunction.managerCondAndLoop.basicStructure.empty?
|
|
55
|
+
wrapper.basic_structure_generate(
|
|
56
|
+
pFunction.managerCondAndLoop.basicStructure)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# @see OutputFormat
|
|
62
|
+
def parameters_generate(pParameters)
|
|
63
|
+
if pParameters.is_a?Hash
|
|
64
|
+
pParameters.each do |nameParam, value|
|
|
65
|
+
@outputEngine.parameterData :name => "#{nameParam}=#{value}"
|
|
66
|
+
end
|
|
67
|
+
elsif pParameters.is_a?String
|
|
68
|
+
@outputEngine.parameterData :name => pParameters
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# @see OutputFormat
|
|
73
|
+
def global_variable_generate(pGlobalVariable)
|
|
74
|
+
pGlobalVariable.each do |globalVar|
|
|
75
|
+
@outputEngine.globalVariableData :name => globalVar.name
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# @see OutputFormat
|
|
80
|
+
def attribute_generate(pAttribute)
|
|
81
|
+
pAttribute.each do |singleAttribute|
|
|
82
|
+
@outputEngine.attributeData :name => singleAttribute.name,
|
|
83
|
+
:visibility => singleAttribute.visibility
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# @see OutputFormat
|
|
88
|
+
def inheritance_generate(pInheritances)
|
|
89
|
+
pInheritances.each do |singleInheritance|
|
|
90
|
+
@outputEngine.inheritanceData :name => singleInheritance
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# @see OutputFormat
|
|
95
|
+
def extern_requirement_generate(pRequirement)
|
|
96
|
+
pRequirement.each do |externRequirement|
|
|
97
|
+
@outputEngine.externRequirementData :name =>
|
|
98
|
+
externRequirement.library
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# @see OutputFormat
|
|
103
|
+
def module_generate(pModule)
|
|
104
|
+
pModule.each do |singleModule|
|
|
105
|
+
@outputEngine.moduleData :name => singleModule.name
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# @see OutputFormat
|
|
110
|
+
def basic_structure_generate(pBasicStructure)
|
|
111
|
+
simple_element(pBasicStructure)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def simple_element(pElement)
|
|
115
|
+
pElement.each do |element|
|
|
116
|
+
if element.type == Languages::ELSE_LABEL
|
|
117
|
+
@outputEngine.send(element.type.downcase,
|
|
118
|
+
{:level => element.level})
|
|
119
|
+
else
|
|
120
|
+
@outputEngine.send(element.type.downcase,
|
|
121
|
+
{:expression => element.expression,
|
|
122
|
+
:level => element.level})
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def comment_generate(pElement)
|
|
128
|
+
if pElement.comments != ""
|
|
129
|
+
@outputEngine.commentData :text => pElement.comments.gsub('"', "'")
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def aggregation_generate(pAggregation)
|
|
134
|
+
pAggregation.each do |aggregation|
|
|
135
|
+
@outputEngine.aggregationData :name => aggregation.name
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
# class
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# module
|
|
143
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require_relative 'oo_structured_state'
|
|
2
|
+
|
|
3
|
+
module StateMachine
|
|
4
|
+
|
|
5
|
+
module OOStructuredFSM
|
|
6
|
+
|
|
7
|
+
# Class responsible for handling aggregation state.
|
|
8
|
+
class AggregationState < OOStructuredState
|
|
9
|
+
|
|
10
|
+
@language
|
|
11
|
+
|
|
12
|
+
def initialize(pLanguage)
|
|
13
|
+
@language = pLanguage
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# @see OOStructuredState
|
|
17
|
+
def handle_line(pLine)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# @see OOStructuredState
|
|
21
|
+
def class_capture
|
|
22
|
+
@language.rewind_state
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# @see OOStructuredState
|
|
26
|
+
def execute(pElementFile, pLine)
|
|
27
|
+
aggregationElement = @language.aggregationHandler.get_aggregation(pLine)
|
|
28
|
+
|
|
29
|
+
if aggregationElement
|
|
30
|
+
pElementFile.classes.last.aggregations.push aggregationElement
|
|
31
|
+
@language.metadata.allAggregations.push aggregationElement
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
class_capture
|
|
35
|
+
return pElementFile
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# End class
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# End OOStructuredFSM
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# End StateMachine
|
|
45
|
+
end
|