Class: Languages::Language Abstract
- Inherits:
-
Object
- Object
- Languages::Language
- Defined in:
- lib/kuniri/language/language.rb
Overview
Abstract class for handling different types of language.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#aggregationHandler ⇒ Object
readonly
Returns the value of attribute aggregationHandler.
-
#aggregationState ⇒ Object
readonly
Returns the value of attribute aggregationState.
-
#attributeHandler ⇒ Object
readonly
Returns the value of attribute attributeHandler.
-
#attributeState ⇒ Object
readonly
Returns the value of attribute attributeState.
-
#classHandler ⇒ Object
readonly
Returns the value of attribute classHandler.
-
#classState ⇒ Object
readonly
Returns the value of attribute classState.
-
#commentHandler ⇒ Object
readonly
Returns the value of attribute commentHandler.
-
#commentState ⇒ Object
readonly
Returns the value of attribute commentState.
-
#conditionalHandler ⇒ Object
readonly
Returns the value of attribute conditionalHandler.
-
#conditionalState ⇒ Object
readonly
Returns the value of attribute conditionalState.
-
#constructorHandler ⇒ Object
readonly
Returns the value of attribute constructorHandler.
-
#constructorState ⇒ Object
readonly
Returns the value of attribute constructorState.
-
#countNestedCondLoop ⇒ Object
readonly
Returns the value of attribute countNestedCondLoop.
-
#endBlockHandler ⇒ Object
readonly
Returns the value of attribute endBlockHandler.
-
#externRequirementHandler ⇒ Object
readonly
Returns the value of attribute externRequirementHandler.
-
#fileElements ⇒ Object
Returns the value of attribute fileElements.
-
#flagFunctionBehaviour ⇒ Object
Those values help state machine to understand which place to add conditional information and repetition data.
-
#functionHandler ⇒ Object
readonly
Returns the value of attribute functionHandler.
-
#functionState ⇒ Object
readonly
Returns the value of attribute functionState.
-
#idleState ⇒ Object
readonly
Returns the value of attribute idleState.
-
#includeState ⇒ Object
readonly
Returns the value of attribute includeState.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#methodHandler ⇒ Object
readonly
Returns the value of attribute methodHandler.
-
#methodState ⇒ Object
readonly
Returns the value of attribute methodState.
-
#moduleHandler ⇒ Object
readonly
Returns the value of attribute moduleHandler.
-
#moduleState ⇒ Object
readonly
Returns the value of attribute moduleState.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#previousState ⇒ Object
readonly
Returns the value of attribute previousState.
-
#repetitionHandler ⇒ Object
readonly
Returns the value of attribute repetitionHandler.
-
#repetitionState ⇒ Object
readonly
Returns the value of attribute repetitionState.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#string_comment_to_transfer ⇒ Object
Returns the value of attribute string_comment_to_transfer.
-
#variableHandler ⇒ Object
readonly
Returns the value of attribute variableHandler.
-
#variableState ⇒ Object
readonly
Returns the value of attribute variableState.
Instance Method Summary collapse
-
#aggregation_capture ⇒ Object
Aggregation state.
-
#analyse_source ⇒ Object
Based on the source, extract the informations inside of it.
-
#attribute_capture ⇒ Object
Handling attribute state.
-
#attribute_extract ⇒ Object
Extract the attribute from source file.
-
#class_capture ⇒ Object
Handling class state, i.e, this state is enable when any class is match.
-
#class_extract ⇒ Object
Extract all the class declared in the source.
-
#comment_extract ⇒ Object
Extract all the comments from the source.
-
#conditional_capture ⇒ Object
Conditional state.
-
#constructor_capture ⇒ Object
Handling constructor, only after class state.
-
#extern_requirement_extract ⇒ Object
Take all the extern requirements.
-
#function_capture ⇒ Object
Handling function, it is related with structured state but not exclusively.
-
#global_variable_extract ⇒ Object
Extract global variables.
-
#handle_line(pLine) ⇒ Object
Handling line.
-
#idle_capture ⇒ Object
Idle state, waiting for action! =D.
-
#include_capture ⇒ Object
Handling external include.
-
#initialize ⇒ Language
constructor
This method initialize all the needed states of state machine.
-
#isNested? ⇒ Boolean
Verify if is nested or not.
-
#lessNested ⇒ Object
Reduce nested level.
-
#method_capture ⇒ Object
Handling method state, this state is enable only after class state.
-
#method_extract ⇒ Object
Extract all the method/function from the source.
-
#module_capture ⇒ Object
Handling module, it can be oriented object or structured.
-
#moreNested ⇒ Object
Increase nested level.
-
#resetNested ⇒ Object
Reset nested structure.
-
#rewind_state ⇒ Object
Rewind state.
-
#set_source(pSource) ⇒ Object
Set the source code to by analysed.
-
#set_state(pState) ⇒ Object
keep track of state.
-
#variable_capture ⇒ Object
Handling variable.
Constructor Details
#initialize ⇒ Language
This method initialize all the needed states of state machine. @note: Never forget to call this method before start parser.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/kuniri/language/language.rb', line 71 def initialize @attributeState = StateMachine::OOStructuredFSM::AttributeState.new(self) @classState = StateMachine::OOStructuredFSM::ClassState.new(self) @constructorState = StateMachine::OOStructuredFSM::ConstructorState.new(self) @functionState = StateMachine::OOStructuredFSM::FunctionState.new(self) @idleState = StateMachine::OOStructuredFSM::IdleState.new(self) @includeState = StateMachine::OOStructuredFSM::IncludeState.new(self) @methodState = StateMachine::OOStructuredFSM::MethodState.new(self) @moduleState = StateMachine::OOStructuredFSM::ModuleState.new(self) @variableState = StateMachine::OOStructuredFSM::VariableState.new(self) @conditionalState = StateMachine::OOStructuredFSM::ConditionalState.new(self) @repetitionState = StateMachine::OOStructuredFSM::RepetitionState.new(self) @commentState = StateMachine::OOStructuredFSM::CommentState.new(self) @aggregationState = StateMachine::OOStructuredFSM::AggregationState.new(self) @state = @idleState @previousState = [] @previousState.push (@state) @fileElements = [] @flagFunctionBehaviour = nil @countNestedCondLoop = 0 @string_comment_to_transfer = "" end |
Instance Attribute Details
#aggregationHandler ⇒ Object (readonly)
Returns the value of attribute aggregationHandler.
55 56 57 |
# File 'lib/kuniri/language/language.rb', line 55 def aggregationHandler @aggregationHandler end |
#aggregationState ⇒ Object (readonly)
Returns the value of attribute aggregationState.
41 42 43 |
# File 'lib/kuniri/language/language.rb', line 41 def aggregationState @aggregationState end |
#attributeHandler ⇒ Object (readonly)
Returns the value of attribute attributeHandler.
49 50 51 |
# File 'lib/kuniri/language/language.rb', line 49 def attributeHandler @attributeHandler end |
#attributeState ⇒ Object (readonly)
Returns the value of attribute attributeState.
27 28 29 |
# File 'lib/kuniri/language/language.rb', line 27 def attributeState @attributeState end |
#classHandler ⇒ Object (readonly)
Returns the value of attribute classHandler.
47 48 49 |
# File 'lib/kuniri/language/language.rb', line 47 def classHandler @classHandler end |
#classState ⇒ Object (readonly)
Returns the value of attribute classState.
30 31 32 |
# File 'lib/kuniri/language/language.rb', line 30 def classState @classState end |
#commentHandler ⇒ Object (readonly)
Returns the value of attribute commentHandler.
54 55 56 |
# File 'lib/kuniri/language/language.rb', line 54 def commentHandler @commentHandler end |
#commentState ⇒ Object (readonly)
Returns the value of attribute commentState.
40 41 42 |
# File 'lib/kuniri/language/language.rb', line 40 def commentState @commentState end |
#conditionalHandler ⇒ Object (readonly)
Returns the value of attribute conditionalHandler.
52 53 54 |
# File 'lib/kuniri/language/language.rb', line 52 def conditionalHandler @conditionalHandler end |
#conditionalState ⇒ Object (readonly)
Returns the value of attribute conditionalState.
38 39 40 |
# File 'lib/kuniri/language/language.rb', line 38 def conditionalState @conditionalState end |
#constructorHandler ⇒ Object (readonly)
Returns the value of attribute constructorHandler.
51 52 53 |
# File 'lib/kuniri/language/language.rb', line 51 def constructorHandler @constructorHandler end |
#constructorState ⇒ Object (readonly)
Returns the value of attribute constructorState.
31 32 33 |
# File 'lib/kuniri/language/language.rb', line 31 def constructorState @constructorState end |
#countNestedCondLoop ⇒ Object (readonly)
Returns the value of attribute countNestedCondLoop.
65 66 67 |
# File 'lib/kuniri/language/language.rb', line 65 def countNestedCondLoop @countNestedCondLoop end |
#endBlockHandler ⇒ Object (readonly)
Returns the value of attribute endBlockHandler.
48 49 50 |
# File 'lib/kuniri/language/language.rb', line 48 def endBlockHandler @endBlockHandler end |
#externRequirementHandler ⇒ Object (readonly)
Returns the value of attribute externRequirementHandler.
43 44 45 |
# File 'lib/kuniri/language/language.rb', line 43 def externRequirementHandler @externRequirementHandler end |
#fileElements ⇒ Object
Returns the value of attribute fileElements.
59 60 61 |
# File 'lib/kuniri/language/language.rb', line 59 def fileElements @fileElements end |
#flagFunctionBehaviour ⇒ Object
Those values help state machine to understand which place to add conditional information and repetition data.
63 64 65 |
# File 'lib/kuniri/language/language.rb', line 63 def flagFunctionBehaviour @flagFunctionBehaviour end |
#functionHandler ⇒ Object (readonly)
Returns the value of attribute functionHandler.
45 46 47 |
# File 'lib/kuniri/language/language.rb', line 45 def functionHandler @functionHandler end |
#functionState ⇒ Object (readonly)
Returns the value of attribute functionState.
32 33 34 |
# File 'lib/kuniri/language/language.rb', line 32 def functionState @functionState end |
#idleState ⇒ Object (readonly)
Returns the value of attribute idleState.
33 34 35 |
# File 'lib/kuniri/language/language.rb', line 33 def idleState @idleState end |
#includeState ⇒ Object (readonly)
Returns the value of attribute includeState.
34 35 36 |
# File 'lib/kuniri/language/language.rb', line 34 def includeState @includeState end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
57 58 59 |
# File 'lib/kuniri/language/language.rb', line 57 def @metadata end |
#methodHandler ⇒ Object (readonly)
Returns the value of attribute methodHandler.
50 51 52 |
# File 'lib/kuniri/language/language.rb', line 50 def methodHandler @methodHandler end |
#methodState ⇒ Object (readonly)
Returns the value of attribute methodState.
35 36 37 |
# File 'lib/kuniri/language/language.rb', line 35 def methodState @methodState end |
#moduleHandler ⇒ Object (readonly)
Returns the value of attribute moduleHandler.
46 47 48 |
# File 'lib/kuniri/language/language.rb', line 46 def moduleHandler @moduleHandler end |
#moduleState ⇒ Object (readonly)
Returns the value of attribute moduleState.
36 37 38 |
# File 'lib/kuniri/language/language.rb', line 36 def moduleState @moduleState end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
24 25 26 |
# File 'lib/kuniri/language/language.rb', line 24 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
25 26 27 |
# File 'lib/kuniri/language/language.rb', line 25 def path @path end |
#previousState ⇒ Object (readonly)
Returns the value of attribute previousState.
29 30 31 |
# File 'lib/kuniri/language/language.rb', line 29 def previousState @previousState end |
#repetitionHandler ⇒ Object (readonly)
Returns the value of attribute repetitionHandler.
53 54 55 |
# File 'lib/kuniri/language/language.rb', line 53 def repetitionHandler @repetitionHandler end |
#repetitionState ⇒ Object (readonly)
Returns the value of attribute repetitionState.
39 40 41 |
# File 'lib/kuniri/language/language.rb', line 39 def repetitionState @repetitionState end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
28 29 30 |
# File 'lib/kuniri/language/language.rb', line 28 def state @state end |
#string_comment_to_transfer ⇒ Object
Returns the value of attribute string_comment_to_transfer.
67 68 69 |
# File 'lib/kuniri/language/language.rb', line 67 def string_comment_to_transfer @string_comment_to_transfer end |
#variableHandler ⇒ Object (readonly)
Returns the value of attribute variableHandler.
44 45 46 |
# File 'lib/kuniri/language/language.rb', line 44 def variableHandler @variableHandler end |
#variableState ⇒ Object (readonly)
Returns the value of attribute variableState.
37 38 39 |
# File 'lib/kuniri/language/language.rb', line 37 def variableState @variableState end |
Instance Method Details
#aggregation_capture ⇒ Object
Aggregation state.
208 209 210 |
# File 'lib/kuniri/language/language.rb', line 208 def aggregation_capture @state.aggregation_capture end |
#analyse_source ⇒ Object
Based on the source, extract the informations inside of it. For example in this is step the algorithm try to find classes, and methods. This method, work like a hook for give more flexibility to implements any needed steps.
112 113 114 |
# File 'lib/kuniri/language/language.rb', line 112 def analyse_source raise NotImplementedError end |
#attribute_capture ⇒ Object
Handling attribute state.
172 173 174 |
# File 'lib/kuniri/language/language.rb', line 172 def attribute_capture @state.attribute_capture end |
#attribute_extract ⇒ Object
Extract the attribute from source file.
132 133 134 |
# File 'lib/kuniri/language/language.rb', line 132 def attribute_extract raise NotImplementedError end |
#class_capture ⇒ Object
Handling class state, i.e, this state is enable when any class is match
157 158 159 |
# File 'lib/kuniri/language/language.rb', line 157 def class_capture @state.class_capture end |
#class_extract ⇒ Object
Extract all the class declared in the source.
127 128 129 |
# File 'lib/kuniri/language/language.rb', line 127 def class_extract raise NotImplementedError end |
#comment_extract ⇒ Object
Extract all the comments from the source.
117 118 119 |
# File 'lib/kuniri/language/language.rb', line 117 def comment_extract raise NotImplementedError end |
#conditional_capture ⇒ Object
Conditional state.
203 204 205 |
# File 'lib/kuniri/language/language.rb', line 203 def conditional_capture @state.conditional_capture end |
#constructor_capture ⇒ Object
Handling constructor, only after class state.
167 168 169 |
# File 'lib/kuniri/language/language.rb', line 167 def constructor_capture @state.constructor_capture end |
#extern_requirement_extract ⇒ Object
Take all the extern requirements
142 143 144 |
# File 'lib/kuniri/language/language.rb', line 142 def extern_requirement_extract raise NotImplementedError end |
#function_capture ⇒ Object
Handling function, it is related with structured state but not exclusively.
183 184 185 |
# File 'lib/kuniri/language/language.rb', line 183 def function_capture @state.function_capture end |
#global_variable_extract ⇒ Object
Extract global variables.
137 138 139 |
# File 'lib/kuniri/language/language.rb', line 137 def global_variable_extract raise NotImplementedError end |
#handle_line(pLine) ⇒ Object
Handling line
152 153 154 |
# File 'lib/kuniri/language/language.rb', line 152 def handle_line(pLine) @state.handle_line end |
#idle_capture ⇒ Object
Idle state, waiting for action! =D
198 199 200 |
# File 'lib/kuniri/language/language.rb', line 198 def idle_capture @state.idle_capture end |
#include_capture ⇒ Object
Handling external include
188 189 190 |
# File 'lib/kuniri/language/language.rb', line 188 def include_capture @state.include_capture end |
#isNested? ⇒ Boolean
Verify if is nested or not
229 230 231 232 |
# File 'lib/kuniri/language/language.rb', line 229 def isNested? return true if @countNestedCondLoop > 0 return false end |
#lessNested ⇒ Object
Reduce nested level
224 225 226 |
# File 'lib/kuniri/language/language.rb', line 224 def lessNested @countNestedCondLoop -= 1 if @countNestedCondLoop > 0 end |
#method_capture ⇒ Object
Handling method state, this state is enable only after class state.
162 163 164 |
# File 'lib/kuniri/language/language.rb', line 162 def method_capture @state.method_capture end |
#method_extract ⇒ Object
Extract all the method/function from the source.
122 123 124 |
# File 'lib/kuniri/language/language.rb', line 122 def method_extract raise NotImplementedError end |
#module_capture ⇒ Object
Handling module, it can be oriented object or structured.
177 178 179 |
# File 'lib/kuniri/language/language.rb', line 177 def module_capture @state.module_capture end |
#moreNested ⇒ Object
Increase nested level
219 220 221 |
# File 'lib/kuniri/language/language.rb', line 219 def moreNested @countNestedCondLoop += 1 end |
#resetNested ⇒ Object
Reset nested structure
235 236 237 |
# File 'lib/kuniri/language/language.rb', line 235 def resetNested @countNestedCondLoop = 0 end |
#rewind_state ⇒ Object
Rewind state
147 148 149 |
# File 'lib/kuniri/language/language.rb', line 147 def rewind_state @state = @previousState.pop end |
#set_source(pSource) ⇒ Object
Set the source code to by analysed.
104 105 106 |
# File 'lib/kuniri/language/language.rb', line 104 def set_source(pSource) @source = pSource end |
#set_state(pState) ⇒ Object
keep track of state.
213 214 215 216 |
# File 'lib/kuniri/language/language.rb', line 213 def set_state (pState) @previousState.push(@state) @state = pState end |
#variable_capture ⇒ Object
Handling variable
193 194 195 |
# File 'lib/kuniri/language/language.rb', line 193 def variable_capture @state.variable_capture end |