rouge 1.10.1 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rouge/cli.rb +1 -1
  3. data/lib/rouge/demos/actionscript +4 -0
  4. data/lib/rouge/demos/apiblueprint +33 -0
  5. data/lib/rouge/demos/biml +38 -0
  6. data/lib/rouge/demos/ceylon +7 -0
  7. data/lib/rouge/demos/cmake +7 -0
  8. data/lib/rouge/demos/coq +11 -0
  9. data/lib/rouge/demos/d +16 -0
  10. data/lib/rouge/demos/eiffel +30 -0
  11. data/lib/rouge/demos/fortran +22 -0
  12. data/lib/rouge/demos/gradle +10 -0
  13. data/lib/rouge/demos/jinja +9 -0
  14. data/lib/rouge/demos/jsonnet +28 -0
  15. data/lib/rouge/demos/julia +11 -0
  16. data/lib/rouge/demos/nasm +26 -0
  17. data/lib/rouge/demos/objective_c +4 -0
  18. data/lib/rouge/demos/protobuf +5 -0
  19. data/lib/rouge/demos/shell_session +10 -0
  20. data/lib/rouge/demos/smarty +12 -0
  21. data/lib/rouge/demos/tap +5 -0
  22. data/lib/rouge/demos/twig +9 -0
  23. data/lib/rouge/demos/typescript +1 -0
  24. data/lib/rouge/demos/verilog +27 -0
  25. data/lib/rouge/demos/viml +14 -5
  26. data/lib/rouge/formatters/html_wrapper.rb +11 -0
  27. data/lib/rouge/formatters/terminal256.rb +1 -1
  28. data/lib/rouge/lexer.rb +4 -2
  29. data/lib/rouge/lexers/actionscript.rb +195 -0
  30. data/lib/rouge/lexers/apache.rb +23 -20
  31. data/lib/rouge/lexers/apache/keywords.yml +721 -410
  32. data/lib/rouge/lexers/apiblueprint.rb +51 -0
  33. data/lib/rouge/lexers/biml.rb +41 -0
  34. data/lib/rouge/lexers/c.rb +7 -2
  35. data/lib/rouge/lexers/ceylon.rb +123 -0
  36. data/lib/rouge/lexers/clojure.rb +1 -1
  37. data/lib/rouge/lexers/cmake.rb +206 -0
  38. data/lib/rouge/lexers/coffeescript.rb +1 -1
  39. data/lib/rouge/lexers/coq.rb +187 -0
  40. data/lib/rouge/lexers/cpp.rb +12 -1
  41. data/lib/rouge/lexers/csharp.rb +12 -5
  42. data/lib/rouge/lexers/css.rb +2 -0
  43. data/lib/rouge/lexers/d.rb +176 -0
  44. data/lib/rouge/lexers/diff.rb +9 -9
  45. data/lib/rouge/lexers/eiffel.rb +65 -0
  46. data/lib/rouge/lexers/fortran.rb +142 -0
  47. data/lib/rouge/lexers/gradle.rb +37 -0
  48. data/lib/rouge/lexers/groovy.rb +2 -2
  49. data/lib/rouge/lexers/ini.rb +2 -2
  50. data/lib/rouge/lexers/java.rb +11 -8
  51. data/lib/rouge/lexers/javascript.rb +2 -1
  52. data/lib/rouge/lexers/jinja.rb +137 -0
  53. data/lib/rouge/lexers/jsonnet.rb +151 -0
  54. data/lib/rouge/lexers/julia.rb +172 -0
  55. data/lib/rouge/lexers/markdown.rb +1 -0
  56. data/lib/rouge/lexers/nasm.rb +203 -0
  57. data/lib/rouge/lexers/objective_c.rb +11 -0
  58. data/lib/rouge/lexers/php.rb +1 -1
  59. data/lib/rouge/lexers/powershell.rb +1 -1
  60. data/lib/rouge/lexers/protobuf.rb +70 -0
  61. data/lib/rouge/lexers/python.rb +23 -0
  62. data/lib/rouge/lexers/r.rb +53 -20
  63. data/lib/rouge/lexers/ruby.rb +4 -4
  64. data/lib/rouge/lexers/rust.rb +2 -2
  65. data/lib/rouge/lexers/shell_session.rb +29 -0
  66. data/lib/rouge/lexers/smarty.rb +91 -0
  67. data/lib/rouge/lexers/sql.rb +1 -1
  68. data/lib/rouge/lexers/swift.rb +20 -5
  69. data/lib/rouge/lexers/tap.rb +91 -0
  70. data/lib/rouge/lexers/twig.rb +37 -0
  71. data/lib/rouge/lexers/typescript.rb +46 -0
  72. data/lib/rouge/lexers/verilog.rb +164 -0
  73. data/lib/rouge/regex_lexer.rb +1 -1
  74. data/lib/rouge/version.rb +1 -1
  75. data/rouge.gemspec +1 -1
  76. metadata +47 -6
  77. data/lib/rouge/formatters/html_inline.rb +0 -20
  78. data/lib/rouge/formatters/html_linewise.rb +0 -31
