forked from rouge-ruby/rouge
-
Notifications
You must be signed in to change notification settings - Fork 1
/
common.rb
48 lines (42 loc) · 1.08 KB
/
common.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# -*- coding: utf-8 -*- #
# frozen_string_literal: true
module Rouge
module Lexers
module TypescriptCommon
def keywords
@keywords ||= super + Set.new(%w(
is namespace static private protected public
implements readonly
))
end
def declarations
@declarations ||= super + Set.new(%w(
type abstract
))
end
def reserved
@reserved ||= super + Set.new(%w(
string any void number namespace module
declare default interface keyof
))
end
def builtins
@builtins ||= super + %w(
Pick Partial Readonly Record
)
end
def self.extended(base)
base.prepend :root do
rule %r/[?][.]/, base::Punctuation
rule %r/[?]{2}/, base::Operator
end
base.prepend :statement do
rule %r/(#{Javascript.id_regex})(\??)(\s*)(:)/ do
groups base::Name::Label, base::Punctuation, base::Text, base::Punctuation
push :expr_start
end
end
end
end
end
end