rouge 3.10.0 → 3.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rouge/demos/apex +9 -0
  3. data/lib/rouge/demos/csvs +8 -0
  4. data/lib/rouge/demos/liquid +0 -1
  5. data/lib/rouge/demos/minizinc +23 -0
  6. data/lib/rouge/demos/nesasm +11 -0
  7. data/lib/rouge/demos/q +6 -0
  8. data/lib/rouge/demos/robot_framework +27 -0
  9. data/lib/rouge/demos/slice +10 -0
  10. data/lib/rouge/demos/ttcn3 +6 -0
  11. data/lib/rouge/guessers/disambiguation.rb +5 -0
  12. data/lib/rouge/lexer.rb +3 -0
  13. data/lib/rouge/lexers/apex.rb +126 -0
  14. data/lib/rouge/lexers/bpf.rb +20 -6
  15. data/lib/rouge/lexers/coq.rb +12 -9
  16. data/lib/rouge/lexers/csvs.rb +44 -0
  17. data/lib/rouge/lexers/d.rb +1 -1
  18. data/lib/rouge/lexers/dot.rb +2 -2
  19. data/lib/rouge/lexers/eex.rb +2 -1
  20. data/lib/rouge/lexers/io.rb +2 -2
  21. data/lib/rouge/lexers/json.rb +1 -1
  22. data/lib/rouge/lexers/json_doc.rb +4 -3
  23. data/lib/rouge/lexers/kotlin.rb +21 -28
  24. data/lib/rouge/lexers/liquid.rb +82 -108
  25. data/lib/rouge/lexers/m68k.rb +2 -2
  26. data/lib/rouge/lexers/magik.rb +1 -1
  27. data/lib/rouge/lexers/markdown.rb +7 -1
  28. data/lib/rouge/lexers/mason.rb +0 -5
  29. data/lib/rouge/lexers/minizinc.rb +87 -0
  30. data/lib/rouge/lexers/nesasm.rb +78 -0
  31. data/lib/rouge/lexers/nginx.rb +1 -1
  32. data/lib/rouge/lexers/perl.rb +1 -1
  33. data/lib/rouge/lexers/pony.rb +1 -1
  34. data/lib/rouge/lexers/protobuf.rb +1 -1
  35. data/lib/rouge/lexers/q.rb +2 -1
  36. data/lib/rouge/lexers/robot_framework.rb +249 -0
  37. data/lib/rouge/lexers/scala.rb +3 -3
  38. data/lib/rouge/lexers/shell.rb +5 -3
  39. data/lib/rouge/lexers/sieve.rb +1 -1
  40. data/lib/rouge/lexers/slice.rb +32 -0
  41. data/lib/rouge/lexers/sqf.rb +1 -1
  42. data/lib/rouge/lexers/swift.rb +1 -1
  43. data/lib/rouge/lexers/toml.rb +16 -1
  44. data/lib/rouge/lexers/ttcn3.rb +119 -0
  45. data/lib/rouge/lexers/verilog.rb +1 -1
  46. data/lib/rouge/plugins/redcarpet.rb +7 -1
  47. data/lib/rouge/version.rb +1 -1
  48. metadata +16 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3fb254c48c7225eb55006a7e1fb0cd713afa34faf35d4f4c92bec44c663a7a49
4
- data.tar.gz: 0d5193efc0336f18a8012f09135deb4eb988051367b78928c5b7bc61f3f0b49c
3
+ metadata.gz: d43552856d88e799ffb7f4255d865641bfaafd5dac3945b2646540ff816628c4
4
+ data.tar.gz: 5768d921766cf2eb677fc63e783b707ee0f52a7320b73f4bbbc333ee14e79f77
5
5
  SHA512:
