Class TaskJuggler::TextParser::StateTransition
In: lib/taskjuggler/TextParser/State.rb
Parent: Object

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.

Methods

new   to_s  

Attributes

loopBack  [R] 
state  [R] 
stateStack  [R] 
tokenType  [R] 

Public Class methods

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.

[Source]

# 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

Public Instance methods

Generate a human readable form of the TransitionState date. It‘s only used for debugging.

[Source]

# 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

[Validate]