rouge 3.19.0 → 3.24.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rouge.rb +1 -0
  3. data/lib/rouge/cli.rb +32 -2
  4. data/lib/rouge/demos/augeas +16 -0
  5. data/lib/rouge/demos/bibtex +12 -0
  6. data/lib/rouge/demos/brightscript +6 -0
  7. data/lib/rouge/demos/email +11 -0
  8. data/lib/rouge/demos/hlsl +20 -0
  9. data/lib/rouge/demos/j +12 -0
  10. data/lib/rouge/demos/janet +3 -0
  11. data/lib/rouge/demos/livescript +15 -0
  12. data/lib/rouge/demos/postscript +9 -0
  13. data/lib/rouge/demos/ssh +4 -0
  14. data/lib/rouge/demos/systemd +4 -0
  15. data/lib/rouge/demos/velocity +9 -0
  16. data/lib/rouge/demos/zig +6 -0
  17. data/lib/rouge/formatters/html_line_highlighter.rb +26 -0
  18. data/lib/rouge/lexer.rb +38 -20
  19. data/lib/rouge/lexers/apex.rb +9 -7
  20. data/lib/rouge/lexers/augeas.rb +93 -0
  21. data/lib/rouge/lexers/batchfile.rb +1 -1
  22. data/lib/rouge/lexers/bibtex.rb +115 -0
  23. data/lib/rouge/lexers/brightscript.rb +147 -0
  24. data/lib/rouge/lexers/cpp.rb +11 -4
  25. data/lib/rouge/lexers/css.rb +3 -1
  26. data/lib/rouge/lexers/diff.rb +1 -1
  27. data/lib/rouge/lexers/docker.rb +1 -1
  28. data/lib/rouge/lexers/elm.rb +5 -5
  29. data/lib/rouge/lexers/email.rb +39 -0
  30. data/lib/rouge/lexers/ghc_core.rb +2 -1
  31. data/lib/rouge/lexers/graphql.rb +1 -1
  32. data/lib/rouge/lexers/hack.rb +1 -1
  33. data/lib/rouge/lexers/haskell.rb +27 -19
  34. data/lib/rouge/lexers/hlsl.rb +166 -0
  35. data/lib/rouge/lexers/html.rb +7 -7
  36. data/lib/rouge/lexers/http.rb +8 -2
  37. data/lib/rouge/lexers/isbl.rb +2 -2
  38. data/lib/rouge/lexers/j.rb +244 -0
  39. data/lib/rouge/lexers/janet.rb +218 -0
  40. data/lib/rouge/lexers/javascript.rb +10 -5
  41. data/lib/rouge/lexers/jinja.rb +22 -7
  42. data/lib/rouge/lexers/jsl.rb +1 -1
  43. data/lib/rouge/lexers/jsonnet.rb +4 -3
  44. data/lib/rouge/lexers/jsp.rb +2 -3
  45. data/lib/rouge/lexers/jsx.rb +47 -59
  46. data/lib/rouge/lexers/julia.rb +4 -2
  47. data/lib/rouge/lexers/kotlin.rb +7 -3
  48. data/lib/rouge/lexers/livescript.rb +310 -0
  49. data/lib/rouge/lexers/opentype_feature_file.rb +26 -42
  50. data/lib/rouge/lexers/perl.rb +21 -3
  51. data/lib/rouge/lexers/php.rb +274 -128
  52. data/lib/rouge/lexers/postscript.rb +93 -0
  53. data/lib/rouge/lexers/powershell.rb +5 -3
  54. data/lib/rouge/lexers/q.rb +1 -1
  55. data/lib/rouge/lexers/rego.rb +27 -12
  56. data/lib/rouge/lexers/ruby.rb +3 -3
  57. data/lib/rouge/lexers/rust.rb +3 -1
  58. data/lib/rouge/lexers/sass/common.rb +1 -0
  59. data/lib/rouge/lexers/smarty.rb +1 -1
  60. data/lib/rouge/lexers/ssh.rb +33 -0
  61. data/lib/rouge/lexers/systemd.rb +34 -0
  62. data/lib/rouge/lexers/tsx.rb +10 -3
  63. data/lib/rouge/lexers/twig.rb +4 -4
  64. data/lib/rouge/lexers/typescript.rb +1 -12
  65. data/lib/rouge/lexers/typescript/common.rb +18 -4
  66. data/lib/rouge/lexers/velocity.rb +71 -0
  67. data/lib/rouge/lexers/wollok.rb +0 -1
  68. data/lib/rouge/lexers/xml.rb +5 -3
  69. data/lib/rouge/lexers/yaml.rb +5 -3
  70. data/lib/rouge/lexers/zig.rb +139 -0
  71. data/lib/rouge/regex_lexer.rb +56 -1
  72. data/lib/rouge/version.rb +1 -1
  73. metadata +29 -2