6
- metadata.gz: 41128ed9650fe8aa804d9c93c44ebaf8f93131ee156ed1b57acfd1b790f435cf9f7f2233fd7ca3701b206b7131d979a2517abbf87da6c01ca931ec8d7ac4c04b
7
- data.tar.gz: 255518b66c766562b22005ade1eebc7bf092e3b29b1f5fe298b0497801a86de2e350e726b57ac52380d58e9aa28bfb84cff2f917759053548704bd2bb4bf4b8c
6
+ metadata.gz: fdfd25582e56396cb78b370372b4587b243c1608fa7d4ee32a9659f13fc8939bba2305b5add8d83569543766eefed1abbb8ff5f0d76593964db2b3624b1d112b
7
+ data.tar.gz: 5d2f0526caf091491969d89180fab9a30441ddc5390bbb10c8acb2ea8b9af96b044e91ed32e6db58fa9783a12c530eb3a25d829f031c0ecb7a7e02858592da57
@@ -0,0 +1,9 @@
1
+ public class with sharing Trigger {
2
+ @Deprecated
3
+ public void resolveSum(int x, int y) {
4
+ System.debug('x is ' + x);
5
+ System.debug('y is ' + y);
6
+
7
+ System.debug('x + y = ' + (x+y));
8
+ }
9
+ }
@@ -0,0 +1,8 @@
1
+ version 1.1
2
+ @totalColumns 5
3
+ @separator ','
4
+ Transaction_Date: xDate
5
+ Transaction_ID: notEmpty
6
+ Originator_Name: notEmpty
7
+ Originator_Address: any("yes","no")
8
+ Originator_Country: notEmpty
@@ -5,7 +5,6 @@
5
5
  Only {{ product.price | format_as_money }}
6
6
 
7
7
  <p>{{ product.description | prettyprint | truncate: 200 }}</p>
8
-
9
8
  </li>
10
9
  {% endfor %}
11
10
  </ul>
@@ -0,0 +1,23 @@
1
+ % from MiniZinc Handbook:
2
+ % https://www.minizinc.org/doc-latest/en/modelling.html
3
+
4
+ % Colouring Australia using nc colours
5
+ int: nc = 3;
6
+
7
+ var 1..nc: wa; var 1..nc: nt; var 1..nc: sa; var 1..nc: q;
8
+ var 1..nc: nsw; var 1..nc: v; var 1..nc: t;
9
+
10
+ constraint wa != nt;
11
+ constraint wa != sa;
12
+ constraint nt != sa;
13
+ constraint nt != q;
14
+ constraint sa != q;
15
+ constraint sa != nsw;
16
+ constraint sa != v;
17
+ constraint q != nsw;
18
+ constraint nsw != v;
19
+ solve satisfy;
20
+
21
+ output ["wa=\(wa)\t nt=\(nt)\t sa=\(sa)\n",
22
+ "q=\(q)\t nsw=\(nsw)\t v=\(v)\n",
23
+ "t=", show(t), "\n"];
@@ -0,0 +1,11 @@
1
+ .bank 0
2
+ .org $C000
3
+ Reset:
4
+ jsr WaitSync ; wait for VSYNC
5
+ jsr ClearRAM ; clear RAM
6
+ jsr WaitSync ; wait for VSYNC (and PPU warmup)
7
+
8
+ lda #$3f ; $3F -> A register
9
+ ldy #$00 ; $00 -> Y register
10
+ sta PPU_ADDR ; write #HIGH byte first
11
+ sty PPU_ADDR ; $3F00 -> PPU address
@@ -1,2 +1,8 @@
1
1
  / comment
2
2
  x: til 10
