Class: TaskJuggler::TextParser::StateTransition
- Defined in:
- lib/taskjuggler/TextParser/State.rb
Overview
A StateTransition maps a token type to the next state to be processed. A token descriptor is either a Symbol that maps to a RegExp in the TextScanner or an expected String. The transition may also have a list of State objects that are being activated by the transition.
Instance Attribute Summary collapse
-
#loopBack ⇒ Object
readonly
Returns the value of attribute loopBack.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#stateStack ⇒ Object
readonly
Returns the value of attribute stateStack.
-
#tokenType ⇒ Object
readonly
Returns the value of attribute tokenType.
Instance Method Summary collapse
-
#initialize(descriptor, state, stateStack, loopBack) ⇒ StateTransition
constructor
Create a new StateTransition object.
-
#to_s ⇒ Object
Generate a human readable form of the TransitionState date.
Constructor Details
#initialize(descriptor, state, stateStack, loopBack) ⇒ StateTransition
Create a new StateTransition object. descriptor is a [ token type, token value ] touple. state is the State objects this transition originates at. stateStack is the list of State objects that have been activated by this transition. loopBack is a boolean flag that specifies whether the transition describes a loop back to the start of the Rule or not.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/taskjuggler/TextParser/State.rb', line 30 def initialize(descriptor, state, stateStack, loopBack) if !descriptor.respond_to?(:length) || descriptor.length != 2 raise "Bad parameter descriptor: #{descriptor} " + "of type #{descriptor.class}" end @tokenType = descriptor[0] == :eof ? :eof : descriptor[1] if !state.is_a?(State) raise "Bad parameter state: #{state} of type #{state.class}" end @state = state if !stateStack.is_a?(Array) raise "Bad parameter stateStack: #{stateStack} " + "of type #{stateStack.class}" end @stateStack = stateStack.dup @loopBack = loopBack end |
Instance Attribute Details
#loopBack ⇒ Object (readonly)
Returns the value of attribute loopBack.
22 23 24 |
# File 'lib/taskjuggler/TextParser/State.rb', line 22 def loopBack @loopBack end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
22 23 24 |
# File 'lib/taskjuggler/TextParser/State.rb', line 22 def state @state end |
#stateStack ⇒ Object (readonly)
Returns the value of attribute stateStack.
22 23 24 |
# File 'lib/taskjuggler/TextParser/State.rb', line 22 def stateStack @stateStack end |
#tokenType ⇒ Object (readonly)
Returns the value of attribute tokenType.
22 23 24 |
# File 'lib/taskjuggler/TextParser/State.rb', line 22 def tokenType @tokenType end |
Instance Method Details
#to_s ⇒ Object
Generate a human readable form of the TransitionState date. It’s only used for debugging.
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/taskjuggler/TextParser/State.rb', line 52 def to_s str = "#{@state.rule.name}, " + "#{@state.rule.patterns.index(@state.pattern)}, #{@state.index} " unless @stateStack.empty? str += "(" @stateStack.each do |s| str += "#{s.rule.name} " end str += ")" end str += '(loop)' if @loopBack str end |