rouge 3.6.0 → 3.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/lib/rouge/demos/ada +26 -0
- data/lib/rouge/demos/apex +9 -0
- data/lib/rouge/demos/armasm +12 -0
- data/lib/rouge/demos/batchfile +3 -0
- data/lib/rouge/demos/bbcbasic +6 -0
- data/lib/rouge/demos/clean +6 -0
- data/lib/rouge/demos/cmhg +8 -0
- data/lib/rouge/demos/csvs +8 -0
- data/lib/rouge/demos/cuda +11 -0
- data/lib/rouge/demos/cython +6 -0
- data/lib/rouge/demos/eex +1 -0
- data/lib/rouge/demos/epp +4 -0
- data/lib/rouge/demos/gdscript +18 -0
- data/lib/rouge/demos/haxe +5 -0
- data/lib/rouge/demos/hocon +8 -0
- data/lib/rouge/demos/hql +5 -0
- data/lib/rouge/demos/jsl +3 -0
- data/lib/rouge/demos/liquid +0 -1
- data/lib/rouge/demos/lustre +6 -0
- data/lib/rouge/demos/lutin +18 -0
- data/lib/rouge/demos/mason +22 -0
- data/lib/rouge/demos/minizinc +23 -0
- data/lib/rouge/demos/msgtrans +4 -0
- data/lib/rouge/demos/opentype_feature_file +6 -0
- data/lib/rouge/demos/plist +1 -132
- data/lib/rouge/demos/reasonml +12 -0
- data/lib/rouge/demos/robot_framework +27 -0
- data/lib/rouge/demos/sas +13 -0
- data/lib/rouge/demos/sparql +6 -0
- data/lib/rouge/demos/terraform +0 -15
- data/lib/rouge/formatters/html_line_table.rb +3 -1
- data/lib/rouge/formatters/tex.rb +14 -12
- data/lib/rouge/guessers/disambiguation.rb +17 -0
- data/lib/rouge/lexer.rb +3 -0
- data/lib/rouge/lexers/ada.rb +162 -0
- data/lib/rouge/lexers/apex.rb +126 -0
- data/lib/rouge/lexers/armasm.rb +145 -0
- data/lib/rouge/lexers/batchfile.rb +164 -0
- data/lib/rouge/lexers/bbcbasic.rb +112 -0
- data/lib/rouge/lexers/clean.rb +156 -0
- data/lib/rouge/lexers/cmhg.rb +34 -0
- data/lib/rouge/lexers/common_lisp.rb +1 -1
- data/lib/rouge/lexers/console.rb +1 -1
- data/lib/rouge/lexers/coq.rb +12 -9
- data/lib/rouge/lexers/cpp.rb +4 -1
- data/lib/rouge/lexers/csvs.rb +44 -0
- data/lib/rouge/lexers/cuda.rb +35 -0
- data/lib/rouge/lexers/cython.rb +151 -0
- data/lib/rouge/lexers/eex.rb +52 -0
- data/lib/rouge/lexers/elixir.rb +20 -9
- data/lib/rouge/lexers/epp.rb +51 -0
- data/lib/rouge/lexers/escape.rb +3 -0
- data/lib/rouge/lexers/gdscript.rb +171 -0
- data/lib/rouge/lexers/gherkin.rb +4 -2
- data/lib/rouge/lexers/graphql.rb +10 -3
- data/lib/rouge/lexers/handlebars.rb +14 -3
- data/lib/rouge/lexers/haxe.rb +246 -0
- data/lib/rouge/lexers/hocon.rb +86 -0
- data/lib/rouge/lexers/hql.rb +139 -0
- data/lib/rouge/lexers/html.rb +2 -2
- data/lib/rouge/lexers/http.rb +5 -5
- data/lib/rouge/lexers/igorpro.rb +1 -1
- data/lib/rouge/lexers/javascript.rb +1 -1
- data/lib/rouge/lexers/jsl.rb +55 -0
- data/lib/rouge/lexers/json.rb +43 -5
- data/lib/rouge/lexers/julia.rb +1 -1
- data/lib/rouge/lexers/kotlin.rb +21 -28
- data/lib/rouge/lexers/liquid.rb +82 -108
- data/lib/rouge/lexers/lustre.rb +79 -0
- data/lib/rouge/lexers/lutin.rb +33 -0
- data/lib/rouge/lexers/make.rb +39 -12
- data/lib/rouge/lexers/markdown.rb +7 -1
- data/lib/rouge/lexers/mason.rb +110 -0
- data/lib/rouge/lexers/matlab.rb +4 -2
- data/lib/rouge/lexers/matlab/builtins.yml +3515 -0
- data/lib/rouge/lexers/minizinc.rb +87 -0
- data/lib/rouge/lexers/msgtrans.rb +26 -0
- data/lib/rouge/lexers/ocaml.rb +12 -48
- data/lib/rouge/lexers/ocaml/common.rb +53 -0
- data/lib/rouge/lexers/opentype_feature_file.rb +113 -0
- data/lib/rouge/lexers/perl.rb +1 -1
- data/lib/rouge/lexers/php.rb +31 -9
- data/lib/rouge/lexers/php/builtins.rb +181 -174
- data/lib/rouge/lexers/plain_text.rb +1 -1
- data/lib/rouge/lexers/puppet.rb +2 -2
- data/lib/rouge/lexers/q.rb +1 -1
- data/lib/rouge/lexers/r.rb +2 -3
- data/lib/rouge/lexers/reasonml.rb +65 -0
- data/lib/rouge/lexers/robot_framework.rb +249 -0
- data/lib/rouge/lexers/rust.rb +12 -9
- data/lib/rouge/lexers/sas.rb +563 -0
- data/lib/rouge/lexers/sed.rb +1 -1
- data/lib/rouge/lexers/shell.rb +5 -3
- data/lib/rouge/lexers/smarty.rb +10 -10
- data/lib/rouge/lexers/sparql.rb +129 -0
- data/lib/rouge/lexers/sql.rb +26 -6
- data/lib/rouge/lexers/swift.rb +1 -1
- data/lib/rouge/lexers/terraform.rb +8 -0
- data/lib/rouge/plugins/redcarpet.rb +7 -1
- data/lib/rouge/tex_theme_renderer.rb +5 -1
- data/lib/rouge/themes/magritte.rb +3 -3
- data/lib/rouge/themes/thankful_eyes.rb +1 -1
- data/lib/rouge/themes/tulip.rb +1 -1
- data/lib/rouge/version.rb +1 -1
- data/rouge.gemspec +4 -3
- metadata +63 -6
- data/lib/rouge/lexers/matlab/builtins.rb +0 -13
@@ -0,0 +1,87 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# Based on Chroma's MiniZinc lexer:
|
5
|
+
# https://github.com/alecthomas/chroma/blob/5152194c717b394686d3d7a7e1946a360ec0728f/lexers/m/minizinc.go
|
6
|
+
|
7
|
+
module Rouge
|
8
|
+
module Lexers
|
9
|
+
class MiniZinc < RegexLexer
|
10
|
+
title "MiniZinc"
|
11
|
+
desc "MiniZinc is a free and open-source constraint modeling language (minizinc.org)"
|
12
|
+
tag 'minizinc'
|
13
|
+
filenames '*.mzn', '*.fzn', '*.dzn'
|
14
|
+
mimetypes 'text/minizinc'
|
15
|
+
|
16
|
+
def self.builtins
|
17
|
+
@builtins = Set.new %w[
|
18
|
+
abort abs acosh array_intersect array_union array1d array2d array3d
|
19
|
+
array4d array5d array6d asin assert atan bool2int card ceil concat
|
20
|
+
cos cosh dom dom_array dom_size fix exp floor index_set
|
21
|
+
index_set_1of2 index_set_2of2 index_set_1of3 index_set_2of3
|
22
|
+
index_set_3of3 int2float is_fixed join lb lb_array length ln log log2
|
23
|
+
log10 min max pow product round set2array show show_int show_float
|
24
|
+
sin sinh sqrt sum tan tanh trace ub ub_array
|
25
|
+
]
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.keywords
|
29
|
+
@keywords = Set.new %w[
|
30
|
+
ann annotation any constraint else endif function for forall if
|
31
|
+
include list of op output minimize maximize par predicate record
|
32
|
+
satisfy solve test then type var where
|
33
|
+
]
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.keywords_type
|
37
|
+
@keywords_type ||= Set.new %w(
|
38
|
+
array set bool enum float int string tuple
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.operators
|
43
|
+
@operators ||= Set.new %w(
|
44
|
+
in subset superset union diff symdiff intersect
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
48
|
+
id = /[$a-zA-Z_]\w*/
|
49
|
+
|
50
|
+
state :root do
|
51
|
+
rule %r(\s+)m, Text::Whitespace
|
52
|
+
rule %r(\\\n)m, Text::Whitespace
|
53
|
+
rule %r(%.*), Comment::Single
|
54
|
+
rule %r(/(\\\n)?[*](.|\n)*?[*](\\\n)?/)m, Comment::Multiline
|
55
|
+
rule %r/"(\\\\|\\"|[^"])*"/, Literal::String
|
56
|
+
|
57
|
+
rule %r(not|<->|->|<-|\\/|xor|/\\), Operator
|
58
|
+
rule %r(<|>|<=|>=|==|=|!=), Operator
|
59
|
+
rule %r(\+|-|\*|/|div|mod), Operator
|
60
|
+
rule %r(\\|\.\.|\+\+), Operator
|
61
|
+
rule %r([|()\[\]{},:;]), Punctuation
|
62
|
+
rule %r((true|false)\b), Keyword::Constant
|
63
|
+
rule %r(([+-]?)\d+(\.(?!\.)\d*)?([eE][-+]?\d+)?), Literal::Number
|
64
|
+
|
65
|
+
rule id do |m|
|
66
|
+
if self.class.keywords.include? m[0]
|
67
|
+
token Keyword
|
68
|
+
elsif self.class.keywords_type.include? m[0]
|
69
|
+
token Keyword::Type
|
70
|
+
elsif self.class.builtins.include? m[0]
|
71
|
+
token Name::Builtin
|
72
|
+
elsif self.class.operators.include? m[0]
|
73
|
+
token Operator
|
74
|
+
else
|
75
|
+
token Name::Other
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
rule %r(::\s*([^\W\d]\w*)(\s*\([^\)]*\))?), Name::Decorator
|
80
|
+
rule %r(\b([^\W\d]\w*)\b(\()) do
|
81
|
+
groups Name::Function, Punctuation
|
82
|
+
end
|
83
|
+
rule %r([^\W\d]\w*), Name::Other
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Rouge
|
5
|
+
module Lexers
|
6
|
+
class MsgTrans < RegexLexer
|
7
|
+
title "MessageTrans"
|
8
|
+
desc "RISC OS message translator messages file"
|
9
|
+
tag 'msgtrans'
|
10
|
+
filenames 'Messages', 'Message[0-9]', 'Message[1-9][0-9]', 'Message[1-9][0-9][0-9]'
|
11
|
+
|
12
|
+
state :root do
|
13
|
+
rule %r/^#[^\n]*/, Comment
|
14
|
+
rule %r/[^\t\n\r ,):?\/]+/, Name::Variable
|
15
|
+
rule %r/[\n\/?]/, Operator
|
16
|
+
rule %r/:/, Operator, :value
|
17
|
+
end
|
18
|
+
|
19
|
+
state :value do
|
20
|
+
rule %r/\n/, Text, :pop!
|
21
|
+
rule %r/%[0-3%]/, Operator
|
22
|
+
rule %r/[^\n%]/, Literal::String
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/rouge/lexers/ocaml.rb
CHANGED
@@ -3,7 +3,9 @@
|
|
3
3
|
|
4
4
|
module Rouge
|
5
5
|
module Lexers
|
6
|
-
|
6
|
+
load_lexer 'ocaml/common.rb'
|
7
|
+
|
8
|
+
class OCaml < OCamlCommon
|
7
9
|
title "OCaml"
|
8
10
|
desc 'Objective Caml (ocaml.org)'
|
9
11
|
tag 'ocaml'
|
@@ -11,35 +13,19 @@ module Rouge
|
|
11
13
|
mimetypes 'text/x-ocaml'
|
12
14
|
|
13
15
|
def self.keywords
|
14
|
-
@keywords ||= Set.new
|
15
|
-
|
16
|
-
|
17
|
-
inherit initializer lazy let match method module mutable new
|
18
|
-
nonrec object of open private raise rec sig struct then to true
|
19
|
-
try type val virtual when while with
|
20
|
-
)
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.word_operators
|
24
|
-
@word_operators ||= Set.new %w(and asr land lor lsl lxor mod or)
|
16
|
+
@keywords ||= super + Set.new(%w(
|
17
|
+
match raise
|
18
|
+
))
|
25
19
|
end
|
26
20
|
|
27
|
-
def self.primitives
|
28
|
-
@primitives ||= Set.new %w(unit int float bool string char list array)
|
29
|
-
end
|
30
|
-
|
31
|
-
operator = %r([;,_!$%&*+./:<=>?@^|~#-]+)
|
32
|
-
id = /[a-z_][\w']*/i
|
33
|
-
upper_id = /[A-Z][\w']*/
|
34
|
-
|
35
21
|
state :root do
|
36
22
|
rule %r/\s+/m, Text
|
37
23
|
rule %r/false|true|[(][)]|\[\]/, Name::Builtin::Pseudo
|
38
|
-
rule %r/#{upper_id}(?=\s*[.])/, Name::Namespace, :dotted
|
39
|
-
rule %r/`#{id}/, Name::Tag
|
40
|
-
rule upper_id, Name::Class
|
24
|
+
rule %r/#{@@upper_id}(?=\s*[.])/, Name::Namespace, :dotted
|
25
|
+
rule %r/`#{@@id}/, Name::Tag
|
26
|
+
rule @@upper_id, Name::Class
|
41
27
|
rule %r/[(][*](?![)])/, Comment, :comment
|
42
|
-
rule id do |m|
|
28
|
+
rule @@id do |m|
|
43
29
|
match = m[0]
|
44
30
|
if self.class.keywords.include? match
|
45
31
|
token Keyword
|
@@ -53,7 +39,7 @@ module Rouge
|
|
53
39
|
end
|
54
40
|
|
55
41
|
rule %r/[(){}\[\];]+/, Punctuation
|
56
|
-
rule operator, Operator
|
42
|
+
rule @@operator, Operator
|
57
43
|
|
58
44
|
rule %r/-?\d[\d_]*(.[\d_]*)?(e[+-]?\d[\d_]*)/i, Num::Float
|
59
45
|
rule %r/0x\h[\h_]*/i, Num::Hex
|
@@ -65,7 +51,7 @@ module Rouge
|
|
65
51
|
rule %r/'[.]'/, Str::Char
|
66
52
|
rule %r/'/, Keyword
|
67
53
|
rule %r/"/, Str::Double, :string
|
68
|
-
rule %r/[~?]#{id}/, Name::Variable
|
54
|
+
rule %r/[~?]#{@@id}/, Name::Variable
|
69
55
|
end
|
70
56
|
|
71
57
|
state :comment do
|
@@ -74,28 +60,6 @@ module Rouge
|
|
74
60
|
rule %r/[*][)]/, Comment, :pop!
|
75
61
|
rule %r/[(*)]/, Comment
|
76
62
|
end
|
77
|
-
|
78
|
-
state :string do
|
79
|
-
rule %r/[^\\"]+/, Str::Double
|
80
|
-
mixin :escape_sequence
|
81
|
-
rule %r/\\\n/, Str::Double
|
82
|
-
rule %r/"/, Str::Double, :pop!
|
83
|
-
end
|
84
|
-
|
85
|
-
state :escape_sequence do
|
86
|
-
rule %r/\\[\\"'ntbr]/, Str::Escape
|
87
|
-
rule %r/\\\d{3}/, Str::Escape
|
88
|
-
rule %r/\\x\h{2}/, Str::Escape
|
89
|
-
end
|
90
|
-
|
91
|
-
state :dotted do
|
92
|
-
rule %r/\s+/m, Text
|
93
|
-
rule %r/[.]/, Punctuation
|
94
|
-
rule %r/#{upper_id}(?=\s*[.])/, Name::Namespace
|
95
|
-
rule upper_id, Name::Class, :pop!
|
96
|
-
rule id, Name, :pop!
|
97
|
-
rule %r/[({\[]/, Punctuation, :pop!
|
98
|
-
end
|
99
63
|
end
|
100
64
|
end
|
101
65
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Rouge
|
5
|
+
module Lexers
|
6
|
+
# shared states with Reasonml
|
7
|
+
class OCamlCommon < RegexLexer
|
8
|
+
def self.keywords
|
9
|
+
@keywords ||= Set.new %w(
|
10
|
+
as assert begin class constraint do done downto else end
|
11
|
+
exception external false for fun function functor if in
|
12
|
+
include inherit initializer lazy let module mutable new
|
13
|
+
nonrec object of open rec sig struct then to true try type
|
14
|
+
val virtual when while with
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.word_operators
|
19
|
+
@word_operators ||= Set.new %w(and asr land lor lsl lxor mod or)
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.primitives
|
23
|
+
@primitives ||= Set.new %w(unit int float bool string char list array)
|
24
|
+
end
|
25
|
+
|
26
|
+
@@operator = %r([;,_!$%&*+./:<=>?@^|~#-]+)
|
27
|
+
@@id = /[a-z_][\w']*/i
|
28
|
+
@@upper_id = /[A-Z][\w']*/
|
29
|
+
|
30
|
+
state :string do
|
31
|
+
rule %r/[^\\"]+/, Str::Double
|
32
|
+
mixin :escape_sequence
|
33
|
+
rule %r/\\\n/, Str::Double
|
34
|
+
rule %r/"/, Str::Double, :pop!
|
35
|
+
end
|
36
|
+
|
37
|
+
state :escape_sequence do
|
38
|
+
rule %r/\\[\\"'ntbr]/, Str::Escape
|
39
|
+
rule %r/\\\d{3}/, Str::Escape
|
40
|
+
rule %r/\\x\h{2}/, Str::Escape
|
41
|
+
end
|
42
|
+
|
43
|
+
state :dotted do
|
44
|
+
rule %r/\s+/m, Text
|
45
|
+
rule %r/[.]/, Punctuation
|
46
|
+
rule %r/#{@@upper_id}(?=\s*[.])/, Name::Namespace
|
47
|
+
rule @@upper_id, Name::Class, :pop!
|
48
|
+
rule @@id, Name, :pop!
|
49
|
+
rule %r/[({\[]/, Punctuation, :pop!
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Rouge
|
5
|
+
module Lexers
|
6
|
+
class OpenTypeFeatureFile < RegexLexer
|
7
|
+
title "OpenType Feature File"
|
8
|
+
desc "Feature specifications for an OpenType font (adobe-type-tools.github.io/afdko)"
|
9
|
+
tag 'opentype_feature_file'
|
10
|
+
aliases 'fea', 'opentype', 'opentypefeature'
|
11
|
+
filenames '*.fea'
|
12
|
+
|
13
|
+
def self.keywords
|
14
|
+
@keywords ||= %w(
|
15
|
+
Ascender Attach CapHeight CaretOffset CodePageRange Descender FontRevision FSType
|
16
|
+
GlyphClassDef HorizAxis.BaseScriptList HorizAxis.BaseTagList HorizAxis.MinMax
|
17
|
+
IgnoreBaseGlyphs IgnoreLigatures IgnoreMarks LigatureCaretByDev LigatureCaretByIndex
|
18
|
+
LigatureCaretByPos LineGap MarkAttachClass MarkAttachmentType NULL Panose RightToLeft
|
19
|
+
TypoAscender TypoDescender TypoLineGap UnicodeRange UseMarkFilteringSet Vendor
|
20
|
+
VertAdvanceY VertAxis.BaseScriptList VertAxis.BaseTagList VertAxis.MinMax VertOriginY
|
21
|
+
VertTypoAscender VertTypoDescender VertTypoLineGap WeightClass WidthClass XHeight
|
22
|
+
|
23
|
+
anchorDef anchor anonymous anon by contour cursive device enumerate enum
|
24
|
+
exclude_dflt featureNames feature from ignore include_dflt include languagesystem
|
25
|
+
language lookupflag lookup markClass mark nameid name parameters position pos required
|
26
|
+
reversesub rsub script sizemenuname substitute subtable sub table useExtension
|
27
|
+
valueRecordDef winAscent winDescent
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
identifier = %r/[a-z_][a-z0-9\/_]*/i
|
33
|
+
|
34
|
+
state :root do
|
35
|
+
rule %r/\s+/m, Text::Whitespace
|
36
|
+
rule %r/#.*$/, Comment
|
37
|
+
|
38
|
+
# feature <tag>
|
39
|
+
rule %r/(anonymous|anon|feature|lookup|table)((?:\s)+)/ do
|
40
|
+
groups Keyword, Text
|
41
|
+
push :featurename
|
42
|
+
end
|
43
|
+
# } <tag> ;
|
44
|
+
rule %r/(\})((?:\s)*)/ do
|
45
|
+
groups Punctuation, Text
|
46
|
+
push :featurename
|
47
|
+
end
|
48
|
+
# solve include( ../path)
|
49
|
+
rule %r/(include)/i, Keyword, :includepath
|
50
|
+
|
51
|
+
rule %r/[\-\[\]\/(){},.:;=%*<>']/, Punctuation
|
52
|
+
|
53
|
+
rule %r/`.*?/, Str::Backtick
|
54
|
+
rule %r/\"/, Str, :dqs
|
55
|
+
|
56
|
+
# classes, start with @<nameOfClass>
|
57
|
+
rule %r/@#{identifier}/, Name::Class
|
58
|
+
|
59
|
+
# using negative lookbehind so we don't match property names
|
60
|
+
rule %r/(?<!\.)#{identifier}/ do |m|
|
61
|
+
if self.class.keywords.include? m[0]
|
62
|
+
token Keyword
|
63
|
+
else
|
64
|
+
token Name
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
rule identifier, Name
|
69
|
+
rule %r/-?\d+/, Num::Integer
|
70
|
+
end
|
71
|
+
|
72
|
+
state :featurename do
|
73
|
+
rule identifier, Name::Function, :pop!
|
74
|
+
end
|
75
|
+
|
76
|
+
state :includepath do
|
77
|
+
rule %r/\s+/, Text::Whitespace
|
78
|
+
rule %r/\)/, Punctuation, :pop!
|
79
|
+
rule %r/\(/, Punctuation
|
80
|
+
rule %r/[a-z0-9\/_.]*/i, Str
|
81
|
+
end
|
82
|
+
|
83
|
+
state :strings do
|
84
|
+
rule %r/(\([a-z0-9_]+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?/i, Str
|
85
|
+
end
|
86
|
+
|
87
|
+
state :strings_double do
|
88
|
+
rule %r/[^\\"%\n]+/, Str
|
89
|
+
mixin :strings
|
90
|
+
end
|
91
|
+
|
92
|
+
state :escape do
|
93
|
+
rule %r(\\
|
94
|
+
( [\\abfnrtv"']
|
95
|
+
| \n
|
96
|
+
| N{[a-zA-z][a-zA-Z ]+[a-zA-Z]}
|
97
|
+
| u[a-fA-F0-9]{4}
|
98
|
+
| U[a-fA-F0-9]{8}
|
99
|
+
| x[a-fA-F0-9]{2}
|
100
|
+
| [0-7]{1,3}
|
101
|
+
)
|
102
|
+
)x, Str::Escape
|
103
|
+
end
|
104
|
+
|
105
|
+
state :dqs do
|
106
|
+
rule %r/"/, Str, :pop!
|
107
|
+
mixin :escape
|
108
|
+
mixin :strings_double
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
data/lib/rouge/lexers/perl.rb
CHANGED
@@ -127,7 +127,7 @@ module Rouge
|
|
127
127
|
rule %r/(q|qq|qw|qr|qx)\(/, Str::Other, :rb_string
|
128
128
|
rule %r/(q|qq|qw|qr|qx)\[/, Str::Other, :sb_string
|
129
129
|
rule %r/(q|qq|qw|qr|qx)</, Str::Other, :lt_string
|
130
|
-
rule %r/(q|qq|qw|qr|qx)(
|
130
|
+
rule %r/(q|qq|qw|qr|qx)(\W)(.|\n)*?\2/, Str::Other
|
131
131
|
|
132
132
|
rule %r/package\s+/, Keyword, :modulename
|
133
133
|
rule %r/sub\s+/, Keyword, :funcname
|
data/lib/rouge/lexers/php.rb
CHANGED
@@ -72,7 +72,7 @@ module Rouge
|
|
72
72
|
while endforeach global __FILE__ endif list __LINE__ endswitch
|
73
73
|
new __sleep endwhile not array __wakeup E_ALL NULL final
|
74
74
|
php_user_filter interface implements public private protected
|
75
|
-
abstract clone try catch throw this use namespace yield
|
75
|
+
abstract clone try catch finally throw this use namespace yield
|
76
76
|
)
|
77
77
|
end
|
78
78
|
|
@@ -98,21 +98,29 @@ module Rouge
|
|
98
98
|
state :php do
|
99
99
|
rule %r/\?>/, Comment::Preproc, :pop!
|
100
100
|
# heredocs
|
101
|
-
rule %r/<<<('?)(#{id})\1\n.*?\n\2
|
101
|
+
rule %r/<<<('?)(#{id})\1\n.*?\n\s*\2;?/im, Str::Heredoc
|
102
102
|
rule %r/\s+/, Text
|
103
103
|
rule %r/#.*?$/, Comment::Single
|
104
104
|
rule %r(//.*?$), Comment::Single
|
105
|
-
|
106
|
-
rule %r(/\*\*/), Comment::Multiline
|
107
|
-
rule %r(/\*\*.*?\*/)m, Str::Doc
|
105
|
+
rule %r(/\*\*(?!/).*?\*/)m, Comment::Doc
|
108
106
|
rule %r(/\*.*?\*/)m, Comment::Multiline
|
107
|
+
|
109
108
|
rule %r/(->|::)(\s*)(#{id})/ do
|
110
109
|
groups Operator, Text, Name::Attribute
|
111
110
|
end
|
112
111
|
|
113
112
|
rule %r/[~!%^&*+=\|:.<>\/?@-]+/, Operator
|
114
113
|
rule %r/[\[\]{}();,]/, Punctuation
|
115
|
-
rule %r/class\
|
114
|
+
rule %r/(class|interface|trait)(\s+)(#{nsid})/ do
|
115
|
+
groups Keyword::Declaration, Text, Name::Class
|
116
|
+
end
|
117
|
+
rule %r/(use)(\s+)(function|const|)(\s*)(#{nsid})/ do
|
118
|
+
groups Keyword::Namespace, Text, Keyword::Namespace, Text, Name::Namespace
|
119
|
+
push :use
|
120
|
+
end
|
121
|
+
rule %r/(namespace)(\s+)(#{nsid})/ do
|
122
|
+
groups Keyword::Namespace, Text, Name::Namespace
|
123
|
+
end
|
116
124
|
# anonymous functions
|
117
125
|
rule %r/(function)(\s*)(?=\()/ do
|
118
126
|
groups Keyword, Text
|
@@ -154,10 +162,24 @@ module Rouge
|
|
154
162
|
rule %r/`([^`\\]*(?:\\.[^`\\]*)*)`/, Str::Backtick
|
155
163
|
rule %r/"/, Str::Double, :string
|
156
164
|
end
|
157
|
-
|
158
|
-
state :
|
165
|
+
|
166
|
+
state :use do
|
167
|
+
rule %r/(\s+)(as)(\s+)(#{id})/ do
|
168
|
+
groups Text, Keyword, Text, Name
|
169
|
+
:pop!
|
170
|
+
end
|
171
|
+
rule %r/\\\{/, Operator, :uselist
|
172
|
+
rule %r/;/, Punctuation, :pop!
|
173
|
+
end
|
174
|
+
|
175
|
+
state :uselist do
|
159
176
|
rule %r/\s+/, Text
|
160
|
-
rule %r
|
177
|
+
rule %r/,/, Operator
|
178
|
+
rule %r/\}/, Operator, :pop!
|
179
|
+
rule %r/(as)(\s+)(#{id})/ do
|
180
|
+
groups Keyword, Text, Name
|
181
|
+
end
|
182
|
+
rule %r/#{id}/, Name::Namespace
|
161
183
|
end
|
162
184
|
|
163
185
|
state :funcname do
|