class Rouge::Lexers::TCL
def self.detect?(text)
def self.detect?(text) return true if text.shebang? 'tclsh' return true if text.shebang? 'wish' return true if text.shebang? 'jimsh' end
def self.gen_command_state(name='')
def self.gen_command_state(name='') state(:"command#{name}") do mixin :word rule %r/##{NOT_CHARS[END_LINE]}+/, Comment::Single rule %r/(?=#{CHARS[END_WORD]})/ do push :"params#{name}" end rule %r/#{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
def self.gen_delimiter_states(name, close, opts={})
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