class Rouge::Lexers::TCL

Constants

ALL
BUILTINS
CHARS
CLOSE
END_LINE
END_WORD
KEYWORDS
NOT_CHARS
OPEN

Public Class Methods

detect?(text) click to toggle source
# File lib/rouge/lexers/tcl.rb, line 12
def self.detect?(text)
  return true if text.shebang? 'tclsh'
  return true if text.shebang? 'wish'
  return true if text.shebang? 'jimsh'
end
gen_command_state(name='') click to toggle source
# File lib/rouge/lexers/tcl.rb, line 57
def self.gen_command_state(name='')
  state(:"command#{name}") do
    mixin :word

    rule /##{NOT_CHARS[END_LINE]}+/, Comment::Single

    rule /(?=#{CHARS[END_WORD]})/ do
      push :"params#{name}"
    end

    rule /#{NOT_CHARS[END_WORD]}+/ do |m|
      if KEYWORDS.include? m[0]
        token Keyword
      elsif BUILTINS.include? m[0]
        token Name::Builtin
      else
        token Text
      end
    end

    mixin :whitespace
  end
end
gen_delimiter_states(name, close, opts={}) click to toggle source
# File lib/rouge/lexers/tcl.rb, line 81
def self.gen_delimiter_states(name, close, opts={})
  gen_command_state("_in_#{name}")

  state :"params_in_#{name}" do
    rule close do
      token Punctuation
      pop! 2
    end

    # mismatched delimiters.  Braced strings with mismatched
    # closing delimiters should be okay, since this is standard
    # practice, like {]]]]}
    if opts[:strict]
      rule CHARS[CLOSE - [close]], Error
    else
      rule CHARS[CLOSE - [close]], Text
    end

    mixin :params
  end

  state name do
    rule close, Punctuation, :pop!
    mixin :"command_in_#{name}"
  end
end