Class: Languages::Language Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/kuniri/language/language.rb

Overview

This class is abstract.

Abstract class for handling different types of language.

Direct Known Subclasses

RubySyntax

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLanguage

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

#aggregationHandlerObject (readonly)

Returns the value of attribute aggregationHandler.



55
56
57
# File 'lib/kuniri/language/language.rb', line 55

def aggregationHandler
  @aggregationHandler
end

#aggregationStateObject (readonly)

Returns the value of attribute aggregationState.



41
42
43
# File 'lib/kuniri/language/language.rb', line 41

def aggregationState
  @aggregationState
end

#attributeHandlerObject (readonly)

Returns the value of attribute attributeHandler.



49
50
51
# File 'lib/kuniri/language/language.rb', line 49

def attributeHandler
  @attributeHandler
end

#attributeStateObject (readonly)

Returns the value of attribute attributeState.



27
28
29
# File 'lib/kuniri/language/language.rb', line 27

def attributeState
  @attributeState
end

#classHandlerObject (readonly)

Returns the value of attribute classHandler.



47
48
49
# File 'lib/kuniri/language/language.rb', line 47

def classHandler
  @classHandler
end

#classStateObject (readonly)

Returns the value of attribute classState.



30
31
32
# File 'lib/kuniri/language/language.rb', line 30

def classState
  @classState
end

#commentHandlerObject (readonly)

Returns the value of attribute commentHandler.



54
55
56
# File 'lib/kuniri/language/language.rb', line 54

def commentHandler
  @commentHandler
end

#commentStateObject (readonly)

Returns the value of attribute commentState.



40
41
42
# File 'lib/kuniri/language/language.rb', line 40

def commentState
  @commentState
end

#conditionalHandlerObject (readonly)

Returns the value of attribute conditionalHandler.



52
53
54
# File 'lib/kuniri/language/language.rb', line 52

def conditionalHandler
  @conditionalHandler
end

#conditionalStateObject (readonly)

Returns the value of attribute conditionalState.



38
39
40
# File 'lib/kuniri/language/language.rb', line 38

def conditionalState
  @conditionalState
end

#constructorHandlerObject (readonly)

Returns the value of attribute constructorHandler.



51
52
53
# File 'lib/kuniri/language/language.rb', line 51

def constructorHandler
  @constructorHandler
end

#constructorStateObject (readonly)

Returns the value of attribute constructorState.



31
32
33
# File 'lib/kuniri/language/language.rb', line 31

def constructorState
  @constructorState
end

#countNestedCondLoopObject (readonly)

Returns the value of attribute countNestedCondLoop.



65
66
67
# File 'lib/kuniri/language/language.rb', line 65

def countNestedCondLoop
  @countNestedCondLoop
end

#endBlockHandlerObject (readonly)

Returns the value of attribute endBlockHandler.



48
49
50
# File 'lib/kuniri/language/language.rb', line 48

def endBlockHandler
  @endBlockHandler
end

#externRequirementHandlerObject (readonly)

Returns the value of attribute externRequirementHandler.



43
44
45
# File 'lib/kuniri/language/language.rb', line 43

def externRequirementHandler
  @externRequirementHandler
end

#fileElementsObject

Returns the value of attribute fileElements.



59
60
61
# File 'lib/kuniri/language/language.rb', line 59

def fileElements
  @fileElements
end

#flagFunctionBehaviourObject

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

#functionHandlerObject (readonly)

Returns the value of attribute functionHandler.



45
46
47
# File 'lib/kuniri/language/language.rb', line 45

def functionHandler
  @functionHandler
end

#functionStateObject (readonly)

Returns the value of attribute functionState.



32
33
34
# File 'lib/kuniri/language/language.rb', line 32

def functionState
  @functionState
end

#idleStateObject (readonly)

Returns the value of attribute idleState.



33
34
35
# File 'lib/kuniri/language/language.rb', line 33

def idleState
  @idleState
end

#includeStateObject (readonly)

Returns the value of attribute includeState.



34
35
36
# File 'lib/kuniri/language/language.rb', line 34

def includeState
  @includeState
end

#metadataObject (readonly)

Returns the value of attribute metadata.



57
58
59
# File 'lib/kuniri/language/language.rb', line 57

def 
  @metadata
end

#methodHandlerObject (readonly)

Returns the value of attribute methodHandler.



50
51
52
# File 'lib/kuniri/language/language.rb', line 50

def methodHandler
  @methodHandler
end

#methodStateObject (readonly)

Returns the value of attribute methodState.



