class RubyLexer::State

Attributes

n[RW]
names[RW]

Public Class Methods

new(o, names) click to toggle source

TODO: take a shared hash of strings for inspect/to_s

# File lib/ruby_lexer.rb, line 1352
def initialize o, names
  raise ArgumentError, "bad state: %p" % [o] unless Integer === o # TODO: remove

  self.n = o
  self.names = names
end

Public Instance Methods

==(o) click to toggle source
# File lib/ruby_lexer.rb, line 1359
def == o
  self.equal?(o) || (o.class == self.class && o.n == self.n)
end
=~(v) click to toggle source
# File lib/ruby_lexer.rb, line 1363
def =~ v
  (self.n & v.n) != 0
end
inspect() click to toggle source
# File lib/ruby_lexer.rb, line 1373
def inspect
  return "Value(0)" if n.zero? # HACK?

  names.map { |v, k| k if self =~ v }.
    compact.
    join("|").
    gsub(/(?:EXPR_|STR_(?:FUNC_)?)/, "")
end
Also aliased as: to_s
to_s()
Alias for: inspect
|(v) click to toggle source
# File lib/ruby_lexer.rb, line 1367
def | v
  raise ArgumentError, "Incompatible State: %p vs %p" % [self, v] unless
    self.names == v.names
  self.class.new(self.n | v.n, self.names)
end