# class Puppet::Parser::Lexer::Token

### Constants

ALWAYS_ACCEPTABLE

### Attributes

accumulate[RW]
accumulate?[RW]
incr_line[RW]
name[RW]
regex[RW]
skip[RW]
skip?[RW]
skip_text[RW]
string[RW]

### Public Class Methods

new(string_or_regex, name, options = {}) click to toggle source

    # File lib/puppet/parser/lexer.rb, line 36
    def initialize(string_or_regex, name, options = {})
      if string_or_regex.is_a?(String)
        @name, @string = name, string_or_regex
        @regex = Regexp.new(Regexp.escape(string_or_regex))
      else
        @name, @regex = name, string_or_regex
      end

      set_options(options)
      @acceptable_when = ALWAYS_ACCEPTABLE
    end

### Public Instance Methods

acceptable?(context={}) click to toggle source

    # File lib/puppet/parser/lexer.rb, line 52
    def acceptable?(context={})
      @acceptable_when.call(context)
    end

acceptable_when(block) click to toggle source

Define when the token is able to match. This provides context that cannot be expressed otherwise, such as feature flags.

@param block [Proc] a proc that given a context returns a boolean

    # File lib/puppet/parser/lexer.rb, line 60
    def acceptable_when(block)
      @acceptable_when = block
    end

to_s() click to toggle source

    # File lib/puppet/parser/lexer.rb, line 48
    def to_s
      string or @name.to_s
    end