35
36
37
# File 'lib/kuniri/language/language.rb', line 35

def methodState
  @methodState
end

#moduleHandlerObject (readonly)

Returns the value of attribute moduleHandler.



46
47
48
# File 'lib/kuniri/language/language.rb', line 46

def moduleHandler
  @moduleHandler
end

#moduleStateObject (readonly)

Returns the value of attribute moduleState.



36
37
38
# File 'lib/kuniri/language/language.rb', line 36

def moduleState
  @moduleState
end

#nameObject (readonly)

Returns the value of attribute name.



24
25
26
# File 'lib/kuniri/language/language.rb', line 24

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



25
26
27
# File 'lib/kuniri/language/language.rb', line 25

def path
  @path
end

#previousStateObject (readonly)

Returns the value of attribute previousState.



29
30
31
# File 'lib/kuniri/language/language.rb', line 29

def previousState
  @previousState
end

#repetitionHandlerObject (readonly)

Returns the value of attribute repetitionHandler.



53
54
55
# File 'lib/kuniri/language/language.rb', line 53

def repetitionHandler
  @repetitionHandler
end

#repetitionStateObject (readonly)

Returns the value of attribute repetitionState.



39
40
41
# File 'lib/kuniri/language/language.rb', line 39

def repetitionState
  @repetitionState
end

#stateObject (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_transferObject

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

#variableHandlerObject (readonly)

Returns the value of attribute variableHandler.



44
45
46
# File 'lib/kuniri/language/language.rb', line 44

def variableHandler
  @variableHandler
end

#variableStateObject (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_captureObject

Aggregation state.



208
209
210
# File 'lib/kuniri/language/language.rb', line 208

def aggregation_capture
  @state.aggregation_capture
end

#analyse_sourceObject

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.

Raises:

  • (NotImplementedError)


112
113
114
# File 'lib/kuniri/language/language.rb', line 112

def analyse_source
  raise NotImplementedError
end

#attribute_captureObject

Handling attribute state.



172
173
174
# File 'lib/kuniri/language/language.rb', line 172

def attribute_capture
  @state.attribute_capture
end

#attribute_extractObject

Extract the attribute from source file.

Raises:

  • (NotImplementedError)


132
133
134
# File 'lib/kuniri/language/language.rb', line 132

def attribute_extract
  raise NotImplementedError
end

#class_captureObject

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_extractObject

Extract all the class declared in the source.

Raises:

  • (NotImplementedError)


127
128
129
# File 'lib/kuniri/language/language.rb', line 127

def class_extract
  raise NotImplementedError
end

#comment_extractObject

Extract all the comments from the source.

Raises:

  • (NotImplementedError)


117
118
119
# File 'lib/kuniri/language/language.rb', line 117

def comment_extract
  raise NotImplementedError
end

#conditional_captureObject

Conditional state.



203
204
205
# File 'lib/kuniri/language/language.rb', line 203

def conditional_capture
  @state.conditional_capture
end

#constructor_captureObject

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_extractObject

Take all the extern requirements

Raises:

  • (NotImplementedError)


142
143
144
# File 'lib/kuniri/language/language.rb', line 142

def extern_requirement_extract
  raise NotImplementedError
end

#function_captureObject

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_extractObject

Extract global variables.

Raises:

  • (NotImplementedError)


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_captureObject

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_captureObject

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

Returns:

  • (Boolean)


229
230
231
232
# File 'lib/kuniri/language/language.rb', line 229

def isNested?
  return true if @countNestedCondLoop > 0
  return false
end

#lessNestedObject

Reduce nested level



224
225
226
# File 'lib/kuniri/language/language.rb', line 224

def lessNested
  @countNestedCondLoop -= 1 if @countNestedCondLoop > 0
end

#method_captureObject

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_extractObject

Extract all the method/function from the source.

Raises:

  • (NotImplementedError)


122
123
124
# File 'lib/kuniri/language/language.rb', line 122

def method_extract
  raise NotImplementedError
end

#module_captureObject

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

#moreNestedObject

Increase nested level



219
220
221
# File 'lib/kuniri/language/language.rb', line 219

def moreNested
  @countNestedCondLoop += 1
end

#resetNestedObject

Reset nested structure



235
236
237
# File 'lib/kuniri/language/language.rb', line 235

def resetNested
  @countNestedCondLoop = 0
end

#rewind_stateObject

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.

Parameters:

  • pSource (String)

    Set the source string.



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_captureObject

Handling variable



193
194
195
# File 'lib/kuniri/language/language.rb', line 193

def variable_capture
  @state.variable_capture
end