3
+
4
+ tab:([]a:1 2 3;b:`a `b `c);
5
+
6
+ function:{[table]
7
+ select from table where b=`c
8
+ };
@@ -0,0 +1,27 @@
1
+ *** Settings ***
2
+ Document Example taken from http://robotframework.org/
3
+ Suite Setup Open Browser To Login Page
4
+ Suite Teardown Close Browser
5
+ Test Setup Go To Login Page
6
+ Test Template Login With Invalid Credentials Should Fail
7
+ Resource resource.txt
8
+
9
+ *** Test Cases *** User Name Password
10
+ Invalid Username invalid ${VALID PASSWORD}
11
+ Invalid Password ${VALID USER} invalid
12
+ Invalid Username And Password invalid whatever
13
+ Empty Username ${EMPTY} ${VALID PASSWORD}
14
+ Empty Password ${VALID USER} ${EMPTY}
15
+ Empty Username And Password ${EMPTY} ${EMPTY}
16
+
17
+ *** Keywords ***
18
+ Login With Invalid Credentials Should Fail
19
+ [Arguments] ${username} ${password}
20
+ Input Username ${username}
21
+ Input Password ${password}
22
+ Submit Credentials
23
+ Login Should Have Failed
24
+
25
+ Login Should Have Failed
26
+ Location Should Be ${ERROR URL}
27
+ Title Should Be Error Page
@@ -0,0 +1,10 @@
1
+ // Printer.ice
2
+ module Demo
3
+ {
4
+ interface Printer
5
+ {
6
+ // A client can invoke this operation on a server.
7
+ // In this example we print the string s
8
+ void printString(string s);
9
+ }
10
+ }
@@ -0,0 +1,6 @@
1
+ module DNSTester {
2
+ type integer Identification( 0..65535 ); // 16-bit integer
3
+ type enumerated MessageKind {e_Question, e_Answer};
4
+ type charstring Question;
5
+ type charstring Answer;
6
+ }
@@ -126,6 +126,11 @@ module Rouge
126
126
 
127
127
  next PlainText
128
128
  end
129
+
130
+ disambiguate '*.cls' do
131
+ next TeX if matches?(/\A\s*(?:\\|%)/)
132
+ next Apex
133
+ end
129
134
  end
130
135
  end
131
136
  end
@@ -49,6 +49,9 @@ module Rouge
49
49
  #
50
50
  # Lexer.find_fancy('guess', "#!/bin/bash\necho Hello, world")
51
51
  #
52
+ # If the code matches more than one lexer then Guesser::Ambiguous
53
+ # is raised.
54
+ #
52
55
  # This is used in the Redcarpet plugin as well as Rouge's own
53
56
  # markdown lexer for highlighting internal code blocks.
54
57
  #