@@ -78,7 +78,7 @@ module Rouge
78
78
 
79
79
  state :basic do
80
80
  # Comments
81
- rule %r/\brem\b.*$/i, Comment
81
+ rule %r/@?\brem\b.*$/i, Comment
82
82
  # Empty Labels
83
83
  rule %r/^::.*$/, Comment
84
84
 
@@ -0,0 +1,115 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
3
+
4
+ # Regular expressions based on https://github.com/SaswatPadhi/prismjs-bibtex
5
+ # and https://github.com/alecthomas/chroma/blob/master/lexers/b/bibtex.go
6
+
7
+ module Rouge
8
+ module Lexers
9
+ class BibTeX < RegexLexer
10
+ title 'BibTeX'
11
+ desc "BibTeX"
12
+ tag 'bibtex'
13
+ aliases 'bib'
14
+ filenames '*.bib'
15
+
16
+ valid_punctuation = Regexp.quote("@!$&.\\:;<>?[]^`|~*/+-")
17
+ valid_name = /[a-z_#{valid_punctuation}][\w#{valid_punctuation}]*/io
18
+
19
+ state :root do
20
+ mixin :whitespace
21
+
22
+ rule %r/@(#{valid_name})/o do |m|
23
+ match = m[1].downcase
24
+
25
+ if match == "comment"
26
+ token Comment
27
+ elsif match == "preamble"
28
+ token Name::Class
29
+ push :closing_brace
30
+ push :value
31
+ push :opening_brace
32
+ elsif match == "string"
33
+ token Name::Class
34
+ push :closing_brace
35
+ push :field
36
+ push :opening_brace
37
+ else
38
+ token Name::Class
39
+ push :closing_brace
40
+ push :command_body
41
+ push :opening_brace
42
+ end
43
+ end
44
+
45
+ rule %r/.+/, Comment
46
+ end
47
+
48
+ state :opening_brace do
49
+ mixin :whitespace
50
+ rule %r/[{(]/, Punctuation, :pop!
51
+ end
52
+
53
+ state :closing_brace do
54
+ mixin :whitespace
55
+ rule %r/[})]/, Punctuation, :pop!
56
+ end
57
+
58
+ state :command_body do
59
+ mixin :whitespace
60
+ rule %r/[^\s\,\}]+/ do
61
+ token Name::Label
62
+ pop!
63
+ push :fields
64
+ end
65
+ end
66
+
67
+ state :fields do
68
+ mixin :whitespace
69
+ rule %r/,/, Punctuation, :field
70
+ rule(//) { pop! }
71
+ end
72
+
73
+ state :field do
74
+ mixin :whitespace
75
+ rule valid_name do
76
+ token Name::Attribute
77
+ push :value
78
+ push :equal_sign
79
+ end
80
+ rule(//) { pop! }
81
+ end
82
+
83
+ state :equal_sign do
84
+ mixin :whitespace
85
+ rule %r/=/, Punctuation, :pop!
86
+ end
87
+
88
+ state :value do
89
+ mixin :whitespace
90
+ rule valid_name, Name::Variable
91
+ rule %r/"/, Literal::String, :quoted_string
92
+ rule %r/\{/, Literal::String, :braced_string
93
+ rule %r/\d+/, Literal::Number
94
+ rule %r/#/, Punctuation
95
+ rule(//) { pop! }
96
+ end
97
+
98
+ state :quoted_string do
99
+ rule %r/\{/, Literal::String, :braced_string
100
+ rule %r/"/, Literal::String, :pop!
101
+ rule %r/[^\{\"]+/, Literal::String
102
+ end
103
+
104
+ state :braced_string do
105
+ rule %r/\{/, Literal::String, :braced_string
106
+ rule %r/\}/, Literal::String, :pop!
107
+ rule %r/[^\{\}]+/, Literal::String
108
+ end
109
+
110
+ state :whitespace do
111
+ rule %r/\s+/, Text
112
+ end
113
+ end
114
+ end
115
+ end
@@ -0,0 +1,147 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
3
+
4
+ module Rouge
5
+ module Lexers
6
+ class Brightscript < RegexLexer
7
+ title "BrightScript"
8
+ desc "BrightScript Programming Language (https://developer.roku.com/en-ca/docs/references/brightscript/language/brightscript-language-reference.md)"
9
+ tag 'brightscript'
10
+ aliases 'bs', 'brs'
11
+ filenames '*.brs'
12
+
13
+ # https://developer.roku.com/en-ca/docs/references/brightscript/language/global-utility-functions.md
14
+ # https://developer.roku.com/en-ca/docs/references/brightscript/language/global-string-functions.md
15
+ # https://developer.roku.com/en-ca/docs/references/brightscript/language/global-math-functions.md
16
+ def self.name_builtin
17
+ @name_builtin ||= Set.new %w(
18
+ ABS ASC ATN CDBL CHR CINT CONTROL COPYFILE COS CREATEDIRECTORY CSNG
19
+ DELETEDIRECTORY DELETEFILE EXP FINDMEMBERFUNCTION FINDNODE FIX
20
+ FORMATDRIVEFORMATJSON GETINTERFACE INSTR INT LCASE LEFT LEN LISTDIR
21
+ LOG MATCHFILES MID MOVEFILE OBSERVEFIELD PARSEJSON PARSEXML
22
+ READASCIIFILE REBOOTSYSTEM RIGHT RND RUNGARBAGECOLLECTOR SGN SIN
23
+ SLEEP SQR STR STRI STRING STRINGI STRTOI SUBSTITUTE TANTEXTTOP TEXT
24
+ TRUCASE UPTIME VALVISIBLE VISIBLE WAIT
25
+ )
26
+ end
27
+
28
+ # https://developer.roku.com/en-ca/docs/references/brightscript/language/reserved-words.md
29
+ def self.keyword_reserved
30
+ @keyword_reserved ||= Set.new %w(
31
+ BOX CREATEOBJECT DIM EACH ELSE ELSEIF END ENDFUNCTION ENDIF ENDSUB
32
+ ENDWHILE EVAL EXIT EXITWHILE FALSE FOR FUNCTION GETGLOBALAA
33
+ GETLASTRUNCOMPILEERROR GETLASTRUNRUNTIMEERROR GOTO IF IN INVALID LET
34
+ LINE_NUM M NEXT OBJFUN POS PRINT REM RETURN RUN STEP STOP SUB TAB TO
35
+ TRUE TYPE WHILE
36
+ )
37
+ end
38
+
39
+ # These keywords are present in BrightScript, but not supported in standard .brs files
40
+ def self.keyword_reserved_unsupported
41
+ @keyword_reserved_unsupported ||= Set.new %w(
42
+ CLASS CONST IMPORT LIBRARY NAMESPACE PRIVATE PROTECTED PUBLIC
43
+ )
44
+ end
45
+
46
+ # https://developer.roku.com/en-ca/docs/references/brightscript/language/expressions-variables-types.md
47
+ def self.keyword_type
48
+ @keyword_type ||= Set.new %w(
49
+ BOOLEAN DIM DOUBLE DYNAMIC FLOAT FUNCTION INTEGER INTERFACE INVALID
50
+ LONGINTEGER OBJECT STRING VOID
51
+ )
52
+ end
53
+
54
+ # https://developer.roku.com/en-ca/docs/references/brightscript/language/expressions-variables-types.md#operators
55
+ def self.operator_word
56
+ @operator_word ||= Set.new %w(
57
+ AND AS MOD NOT OR THEN
58
+ )
59
+ end
60
+
61
+ # Scene graph components configured as builtins. See BrightScript component documentation e.g.
62
+ # https://developer.roku.com/en-ca/docs/references/brightscript/components/roappinfo.md
63
+ def self.builtins
64
+ @builtins ||= Set.new %w(
65
+ roAppendFile roAppInfo roAppManager roArray roAssociativeArray
66
+ roAudioGuide roAudioMetadata roAudioPlayer roAudioPlayerEvent
67
+ roAudioResourceroBitmap roBoolean roBoolean roBrightPackage roBrSub
68
+ roButton roByteArray roCaptionRenderer roCaptionRendererEvent
69
+ roCecInterface roCECStatusEvent roChannelStore roChannelStoreEvent
70
+ roClockWidget roCodeRegistrationScreen
71
+ roCodeRegistrationScreenEventroCompositor roControlDown roControlPort
72
+ roControlPort roControlUp roCreateFile roDatagramReceiver
73
+ roDatagramSender roDataGramSocket roDateTime roDeviceInfo
74
+ roDeviceInfoEvent roDoubleroEVPCipher roEVPDigest roFileSystem
75
+ roFileSystemEvent roFloat roFont roFontMetrics roFontRegistry
76
+ roFunction roGlobal roGpio roGridScreen roGridScreenEvent
77
+ roHdmiHotPlugEventroHdmiStatus roHdmiStatusEvent roHMAC roHttpAgent
78
+ roImageCanvas roImageCanvasEvent roImageMetadata roImagePlayer
79
+ roImageWidgetroInput roInputEvent roInt roInt roInvalid roInvalid
80
+ roIRRemote roKeyboard roKeyboardPress roKeyboardScreen
81
+ roKeyboardScreenEventroList roListScreen roListScreenEvent
82
+ roLocalization roLongInteger roMessageDialog roMessageDialogEvent
83
+ roMessagePort roMicrophone roMicrophoneEvent roNetworkConfiguration
84
+ roOneLineDialog roOneLineDialogEventroParagraphScreen
85
+ roParagraphScreenEvent roPath roPinEntryDialog roPinEntryDialogEvent
86
+ roPinentryScreen roPosterScreen roPosterScreenEventroProgramGuide
87
+ roQuadravoxButton roReadFile roRectangleroRegexroRegion roRegistry
88
+ roRegistrySection roResourceManager roRSA roRssArticle roRssParser
89
+ roScreen roSearchHistory roSearchScreen roSearchScreenEvent
90
+ roSerialPort roSGNode roSGNodeEvent roSGScreenroSGScreenEvent
91
+ roSlideShowroSlideShowEvent roSNS5 roSocketAddress roSocketEvent
92
+ roSpringboardScreen roSpringboardScreenEventroSprite roStorageInfo
93
+ roStreamSocket roStringroSystemLogroSystemLogEvent roSystemTime
94
+ roTextFieldroTextScreen roTextScreenEvent roTextToSpeech
95
+ roTextToSpeechEvent roTextureManager roTextureRequest
96
+ roTextureRequestEventroTextWidget roTimer roTimespan roTouchScreen
97
+ roTunerroTunerEvent roUniversalControlEvent roUrlEvent roUrlTransfer
98
+ roVideoEvent roVideoInput roVideoMode roVideoPlayer roVideoPlayerEvent
99
+ roVideoScreen roVideoScreenEventroWriteFile roXMLElement roXMLList
100
+ )
101
+ end
102
+
103
+ id = /[$a-z_][a-z0-9_]*/io
104
+
105
+ state :root do
106
+ rule %r/\s+/m, Text::Whitespace
107
+
108
+ # https://developer.roku.com/en-ca/docs/references/brightscript/language/expressions-variables-types.md#comments
109
+ rule %r/\'.*/, Comment::Single
110
+ rule %r/REM.*/i, Comment::Single
111
+
112
+ # https://developer.roku.com/en-ca/docs/references/brightscript/language/expressions-variables-types.md#operators
113
+ rule %r([~!%^&*+=\|?:<>/-]), Operator
114
+
115
+ rule %r/\d*\.\d+(e-?\d+)?/i, Num::Float
116
+ rule %r/\d+[lu]*/i, Num::Integer
117
+
118
+ rule %r/".*?"/, Str::Double
119
+
120
+ rule %r/#{id}(?=\s*[(])/, Name::Function
121
+
122
+ rule %r/[()\[\],.;{}]/, Punctuation
123
+
124
+ rule id do |m|
125
+ caseSensitiveChunk = m[0]
126
+ caseInsensitiveChunk = m[0].upcase
127
+
128
+ if self.class.builtins.include?(caseSensitiveChunk)
129
+ token Keyword::Reserved
130
+ elsif self.class.keyword_reserved.include?(caseInsensitiveChunk)
131
+ token Keyword::Reserved
132
+ elsif self.class.keyword_reserved_unsupported.include?(caseInsensitiveChunk)
133
+ token Keyword::Reserved
134
+ elsif self.class.keyword_type.include?(caseInsensitiveChunk)
135
+ token Keyword::Type
136
+ elsif self.class.name_builtin.include?(caseInsensitiveChunk)
137
+ token Name::Builtin
138
+ elsif self.class.operator_word.include?(caseInsensitiveChunk)
139
+ token Operator::Word
140
+ else
141
+ token Name
142
+ end
143
+ end
144
+ end
145
+ end
146
+ end
147
+ end
@@ -68,21 +68,28 @@ module Rouge
68
68
  rule %r/#{dq}[lu]*/i, Num::Integer
69
69
  rule %r/\bnullptr\b/, Name::Builtin
70
70
  rule %r/(?:u8|u|U|L)?R"([a-zA-Z0-9_{}\[\]#<>%:;.?*\+\-\/\^&|~!=,"']{,16})\(.*?\)\1"/m, Str
71
+ rule %r/::/, Operator
71
72
  end
72
73
 
73
74
  state :classname do
74
75
  rule id, Name::Class, :pop!
75
76
 
76
77
  # template specification
77
- rule %r/\s*(?=>)/m, Text, :pop!
78
- rule %r/[.]{3}/, Operator
79
78
  mixin :whitespace
79
+ rule %r/[.]{3}/, Operator
80
+ rule %r/,/, Punctuation, :pop!
81
+ rule(//) { pop! }
80
82
  end
81
83
 
82
84
  state :template do
83
- rule %r/>/, Punctuation, :pop!
85
+ rule %r/[>;]/, Punctuation, :pop!
84
86
  rule %r/typename\b/, Keyword, :classname
85
- mixin :root
87
+ mixin :statements
88
+ end
89
+
90
+ state :case do
91
+ rule %r/:(?!:)/, Punctuation, :pop!
92
+ mixin :statements
86
93
  end
87
94
  end
88
95
  end
@@ -11,7 +11,9 @@ module Rouge
11
11
  filenames '*.css'
12
12
  mimetypes 'text/css'
13
13
 
14
- identifier = /[a-zA-Z0-9_-]+/
14
+ # Documentation: https://www.w3.org/TR/CSS21/syndata.html#characters
15
+
16
+ identifier = /[\p{L}_-][\p{Word}\p{Cf}-]*/
15
17
  number = /-?(?:[0-9]+(\.[0-9]+)?|\.[0-9]+)/
16
18
 
17
19
  def self.attributes
@@ -14,7 +14,7 @@ module Rouge
14
14
  def self.detect?(text)
15
15
  return true if text.start_with?('Index: ')
16
16
  return true if text =~ %r(\Adiff[^\n]*?\ba/[^\n]*\bb/)
17
- return true if text =~ /(---|[+][+][+]).*?\n(---|[+][+][+])/
17
+ return true if text =~ /---.*?\n[+][+][+]/ || text =~ /[+][+][+].*?\n---/
18
18
  end
19
19
 
20
20
  state :root do
@@ -8,7 +8,7 @@ module Rouge
8
8
  desc "Dockerfile syntax"
9
9
  tag 'docker'
10
10
  aliases 'dockerfile'
11
- filenames 'Dockerfile', '*.Dockerfile', '*.docker', 'Dockerfile_*'
11
+ filenames 'Dockerfile', '*.Dockerfile', '*.docker'
12
12
  mimetypes 'text/x-dockerfile-config'
13
13
 
14
14
  KEYWORDS = %w(
@@ -78,13 +78,13 @@ module Rouge
78
78
  rule %r/"/, Str::Double, :pop!
79
79
  end
80
80
 
81
- # Multiple line string with tripple double quotes, e.g. """ multi """
81
+ # Multiple line string with triple double quotes, e.g. """ multi """
82
82
  state :multiline_string do
83
- rule %r/\s*"""/, Str, :pop!
84
- rule %r/.*/, Str
85
- rule %r/\s*/, Str
83
+ rule %r/\\"/, Str::Escape
84
+ rule %r/"""/, Str, :pop!
85
+ rule %r/[^"]+/, Str
86
+ rule %r/"/, Str
86
87
  end
87
-
88
88
  end
89
89
  end
90
90
  end
@@ -0,0 +1,39 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
3
+
4
+ module Rouge
5
+ module Lexers
6
+ class Email < RegexLexer
7
+ tag 'email'
8
+ aliases 'eml', 'e-mail'
9
+ filenames '*.eml'
10
+ mimetypes 'message/rfc822'
11
+
12
+ title "Email"
13
+ desc "An email message"
14
+
15
+ start do
16
+ push :fields
17
+ end
18
+
19
+ state :fields do
20
+ rule %r/[:]/, Operator, :field_body
21
+ rule %r/[^\n\r:]+/, Name::Tag
22
+ rule %r/[\n\r]/, Name::Tag
23
+ end
24
+
25
+ state :field_body do
26
+ rule(/(\r?\n){2}/) { token Text; pop!(2) }
27
+ rule %r/\r?\n(?![ \v\t\f])/, Text, :pop!
28
+ rule %r/[^\n\r]+/, Name::Attribute
29
+ rule %r/[\n\r]/, Name::Attribute
30
+ end
31
+
32
+ state :root do
33
+ rule %r/\n/, Text
34
+ rule %r/^>.*/, Comment
35
+ rule %r/.+/, Text
36
+ end
37
+ end
38
+ end
39
+ end
@@ -27,8 +27,9 @@ module Rouge
27
27
  mixin :function
28
28
 
29
29
  # rest is Text
30
+ # TODO: this is really inefficient
30
31
  rule %r/\s/m, Text
31
- rule %r/.*/, Text
32
+ rule %r/./, Text
32
33
  end
33
34
 
34
35
  state :expression do
@@ -20,7 +20,7 @@ module Rouge
20
20
  end
21
21
 
22
22
  rule %r/\bfragment\b/, Keyword, :fragment_definition
23
-
23
+
24
24
  rule %r/\bscalar\b/, Keyword, :value
25
25
 
26
26
  rule %r/\b(?:type|interface|enum)\b/, Keyword, :type_definition
@@ -32,7 +32,7 @@ module Rouge
32
32
  )
33
33
  end
34
34
 
35
- prepend :template do
35
+ prepend :root do
36
36
  rule %r/<\?hh(\s*\/\/\s*(strict|decl|partial))?$/, Comment::Preproc, :php
37
37
  end
38
38
 
@@ -17,8 +17,8 @@ module Rouge
17
17
  end
18
18
 
19
19
  reserved = %w(
20
- _ case class data default deriving do else if in
21
- infix[lr]? instance let newtype of then type where
20
+ _ case class data default deriving do else if in infix infixl infixr
21
+ instance let newtype of then type where
22
22
  )
23
23
 
24
24
  ascii = %w(
@@ -54,14 +54,31 @@ module Rouge
54
54
  state :root do
55
55
  mixin :basic
56
56
 
57
- rule %r/\bimport\b/, Keyword::Reserved, :import
58
- rule %r/\bmodule\b/, Keyword::Reserved, :module
59
- rule %r/\b(?:#{reserved.join('|')})\b/, Keyword::Reserved
60
- # not sure why, but ^ doesn't work here
61
- # rule %r/^[_a-z][\w']*/, Name::Function
62
- rule %r/[_a-z][\w']*/, Name
63
- rule %r/[A-Z][\w']*/, Keyword::Type
64
- rule %r/'[A-Z]\w+'?/, Keyword::Type # promoted data constructor
57
+ rule %r/'(?=(?:.|\\\S+)')/, Str::Char, :character
58
+ rule %r/"/, Str, :string
59
+
60
+ rule %r/\d+e[+-]?\d+/i, Num::Float
61
+ rule %r/\d+\.\d+(e[+-]?\d+)?/i, Num::Float
62
+ rule %r/0o[0-7]+/i, Num::Oct
63
+ rule %r/0x[\da-f]+/i, Num::Hex
64
+ rule %r/\d+/, Num::Integer
65
+
66
+ rule %r/[\w']+/ do |m|
67
+ match = m[0]
68
+ if match == "import"
69
+ token Keyword::Reserved
70
+ push :import
71
+ elsif match == "module"
72
+ token Keyword::Reserved
73
+ push :module
74
+ elsif reserved.include?(match)
75
+ token Keyword::Reserved
76
+ elsif match =~ /\A'?[A-Z]/
77
+ token Keyword::Type
78
+ else
79
+ token Name
80
+ end
81
+ end
65
82
 
66
83
  # lambda operator
67
84
  rule %r(\\(?![:!#\$\%&*+.\\/<=>?@^\|~-]+)), Name::Function
@@ -72,15 +89,6 @@ module Rouge
72
89
  # other operators
73
90
  rule %r([:!#\$\%&*+.\\/<=>?@^\|~-]+), Operator
74
91
 
75
- rule %r/\d+e[+-]?\d+/i, Num::Float
76
- rule %r/\d+\.\d+(e[+-]?\d+)?/i, Num::Float
77
- rule %r/0o[0-7]+/i, Num::Oct
78
- rule %r/0x[\da-f]+/i, Num::Hex
79
- rule %r/\d+/, Num::Integer
80
-
81
- rule %r/'/, Str::Char, :character
82
- rule %r/"/, Str, :string
83
-
84
92
  rule %r/\[\s*\]/, Keyword::Type
85
93
  rule %r/\(\s*\)/, Name::Builtin
86
94