rouge 3.4.1 → 3.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rouge.rb +3 -0
- data/lib/rouge/cli.rb +19 -2
- data/lib/rouge/demos/bpf +7 -0
- data/lib/rouge/demos/brainfuck +5 -0
- data/lib/rouge/demos/magik +6 -0
- data/lib/rouge/formatter.rb +2 -2
- data/lib/rouge/formatters/tex.rb +90 -0
- data/lib/rouge/guessers/glob_mapping.rb +1 -1
- data/lib/rouge/lexer.rb +22 -10
- data/lib/rouge/lexers/abap.rb +11 -11
- data/lib/rouge/lexers/actionscript.rb +34 -34
- data/lib/rouge/lexers/apache.rb +8 -8
- data/lib/rouge/lexers/apple_script.rb +15 -14
- data/lib/rouge/lexers/awk.rb +25 -25
- data/lib/rouge/lexers/biml.rb +4 -4
- data/lib/rouge/lexers/bpf.rb +104 -0
- data/lib/rouge/lexers/brainfuck.rb +53 -0
- data/lib/rouge/lexers/bsl.rb +12 -12
- data/lib/rouge/lexers/c.rb +30 -30
- data/lib/rouge/lexers/ceylon.rb +1 -29
- data/lib/rouge/lexers/cfscript.rb +26 -26
- data/lib/rouge/lexers/clojure.rb +14 -14
- data/lib/rouge/lexers/cmake.rb +14 -14
- data/lib/rouge/lexers/coffeescript.rb +30 -30
- data/lib/rouge/lexers/common_lisp.rb +36 -36
- data/lib/rouge/lexers/conf.rb +6 -6
- data/lib/rouge/lexers/coq.rb +18 -18
- data/lib/rouge/lexers/cpp.rb +8 -8
- data/lib/rouge/lexers/crystal.rb +70 -70
- data/lib/rouge/lexers/csharp.rb +28 -28
- data/lib/rouge/lexers/css.rb +23 -23
- data/lib/rouge/lexers/d.rb +59 -59
- data/lib/rouge/lexers/dart.rb +33 -33
- data/lib/rouge/lexers/digdag.rb +1 -1
- data/lib/rouge/lexers/docker.rb +10 -10
- data/lib/rouge/lexers/dot.rb +16 -16
- data/lib/rouge/lexers/eiffel.rb +20 -20
- data/lib/rouge/lexers/elixir.rb +29 -28
- data/lib/rouge/lexers/elm.rb +29 -29
- data/lib/rouge/lexers/erb.rb +4 -4
- data/lib/rouge/lexers/factor.rb +40 -40
- data/lib/rouge/lexers/fortran.rb +32 -32
- data/lib/rouge/lexers/fsharp.rb +26 -26
- data/lib/rouge/lexers/gherkin.rb +13 -13
- data/lib/rouge/lexers/glsl.rb +0 -4
- data/lib/rouge/lexers/go.rb +1 -1
- data/lib/rouge/lexers/graphql.rb +62 -62
- data/lib/rouge/lexers/groovy.rb +23 -25
- data/lib/rouge/lexers/hack.rb +1 -1
- data/lib/rouge/lexers/haml.rb +25 -29
- data/lib/rouge/lexers/handlebars.rb +18 -18
- data/lib/rouge/lexers/haskell.rb +66 -65
- data/lib/rouge/lexers/hcl.rb +25 -25
- data/lib/rouge/lexers/html.rb +31 -31
- data/lib/rouge/lexers/http.rb +4 -4
- data/lib/rouge/lexers/hylang.rb +14 -14
- data/lib/rouge/lexers/idlang.rb +32 -32
- data/lib/rouge/lexers/igorpro.rb +30 -30
- data/lib/rouge/lexers/ini.rb +12 -12
- data/lib/rouge/lexers/io.rb +7 -7
- data/lib/rouge/lexers/irb.rb +5 -5
- data/lib/rouge/lexers/java.rb +24 -24
- data/lib/rouge/lexers/javascript.rb +51 -51
- data/lib/rouge/lexers/jinja.rb +22 -22
- data/lib/rouge/lexers/json.rb +11 -10
- data/lib/rouge/lexers/json_doc.rb +2 -2
- data/lib/rouge/lexers/jsonnet.rb +18 -18
- data/lib/rouge/lexers/jsp.rb +28 -28
- data/lib/rouge/lexers/jsx.rb +16 -16
- data/lib/rouge/lexers/julia.rb +44 -44
- data/lib/rouge/lexers/kotlin.rb +3 -3
- data/lib/rouge/lexers/lasso.rb +50 -50
- data/lib/rouge/lexers/liquid.rb +53 -53
- data/lib/rouge/lexers/literate_coffeescript.rb +2 -2
- data/lib/rouge/lexers/literate_haskell.rb +5 -5
- data/lib/rouge/lexers/llvm.rb +23 -16
- data/lib/rouge/lexers/lua.rb +3 -3
- data/lib/rouge/lexers/m68k.rb +18 -19
- data/lib/rouge/lexers/magik.rb +126 -0
- data/lib/rouge/lexers/make.rb +22 -28
- data/lib/rouge/lexers/markdown.rb +37 -37
- data/lib/rouge/lexers/mathematica.rb +11 -11
- data/lib/rouge/lexers/matlab.rb +20 -20
- data/lib/rouge/lexers/moonscript.rb +3 -3
- data/lib/rouge/lexers/mosel.rb +17 -17
- data/lib/rouge/lexers/mxml.rb +18 -18
- data/lib/rouge/lexers/nasm.rb +24 -25
- data/lib/rouge/lexers/nginx.rb +14 -14
- data/lib/rouge/lexers/nim.rb +1 -1
- data/lib/rouge/lexers/nix.rb +42 -42
- data/lib/rouge/lexers/objective_c.rb +38 -38
- data/lib/rouge/lexers/ocaml.rb +29 -29
- data/lib/rouge/lexers/pascal.rb +4 -4
- data/lib/rouge/lexers/perl.rb +68 -68
- data/lib/rouge/lexers/php.rb +38 -38
- data/lib/rouge/lexers/plist.rb +14 -14
- data/lib/rouge/lexers/pony.rb +19 -19
- data/lib/rouge/lexers/powershell.rb +25 -25
- data/lib/rouge/lexers/praat.rb +75 -75
- data/lib/rouge/lexers/prolog.rb +26 -20
- data/lib/rouge/lexers/prometheus.rb +30 -30
- data/lib/rouge/lexers/properties.rb +12 -12
- data/lib/rouge/lexers/protobuf.rb +22 -22
- data/lib/rouge/lexers/puppet.rb +31 -31
- data/lib/rouge/lexers/python.rb +52 -52
- data/lib/rouge/lexers/q.rb +12 -12
- data/lib/rouge/lexers/qml.rb +12 -12
- data/lib/rouge/lexers/r.rb +12 -12
- data/lib/rouge/lexers/racket.rb +22 -22
- data/lib/rouge/lexers/ruby.rb +71 -69
- data/lib/rouge/lexers/rust.rb +30 -30
- data/lib/rouge/lexers/sass.rb +8 -8
- data/lib/rouge/lexers/sass/common.rb +40 -40
- data/lib/rouge/lexers/scala.rb +43 -43
- data/lib/rouge/lexers/scheme.rb +18 -18
- data/lib/rouge/lexers/scss.rb +3 -3
- data/lib/rouge/lexers/sed.rb +29 -29
- data/lib/rouge/lexers/shell.rb +61 -52
- data/lib/rouge/lexers/sieve.rb +8 -8
- data/lib/rouge/lexers/slim.rb +24 -24
- data/lib/rouge/lexers/smalltalk.rb +33 -33
- data/lib/rouge/lexers/smarty.rb +12 -12
- data/lib/rouge/lexers/sml.rb +67 -67
- data/lib/rouge/lexers/sqf.rb +1 -1
- data/lib/rouge/lexers/sql.rb +21 -21
- data/lib/rouge/lexers/supercollider.rb +19 -19
- data/lib/rouge/lexers/swift.rb +42 -39
- data/lib/rouge/lexers/tap.rb +20 -20
- data/lib/rouge/lexers/tcl.rb +27 -27
- data/lib/rouge/lexers/terraform.rb +13 -13
- data/lib/rouge/lexers/tex.rb +19 -19
- data/lib/rouge/lexers/toml.rb +18 -18
- data/lib/rouge/lexers/tulip.rb +36 -36
- data/lib/rouge/lexers/turtle.rb +35 -38
- data/lib/rouge/lexers/vala.rb +17 -17
- data/lib/rouge/lexers/vb.rb +27 -27
- data/lib/rouge/lexers/verilog.rb +25 -27
- data/lib/rouge/lexers/vhdl.rb +10 -10
- data/lib/rouge/lexers/viml.rb +14 -14
- data/lib/rouge/lexers/vue.rb +9 -9
- data/lib/rouge/lexers/wollok.rb +25 -25
- data/lib/rouge/lexers/xml.rb +17 -21
- data/lib/rouge/lexers/xojo.rb +15 -15
- data/lib/rouge/lexers/yaml.rb +61 -61
- data/lib/rouge/plugins/redcarpet.rb +1 -1
- data/lib/rouge/tex_theme_renderer.rb +128 -0
- data/lib/rouge/theme.rb +4 -0
- data/lib/rouge/themes/magritte.rb +78 -0
- data/lib/rouge/version.rb +1 -1
- metadata +11 -2
data/lib/rouge/lexers/hcl.rb
CHANGED
@@ -16,19 +16,19 @@ module Rouge
|
|
16
16
|
end
|
17
17
|
|
18
18
|
state :comments_and_whitespace do
|
19
|
-
rule /\s+/, Text
|
19
|
+
rule %r/\s+/, Text
|
20
20
|
rule %r(//.*?$), Comment::Single
|
21
21
|
rule %r(#.*?$), Comment::Single
|
22
22
|
rule %r(/[*]), Comment::Multiline, :multiline_comment
|
23
23
|
end
|
24
24
|
|
25
25
|
state :primitives do
|
26
|
-
rule /[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?([kKmMgG]b?)?/, Num::Float
|
27
|
-
rule /[0-9]+([kKmMgG]b?)?/, Num::Integer
|
26
|
+
rule %r/[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?([kKmMgG]b?)?/, Num::Float
|
27
|
+
rule %r/[0-9]+([kKmMgG]b?)?/, Num::Integer
|
28
28
|
|
29
|
-
rule /"/, Str::Double, :dq
|
30
|
-
rule /'/, Str::Single, :sq
|
31
|
-
rule /(<<-?)(\s*)(\'?)(\\?)(\w+)(\3)/ do |m|
|
29
|
+
rule %r/"/, Str::Double, :dq
|
30
|
+
rule %r/'/, Str::Single, :sq
|
31
|
+
rule %r/(<<-?)(\s*)(\'?)(\\?)(\w+)(\3)/ do |m|
|
32
32
|
groups Operator, Text, Str::Heredoc, Str::Heredoc, Name::Constant, Str::Heredoc
|
33
33
|
@heredocstr = Regexp.escape(m[5])
|
34
34
|
push :heredoc
|
@@ -61,11 +61,11 @@ module Rouge
|
|
61
61
|
mixin :comments_and_whitespace
|
62
62
|
mixin :primitives
|
63
63
|
|
64
|
-
rule /\{/ do
|
64
|
+
rule %r/\{/ do
|
65
65
|
token Punctuation
|
66
66
|
push :hash
|
67
67
|
end
|
68
|
-
rule /\[/ do
|
68
|
+
rule %r/\[/ do
|
69
69
|
token Punctuation
|
70
70
|
push :array
|
71
71
|
end
|
@@ -93,13 +93,13 @@ module Rouge
|
|
93
93
|
state :composite do
|
94
94
|
mixin :comments_and_whitespace
|
95
95
|
|
96
|
-
rule /[{]/ do
|
96
|
+
rule %r/[{]/ do
|
97
97
|
token Punctuation
|
98
98
|
pop!
|
99
99
|
push :hash
|
100
100
|
end
|
101
101
|
|
102
|
-
rule /[\[]/ do
|
102
|
+
rule %r/[\[]/ do
|
103
103
|
token Punctuation
|
104
104
|
pop!
|
105
105
|
push :array
|
@@ -107,14 +107,14 @@ module Rouge
|
|
107
107
|
|
108
108
|
mixin :root
|
109
109
|
|
110
|
-
rule //, Text, :pop!
|
110
|
+
rule %r//, Text, :pop!
|
111
111
|
end
|
112
112
|
|
113
113
|
state :hash do
|
114
114
|
mixin :comments_and_whitespace
|
115
115
|
|
116
|
-
rule /\=/, Punctuation
|
117
|
-
rule /\}/, Punctuation, :pop!
|
116
|
+
rule %r/\=/, Punctuation
|
117
|
+
rule %r/\}/, Punctuation, :pop!
|
118
118
|
|
119
119
|
mixin :root
|
120
120
|
end
|
@@ -122,32 +122,32 @@ module Rouge
|
|
122
122
|
state :array do
|
123
123
|
mixin :comments_and_whitespace
|
124
124
|
|
125
|
-
rule /,/, Punctuation
|
126
|
-
rule /\]/, Punctuation, :pop!
|
125
|
+
rule %r/,/, Punctuation
|
126
|
+
rule %r/\]/, Punctuation, :pop!
|
127
127
|
|
128
128
|
mixin :root
|
129
129
|
end
|
130
130
|
|
131
131
|
state :dq do
|
132
|
-
rule /[^\\"]+/, Str::Double
|
133
|
-
rule /\\"/, Str::Escape
|
134
|
-
rule /"/, Str::Double, :pop!
|
132
|
+
rule %r/[^\\"]+/, Str::Double
|
133
|
+
rule %r/\\"/, Str::Escape
|
134
|
+
rule %r/"/, Str::Double, :pop!
|
135
135
|
end
|
136
136
|
|
137
137
|
state :sq do
|
138
|
-
rule /[^\\']+/, Str::Single
|
139
|
-
rule /\\'/, Str::Escape
|
140
|
-
rule /'/, Str::Single, :pop!
|
138
|
+
rule %r/[^\\']+/, Str::Single
|
139
|
+
rule %r/\\'/, Str::Escape
|
140
|
+
rule %r/'/, Str::Single, :pop!
|
141
141
|
end
|
142
142
|
|
143
143
|
state :heredoc do
|
144
|
-
rule /\n/, Str::Heredoc, :heredoc_nl
|
145
|
-
rule /[^$\n]+/, Str::Heredoc
|
146
|
-
rule /[$]/, Str::Heredoc
|
144
|
+
rule %r/\n/, Str::Heredoc, :heredoc_nl
|
145
|
+
rule %r/[^$\n]+/, Str::Heredoc
|
146
|
+
rule %r/[$]/, Str::Heredoc
|
147
147
|
end
|
148
148
|
|
149
149
|
state :heredoc_nl do
|
150
|
-
rule /\s*(\w+)\s*\n/ do |m|
|
150
|
+
rule %r/\s*(\w+)\s*\n/ do |m|
|
151
151
|
if m[1] == @heredocstr
|
152
152
|
token Name::Constant
|
153
153
|
pop! 2
|
data/lib/rouge/lexers/html.rb
CHANGED
@@ -22,21 +22,21 @@ module Rouge
|
|
22
22
|
end
|
23
23
|
|
24
24
|
state :root do
|
25
|
-
rule /[^<&]+/m, Text
|
26
|
-
rule /&\S*?;/, Name::Entity
|
27
|
-
rule /<!DOCTYPE .*?>/im, Comment::Preproc
|
28
|
-
rule /<!\[CDATA\[.*?\]\]>/m, Comment::Preproc
|
29
|
-
rule /<!--/, Comment, :comment
|
30
|
-
rule /<\?.*?\?>/m, Comment::Preproc # php? really?
|
31
|
-
|
32
|
-
rule /<\s*script\s*/m do
|
25
|
+
rule %r/[^<&]+/m, Text
|
26
|
+
rule %r/&\S*?;/, Name::Entity
|
27
|
+
rule %r/<!DOCTYPE .*?>/im, Comment::Preproc
|
28
|
+
rule %r/<!\[CDATA\[.*?\]\]>/m, Comment::Preproc
|
29
|
+
rule %r/<!--/, Comment, :comment
|
30
|
+
rule %r/<\?.*?\?>/m, Comment::Preproc # php? really?
|
31
|
+
|
32
|
+
rule %r/<\s*script\s*/m do
|
33
33
|
token Name::Tag
|
34
34
|
@javascript.reset!
|
35
35
|
push :script_content
|
36
36
|
push :tag
|
37
37
|
end
|
38
38
|
|
39
|
-
rule /<\s*style\s*/m do
|
39
|
+
rule %r/<\s*style\s*/m do
|
40
40
|
token Name::Tag
|
41
41
|
@css.reset!
|
42
42
|
@lang = @css
|
@@ -44,8 +44,8 @@ module Rouge
|
|
44
44
|
push :tag
|
45
45
|
end
|
46
46
|
|
47
|
-
rule
|
48
|
-
rule /</, Name::Tag, :tag_start
|
47
|
+
rule %r(</), Name::Tag, :tag_end
|
48
|
+
rule %r/</, Name::Tag, :tag_start
|
49
49
|
|
50
50
|
rule %r(<\s*[a-zA-Z0-9:-]+), Name::Tag, :tag # opening tags
|
51
51
|
rule %r(<\s*/\s*[a-zA-Z0-9:-]+\s*>), Name::Tag # closing tags
|
@@ -53,21 +53,21 @@ module Rouge
|
|
53
53
|
|
54
54
|
state :tag_end do
|
55
55
|
mixin :tag_end_end
|
56
|
-
rule /[a-zA-Z0-9:-]+/ do
|
56
|
+
rule %r/[a-zA-Z0-9:-]+/ do
|
57
57
|
token Name::Tag
|
58
58
|
goto :tag_end_end
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
62
|
state :tag_end_end do
|
63
|
-
rule /\s+/, Text
|
64
|
-
rule />/, Name::Tag, :pop!
|
63
|
+
rule %r/\s+/, Text
|
64
|
+
rule %r/>/, Name::Tag, :pop!
|
65
65
|
end
|
66
66
|
|
67
67
|
state :tag_start do
|
68
|
-
rule /\s+/, Text
|
68
|
+
rule %r/\s+/, Text
|
69
69
|
|
70
|
-
rule /[a-zA-Z0-9:-]+/ do
|
70
|
+
rule %r/[a-zA-Z0-9:-]+/ do
|
71
71
|
token Name::Tag
|
72
72
|
goto :tag
|
73
73
|
end
|
@@ -76,41 +76,41 @@ module Rouge
|
|
76
76
|
end
|
77
77
|
|
78
78
|
state :comment do
|
79
|
-
rule /[^-]+/, Comment
|
80
|
-
rule /-->/, Comment, :pop!
|
81
|
-
rule /-/, Comment
|
79
|
+
rule %r/[^-]+/, Comment
|
80
|
+
rule %r/-->/, Comment, :pop!
|
81
|
+
rule %r/-/, Comment
|
82
82
|
end
|
83
83
|
|
84
84
|
state :tag do
|
85
|
-
rule /\s+/m, Text
|
86
|
-
rule /[a-zA-Z0-9_:-]+\s*=\s*/m, Name::Attribute, :attr
|
87
|
-
rule /[a-zA-Z0-9_:-]+/, Name::Attribute
|
85
|
+
rule %r/\s+/m, Text
|
86
|
+
rule %r/[a-zA-Z0-9_:-]+\s*=\s*/m, Name::Attribute, :attr
|
87
|
+
rule %r/[a-zA-Z0-9_:-]+/, Name::Attribute
|
88
88
|
rule %r(/?\s*>)m, Name::Tag, :pop!
|
89
89
|
end
|
90
90
|
|
91
91
|
state :attr do
|
92
92
|
# TODO: are backslash escapes valid here?
|
93
|
-
rule /"/ do
|
93
|
+
rule %r/"/ do
|
94
94
|
token Str
|
95
95
|
goto :dq
|
96
96
|
end
|
97
97
|
|
98
|
-
rule /'/ do
|
98
|
+
rule %r/'/ do
|
99
99
|
token Str
|
100
100
|
goto :sq
|
101
101
|
end
|
102
102
|
|
103
|
-
rule /[^\s>]+/, Str, :pop!
|
103
|
+
rule %r/[^\s>]+/, Str, :pop!
|
104
104
|
end
|
105
105
|
|
106
106
|
state :dq do
|
107
|
-
rule /"/, Str, :pop!
|
108
|
-
rule /[^"]+/, Str
|
107
|
+
rule %r/"/, Str, :pop!
|
108
|
+
rule %r/[^"]+/, Str
|
109
109
|
end
|
110
110
|
|
111
111
|
state :sq do
|
112
|
-
rule /'/, Str, :pop!
|
113
|
-
rule /[^']+/, Str
|
112
|
+
rule %r/'/, Str, :pop!
|
113
|
+
rule %r/[^']+/, Str
|
114
114
|
end
|
115
115
|
|
116
116
|
state :script_content do
|
@@ -126,13 +126,13 @@ module Rouge
|
|
126
126
|
end
|
127
127
|
|
128
128
|
state :style_content do
|
129
|
-
rule /[^<]+/ do
|
129
|
+
rule %r/[^<]+/ do
|
130
130
|
delegate @lang
|
131
131
|
end
|
132
132
|
|
133
133
|
rule %r(<\s*/\s*style\s*>)m, Name::Tag, :pop!
|
134
134
|
|
135
|
-
rule /</ do
|
135
|
+
rule %r/</ do
|
136
136
|
delegate @lang
|
137
137
|
end
|
138
138
|
end
|
data/lib/rouge/lexers/http.rb
CHANGED
@@ -54,7 +54,7 @@ module Rouge
|
|
54
54
|
end
|
55
55
|
|
56
56
|
state :headers do
|
57
|
-
rule /([^\s:]+)( *)(:)( *)([^\r\n]+)(\r?\n|$)/ do |m|
|
57
|
+
rule %r/([^\s:]+)( *)(:)( *)([^\r\n]+)(\r?\n|$)/ do |m|
|
58
58
|
key = m[1]
|
59
59
|
value = m[5]
|
60
60
|
if key.strip.casecmp('content-type').zero?
|
@@ -64,15 +64,15 @@ module Rouge
|
|
64
64
|
groups Name::Attribute, Text, Punctuation, Text, Str, Text
|
65
65
|
end
|
66
66
|
|
67
|
-
rule /([^\r\n]+)(\r?\n|$)/ do
|
67
|
+
rule %r/([^\r\n]+)(\r?\n|$)/ do
|
68
68
|
groups Str, Text
|
69
69
|
end
|
70
70
|
|
71
|
-
rule /\r?\n/, Text, :content
|
71
|
+
rule %r/\r?\n/, Text, :content
|
72
72
|
end
|
73
73
|
|
74
74
|
state :content do
|
75
|
-
rule /.+/m do |m|
|
75
|
+
rule %r/.+/m do |m|
|
76
76
|
delegate(content_lexer)
|
77
77
|
end
|
78
78
|
end
|
data/lib/rouge/lexers/hylang.rb
CHANGED
@@ -54,22 +54,22 @@ module Rouge
|
|
54
54
|
end
|
55
55
|
|
56
56
|
state :root do
|
57
|
-
rule /;.*?$/, Comment::Single
|
58
|
-
rule /\s+/m, Text::Whitespace
|
57
|
+
rule %r/;.*?$/, Comment::Single
|
58
|
+
rule %r/\s+/m, Text::Whitespace
|
59
59
|
|
60
|
-
rule /-?\d+\.\d+/, Num::Float
|
61
|
-
rule /-?\d+/, Num::Integer
|
62
|
-
rule /0x-?[0-9a-fA-F]+/, Num::Hex
|
60
|
+
rule %r/-?\d+\.\d+/, Num::Float
|
61
|
+
rule %r/-?\d+/, Num::Integer
|
62
|
+
rule %r/0x-?[0-9a-fA-F]+/, Num::Hex
|
63
63
|
|
64
|
-
rule /"(\\.|[^"])*"/, Str
|
65
|
-
rule /'#{keyword}/, Str::Symbol
|
66
|
-
rule /::?#{keyword}/, Name::Constant
|
67
|
-
rule /\\(.|[a-z]+)/i, Str::Char
|
64
|
+
rule %r/"(\\.|[^"])*"/, Str
|
65
|
+
rule %r/'#{keyword}/, Str::Symbol
|
66
|
+
rule %r/::?#{keyword}/, Name::Constant
|
67
|
+
rule %r/\\(.|[a-z]+)/i, Str::Char
|
68
68
|
|
69
69
|
|
70
|
-
rule /~@|[`\'#^~&@]/, Operator
|
70
|
+
rule %r/~@|[`\'#^~&@]/, Operator
|
71
71
|
|
72
|
-
rule /(\()(\s*)(#{identifier})/m do |m|
|
72
|
+
rule %r/(\()(\s*)(#{identifier})/m do |m|
|
73
73
|
token Punctuation, m[1]
|
74
74
|
token Text::Whitespace, m[2]
|
75
75
|
token(name_token(m[3]) || Name::Function, m[3])
|
@@ -80,13 +80,13 @@ module Rouge
|
|
80
80
|
end
|
81
81
|
|
82
82
|
# vectors
|
83
|
-
rule /[\[\]]/, Punctuation
|
83
|
+
rule %r/[\[\]]/, Punctuation
|
84
84
|
|
85
85
|
# maps
|
86
|
-
rule /[{}]/, Punctuation
|
86
|
+
rule %r/[{}]/, Punctuation
|
87
87
|
|
88
88
|
# parentheses
|
89
|
-
rule /[()]/, Punctuation
|
89
|
+
rule %r/[()]/, Punctuation
|
90
90
|
end
|
91
91
|
end
|
92
92
|
end
|
data/lib/rouge/lexers/idlang.rb
CHANGED
@@ -209,17 +209,17 @@ module Rouge
|
|
209
209
|
end
|
210
210
|
|
211
211
|
state :root do
|
212
|
-
rule
|
212
|
+
rule %r/\s+/, Text::Whitespace
|
213
213
|
# Normal comments
|
214
|
-
rule /;.*$/, Comment::Single
|
215
|
-
rule /\,\s*\,/, Error
|
216
|
-
rule /\!#{name}/, Name::Variable::Global
|
214
|
+
rule %r/;.*$/, Comment::Single
|
215
|
+
rule %r/\,\s*\,/, Error
|
216
|
+
rule %r/\!#{name}/, Name::Variable::Global
|
217
217
|
|
218
|
-
rule /[(),:\&\$]/, Punctuation
|
218
|
+
rule %r/[(),:\&\$]/, Punctuation
|
219
219
|
|
220
220
|
## Format statements are quite a strange beast.
|
221
221
|
## Better process them in their own state.
|
222
|
-
#rule /\b(FORMAT)(\s*)(\()/mi do |m|
|
222
|
+
#rule %r/\b(FORMAT)(\s*)(\()/mi do |m|
|
223
223
|
# token Keyword, m[1]
|
224
224
|
# token Text::Whitespace, m[2]
|
225
225
|
# token Punctuation, m[3]
|
@@ -235,25 +235,25 @@ module Rouge
|
|
235
235
|
(_#{kind_param})? # kind parameter
|
236
236
|
)xi, Num::Float
|
237
237
|
|
238
|
-
rule /\d+(B|S|U|US|LL|L|ULL|UL)?/i, Num::Integer
|
239
|
-
rule /"[0-7]+(B|O|U|ULL|UL|LL|L)?/i, Num::Oct
|
240
|
-
rule /'[0-9A-F]+'X(B|S|US|ULL|UL|U|LL|L)?/i, Num::Hex
|
241
|
-
rule /(#{kind_param}_)?'/, Str::Single, :string_single
|
242
|
-
rule /(#{kind_param}_)?"/, Str::Double, :string_double
|
238
|
+
rule %r/\d+(B|S|U|US|LL|L|ULL|UL)?/i, Num::Integer
|
239
|
+
rule %r/"[0-7]+(B|O|U|ULL|UL|LL|L)?/i, Num::Oct
|
240
|
+
rule %r/'[0-9A-F]+'X(B|S|US|ULL|UL|U|LL|L)?/i, Num::Hex
|
241
|
+
rule %r/(#{kind_param}_)?'/, Str::Single, :string_single
|
242
|
+
rule %r/(#{kind_param}_)?"/, Str::Double, :string_double
|
243
243
|
|
244
244
|
rule %r{\#\#|\#|\&\&|\|\||/=|<=|>=|->|\@|\?|[-+*/<=~^{}]}, Operator
|
245
245
|
# Structures and the like
|
246
|
-
rule /(#{name})(\.)([^\s,]*)/i do |m|
|
246
|
+
rule %r/(#{name})(\.)([^\s,]*)/i do |m|
|
247
247
|
groups Name, Operator, Name
|
248
248
|
#delegate IDLang, m[3]
|
249
249
|
end
|
250
250
|
|
251
|
-
rule /(function|pro)((?:\s|\$\s)+)/i do
|
251
|
+
rule %r/(function|pro)((?:\s|\$\s)+)/i do
|
252
252
|
groups Keyword, Text::Whitespace
|
253
253
|
push :funcname
|
254
254
|
end
|
255
255
|
|
256
|
-
rule /#{name}/m do |m|
|
256
|
+
rule %r/#{name}/m do |m|
|
257
257
|
match = m[0].upcase
|
258
258
|
if self.class.keywords.include? match
|
259
259
|
token Keyword
|
@@ -275,37 +275,37 @@ module Rouge
|
|
275
275
|
end
|
276
276
|
|
277
277
|
state :funcname do
|
278
|
-
rule /#{name}/, Name::Function
|
278
|
+
rule %r/#{name}/, Name::Function
|
279
279
|
|
280
|
-
rule /\s+/, Text::Whitespace
|
281
|
-
rule /(:+|\$)/, Operator
|
282
|
-
rule /;.*/, Comment::Single
|
280
|
+
rule %r/\s+/, Text::Whitespace
|
281
|
+
rule %r/(:+|\$)/, Operator
|
282
|
+
rule %r/;.*/, Comment::Single
|
283
283
|
|
284
284
|
# Be done with this state if we hit EOL or comma
|
285
|
-
rule /$/, Text::Whitespace, :pop!
|
286
|
-
rule /,/, Operator, :pop!
|
285
|
+
rule %r/$/, Text::Whitespace, :pop!
|
286
|
+
rule %r/,/, Operator, :pop!
|
287
287
|
end
|
288
288
|
|
289
289
|
state :string_single do
|
290
|
-
rule /[^']+/, Str::Single
|
291
|
-
rule /''/, Str::Escape
|
292
|
-
rule /'/, Str::Single, :pop!
|
290
|
+
rule %r/[^']+/, Str::Single
|
291
|
+
rule %r/''/, Str::Escape
|
292
|
+
rule %r/'/, Str::Single, :pop!
|
293
293
|
end
|
294
294
|
|
295
295
|
state :string_double do
|
296
|
-
rule /[^"]+/, Str::Double
|
297
|
-
rule /"/, Str::Double, :pop!
|
296
|
+
rule %r/[^"]+/, Str::Double
|
297
|
+
rule %r/"/, Str::Double, :pop!
|
298
298
|
end
|
299
299
|
|
300
300
|
state :format_spec do
|
301
|
-
rule /'/, Str::Single, :string_single
|
302
|
-
rule /"/, Str::Double, :string_double
|
303
|
-
rule /\(/, Punctuation, :format_spec
|
304
|
-
rule /\)/, Punctuation, :pop!
|
305
|
-
rule /,/, Punctuation
|
306
|
-
rule
|
301
|
+
rule %r/'/, Str::Single, :string_single
|
302
|
+
rule %r/"/, Str::Double, :string_double
|
303
|
+
rule %r/\(/, Punctuation, :format_spec
|
304
|
+
rule %r/\)/, Punctuation, :pop!
|
305
|
+
rule %r/,/, Punctuation
|
306
|
+
rule %r/\s+/, Text::Whitespace
|
307
307
|
# Edit descriptors could be seen as a kind of "format literal".
|
308
|
-
rule /[^\s'"(),]+/, Literal
|
308
|
+
rule %r/[^\s'"(),]+/, Literal
|
309
309
|
end
|
310
310
|
end
|
311
311
|
end
|
data/lib/rouge/lexers/igorpro.rb
CHANGED
@@ -521,7 +521,7 @@ module Rouge
|
|
521
521
|
state :root do
|
522
522
|
rule %r(//), Comment, :comments
|
523
523
|
|
524
|
-
rule /#{object}/ do |m|
|
524
|
+
rule %r/#{object}/ do |m|
|
525
525
|
if m[0].downcase =~ /function/
|
526
526
|
token Keyword::Declaration
|
527
527
|
push :parse_function
|
@@ -567,22 +567,22 @@ module Rouge
|
|
567
567
|
|
568
568
|
state :assignment do
|
569
569
|
mixin :whitespace
|
570
|
-
rule /\"/, Literal::String::Double, :string1 #punctuation for string
|
570
|
+
rule %r/\"/, Literal::String::Double, :string1 #punctuation for string
|
571
571
|
mixin :string2
|
572
|
-
rule /#{number_float}/, Literal::Number::Float, :pop!
|
573
|
-
rule /#{number_int}/, Literal::Number::Integer, :pop!
|
574
|
-
rule /[\(\[\{][^\)\]\}]+[\)\]\}]/, Generic, :pop!
|
575
|
-
rule /[^\s\/\(]+/, Generic, :pop!
|
572
|
+
rule %r/#{number_float}/, Literal::Number::Float, :pop!
|
573
|
+
rule %r/#{number_int}/, Literal::Number::Integer, :pop!
|
574
|
+
rule %r/[\(\[\{][^\)\]\}]+[\)\]\}]/, Generic, :pop!
|
575
|
+
rule %r/[^\s\/\(]+/, Generic, :pop!
|
576
576
|
rule(//) { pop! }
|
577
577
|
end
|
578
578
|
|
579
579
|
state :parse_variables do
|
580
580
|
mixin :whitespace
|
581
|
-
rule /[=]/, Punctuation, :assignment
|
581
|
+
rule %r/[=]/, Punctuation, :assignment
|
582
582
|
rule object, Name::Variable
|
583
|
-
rule /[\[\]]/, Punctuation # optional variables in functions
|
584
|
-
rule /[,]/, Punctuation, :parse_variables
|
585
|
-
rule /\)/, Punctuation, :pop! # end of function
|
583
|
+
rule %r/[\[\]]/, Punctuation # optional variables in functions
|
584
|
+
rule %r/[,]/, Punctuation, :parse_variables
|
585
|
+
rule %r/\)/, Punctuation, :pop! # end of function
|
586
586
|
rule %r([/][a-z]+)i, Keyword::Pseudo, :parse_variables
|
587
587
|
rule(//) { pop! }
|
588
588
|
end
|
@@ -591,15 +591,15 @@ module Rouge
|
|
591
591
|
rule %r([/][a-z]+)i, Keyword::Pseudo # only one flag
|
592
592
|
mixin :whitespace
|
593
593
|
rule object, Name::Function
|
594
|
-
rule /[\(]/, Punctuation, :parse_variables
|
594
|
+
rule %r/[\(]/, Punctuation, :parse_variables
|
595
595
|
rule(//) { pop! }
|
596
596
|
end
|
597
597
|
|
598
598
|
state :operationFlags do
|
599
|
-
rule /#{noLineBreak}/, Text
|
600
|
-
rule /[=]/, Punctuation, :assignment
|
599
|
+
rule %r/#{noLineBreak}/, Text
|
600
|
+
rule %r/[=]/, Punctuation, :assignment
|
601
601
|
rule %r([/][a-z]+)i, Keyword::Pseudo, :operationFlags
|
602
|
-
rule /(as)(\s*)(#{object})/i do
|
602
|
+
rule %r/(as)(\s*)(#{object})/i do
|
603
603
|
groups Keyword::Type, Text, Name::Label
|
604
604
|
end
|
605
605
|
rule(//) { pop! }
|
@@ -621,34 +621,34 @@ module Rouge
|
|
621
621
|
end
|
622
622
|
|
623
623
|
state :characters do
|
624
|
-
rule /\s/, Text
|
625
|
-
rule /#{operator}/, Operator
|
626
|
-
rule /#{punctuation}/, Punctuation
|
627
|
-
rule /\"/, Literal::String::Double, :string1 #punctuation for string
|
624
|
+
rule %r/\s/, Text
|
625
|
+
rule %r/#{operator}/, Operator
|
626
|
+
rule %r/#{punctuation}/, Punctuation
|
627
|
+
rule %r/\"/, Literal::String::Double, :string1 #punctuation for string
|
628
628
|
mixin :string2
|
629
629
|
end
|
630
630
|
|
631
631
|
state :numbers do
|
632
|
-
rule /#{number_float}/, Literal::Number::Float
|
633
|
-
rule /#{number_hex}/, Literal::Number::Hex
|
634
|
-
rule /#{number_int}/, Literal::Number::Integer
|
632
|
+
rule %r/#{number_float}/, Literal::Number::Float
|
633
|
+
rule %r/#{number_hex}/, Literal::Number::Hex
|
634
|
+
rule %r/#{number_int}/, Literal::Number::Integer
|
635
635
|
end
|
636
636
|
|
637
637
|
state :whitespace do
|
638
|
-
rule /#{noLineBreak}/, Text
|
638
|
+
rule %r/#{noLineBreak}/, Text
|
639
639
|
end
|
640
640
|
|
641
641
|
state :string1 do
|
642
|
-
rule /%\w\b/, Literal::String::Other
|
643
|
-
rule /\\\\/, Literal::String::Escape
|
644
|
-
rule /\\\"/, Literal::String::Escape
|
645
|
-
rule /\\/, Literal::String::Escape
|
646
|
-
rule /[^"]/, Literal::String
|
647
|
-
rule /\"/, Literal::String::Double, :pop! #punctuation for string
|
642
|
+
rule %r/%\w\b/, Literal::String::Other
|
643
|
+
rule %r/\\\\/, Literal::String::Escape
|
644
|
+
rule %r/\\\"/, Literal::String::Escape
|
645
|
+
rule %r/\\/, Literal::String::Escape
|
646
|
+
rule %r/[^"]/, Literal::String
|
647
|
+
rule %r/\"/, Literal::String::Double, :pop! #punctuation for string
|
648
648
|
end
|
649
649
|
|
650
650
|
state :string2 do
|
651
|
-
rule /\'[^']*\'/, Literal::String::Single
|
651
|
+
rule %r/\'[^']*\'/, Literal::String::Single
|
652
652
|
end
|
653
653
|
|
654
654
|
state :comments do
|
@@ -656,7 +656,7 @@ module Rouge
|
|
656
656
|
# doxygen comments
|
657
657
|
groups Comment, Comment::Special
|
658
658
|
end
|
659
|
-
rule /[^\r\n]/, Comment
|
659
|
+
rule %r/[^\r\n]/, Comment
|
660
660
|
rule(//) { pop! }
|
661
661
|
end
|
662
662
|
end
|