kuniri 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +43 -0
- data/.rspec +2 -0
- data/.travis.yml +18 -0
- data/.yardopts +1 -0
- data/COPYING +661 -0
- data/Gemfile +14 -0
- data/Guardfile +8 -0
- data/README.md +102 -0
- data/Rakefile +114 -0
- data/bin/kuniri +53 -0
- data/data/attribute_lang.rb +131 -0
- data/data/class_lang.rb +77 -0
- data/data/conditional_lang.rb +71 -0
- data/data/constructor_lang.rb +34 -0
- data/data/end_block_lang.rb +30 -0
- data/data/extern_requirement_lang.rb +45 -0
- data/data/function_behavior_lang.rb +113 -0
- data/data/lang_syntax.rb +111 -0
- data/data/module_namespace_lang.rb +43 -0
- data/data/repetition_lang.rb +62 -0
- data/data/token_lang.rb +55 -0
- data/data/variable_global_lang.rb +118 -0
- data/kuniri.gemspec +24 -0
- data/lib/kuniri/core/configuration/language_available.rb +7 -0
- data/lib/kuniri/core/configuration/log_available.rb +7 -0
- data/lib/kuniri/core/configuration/monitor_available.rb +13 -0
- data/lib/kuniri/core/kuniri.rb +78 -0
- data/lib/kuniri/core/setting.rb +143 -0
- data/lib/kuniri/error/configuration_file_error.rb +12 -0
- data/lib/kuniri/error/language_error.rb +12 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/attribute.rb +73 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/class.rb +51 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/comment.rb +57 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/conditional.rb +42 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/constructor.rb +52 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/end_block.rb +27 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/extern_requirement.rb +36 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/function_behavior.rb +55 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/module_namespace.rb +36 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/repetition.rb +42 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/variable_behaviour.rb +53 -0
- data/lib/kuniri/language/abstract_container/structured_and_oo/variable_global.rb +67 -0
- data/lib/kuniri/language/container_data/structured_and_oo/attribute_data.rb +26 -0
- data/lib/kuniri/language/container_data/structured_and_oo/basic_data.rb +18 -0
- data/lib/kuniri/language/container_data/structured_and_oo/class_data.rb +77 -0
- data/lib/kuniri/language/container_data/structured_and_oo/conditional_data.rb +23 -0
- data/lib/kuniri/language/container_data/structured_and_oo/constructor_data.rb +18 -0
- data/lib/kuniri/language/container_data/structured_and_oo/extern_requirement_data.rb +26 -0
- data/lib/kuniri/language/container_data/structured_and_oo/file_element.rb +77 -0
- data/lib/kuniri/language/container_data/structured_and_oo/function_abstract.rb +52 -0
- data/lib/kuniri/language/container_data/structured_and_oo/function_data.rb +21 -0
- data/lib/kuniri/language/container_data/structured_and_oo/method_data.rb +20 -0
- data/lib/kuniri/language/container_data/structured_and_oo/module_namespace_data.rb +18 -0
- data/lib/kuniri/language/container_data/structured_and_oo/repetition_data.rb +23 -0
- data/lib/kuniri/language/container_data/structured_and_oo/variable_global_data.rb +22 -0
- data/lib/kuniri/language/language.rb +222 -0
- data/lib/kuniri/language/language_factory.rb +48 -0
- data/lib/kuniri/language/ruby/attribute_ruby.rb +134 -0
- data/lib/kuniri/language/ruby/class_ruby.rb +83 -0
- data/lib/kuniri/language/ruby/comment_ruby.rb +84 -0
- data/lib/kuniri/language/ruby/conditional_ruby.rb +77 -0
- data/lib/kuniri/language/ruby/constructor_ruby.rb +36 -0
- data/lib/kuniri/language/ruby/end_block_ruby.rb +33 -0
- data/lib/kuniri/language/ruby/extern_requirement_ruby.rb +49 -0
- data/lib/kuniri/language/ruby/function_behavior_ruby.rb +120 -0
- data/lib/kuniri/language/ruby/module_namespace_ruby.rb +47 -0
- data/lib/kuniri/language/ruby/repetition_ruby.rb +68 -0
- data/lib/kuniri/language/ruby/ruby_syntax.rb +117 -0
- data/lib/kuniri/language/ruby/token_ruby.rb +59 -0
- data/lib/kuniri/language/ruby/variable_behaviour_ruby.rb +83 -0
- data/lib/kuniri/language/ruby/variable_global_ruby.rb +123 -0
- data/lib/kuniri/parser/parser.rb +45 -0
- data/lib/kuniri/parser/parser_xml.rb +128 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/attribute_state.rb +51 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/class_state.rb +94 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/comment_state.rb +76 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/conditional_state.rb +92 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/constructor_state.rb +71 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/function_state.rb +82 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/idle_state.rb +80 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/include_state.rb +59 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/method_state.rb +69 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/module_state.rb +79 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/oo_structured_state.rb +92 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/repetition_state.rb +85 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/token_state_machine.rb +8 -0
- data/lib/kuniri/state_machine/OO_structured_fsm/variable_state.rb +49 -0
- data/lib/kuniri/util/html_logger.rb +41 -0
- data/lib/kuniri/util/logger.rb +34 -0
- data/lib/kuniri/util/txt_logger.rb +29 -0
- data/lib/kuniri/version.rb +3 -0
- data/lib/kuniri.rb +5 -0
- data/other/analyseFile.asta +0 -0
- data/spec/core/kuniri_spec.rb +14 -0
- data/spec/core/setting_spec.rb +114 -0
- data/spec/language/abstract_container/attribute_spec.rb +13 -0
- data/spec/language/abstract_container/class_spec.rb +13 -0
- data/spec/language/abstract_container/comment_spec.rb +31 -0
- data/spec/language/abstract_container/conditional_spec.rb +13 -0
- data/spec/language/abstract_container/constructor_spec.rb +13 -0
- data/spec/language/abstract_container/end_block_spec.rb +14 -0
- data/spec/language/abstract_container/module_namespace_spec.rb +13 -0
- data/spec/language/abstract_container/repetition_spec.rb +13 -0
- data/spec/language/container_data/structured_and_oo/attribute_data_spec.rb +32 -0
- data/spec/language/container_data/structured_and_oo/class_data_spec.rb +121 -0
- data/spec/language/container_data/structured_and_oo/conditional_data_spec.rb +34 -0
- data/spec/language/container_data/structured_and_oo/constructor_data_spec.rb +46 -0
- data/spec/language/container_data/structured_and_oo/extern_requirement_data_spec.rb +26 -0
- data/spec/language/container_data/structured_and_oo/file_element_spec.rb +91 -0
- data/spec/language/container_data/structured_and_oo/function_data_spec.rb +22 -0
- data/spec/language/container_data/structured_and_oo/module_namespace_spec.rb +20 -0
- data/spec/language/container_data/structured_and_oo/repetition_data_spec.rb +34 -0
- data/spec/language/container_data/structured_and_oo/variable_global_data_spec.rb +39 -0
- data/spec/language/language_factory_spec.rb +64 -0
- data/spec/language/language_spec.rb +74 -0
- data/spec/language/ruby/attribute_ruby_spec.rb +126 -0
- data/spec/language/ruby/class_ruby_spec.rb +102 -0
- data/spec/language/ruby/comment_ruby_spec.rb +78 -0
- data/spec/language/ruby/conditional_ruby_spec.rb +106 -0
- data/spec/language/ruby/constructor_ruby_spec.rb +57 -0
- data/spec/language/ruby/end_block_ruby_spec.rb +62 -0
- data/spec/language/ruby/function_behavior_ruby_spec.rb +246 -0
- data/spec/language/ruby/module_namespace_ruby_spec.rb +55 -0
- data/spec/language/ruby/repetition_ruby_spec.rb +33 -0
- data/spec/language/ruby/ruby_syntax_spec.rb +482 -0
- data/spec/language/ruby/variable_ruby_spec.rb +134 -0
- data/spec/parser/parser_spec.rb +25 -0
- data/spec/samples/rubySyntaxParts/attribute/simpleAttribute.rb +15 -0
- data/spec/samples/rubySyntaxParts/class/simpleClass.rb +19 -0
- data/spec/samples/rubySyntaxParts/comment/simple_multiple_line_comment_class.rb +33 -0
- data/spec/samples/rubySyntaxParts/comment/simple_multiple_line_comment_global.rb +20 -0
- data/spec/samples/rubySyntaxParts/comment/simple_single_line_comment_class.rb +23 -0
- data/spec/samples/rubySyntaxParts/comment/simple_single_line_comment_global.rb +16 -0
- data/spec/samples/rubySyntaxParts/conditionalStatment/constructorConditional.rb +28 -0
- data/spec/samples/rubySyntaxParts/conditionalStatment/methodConditional.rb +42 -0
- data/spec/samples/rubySyntaxParts/conditionalStatment/nestedConditional.rb +0 -0
- data/spec/samples/rubySyntaxParts/conditionalStatment/simpleConditional.rb +43 -0
- data/spec/samples/rubySyntaxParts/constructor/simpleConstructor.rb +27 -0
- data/spec/samples/rubySyntaxParts/extern/multipleLineExternRequirement.rb +0 -0
- data/spec/samples/rubySyntaxParts/extern/requireRelative.rb +6 -0
- data/spec/samples/rubySyntaxParts/extern/simpleExternRequirement.rb +14 -0
- data/spec/samples/rubySyntaxParts/fullCode/simpleCodeWithConditional.rb +18 -0
- data/spec/samples/rubySyntaxParts/fullCode/simpleFullCode.rb +19 -0
- data/spec/samples/rubySyntaxParts/function/simpleFunction.rb +29 -0
- data/spec/samples/rubySyntaxParts/method/simpleMethod.rb +13 -0
- data/spec/samples/rubySyntaxParts/module/simpleModule.rb +12 -0
- data/spec/samples/rubySyntaxParts/repetition/simpleRepetition.rb +28 -0
- data/spec/samples/rubySyntaxParts/variable/simpleVariable.rb +13 -0
- data/spec/spec_helper.rb +20 -0
- data/spec/state_machine/OO_structured_fsm/attribute_state_spec.rb +44 -0
- data/spec/state_machine/OO_structured_fsm/class_state_spec.rb +90 -0
- data/spec/state_machine/OO_structured_fsm/comment_state_spec.rb +30 -0
- data/spec/state_machine/OO_structured_fsm/conditional_state_spec.rb +83 -0
- data/spec/state_machine/OO_structured_fsm/constructor_state_spec.rb +48 -0
- data/spec/state_machine/OO_structured_fsm/function_state_spec.rb +41 -0
- data/spec/state_machine/OO_structured_fsm/idle_state_spec.rb +101 -0
- data/spec/state_machine/OO_structured_fsm/include_state_spec.rb +62 -0
- data/spec/state_machine/OO_structured_fsm/method_state_spec.rb +42 -0
- data/spec/state_machine/OO_structured_fsm/module_state_spec.rb +54 -0
- data/spec/state_machine/OO_structured_fsm/oo_structured_state_spec.rb +0 -0
- data/spec/state_machine/OO_structured_fsm/repetition_state_spec.rb +83 -0
- data/spec/state_machine/OO_structured_fsm/variable_state_spec.rb +40 -0
- data/spec/util/html_logger_spec.rb +31 -0
- data/spec/util/logger_spec.rb +20 -0
- data/spec/util/txt_logger_spec.rb +31 -0
- metadata +326 -0
@@ -0,0 +1,143 @@
|
|
1
|
+
require_relative 'configuration/language_available'
|
2
|
+
require_relative 'configuration/monitor_available'
|
3
|
+
require_relative 'configuration/log_available'
|
4
|
+
|
5
|
+
require_relative '../util/html_logger'
|
6
|
+
require_relative '../util/txt_logger'
|
7
|
+
require_relative '../error/configuration_file_error'
|
8
|
+
|
9
|
+
module Kuniri
|
10
|
+
|
11
|
+
# Class Setting that read and handling .kuniri file.
|
12
|
+
class Setting
|
13
|
+
|
14
|
+
public
|
15
|
+
|
16
|
+
private_class_method :new
|
17
|
+
attr_reader :configurationInfo
|
18
|
+
attr_reader :log
|
19
|
+
|
20
|
+
def initialize
|
21
|
+
initializate_settings
|
22
|
+
end
|
23
|
+
|
24
|
+
def Setting.create
|
25
|
+
@@settings = new unless @@settings
|
26
|
+
return @@settings
|
27
|
+
end
|
28
|
+
|
29
|
+
def initializate_settings(pFilePath = ".kuniri")
|
30
|
+
begin
|
31
|
+
@configurationInfo = read_configuration_file(pFilePath)
|
32
|
+
initialize_object
|
33
|
+
rescue Error::ConfigurationFileError
|
34
|
+
puts "You have a syntax problem on your configuration file."
|
35
|
+
abort
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
# Read the configuration file and return a list with the configurations.
|
41
|
+
# In this method it is checked the configuration file syntax.
|
42
|
+
# @param pPath [String] Path to ".kuniri" file, it means, the
|
43
|
+
# configurations.
|
44
|
+
# @return [Hash] Return a Hash with the configurations read in ".kuniri",
|
45
|
+
# otherwise, raise an exception.
|
46
|
+
# @raise [type] Raise an syntax error if ".kuniri" has any syntax mistake
|
47
|
+
# @raise [type] Raised in the case of the path is wrong.
|
48
|
+
def read_configuration_file(pPath = ".kuniri")
|
49
|
+
configuration = {}
|
50
|
+
|
51
|
+
unless File.exists?(pPath)
|
52
|
+
# @log.write_log("Info: Not provide configuration file. Get default")
|
53
|
+
configuration = default_configuration
|
54
|
+
else
|
55
|
+
configuration = parser_configuration_file(pPath)
|
56
|
+
end
|
57
|
+
|
58
|
+
# @log.write_log("First reading configuration file: #{configuration}")
|
59
|
+
|
60
|
+
validate_field(configuration, "language") do |language|
|
61
|
+
Configuration::Language_Available::LANGUAGES.include?(language)
|
62
|
+
end
|
63
|
+
|
64
|
+
validate_field(configuration, "source") do |sourcePath|
|
65
|
+
File.exists?(sourcePath)
|
66
|
+
end
|
67
|
+
|
68
|
+
validate_field(configuration, "output") do |outputPath|
|
69
|
+
File.exists?(outputPath)
|
70
|
+
end
|
71
|
+
|
72
|
+
validate_field(configuration, "extract") do |extract|
|
73
|
+
Configuration::Monitor_Available::MONITORS.include?(extract.downcase)
|
74
|
+
end
|
75
|
+
|
76
|
+
validate_field(configuration, "log") do |log|
|
77
|
+
Configuration::Log_Available::LOG.include?(log.downcase)
|
78
|
+
end
|
79
|
+
|
80
|
+
# @log.write_log("Debug: Configuration: #{configuration}")
|
81
|
+
|
82
|
+
return configuration
|
83
|
+
end
|
84
|
+
|
85
|
+
private
|
86
|
+
|
87
|
+
@@settings = nil
|
88
|
+
|
89
|
+
def default_configuration
|
90
|
+
configuration = {"language" => "ruby",
|
91
|
+
"source" => "./",
|
92
|
+
"output" => "./",
|
93
|
+
"extract" => "uml",
|
94
|
+
"log" => "html"}
|
95
|
+
return configuration
|
96
|
+
end
|
97
|
+
|
98
|
+
def parser_configuration_file(pPath)
|
99
|
+
configuration = default_configuration
|
100
|
+
|
101
|
+
# @log.write_log("Debug: Reading cofiguration file in: #{pPath}")
|
102
|
+
File.open(pPath, mode="r").each_line do |line|
|
103
|
+
parts = line.split(':').size
|
104
|
+
unless (parts == 2)
|
105
|
+
# @log.write_log("Syntax error on configuration file.")
|
106
|
+
raise Error::ConfigurationFileError
|
107
|
+
end
|
108
|
+
key = handling_basic_syntax(line, 0)
|
109
|
+
value = handling_basic_syntax(line, 1)
|
110
|
+
configuration[key] = value
|
111
|
+
end
|
112
|
+
return configuration
|
113
|
+
end
|
114
|
+
|
115
|
+
def validate_field(pConfiguration_hash, pKey)
|
116
|
+
if pConfiguration_hash.has_key?(pKey)
|
117
|
+
value = pConfiguration_hash[pKey]
|
118
|
+
value.split(',').each do |element|
|
119
|
+
raise Error::ConfigurationFileError unless yield(element)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def handling_basic_syntax(pLine, pIndex)
|
125
|
+
text = pLine.split(':')[pIndex].downcase
|
126
|
+
text.gsub!(/\s/, '')
|
127
|
+
return text
|
128
|
+
end
|
129
|
+
|
130
|
+
def initialize_object
|
131
|
+
logType = @configurationInfo["log"]
|
132
|
+
if logType == "html"
|
133
|
+
@log = Util::HtmlLogger.new
|
134
|
+
elsif logType == "txt"
|
135
|
+
@log = Util::TxtLogger.new
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
# Class
|
140
|
+
end
|
141
|
+
|
142
|
+
# Module
|
143
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# Error module, responsible for manage the errors.
|
2
|
+
module Error
|
3
|
+
|
4
|
+
# Configuration_file_error is a class responsable for handling the many
|
5
|
+
# different kind of error that can be raised in case of syntax error.
|
6
|
+
class ConfigurationFileError < RuntimeError
|
7
|
+
|
8
|
+
# Class
|
9
|
+
end
|
10
|
+
|
11
|
+
# Error
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# Error module, responsible for manage the errors.
|
2
|
+
module Error
|
3
|
+
|
4
|
+
# Configuration_file_error is a class responsable for handling the many
|
5
|
+
# different kind of error that can be raised in case of syntax error.
|
6
|
+
class LanguageError < RuntimeError
|
7
|
+
|
8
|
+
# Class
|
9
|
+
end
|
10
|
+
|
11
|
+
# Error
|
12
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module Languages
|
2
|
+
|
3
|
+
# @abstract Abstract class for handling attribute.
|
4
|
+
class Attribute
|
5
|
+
|
6
|
+
public
|
7
|
+
|
8
|
+
# Verify if a line has an attribute. If it has attribute, firstly, the
|
9
|
+
# function capture all lines and removes specific language declaration
|
10
|
+
# (for instance, in ruby it is: "@" or ":" and whitespace), finally
|
11
|
+
# it splits the string by an special character and return an object of
|
12
|
+
# AttributeData.
|
13
|
+
# @param pLine An line to be analysed for find attribute.
|
14
|
+
# @return Return on filled object of AttributeData if it find an
|
15
|
+
# attribute, otherwise it returns nil.
|
16
|
+
def get_attribute(pLine)
|
17
|
+
raise NotImplementedError
|
18
|
+
end
|
19
|
+
|
20
|
+
protected
|
21
|
+
|
22
|
+
# Detect if line has attribute.
|
23
|
+
# @param pLine Line with potential attribute.
|
24
|
+
# @return Return a matched STRING or nil if not found.
|
25
|
+
def detect_attribute(pLine)
|
26
|
+
raise NotImplementedError
|
27
|
+
end
|
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
|
+
# Class
|
70
|
+
end
|
71
|
+
|
72
|
+
# Language
|
73
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Languages
|
2
|
+
|
3
|
+
# @abstract Class is an container for handling class
|
4
|
+
class Class
|
5
|
+
|
6
|
+
public
|
7
|
+
|
8
|
+
# Inspect line, and verify if it has a class or not.
|
9
|
+
# @param pLine Line with the potential class.
|
10
|
+
# @return Return an object ClassData if it find a class in the line,
|
11
|
+
# otherwise return nil.
|
12
|
+
def get_class(pLine)
|
13
|
+
raise NotImplementedError
|
14
|
+
end
|
15
|
+
|
16
|
+
protected
|
17
|
+
|
18
|
+
# Verify if line can have a class.
|
19
|
+
# @param pLine Line to inspect.
|
20
|
+
# @return Returns an row string with class name, otherwise returns nil.
|
21
|
+
def detect_class(pLine)
|
22
|
+
raise NotImplementedError
|
23
|
+
end
|
24
|
+
|
25
|
+
# Check if class has an inheritance inside.
|
26
|
+
# @param pString Line with the potential inheritance inside.
|
27
|
+
# @return Returns a string with the inheritance class, or return nil.
|
28
|
+
def get_inheritance(pString)
|
29
|
+
raise NotImplementedError
|
30
|
+
end
|
31
|
+
|
32
|
+
# Take an partial result of string, and remove unnecessary informations.
|
33
|
+
# @param pString Line with string.
|
34
|
+
# @return Return a string without any unnecessary information.
|
35
|
+
def remove_unnecessary_information(pString)
|
36
|
+
raise NotImplementedError
|
37
|
+
end
|
38
|
+
|
39
|
+
# Prepare final string before save it. Here it is the place to prune the
|
40
|
+
# final details in the string.
|
41
|
+
# @param pString String to be improved before save it.
|
42
|
+
# @return Returns a string prepared to be saved.
|
43
|
+
def prepare_final_string(pString)
|
44
|
+
raise NotImplementedError
|
45
|
+
end
|
46
|
+
|
47
|
+
# Class
|
48
|
+
end
|
49
|
+
|
50
|
+
# Languages
|
51
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Languages
|
2
|
+
|
3
|
+
# @abstract Class responsible for handling comments. Attention, this class
|
4
|
+
# is the only exception to the pattern. Usually, we implements a method
|
5
|
+
# called detect_something. However, in the case of comment, it is easier
|
6
|
+
# to create another set of methods.
|
7
|
+
class Comment
|
8
|
+
|
9
|
+
public
|
10
|
+
|
11
|
+
# This method is responsible for handling comments.
|
12
|
+
# @param pLine String to be analysed.
|
13
|
+
# @return Returns nil if doesn't find any comment line, or returns a
|
14
|
+
# string with comments. Finally, if it find the final of
|
15
|
+
# multiple line comment it returns END_MULTIPLE_LINE_COMMENT.
|
16
|
+
def get_comment(pLine)
|
17
|
+
raise NotImplementedError
|
18
|
+
end
|
19
|
+
|
20
|
+
# This method is responsible for checking if is a single line comment.
|
21
|
+
# @param pLine String for verify if is a single line comment.
|
22
|
+
# @return Return true if is a single line comment, otherwise, return
|
23
|
+
# false.
|
24
|
+
def is_single_line_comment?(pLine)
|
25
|
+
raise NotImplementedError
|
26
|
+
end
|
27
|
+
|
28
|
+
# This method verify if it a multiple line comment.
|
29
|
+
# @param pLine String for verify if is a multiple line comment.
|
30
|
+
# @return Return true if is a multiple line comment, otherwise, return
|
31
|
+
# false.
|
32
|
+
def is_multiple_line_comment?(pLine)
|
33
|
+
raise NotImplementedError
|
34
|
+
end
|
35
|
+
|
36
|
+
# This method verify if it is the end of multiple line comment.
|
37
|
+
# @param pLine String to be inspected.
|
38
|
+
# @return Return true if is the end of multiple line comment, otherwise,
|
39
|
+
# return true.
|
40
|
+
def is_multiple_line_comment_end?(pLine)
|
41
|
+
raise NotImplementedError
|
42
|
+
end
|
43
|
+
|
44
|
+
protected
|
45
|
+
|
46
|
+
# Method responsible for doing the final adjustment in the comment.
|
47
|
+
# @param pString Comment string to be handled.
|
48
|
+
# @return Return a string.
|
49
|
+
def prepare_line_comment(pString)
|
50
|
+
raise NotImplementedError
|
51
|
+
end
|
52
|
+
|
53
|
+
# End class
|
54
|
+
end
|
55
|
+
|
56
|
+
# module
|
57
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Languages
|
2
|
+
|
3
|
+
# @abstract Class responsible for handling conditional instructions.
|
4
|
+
class Conditional
|
5
|
+
|
6
|
+
public
|
7
|
+
|
8
|
+
# Get conditional
|
9
|
+
# @param pLine String with possible conditional statement.
|
10
|
+
# @return Returns an ConditionalData, otherwise return nil.
|
11
|
+
def get_conditional(pLine)
|
12
|
+
raise NotImplementedError
|
13
|
+
end
|
14
|
+
|
15
|
+
protected
|
16
|
+
|
17
|
+
# Try to detect possible conditional in the line.
|
18
|
+
# @param pLine String with possible conditional event.
|
19
|
+
# @return Return a partial string, otherwise return nil.
|
20
|
+
def detect_conditional(pLine)
|
21
|
+
raise NotImplementedError
|
22
|
+
end
|
23
|
+
|
24
|
+
# Handling string type
|
25
|
+
# @param pString String for find the conditional type.
|
26
|
+
# @return Return a string with the type.
|
27
|
+
def conditional_type(pString)
|
28
|
+
raise NotImplementedError
|
29
|
+
end
|
30
|
+
|
31
|
+
# Try to extract the expression.
|
32
|
+
# @param pString String with conditional expression.
|
33
|
+
# @return Return a partial string.
|
34
|
+
def get_expression(pString)
|
35
|
+
raise NotImplementedError
|
36
|
+
end
|
37
|
+
|
38
|
+
# class
|
39
|
+
end
|
40
|
+
|
41
|
+
# Languages
|
42
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Languages
|
2
|
+
|
3
|
+
# @abstract Constructor.
|
4
|
+
class Constructor
|
5
|
+
|
6
|
+
public
|
7
|
+
|
8
|
+
# Inspect line for trying to find a constructor.
|
9
|
+
# @param pLine String with potential function.
|
10
|
+
# @return Returns ConstructorData, or nil if line doesn't have method.
|
11
|
+
def get_constructor(pLine)
|
12
|
+
raise NotImplementedError
|
13
|
+
end
|
14
|
+
|
15
|
+
protected
|
16
|
+
|
17
|
+
@type
|
18
|
+
|
19
|
+
# Detect constructor in line
|
20
|
+
# @param pLine Line string with the potential constructor inside.
|
21
|
+
# @return Return the constructor if it is find in the string, otherwise
|
22
|
+
# return nil
|
23
|
+
def detect_constructor(pLine)
|
24
|
+
raise NotImplementedError
|
25
|
+
end
|
26
|
+
|
27
|
+
# Trim unnecessary information from the string.
|
28
|
+
# @param pLine String for handling.
|
29
|
+
# @return Return an string.
|
30
|
+
def remove_unnecessary_information(pLine)
|
31
|
+
raise NotImplementedError
|
32
|
+
end
|
33
|
+
|
34
|
+
# Handling default parameters.
|
35
|
+
# @param pLine String with parameters.
|
36
|
+
# @return Return an array with default parameters.
|
37
|
+
def handling_default_parameter(pLine)
|
38
|
+
raise NotImplementedError
|
39
|
+
end
|
40
|
+
|
41
|
+
# Handling parameters.
|
42
|
+
# @param pLine String to try to find the parameters.
|
43
|
+
# @return Return a list with all the parameter, otherwise return nil
|
44
|
+
def handling_parameter(pLine)
|
45
|
+
raise NotImplementedError
|
46
|
+
end
|
47
|
+
|
48
|
+
# Class
|
49
|
+
end
|
50
|
+
|
51
|
+
# Languages
|
52
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Languages
|
2
|
+
|
3
|
+
# @abstract Class responsible for handling end block of each language.
|
4
|
+
class EndBlock
|
5
|
+
|
6
|
+
public
|
7
|
+
|
8
|
+
# Verify if line has an end of line token.
|
9
|
+
# @param pLine Line to inspect.
|
10
|
+
# @return Return true if find an end block, otherwise return false.
|
11
|
+
def has_end_of_block?(pLine)
|
12
|
+
raise NotImplementedError
|
13
|
+
end
|
14
|
+
|
15
|
+
protected
|
16
|
+
|
17
|
+
# Keeps some operation for find line.
|
18
|
+
# @param pLine Line with potential end of block.
|
19
|
+
def detect_end(pLine)
|
20
|
+
raise NotImplementedError
|
21
|
+
end
|
22
|
+
|
23
|
+
# End block
|
24
|
+
end
|
25
|
+
|
26
|
+
# End module
|
27
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Languages
|
2
|
+
|
3
|
+
# ExternRequirement is responsible for handling external requirement.
|
4
|
+
# An external requirement is the "#include" in C, "require" in Ruby,
|
5
|
+
# "import" in Java, etc.
|
6
|
+
class ExternRequirement
|
7
|
+
|
8
|
+
public
|
9
|
+
|
10
|
+
# Get requirement name.
|
11
|
+
# @param pLine Line to be analysed.
|
12
|
+
# @return Return the ExternRequirementData object, or nil.
|
13
|
+
def get_requirement(pLine)
|
14
|
+
raise NotImplementedError
|
15
|
+
end
|
16
|
+
|
17
|
+
protected
|
18
|
+
|
19
|
+
# @param pLine Line to detect requirement.
|
20
|
+
# @return Returns a string with row extern requirement, or nil if not
|
21
|
+
# detects anything.
|
22
|
+
def detect_extern_requirement(pLine)
|
23
|
+
raise NotImplementedError
|
24
|
+
end
|
25
|
+
|
26
|
+
# @param pLine Line with row string to be pruned.
|
27
|
+
# @return Returns an string.
|
28
|
+
def remove_unnecessary_information(pLine)
|
29
|
+
raise NotImplementedError
|
30
|
+
end
|
31
|
+
|
32
|
+
# Class
|
33
|
+
end
|
34
|
+
|
35
|
+
# Module
|
36
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Languages
|
2
|
+
|
3
|
+
# @abstract This class is responsible for handling elements whose the
|
4
|
+
# behaviour is similar to a function. For example, method and global
|
5
|
+
# function has a very similar behaviour, because of this is a good idea
|
6
|
+
# to use this class as parent.
|
7
|
+
class FunctionBehavior
|
8
|
+
|
9
|
+
public
|
10
|
+
|
11
|
+
# Verify if line has a potential function.
|
12
|
+
# @param pLine String with potencial function.
|
13
|
+
# @return Returns FuntionData, or nil if line doesn't have method.
|
14
|
+
def get_function(pLine, type = 'globalFunction')
|
15
|
+
raise NotImplementedError
|
16
|
+
end
|
17
|
+
|
18
|
+
protected
|
19
|
+
|
20
|
+
@type
|
21
|
+
|
22
|
+
# Detect function in line.
|
23
|
+
# @param pLine Line string with the potential method inside.
|
24
|
+
# @return Return the method if it is find in the string, othewise return
|
25
|
+
# nil.
|
26
|
+
def detect_function(pLine)
|
27
|
+
raise NotImplementedError
|
28
|
+
end
|
29
|
+
|
30
|
+
# Remove unnecessary information inside the string.
|
31
|
+
# @param pLine Line for handling the string.
|
32
|
+
# @return Return a string.
|
33
|
+
def remove_unnecessary_information(pLine)
|
34
|
+
raise NotImplementedError
|
35
|
+
end
|
36
|
+
|
37
|
+
# Handling default parameters.
|
38
|
+
# @param pLine Line to be check.
|
39
|
+
# @return Return a string.
|
40
|
+
def handling_default_parameter(pLine)
|
41
|
+
raise NotImplementedError
|
42
|
+
end
|
43
|
+
|
44
|
+
# Handling parameters.
|
45
|
+
# @param pLine String to try to find the parameters.
|
46
|
+
# @return Return a list with all the parameter, othewise return nil
|
47
|
+
def handling_parameter(pLine)
|
48
|
+
raise NotImplementedError
|
49
|
+
end
|
50
|
+
|
51
|
+
# Class
|
52
|
+
end
|
53
|
+
|
54
|
+
# Languages
|
55
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Languages
|
2
|
+
|
3
|
+
# @abstract Class responsible for handling namespaces, module, package or
|
4
|
+
# anything similar.
|
5
|
+
class ModuleNamespace
|
6
|
+
|
7
|
+
public
|
8
|
+
|
9
|
+
# Get a string and try to find a pattern, that match or not with module.
|
10
|
+
# @param pLine Receives a line for try to find module inside it.
|
11
|
+
# @return Return an ModuleNamespaceData.
|
12
|
+
def get_module(pLine)
|
13
|
+
raise NotImplementedError
|
14
|
+
end
|
15
|
+
|
16
|
+
protected
|
17
|
+
|
18
|
+
# Verify if line has a potential module.
|
19
|
+
# @param pLine String for try to find a pattern.
|
20
|
+
# @return Return an string pre-processed, or nil in case of not match
|
21
|
+
# string.
|
22
|
+
def detect_module(pLine)
|
23
|
+
raise NotImplementedError
|
24
|
+
end
|
25
|
+
|
26
|
+
# @param pLine Receives a line for handling.
|
27
|
+
# @return Return an string.
|
28
|
+
def remove_unnecessary_information(pLine)
|
29
|
+
raise NotImplementedError
|
30
|
+
end
|
31
|
+
|
32
|
+
# class
|
33
|
+
end
|
34
|
+
|
35
|
+
# Languages module
|
36
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Languages
|
2
|
+
|
3
|
+
# @abstract Repetition class handling repetition structures.
|
4
|
+
class Repetition
|
5
|
+
|
6
|
+
public
|
7
|
+
|
8
|
+
# Get conditional.
|
9
|
+
# @param pLine String with possible repetition statement.
|
10
|
+
# @return Return an ConditionalData, otherwise return nil.
|
11
|
+
def get_repetition(pLine)
|
12
|
+
raise NotImplementedError
|
13
|
+
end
|
14
|
+
|
15
|
+
protected
|
16
|
+
|
17
|
+
# Try to detect possible repetition in the line.
|
18
|
+
# @param pLine String with possible repetition event.
|
19
|
+
# @return Return a partial string, otherwise return nil.
|
20
|
+
def detect_repetition(pLine)
|
21
|
+
raise NotImplementedError
|
22
|
+
end
|
23
|
+
|
24
|
+
# Handling string type
|
25
|
+
# @param pString String for find the repetition type.
|
26
|
+
# @return Return a string with the type.
|
27
|
+
def repetition_type(pString)
|
28
|
+
raise NotImplementedError
|
29
|
+
end
|
30
|
+
|
31
|
+
# Try to extract the expression.
|
32
|
+
# @param pString String with conditional expression.
|
33
|
+
# @return Return a partial string.
|
34
|
+
def get_expression(pString)
|
35
|
+
raise NotImplementedError
|
36
|
+
end
|
37
|
+
|
38
|
+
# class
|
39
|
+
end
|
40
|
+
|
41
|
+
# Languages
|
42
|
+
end
|