Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to Make lexer #1285

Merged
merged 13 commits into from
Jul 30, 2019
Merged
Prev Previous commit
Next Next commit
[make] support all built-in functions, not just $(shell...)
  • Loading branch information
bavison committed Jul 26, 2019
commit 0860047a528a23c9a3c84cab803e710a26a02b56
13 changes: 11 additions & 2 deletions lib/rouge/lexers/make.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ class Make < RegexLexer
filenames '*.make', 'Makefile', 'makefile', 'Makefile.*', 'GNUmakefile'
mimetypes 'text/x-makefile'

def self.functions
@functions ||= %w(
abspath addprefix addsuffix and basename call dir error eval file
filter filter-out findstring firstword flavor foreach if join lastword
notdir or origin patsubst realpath shell sort strip subst suffix value
warning wildcard word wordlist words
)
end

# TODO: Add support for special keywords
# bsd_special = %w(
# include undef error warning if else elif endif for endfor
Expand Down Expand Up @@ -81,8 +90,8 @@ def initialize(opts={})
state :shell do
# macro interpolation
rule %r/\$[({][\t ]*[a-z_]\w*[\t ]*[)}]/i, Name::Variable
# $(shell ...)
rule %r/(\$[({])([\t ]*)(shell)([\t ]+)/m do
# function invocation
rule %r/(\$[({])([\t ]*)(#{Make.functions.join('|')})([\t ]+)/m do
pyrmont marked this conversation as resolved.
Show resolved Hide resolved
groups Name::Function, Text, Name::Builtin, Text
push :shell_expr
end
Expand Down