@@ -0,0 +1,126 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
3
+
4
+ module Rouge
5
+ module Lexers
6
+ class Apex < RegexLexer
7
+ title "Apex"
8
+ desc "The Apex programming language (provided by salesforce)"
9
+
10
+ tag 'apex'
11
+ filenames '*.cls'
12
+ mimetypes 'text/x-apex'
13
+
14
+ def self.keywords
15
+ @keywords ||= Set.new %w(
16
+ assert break case catch continue default do else finally for if goto
17
+ instanceof new return switch this throw try while insert update
18
+ delete
19
+ )
20
+ end
21
+
22
+ def self.declarations
23
+ @declarations ||= Set.new %w(
24
+ abstract const enum extends final implements native private protected
25
+ public static super synchronized throws transient volatile with
26
+ sharing without inherited virtual global testmethod
27
+ )
28
+ end
29
+
30
+ def self.soql
31
+ @soql ||= Set.new %w(
32
+ SELECT FROM WHERE UPDATE LIKE TYPEOF END USING SCOPE WITH DATA
33
+ CATEGORY GROUP BY ROLLUP CUBE HAVING ORDER BY ASC DESC NULLS FIRST
34
+ LAST LIMIT OFFSET FOR VIEW REFERENCE UPDATE TRACKING VIEWSTAT OR AND
35
+ )
36
+ end
37
+
38
+ def self.types
39
+ @types ||= Set.new %w(
40
+ String boolean byte char double float int long short var void
41
+ )
42
+ end
43
+
44
+ def self.constants
45
+ @constants ||= Set.new %w(true false null)
46
+ end
47
+
48
+ id = /[a-z_][a-z0-9_]*/i
49
+
50
+ state :root do
51
+ rule %r/\s+/m, Text
52
+
53
+ rule %r(//.*?$), Comment::Single
54
+ rule %r(/\*.*?\*/)m, Comment::Multiline
55
+
56
+ rule %r/(?:class|interface)\b/, Keyword::Declaration, :class
57
+ rule %r/import\b/, Keyword::Namespace, :import
58
+
59
+ rule %r/([@$.]?)(#{id})([:(]?)/io do |m|
60
+ if self.class.keywords.include? m[0].downcase
61
+ token Keyword
62
+ elsif self.class.soql.include? m[0].upcase
63
+ token Keyword
64
+ elsif self.class.declarations.include? m[0].downcase
65
+ token Keyword::Declaration
66
+ elsif self.class.types.include? m[0].downcase
67
+ token Keyword::Type
68
+ elsif self.class.constants.include? m[0].downcase
69
+ token Keyword::Constant
70
+ elsif 'package'.casecmp m[0]
71
+ token Keyword::Namespace
72
+ elsif m[1] == "@"
73
+ token Name::Decorator
74
+ elsif m[3] == ":"
75
+ groups Operator, Name::Label, Punctuation
76
+ elsif m[3] == "("
77
+ groups Operator, Name::Function, Punctuation
78
+ elsif m[1] == "."
79
+ groups Operator, Name::Property, Punctuation
80
+ else
81
+ token Name
82
+ end
83
+ end
84
+
85
+ rule %r/"/, Str::Double, :dq
86
+ rule %r/'/, Str::Single, :sq
87
+
88
+ digit = /[0-9]_+[0-9]|[0-9]/
89
+ rule %r/#{digit}+\.#{digit}+([eE]#{digit}+)?[fd]?/, Num::Float
90
+ rule %r/0b(?:[01]_+[01]|[01])+/i, Num::Bin
91
+ rule %r/0x(?:\h_+\h|\h)+/i, Num::Hex
92
+ rule %r/0(?:[0-7]_+[0-7]|[0-7])+/, Num::Oct
93
+ rule %r/#{digit}+L?/, Num::Integer
94
+
95
+ rule %r/[-+\/*~^!%&<>|=.?]/, Operator
96
+ rule %r/[\[\](){},:;]/, Punctuation;
97
+ end
98
+
99
+ state :class do
100
+ rule %r/\s+/m, Text
101
+ rule id, Name::Class, :pop!
102
+ end
103
+
104
+ state :import do
105
+ rule %r/\s+/m, Text
106
+ rule %r/[a-z0-9_.]+\*?/i, Name::Namespace, :pop!
107
+ end
108
+
109
+ state :escape do
110
+ rule %r/\\[btnfr\\"']/, Str::Escape
111
+ end
112
+
113
+ state :dq do
114
+ mixin :escape
115
+ rule %r/[^\\"]+/, Str::Double
116
+ rule %r/"/, Str::Double, :pop!
117
+ end
118
+
119
+ state :sq do
120
+ mixin :escape
121
+ rule %r/[^\\']+/, Str::Double
122
+ rule %r/'/, Str::Double, :pop!
123
+ end
124
+ end
125
+ end
126
+ end
@@ -13,14 +13,28 @@ module Rouge
13
13
  ).join('|')
14
14
 
15
15
  MISC_KEYWORDS = %w(
16
- be16 be32 be64 exit lock
16
+ be16 be32 be64 exit lock map
17
17
  ).join('|')
18
18
 
19
19
  state :root do
20
+ # Line numbers and hexadecimal output from bpftool/objdump
21
+ rule %r/(\d+)(:)(\s+)(\(\h{2}\))/i do
22
+ groups Generic::Lineno, Punctuation, Text::Whitespace, Generic
23
+ end
24
+ rule %r/(\d+)(:)(\s+)((?:\h{2} ){8})/i do
25
+ groups Generic::Lineno, Punctuation, Text::Whitespace, Generic
26
+ end
27
+ rule %r/(\d+)(:)(\s+)/i do
28
+ groups Generic::Lineno, Punctuation, Text::Whitespace
29
+ end
30
+
20
31
  # Calls to helpers
21
32
  rule %r/(call)(\s+)(\d+)/i do
22
33
  groups Keyword, Text::Whitespace, Literal::Number::Integer
23
34
  end
35
+ rule %r/(call)(\s+)(\w+)(#)(\d+)/i do
36
+ groups Keyword, Text::Whitespace, Name::Builtin, Punctuation, Literal::Number::Integer
37
+ end
24
38
 
25
39
  # Unconditional jumps
26
40
  rule %r/(goto)(\s*)(\+\d+)?(\s*)(<?\w+>?)/i do
@@ -28,10 +42,10 @@ module Rouge
28
42
  end
29
43
 
30
44
  # Conditional jumps
31
- rule %r/(if)(\s+)(r\d+)(\s*)([s!=<>]+)(\s*)(0x\h+|[-]?\d+)(\s*)(goto)(\s*)(\+\d+)?(\s*)(<?\w+>?)/i do
45
+ rule %r/(if)(\s+)([rw]\d+)(\s*)([s!=<>]+)(\s*)(0x\h+|[-]?\d+)(\s*)(goto)(\s*)(\+\d+)?(\s*)(<?\w+>?)/i do
32
46
  groups Keyword, Text::Whitespace, Name, Text::Whitespace, Operator, Text::Whitespace, Literal::Number, Text::Whitespace, Keyword, Text::Whitespace, Literal::Number::Integer, Text::Whitespace, Name::Label
33
47
  end
34
- rule %r/(if)(\s+)(r\d+)(\s*)([s!=<>]+)(\s*)(r\d+)(\s*)(goto)(\s*)(\+\d+)?(\s*)(<?\w+>?)/i do
48
+ rule %r/(if)(\s+)([rw]\d+)(\s*)([s!=<>]+)(\s*)([rw]\d+)(\s*)(goto)(\s*)(\+\d+)?(\s*)(<?\w+>?)/i do
35
49
  groups Keyword, Text::Whitespace, Name, Text::Whitespace, Operator, Text::Whitespace, Name, Text::Whitespace, Keyword, Text::Whitespace, Literal::Number::Integer, Text::Whitespace, Name::Label
36
50
  end
37
51
 
@@ -45,7 +59,7 @@ module Rouge
45
59
  rule %r/[+-\/\*&|><^s]{0,3}=/i, Operator
46
60
 
47
61
  # Registers
48
- rule %r/([+-]?)(r\d+)/i do
62
+ rule %r/([+-]?)([rw]\d+)/i do
49
63
  groups Punctuation, Name
50
64
  end
51
65
 
@@ -73,7 +87,7 @@ module Rouge
73
87
 
74
88
  state :address do
75
89
  # Address is offset from register
76
- rule %r/(\()(r\d+)(\s*)([+-])(\s*)(\d+)(\))/i do
90
+ rule %r/(\()([rw]\d+)(\s*)([+-])(\s*)(\d+)(\))/i do
77
91
  groups Punctuation, Name, Text::Whitespace, Operator, Text::Whitespace, Literal::Number::Integer, Punctuation
78
92
  pop!
79
93
  end
@@ -83,7 +97,7 @@ module Rouge
83
97
  groups Name, Punctuation, Literal::Number::Integer, Punctuation
84
98
  pop!
85
99
  end
86
- rule %r/(\w+)(\[)(r\d+)(\])/i do
100
+ rule %r/(\w+)(\[)([rw]\d+)(\])/i do
87
101
  groups Name, Punctuation, Name, Punctuation
88
102
  pop!
89
103
  end
@@ -58,7 +58,7 @@ module Rouge
58
58
 
59
59
  def self.keyopts
60
60
  @keyopts ||= Set.new %w(
61
- := => -> /\\ \\/ _ ; :> :
61
+ := => -> /\\ \\/ _ ; :> : ⇒ → ↔ ⇔ ≔ ≡ ∀ ∃ ∧ ∨ ¬ ⊤ ⊥ ⊢ ⊨ ∈
62
62
  )
63
63
  end
64
64
 
@@ -115,14 +115,6 @@ module Rouge
115
115
  end
116
116
  rule %r(/\\), Operator
117
117
  rule %r/\\\//, Operator
118
- rule operator do |m|
119
- match = m[0]
120
- if self.class.keyopts.include? match
121
- token Punctuation
122
- else
123
- token Operator
124
- end
125
- end
126
118
 
127
119
  rule %r/-?\d[\d_]*(.[\d_]*)?(e[+-]?\d[\d_]*)/i, Num::Float
128
120
  rule %r/\d[\d_]*/, Num::Integer
@@ -131,6 +123,17 @@ module Rouge
131
123
  rule %r/'/, Keyword
132
124
  rule %r/"/, Str::Double, :string
133
125
  rule %r/[~?]#{id}/, Name::Variable
126
+
127
+ rule %r/./ do |m|
128
+ match = m[0]
129
+ if self.class.keyopts.include? match
130
+ token Punctuation
131
+ elsif match =~ operator
132
+ token Operator
133
+ else
134
+ token Error
135
+ end
136
+ end
134
137
  end
135
138
 
136
139
  state :comment do
@@ -0,0 +1,44 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
3
+
4
+ module Rouge
5
+ module Lexers
6
+ class CSVS < RegexLexer
7
+ tag 'csvs'
8
+ title "csvs"
9
+ desc 'The CSV Schema Language (digital-preservation.github.io)'
10
+ filenames '*.csvs'
11
+
12
+ state :root do
13
+ rule %r/\s+/m, Text
14
+
15
+ rule %r(//[\S\t ]*), Comment::Single
16
+ rule %r(/\*[^*]*\*/)m, Comment::Multiline
17
+
18
+ rule %r/(version)( )(\d+\.\d+)/ do
19
+ groups Keyword, Text::Whitespace, Num::Float
20
+ end
21
+
22
+ rule %r/T?\d{2}:\d{2}:\d{2}(\.\d{5})?(Z|(?:[-+]\d{2}:\d{2}))?/, Literal::Date
23
+ rule %r/\d{4}-\d{2}-\d{2}/, Literal::Date
24
+ rule %r/\d{2}\/\d{2}\/\d{4}/, Literal::Date
25
+
26
+ rule %r((\d+[.]?\d*|\d*[.]\d+)(e[+-]?[0-9]+)?)i, Num::Float
27
+ rule %r/\d+/, Num::Integer
28
+
29
+ rule %r/@\w+/, Keyword::Pseudo
30
+
31
+ rule %r/[-.\w]+:/, Name::Variable
32
+ rule %r/^"[^"]+"/, Name::Variable
33
+ rule %r/\$([-.\w]+|("[^"]+"))\/?/, Name::Variable
34
+
35
+ rule %r/[A-Z]+/i, Keyword
36
+
37
+ rule %r/"[^"]*"/, Str::Double
38
+ rule %r/'[^\r\n\f']'/, Str::Char
39
+
40
+ rule %r/[,()*]/, Punctuation
41
+ end
42
+ end
43
+ end
44
+ end
@@ -48,7 +48,7 @@ module Rouge
48
48
  state :root do
49
49
  mixin :whitespace
50
50
  # Comments
51
- rule %r(//(.*?)\n), Comment::Single
51
+ rule %r(//.*), Comment::Single
52
52
  rule %r(/(\\\n)?[*](.|\n)*?[*](\\\n)?/), Comment::Multiline
53
53
  rule %r(/\+), Comment::Multiline, :nested_comment
54
54
  # Keywords