lib/rouge/lexers/javascript.rb in rouge-2.0.7 vs lib/rouge/lexers/javascript.rb in rouge-2.1.0
- old
+ new
@@ -95,26 +95,30 @@
rule /[^\n]+/, Error, :pop!
end
def self.keywords
@keywords ||= Set.new %w(
- for in while do break return continue switch case default
+ for in of while do break return continue switch case default
if else throw try catch finally new delete typeof instanceof
- void this yield
+ void this yield import export from as async super this
)
end
def self.declarations
- @declarations ||= Set.new %w(var let with function)
+ @declarations ||= Set.new %w(
+ var let const with function class
+ extends constructor get set
+ )
end
def self.reserved
@reserved ||= Set.new %w(
- abstract boolean byte char class const debugger double enum
- export extends final float goto implements import int interface
+ abstract boolean byte char debugger double enum
+ final float goto implements int interface
long native package private protected public short static
- super synchronized throws transient volatile
+ synchronized throws transient volatile
+ eval arguments await
)
end
def self.constants
@constants ||= Set.new %w(true false null NaN Infinity undefined)
@@ -123,12 +127,17 @@
def self.builtins
@builtins ||= %w(
Array Boolean Date Error Function Math netscape
Number Object Packages RegExp String sun decodeURI
decodeURIComponent encodeURI encodeURIComponent
- Error eval isFinite isNaN parseFloat parseInt document this
- window
+ Error eval isFinite isNaN parseFloat parseInt
+ document window navigator self global
+ Promise Set Map WeakSet WeakMap Symbol Proxy Reflect
+ Int8Array Uint8Array Uint8ClampedArray
+ Int16Array Uint16Array Uint16ClampedArray
+ Int32Array Uint32Array Uint32ClampedArray
+ Float32Array Float64Array DataView ArrayBuffer
)
end
def self.id_regex
/[$a-z_][a-z0-9_]*/io
@@ -136,11 +145,10 @@
id = self.id_regex
state :root do
rule /\A\s*#!.*?\n/m, Comment::Preproc, :statement
- rule /\n/, Text, :statement
rule %r((?<=\n)(?=\s|/|<!--)), Text, :expr_start
mixin :comments_and_whitespace
rule %r(\+\+ | -- | ~ | && | \|\| | \\(?=\n) | << | >>>? | ===
| !== )x,
Operator, :expr_start
@@ -184,11 +192,14 @@
token Name::Other
end
end
rule /[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?/, Num::Float
- rule /0x[0-9a-fA-F]+/, Num::Hex
+ rule /0x[0-9a-fA-F]+/i, Num::Hex
+ rule /0o[0-7][0-7_]*/i, Num::Oct
+ rule /0b[01][01_]*/i, Num::Bin
rule /[0-9]+/, Num::Integer
+
rule /"(\\[\\"]|[^"])*"/, Str::Double
rule /'(\\[\\']|[^'])*'/, Str::Single
rule /:/, Punctuation
end