/usr/lib/ruby/vendor_ruby/rugments/lexers/make.rb is in ruby-rugments 1.0.0~beta8-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | module Rugments
module Lexers
class Make < RegexLexer
title 'Make'
desc 'Makefile syntax'
tag 'make'
aliases 'makefile', 'mf', 'gnumake', 'bsdmake'
filenames '*.make', 'Makefile', 'makefile', 'Makefile.*', 'GNUmakefile'
mimetypes 'text/x-makefile'
def self.analyze_text(text)
return 0.6 if text =~ /^\.PHONY:/
end
bsd_special = %w(
include undef error warning if else elif endif for endfor
)
gnu_special = %w(
ifeq ifneq ifdef ifndef else endif include -include define endef :
)
line = /(?:\\.|\\\n|[^\\\n])*/m
def initialize(opts = {})
super
@shell = Shell.new(opts)
end
start { @shell.reset! }
state :root do
rule /\s+/, Text
rule /#.*?\n/, Comment
rule /(export)(\s+)(?=[a-zA-Z0-9_\${}\t -]+\n)/ do
groups Keyword, Text
push :export
end
rule /export\s+/, Keyword
# assignment
rule /([a-zA-Z0-9_${}.-]+)(\s*)([!?:+]?=)/m do |m|
token Name::Variable, m[1]
token Text, m[2]
token Operator, m[3]
push :shell_line
end
rule /"(\\\\|\\.|[^"\\])*"/, Str::Double
rule /'(\\\\|\\.|[^'\\])*'/, Str::Single
rule /([^\n:]+)(:+)([ \t]*)/ do
groups Name::Label, Operator, Text
push :block_header
end
end
state :export do
rule /[\w\${}-]/, Name::Variable
rule /\n/, Text, :pop!
rule /\s+/, Text
end
state :block_header do
rule /[^,\\\n#]+/, Name::Function
rule /,/, Punctuation
rule /#.*?/, Comment
rule /\\\n/, Text
rule /\\./, Text
rule /\n/ do
token Text
goto :block_body
end
end
state :block_body do
rule /(\t[\t ]*)([@-]?)/ do |_m|
groups Text, Punctuation
push :shell_line
end
rule(//) { @shell.reset!; pop! }
end
state :shell do
# macro interpolation
rule /\$\(\s*[a-z_]\w*\s*\)/i, Name::Variable
# $(shell ...)
rule /(\$\()(\s*)(shell)(\s+)/m do
groups Name::Function, Text, Name::Builtin, Text
push :shell_expr
end
rule(/\\./m) { delegate @shell }
stop = /\$\(|\(|\)|\n|\\/
rule(/.+?(?=#{stop})/m) { delegate @shell }
rule(stop) { delegate @shell }
end
state :shell_expr do
rule(/\(/) { delegate @shell; push }
rule /\)/, Name::Variable, :pop!
mixin :shell
end
state :shell_line do
rule /\n/, Text, :pop!
mixin :shell
end
end
end
end
|