ThirdParty/Pygments/pygments/lexers/ruby.py

changeset 4697
c2e9bf425554
parent 4172
4f20dba37ab6
child 5713
6762afd9f963
equal deleted inserted replaced
4696:bf4d19a7cade 4697:c2e9bf425554
3 pygments.lexers.ruby 3 pygments.lexers.ruby
4 ~~~~~~~~~~~~~~~~~~~~ 4 ~~~~~~~~~~~~~~~~~~~~
5 5
6 Lexers for Ruby and related languages. 6 Lexers for Ruby and related languages.
7 7
8 :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 8 :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
9 :license: BSD, see LICENSE for details. 9 :license: BSD, see LICENSE for details.
10 """ 10 """
11 11
12 import re 12 import re
13 13
34 """ 34 """
35 35
36 name = 'Ruby' 36 name = 'Ruby'
37 aliases = ['rb', 'ruby', 'duby'] 37 aliases = ['rb', 'ruby', 'duby']
38 filenames = ['*.rb', '*.rbw', 'Rakefile', '*.rake', '*.gemspec', 38 filenames = ['*.rb', '*.rbw', 'Rakefile', '*.rake', '*.gemspec',
39 '*.rbx', '*.duby'] 39 '*.rbx', '*.duby', 'Gemfile']
40 mimetypes = ['text/x-ruby', 'application/x-ruby'] 40 mimetypes = ['text/x-ruby', 'application/x-ruby']
41 41
42 flags = re.DOTALL | re.MULTILINE 42 flags = re.DOTALL | re.MULTILINE
43 43
44 def heredoc_callback(self, match, ctx): 44 def heredoc_callback(self, match, ctx):
188 188
189 return states 189 return states
190 190
191 tokens = { 191 tokens = {
192 'root': [ 192 'root': [
193 (r'\A#!.+?$', Comment.Hashbang),
193 (r'#.*?$', Comment.Single), 194 (r'#.*?$', Comment.Single),
194 (r'=begin\s.*?\n=end.*?$', Comment.Multiline), 195 (r'=begin\s.*?\n=end.*?$', Comment.Multiline),
195 # keywords 196 # keywords
196 (words(( 197 (words((
197 'BEGIN', 'END', 'alias', 'begin', 'break', 'case', 'defined?', 198 'BEGIN', 'END', 'alias', 'begin', 'break', 'case', 'defined?',
254 # multiline regex (after keywords or assignments) 255 # multiline regex (after keywords or assignments)
255 (r'(?:^|(?<=[=<>~!:])|' 256 (r'(?:^|(?<=[=<>~!:])|'
256 r'(?<=(?:\s|;)when\s)|' 257 r'(?<=(?:\s|;)when\s)|'
257 r'(?<=(?:\s|;)or\s)|' 258 r'(?<=(?:\s|;)or\s)|'
258 r'(?<=(?:\s|;)and\s)|' 259 r'(?<=(?:\s|;)and\s)|'
259 r'(?<=(?:\s|;|\.)index\s)|' 260 r'(?<=\.index\s)|'
260 r'(?<=(?:\s|;|\.)scan\s)|' 261 r'(?<=\.scan\s)|'
261 r'(?<=(?:\s|;|\.)sub\s)|' 262 r'(?<=\.sub\s)|'
262 r'(?<=(?:\s|;|\.)sub!\s)|' 263 r'(?<=\.sub!\s)|'
263 r'(?<=(?:\s|;|\.)gsub\s)|' 264 r'(?<=\.gsub\s)|'
264 r'(?<=(?:\s|;|\.)gsub!\s)|' 265 r'(?<=\.gsub!\s)|'
265 r'(?<=(?:\s|;|\.)match\s)|' 266 r'(?<=\.match\s)|'
266 r'(?<=(?:\s|;)if\s)|' 267 r'(?<=(?:\s|;)if\s)|'
267 r'(?<=(?:\s|;)elsif\s)|' 268 r'(?<=(?:\s|;)elsif\s)|'
268 r'(?<=^when\s)|' 269 r'(?<=^when\s)|'
269 r'(?<=^index\s)|' 270 r'(?<=^index\s)|'
270 r'(?<=^scan\s)|' 271 r'(?<=^scan\s)|'

eric ide

mercurial