@@ -16,15 +16,15 @@ module Rouge
16
16
  end
17
17
 
18
18
  state :root do
19
- rule(/^ .*\n/, Text)
20
- rule(/^---\n/, Text)
21
- rule(/^\+.*\n/, Generic::Inserted)
22
- rule(/^-+.*\n/, Generic::Deleted)
23
- rule(/^!.*\n/, Generic::Strong)
24
- rule(/^@.*\n/, Generic::Subheading)
25
- rule(/^([Ii]ndex|diff).*\n/, Generic::Heading)
26
- rule(/^=.*\n/, Generic::Heading)
27
- rule(/.*\n/, Text)
19
+ rule(/^ .*$\n?/, Text)
20
+ rule(/^---$\n?/, Text)
21
+ rule(/^\+.*$\n?/, Generic::Inserted)
22
+ rule(/^-+.*$\n?/, Generic::Deleted)
23
+ rule(/^!.*$\n?/, Generic::Strong)
24
+ rule(/^@.*$\n?/, Generic::Subheading)
25
+ rule(/^([Ii]ndex|diff).*$\n?/, Generic::Heading)
26
+ rule(/^=.*$\n?/, Generic::Heading)
27
+ rule(/.*$\n?/, Text)
28
28
  end
29
29
  end
30
30
  end
