Skip to content

Commit

Permalink
fix rubocop Lint/AmbiguousRegexpLiteral warmnings
Browse files Browse the repository at this point in the history
  • Loading branch information
gfx committed Feb 10, 2020
1 parent 8abe647 commit e6dd5b5
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions lib/rouge/lexers/varnish.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,77 +145,77 @@ class Varnish < RegexLexer
}

state :default do
rule /\r\n?|\n/ do
rule(/\r\n?|\n/) do
token STATES_MAP[state.name.to_sym]
end
rule /./ do
rule(/./) do
token STATES_MAP[state.name.to_sym]
end
end

state :root do
# long strings ({" ... "})
rule %r'\{".*?"}'m, Str::Single
rule(%r'\{".*?"}'m, Str::Single)

# comments
rule %r'/\*.*?\*/'m, Comment::Multiline
rule %r'(?://|#).*', Comment::Single
rule(%r'/\*.*?\*/'m, Comment::Multiline)
rule(%r'(?://|#).*', Comment::Single)

rule /true|false/, Keyword::Constant
rule(/true|false/, Keyword::Constant)

# "wildcard variables"
rule /(?:(?:be)?re(?:sp|q)|obj)\.http\.[a-zA-Z0-9_.-]+/ do
rule(/(?:(?:be)?re(?:sp|q)|obj)\.http\.[a-zA-Z0-9_.-]+/) do
token Name::Variable
end

rule /(sub)(#{SPACE})([a-zA-Z0-9_-]+)/ do
rule(/(sub)(#{SPACE})([a-zA-Z0-9_-]+)/) do
groups Keyword, Text, Name::Function
end

# inline C (C{ ... }C)
rule /C\{/ do
rule(/C\{/) do
token Comment::Preproc
push :inline_c
end

rule /[a-zA-Z_.-]+/ do |m|
rule(/[a-zA-Z_.-]+/) do |m|
next token Keyword if KEYWORDS.include? m[0]
next token Name::Function if BUILTIN_FUNCTIONS.include? m[0]
next token Name::Variable if BUILTIN_VARIABLES.include? m[0]
token Text
end

# duration
rule /(?:#{LNUM}|#{DNUM})(?:ms|[smhdwy])/, Literal::Number::Other
rule(/(?:#{LNUM}|#{DNUM})(?:ms|[smhdwy])/, Literal::Number::Other)
# size in bytes
rule /#{LNUM}[KMGT]?B/, Literal::Number::Other
rule(/#{LNUM}[KMGT]?B/, Literal::Number::Other)
# literal numeric values (integer/float)
rule /#{LNUM}/, Num::Integer
rule /#{DNUM}/, Num::Float
rule(/#{LNUM}/, Num::Integer)
rule(/#{DNUM}/, Num::Float)

# standard strings
rule /"/ do |m|
rule(/"/) do |m|
token Str::Double
push :string
end

rule %r'[&|+-]{2}|[<=>!*/+-]=|<<|>>|!~|[-+*/%><=!&|~]', Operator
rule(%r'[&|+-]{2}|[<=>!*/+-]=|<<|>>|!~|[-+*/%><=!&|~]', Operator)

rule /[{}();.,]/, Punctuation
rule(/[{}();.,]/, Punctuation)

mixin :default
end

state :string do
rule /"/, Str::Double, :pop!
rule /\\[\\"nt]/, Str::Escape
rule(/"/, Str::Double, :pop!)
rule(/\\[\\"nt]/, Str::Escape)

mixin :default
end

state :inline_c do
rule /}C/, Comment::Preproc, :pop!
rule /.*?(?=}C)/m do
rule(/}C/, Comment::Preproc, :pop!)
rule(/.*?(?=}C)/m) do
delegate C
end
end
Expand Down

0 comments on commit e6dd5b5

Please sign in to comment.