Sha256: 97e352f79fe3a2f39709157c8c8cc0cb1efbac1c8ebcb319100eedd9ef50bf0b

Contents?: true

Size: 1.42 KB

Versions: 1

Compression:

Stored size: 1.42 KB

Contents

# finished

module Antlr4ruby
  # @abstract
  class Transition
    EPSILON = 1
    RANGE = 2
    RULE = 3
    PREDICATE = 4
    ATOM = 5
    ACTION = 6
    SET = 7
    NOT_SET = 8
    WILDCARD = 9
    PRECEDENCE = 10

    @@serialization_names = %w[INVALID EPSILON RANGE RULE PREDICATE ATOM ACTION SET NOT_SET WILDCARD PRECEDENCE]
    @@serialization_types = {
      EpsilonTransition => EPSILON,
      RangeTransition => RANGE,
      RuleTransition => RULE,
      PredicateTransition => PREDICATE,
      AtomTransition => ATOM,
      ActionTransition => ACTION,
      SetTransition => SET,
      NotSetTransition => NOT_SET,
      WildcardTransition => WILDCARD,
      PrecedencePredicateTransition => PRECEDENCE
    }

    attr_accessor :target

    def self.serialization_names
      @@serialization_names
    end

    def self.serialization_types
      @@serialization_types
    end

    def initialize(target)
      super()
      raise "target can not be nil." unless target
      @target = target
    end

    def get_serialization_type
      raise NotImplementedError.new("#{self.class.name}#get_serialization_type is abstract method.")
    end

    def is_epsilon?
      false
    end

    def label
      nil
    end

    def matches?(symbol, min_vocab_symbol, max_vocab_symbol)
      raise NotImplementedError.new("#{self.class.name}#matches is abstract method.")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
antlr4ruby-0.1.0 lib/antlr4ruby/atn/transition/transition.rb