@@ -0,0 +1,65 @@
1
+ # -*- coding: utf-8 -*- #
2
+
3
+ module Rouge
4
+ module Lexers
5
+ class Eiffel < RegexLexer
6
+ title "Eiffel"
7
+ desc "Eiffel programming language"
8
+
9
+ tag 'eiffel'
10
+ filenames '*.e'
11
+ mimetypes 'text/x-eiffel'
12
+
13
+ LanguageKeywords = %w(
14
+ across agent alias all and attached as assign attribute check
15
+ class convert create debug deferred detachable do else elseif end
16
+ ensure expanded export external feature from frozen if implies inherit
17
+ inspect invariant like local loop not note obsolete old once or
18
+ Precursor redefine rename require rescue retry select separate
19
+ some then undefine until variant Void when xor
20
+ )
21
+
22
+ BooleanConstants = %w(True False)
23
+
24
+ LanguageVariables = %w(Current Result)
25
+
26
+ SimpleString = /(?:[^"%\b\f\v]|%[A-DFHLNQR-V%'"()<>]|%\/(?:0[xX][\da-fA-F](?:_*[\da-fA-F])*|0[cC][0-7](?:_*[0-7])*|0[bB][01](?:_*[01])*|\d(?:_*\d)*)\/)+?/
27
+
28
+ state :root do
29
+ rule /"\[/, Str::Other, :aligned_verbatim_string
30
+ rule /"\{/, Str::Other, :non_aligned_verbatim_string
31
+ rule /"(?:[^%\b\f\n\r\v]|%[A-DFHLNQR-V%'"()<>]|%\/(?:0[xX][\da-fA-F](?:_*[\da-fA-F])*|0[cC][0-7](?:_*[0-7])*|0[bB][01](?:_*[01])*|\d(?:_*\d)*)\/)*?"/, Str::Double
32
+ rule /--.*/, Comment::Single
33
+ rule /'(?:[^%\b\f\n\r\t\v]|%[A-DFHLNQR-V%'"()<>]|%\/(?:0[xX][\da-fA-F](?:_*[\da-fA-F])*|0[cC][0-7](?:_*[0-7])*|0[bB][01](?:_*[01])*|\d(?:_*\d)*)\/)'/, Str::Char
34
+
35
+ rule /(?:#{LanguageKeywords.join('|')})\b/, Keyword
36
+ rule /(?:#{LanguageVariables.join('|')})\b/, Keyword::Variable
37
+ rule /(?:#{BooleanConstants.join('|')})\b/, Keyword::Constant
38
+
39
+ rule /\b0[xX][\da-fA-F](?:_*[\da-fA-F])*b/, Num::Hex
40
+ rule /\b0[cC][0-7](?:_*[0-7])*\b/, Num::Oct
41
+ rule /\b0[bB][01](?:_*[01])*\b/, Num::Bin
42
+ rule /\d(?:_*\d)*/, Num::Integer
43
+ rule /(?:\d(?:_*\d)*)?\.(?:(?:\d(?:_*\d)*)?[eE][+-]?)?\d(?:_*\d)*|\d(?:_*\d)*\.?/, Num::Float
44
+
45
+ rule /:=|<<|>>|\(\||\|\)|->|\.|[{}\[\];(),:?]/, Punctuation::Indicator
46
+ rule /\\\\|\|\.\.\||\.\.|\/[~\/]?|[><\/]=?|[-+*^=~]/, Operator
47
+
48
+ rule /[A-Z][\dA-Z_]*/, Name::Class
49
+ rule /[A-Za-z][\dA-Za-z_]*/, Name
50
+ rule /\s+/, Text
51
+ end
52
+
53
+ state :aligned_verbatim_string do
54
+ rule /]"/, Str::Other, :pop!
55
+ rule SimpleString, Str::Other
56
+ end
57
+
58
+ state :non_aligned_verbatim_string do
59
+ rule /}"/, Str::Other, :pop!
60
+ rule SimpleString, Str::Other
61
+ end
62
+ end
63
+ end
64
+ end
65
+
@@ -0,0 +1,142 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # vim: set ts=2 sw=2 et:
3
+
4
+ # TODO: Implement format list support.
5
+
6
+ module Rouge
7
+ module Lexers
8
+ class Fortran < RegexLexer
9
+ title "Fortran"
10
+ desc "Fortran 95 Programming Language"
11
+
12
+ tag 'fortran'
13
+ filenames '*.f90', '*.f95',
14
+ '*.F90', '*.F95'
15
+ mimetypes 'text/x-fortran'
16
+
17
+ name = /[A-Z][_A-Z0-9]*/i
18
+ kind_param = /(\d+|#{name})/
19
+ exponent = /[ED][+-]\d+/
20
+
21
+ def self.keywords
22
+ # Fortran allows to omit whitespace between certain keywords...
23
+ @keywords ||= Set.new %w(
24
+ allocatable allocate assignment backspace block blockdata call case
25
+ close common contains continue cycle data deallocate default
26
+ dimension do elemental else elseif elsewhere end endblockdata enddo
27
+ endfile endforall endfunction endif endinterface endmodule endprogram
28
+ endselect endsubroutine endtype endwhere entry equivalence exit
29
+ external forall format function go goto if implicit in include inout
30
+ inquire intent interface intrinsic module namelist none nullify only
31
+ open operator optional out parameter pointer print private procedure
32
+ program public pure read recursive result return rewind save select
33
+ selectcase sequence stop subroutine target then to type use where
34
+ while write
35
+ )
36
+ end
37
+
38
+ def self.types
39
+ @types ||= Set.new %w(
40
+ character complex double precision doubleprecision integer logical real
41
+ )
42
+ end
43
+
44
+ def self.intrinsics
45
+ @intrinsics ||= Set.new %w(
46
+ abs achar acos adjustl adjustr aimag aint all allocated anint any
47
+ asin associated atan atan2 bit_size btest ceiling char cmplx conjg
48
+ cos cosh count cpu_time cshift date_and_time dble digits dim
49
+ dot_product dprod eoshift epsilon exp exponent floor fraction huge
50
+ iachar iand ibclr ibits ibset ichar ieor index int ior ishift ishiftc
51
+ kind lbound len len_trim lge lgt lle llt log log10 logical matmul max
52
+ maxexponent maxloc maxval merge min minexponent minloc minval mod
53
+ modulo mvbits nearest nint not null pack precision present product
54
+ radix random_number random_seed range real repeat reshape rrspacing
55
+ scale scan selected_int_kind selected_real_kind set_exponent shape
56
+ sign sin sinh size spacing spread sqrt sum system_clock tan tanh tiny
57
+ transfer transpose trim ubound unpack verify
58
+ )
59
+ end
60
+
61
+ state :root do
62
+ rule /[\s\n]+/, Text::Whitespace
63
+ rule /!.*$/, Comment::Single
64
+ rule /^#.*$/, Comment::Preproc
65
+
66
+ rule /::|[()\/;,:&]/, Punctuation
67
+
68
+ # TODO: This does not take into account line continuation.
69
+ rule /^(\s*)([0-9]+)\b/m do |m|
70
+ token Text::Whitespace, m[1]
71
+ token Name::Label, m[2]
72
+ end
73
+
74
+ # Format statements are quite a strange beast.
75
+ # Better process them in their own state.
76
+ rule /\b(FORMAT)(\s*)(\()/mi do |m|
77
+ token Keyword, m[1]
78
+ token Text::Whitespace, m[2]
79
+ token Punctuation, m[3]
80
+ push :format_spec
81
+ end
82
+
83
+ rule %r(
84
+ [+-]? # sign
85
+ (
86
+ (\d+[.]\d*|[.]\d+)(#{exponent})?
87
+ | \d+#{exponent} # exponent is mandatory
88
+ )
89
+ (_#{kind_param})? # kind parameter
90
+ )xi, Num::Float
91
+
92
+ rule /[+-]?\d+(_#{kind_param})?/i, Num::Integer
93
+ rule /B'[01]+'|B"[01]+"/i, Num::Bin
94
+ rule /O'[0-7]+'|O"[0-7]+"/i, Num::Oct
95
+ rule /Z'[0-9A-F]+'|Z"[0-9A-F]+"/i, Num::Hex
96
+ rule /(#{kind_param}_)?'/, Str::Single, :string_single
97
+ rule /(#{kind_param}_)?"/, Str::Double, :string_double
98
+ rule /[.](TRUE|FALSE)[.](_#{kind_param})?/i, Keyword::Constant
99
+
100
+ rule %r{\*\*|//|==|/=|<=|>=|=>|[-+*/<>=%]}, Operator
101
+ rule /\.(?:EQ|NE|LT|LE|GT|GE|NOT|AND|OR|EQV|NEQV|[A-Z]+)\./i, Operator::Word
102
+
103
+ rule /#{name}/m do |m|
104
+ match = m[0].downcase
105
+ if self.class.keywords.include? match
106
+ token Keyword
107
+ elsif self.class.types.include? match
108
+ token Keyword::Type
109
+ elsif self.class.intrinsics.include? match
110
+ token Name::Builtin
111
+ else
112
+ token Name
113
+ end
114
+ end
115
+
116
+ end
117
+
118
+ state :string_single do
119
+ rule /[^']+/, Str::Single
120
+ rule /''/, Str::Escape
121
+ rule /'/, Str::Single, :pop!
122
+ end
123
+
124
+ state :string_double do
125
+ rule /[^"]+/, Str::Double
126
+ rule /""/, Str::Escape
127
+ rule /"/, Str::Double, :pop!
128
+ end
129
+
130
+ state :format_spec do
131
+ rule /'/, Str::Single, :string_single
132
+ rule /"/, Str::Double, :string_double
133
+ rule /\(/, Punctuation, :format_spec
134
+ rule /\)/, Punctuation, :pop!
135
+ rule /,/, Punctuation
136
+ rule /[\s\n]+/, Text::Whitespace
137
+ # Edit descriptors could be seen as a kind of "format literal".
138
+ rule /[^\s'"(),]+/, Literal
139
+ end
140
+ end
141
+ end
142
+ end
@@ -0,0 +1,37 @@
1
+ # -*- coding: utf-8 -*- #
2
+
3
+ module Rouge
4
+ module Lexers
5
+ load_lexer 'groovy.rb'
6
+
7
+ class Gradle < Groovy
8
+ title "Gradle"
9
+ desc "A powerful build system for the JVM"
10
+
11
+ tag 'gradle'
12
+ filenames '*.gradle'
13
+ mimetypes 'text/x-gradle'
14
+
15
+ def self.keywords
16
+ @keywords ||= super + Set.new(%w(
17
+ allprojects artifacts buildscript configuration dependencies
18
+ repositories sourceSets subprojects publishing
19
+ ))
20
+ end
21
+
22
+ def self.types
23
+ @types ||= super + Set.new(%w(
24
+ Project Task Gradle Settings Script JavaToolChain SourceSet
25
+ SourceSetOutput IncrementalTaskInputs Configuration
26
+ ResolutionStrategy ArtifactResolutionQuery ComponentSelection
27
+ ComponentSelectionRules ConventionProperty ExtensionAware
28
+ ExtraPropertiesExtension PublishingExtension IvyPublication
29
+ IvyArtifact IvyArtifactSet IvyModuleDescriptorSpec
30
+ MavenPublication MavenArtifact MavenArtifactSet MavenPom
31
+ PluginDependenciesSpec PluginDependencySpec ResourceHandler
32
+ TextResourceFactory
33
+ ))
34
+ end
35
+ end
36
+ end
37
+ end
@@ -4,7 +4,7 @@ module Rouge
4
4
  module Lexers
5
5
  class Groovy < RegexLexer
6
6
  title "Groovy"
7
- desc 'The Groovy programming language (groovy.codehaus.org)'
7
+ desc 'The Groovy programming language (http://www.groovy-lang.org/)'
8
8
  tag 'groovy'
9
9
  filenames '*.groovy'
10
10
  mimetypes 'text/x-groovy'
@@ -53,7 +53,7 @@ module Rouge
53
53
  rule %r(//.*?$), Comment::Single
54
54
  rule %r(/[*].*?[*]/)m, Comment::Multiline
55
55
  rule /@\w[\w\d.]*/, Name::Decorator
56
- rule /(class|interface)\b/, Keyword::Declaration, :class
56
+ rule /(class|interface|trait)\b/, Keyword::Declaration, :class
57
57
  rule /package\b/, Keyword::Namespace, :import
58
58
  rule /import\b/, Keyword::Namespace, :import
59
59
 
@@ -12,10 +12,10 @@ module Rouge
12
12
  mimetypes 'text/x-ini'
13
13
 
14
14
  def self.analyze_text(text)
15
- return 0.1 if text =~ /\A\[[\w.]+\]\s*\w+=\w+/
15
+ return 0.1 if text =~ /\A\[[\w\-.]+\]\s*[\w\-]+=\w+/
16
16
  end
17
17
 
18
- identifier = /[\w.]+/
18
+ identifier = /[\w\-.]+/
19
19
 
20
20
  state :basic do
21
21
  rule /[;#].*?\n/, Comment
@@ -25,8 +25,15 @@ module Rouge
25
25
  id = /[a-zA-Z_][a-zA-Z0-9_]*/
26
26
 
27
27
  state :root do
28
- rule %r(^
29
- (\s*(?:[a-zA-Z_][a-zA-Z0-9_.\[\]]*\s+)+?) # return arguments
28
+ rule /[^\S\n]+/, Text
29
+ rule %r(//.*?$), Comment::Single
30
+ rule %r(/\*.*?\*/)m, Comment::Multiline
31
+ # keywords: go before method names to avoid lexing "throw new XYZ"
32
+ # as a method signature
33
+ rule /(?:#{keywords.join('|')})\b/, Keyword
34
+
35
+ rule %r(
36
+ (\s*(?:[a-zA-Z_][a-zA-Z0-9_.\[\]<>]*\s+)+?) # return arguments
30
37
  ([a-zA-Z_][a-zA-Z0-9_]*) # method name
31
38
  (\s*)(\() # signature start
32
39
  )mx do |m|
@@ -34,14 +41,10 @@ module Rouge
34
41
  delegate Java, m[1]
35
42
  token Name::Function, m[2]
36
43
  token Text, m[3]
37
- token Punctuation, m[4]
44
+ token Operator, m[4]
38
45
  end
39
46
 
40
- rule /\s+/, Text
41
- rule %r(//.*?$), Comment::Single
42
- rule %r(/\*.*?\*/)m, Comment::Multiline
43
47
  rule /@#{id}/, Name::Decorator
44
- rule /(?:#{keywords.join('|')})\b/, Keyword
45
48
  rule /(?:#{declarations.join('|')})\b/, Keyword::Declaration
46
49
  rule /(?:#{types.join('|')})\b/, Keyword::Type
47
50
  rule /package\b/, Keyword::Namespace
@@ -59,7 +62,7 @@ module Rouge
59
62
  rule /[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?/, Num::Float
60
63
  rule /0x[0-9a-f]+/, Num::Hex
61
64
  rule /[0-9]+L?/, Num::Integer
62
- # rule /\n/, Text
65
+ rule /\n/, Text
63
66
  end
64
67
 
65
68
  state :class do
@@ -206,7 +206,8 @@ module Rouge
206
206
  desc "JavaScript Object Notation (json.org)"
207
207
  tag 'json'
208
208
  filenames '*.json'
209
- mimetypes 'application/json', 'application/vnd.api+json'
209
+ mimetypes 'application/json', 'application/vnd.api+json',
210
+ 'application/hal+json'
210
211
 
211
212
  # TODO: is this too much of a performance hit? JSON is quite simple,
212
213
  # so I'd think this wouldn't be too bad, but for large documents this
@@ -0,0 +1,137 @@
1
+ # -*- coding: utf-8 -*- #
2
+
3
+ module Rouge
4
+ module Lexers
5
+ class Jinja < TemplateLexer
6
+ title "Jinja"
7
+ desc "Django/Jinja template engine (jinja.pocoo.org)"
8
+
9
+ tag 'jinja'
10
+ aliases 'django'
11
+
12
+ mimetypes 'application/x-django-templating', 'application/x-jinja',
13
+ 'text/html+django', 'text/html+jinja'
14
+
15
+ def self.keywords
16
+ @@keywords ||= %w(as context do else extends from ignore missing
17
+ import include reversed recursive scoped
18
+ autoescape endautoescape block endblock call endcall
19
+ filter endfilter for endfor if endif macro endmacro
20
+ set endset trans endtrans with endwith without)
21
+ end
22
+
23
+ def self.tests
24
+ @@tests ||= %w(callable defined divisibleby equalto escaped even iterable
25
+ lower mapping none number odd sameas sequence string
26
+ undefined upper)
27
+ end
28
+
29
+ def self.pseudo_keywords
30
+ @@pseudo_keywords ||= %w(true false none True False None)
31
+ end
32
+
33
+ def self.word_operators
34
+ @@word_operators ||= %w(is in and or not)
35
+ end
36
+
37
+ state :root do
38
+ # Comments
39
+ rule /{#/, Comment, :comment
40
+
41
+ # Statements
42
+ rule /\{\%/ do
43
+ token Comment::Preproc
44
+ push :statement
45
+ end
46
+
47
+ # Expressions
48
+ rule /\{\{/ do
49
+ token Comment::Preproc
50
+ push :expression
51
+ end
52
+
53
+ rule(/(.+?)(?=\\|{{|{%|{#)/m) { delegate parent }
54
+ rule(/.+/m) { delegate parent }
55
+ end
56
+
57
+ state :filter do
58
+ # Filters are called like variable|foo(arg1, ...)
59
+ rule /(\|)(\w+)/ do
60
+ groups Operator, Name::Function
61
+ end
62
+ end
63
+
64
+ state :function do
65
+ rule /(\w+)(\()/ do
66
+ groups Name::Function, Punctuation
67
+ end
68
+ end
69
+
70
+ state :text do
71
+ rule /\s+/m, Text
72
+ end
73
+
74
+ state :literal do
75
+ # Strings
76
+ rule /"(\\.|.)*?"/, Str::Double
77
+ rule /'(\\.|.)*?'/, Str::Single
78
+
79
+ # Numbers
80
+ rule /\d+(?=}\s)/, Num
81
+
82
+ # Arithmetic operators (+, -, *, **, //, /)
83
+ # TODO : implement modulo (%)
84
+ rule /(\+|\-|\*|\/\/?|\*\*?)/, Operator
85
+
86
+ # Comparisons operators (<=, <, >=, >, ==, ===, !=)
87
+ rule /(<=?|>=?|===?|!=)/, Operator
88
+
89
+ # Punctuation (the comma, [], ())
90
+ rule /,/, Punctuation
91
+ rule /\[/, Punctuation
92
+ rule /\]/, Punctuation
93
+ rule /\(/, Punctuation
94
+ rule /\)/, Punctuation
95
+ end
96
+
97
+ state :comment do
98
+ rule(/[^{#]+/m) { token Comment }
99
+ rule(/#}/) { token Comment; pop! }
100
+ end
101
+
102
+ state :expression do
103
+ rule /\w+\.?/m, Name::Variable
104
+
105
+ mixin :filter
106
+ mixin :function
107
+ mixin :literal
108
+ mixin :text
109
+
110
+ rule /%}|}}/, Comment::Preproc, :pop!
111
+ end
112
+
113
+ state :statement do
114
+ rule /(\w+\.?)/ do |m|
115
+ if self.class.keywords.include?(m[0])
116
+ groups Keyword
117
+ elsif self.class.pseudo_keywords.include?(m[0])
118
+ groups Keyword::Pseudo
119
+ elsif self.class.word_operators.include?(m[0])
120
+ groups Operator::Word
121
+ elsif self.class.tests.include?(m[0])
122
+ groups Name::Builtin
123
+ else
124
+ groups Name::Variable
125
+ end
126
+ end
127
+
128
+ mixin :filter
129
+ mixin :function
130
+ mixin :literal
131
+ mixin :text
132
+
133
+ rule /\%\}/, Comment::Preproc, :pop!
134
+ end
135
+ end
136
+ end
137
+ end