rouge 3.8.0 → 3.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rouge/demos/eex +1 -0
- data/lib/rouge/demos/haxe +5 -0
- data/lib/rouge/demos/hql +5 -0
- data/lib/rouge/demos/terraform +0 -15
- data/lib/rouge/lexers/eex.rb +51 -0
- data/lib/rouge/lexers/elixir.rb +20 -9
- data/lib/rouge/lexers/haxe.rb +246 -0
- data/lib/rouge/lexers/hql.rb +139 -0
- data/lib/rouge/lexers/http.rb +5 -5
- data/lib/rouge/lexers/javascript.rb +1 -1
- data/lib/rouge/lexers/matlab.rb +4 -2
- data/lib/rouge/lexers/matlab/builtins.yml +3515 -0
- data/lib/rouge/lexers/q.rb +1 -1
- data/lib/rouge/lexers/sql.rb +26 -6
- data/lib/rouge/lexers/terraform.rb +8 -0
- data/lib/rouge/version.rb +1 -1
- metadata +9 -3
- data/lib/rouge/lexers/matlab/builtins.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2f0b54640482b19036e531f9a7da24b88a57e4f908f58ca5d9a515771ff5d31
|
4
|
+
data.tar.gz: bb378080c11eec20243d1a9abb85fbe8bbaddbcdeb836d60a80972cbe69ae25b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11f884bbfd8b631eacae6da8497d6b8444c4ec748dfceea4e8d8a7d5b92aadc6f36ca6e50367477b7b4e465004ed3c52ac597c3ed19a9e49742ed93de4c40d71
|
7
|
+
data.tar.gz: 137d26aa2078d6d26ba17d57b75f330e071e15211816a60daa35b269784c8fba44ddd00813d4c0d2427412084d0a47a19edace54b3bc3320751d3b10105e4a07
|
data/lib/rouge/demos/eex
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
<title><%= @title %></title>
|
data/lib/rouge/demos/hql
ADDED
data/lib/rouge/demos/terraform
CHANGED
@@ -1,10 +1,3 @@
|
|
1
|
-
# From: https://github.com/terraform-providers/terraform-provider-aws/blob/master/examples/count/main.tf
|
2
|
-
|
3
|
-
# Specify the provider and access details
|
4
|
-
provider "aws" {
|
5
|
-
region = "${var.aws_region}"
|
6
|
-
}
|
7
|
-
|
8
1
|
resource "aws_elb" "web" {
|
9
2
|
name = "terraform-example-elb"
|
10
3
|
|
@@ -21,11 +14,3 @@ resource "aws_elb" "web" {
|
|
21
14
|
# The instances are registered automatically
|
22
15
|
instances = ["${aws_instance.web.*.id}"]
|
23
16
|
}
|
24
|
-
|
25
|
-
resource "aws_instance" "web" {
|
26
|
-
instance_type = "m1.small"
|
27
|
-
ami = "${lookup(var.aws_amis, var.aws_region)}"
|
28
|
-
|
29
|
-
# This will create 4 instances
|
30
|
-
count = 4
|
31
|
-
}
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
|
3
|
+
module Rouge
|
4
|
+
module Lexers
|
5
|
+
class EEX < TemplateLexer
|
6
|
+
title "EEX"
|
7
|
+
desc "Embedded Elixir"
|
8
|
+
|
9
|
+
tag 'eex'
|
10
|
+
|
11
|
+
filenames '*.eex'
|
12
|
+
|
13
|
+
def initialize(opts={})
|
14
|
+
@elixir_lexer = Elixir.new(opts)
|
15
|
+
|
16
|
+
super(opts)
|
17
|
+
end
|
18
|
+
|
19
|
+
start do
|
20
|
+
parent.reset!
|
21
|
+
@elixir_lexer.reset!
|
22
|
+
end
|
23
|
+
|
24
|
+
open = /<%%|<%=|<%#|<%/
|
25
|
+
close = /%%>|%>/
|
26
|
+
|
27
|
+
state :root do
|
28
|
+
rule %r/<%#/, Comment, :comment
|
29
|
+
|
30
|
+
rule open, Comment::Preproc, :elixir
|
31
|
+
|
32
|
+
rule %r/.+?(?=#{open})|.+/mo do
|
33
|
+
delegate parent
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
state :comment do
|
38
|
+
rule close, Comment, :pop!
|
39
|
+
rule %r/.+?(?=#{close})|.+/mo, Comment
|
40
|
+
end
|
41
|
+
|
42
|
+
state :elixir do
|
43
|
+
rule close, Comment::Preproc, :pop!
|
44
|
+
|
45
|
+
rule %r/.+?(?=#{close})|.+/mo do
|
46
|
+
delegate @elixir_lexer
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/lib/rouge/lexers/elixir.rb
CHANGED
@@ -51,15 +51,25 @@ module Rouge
|
|
51
51
|
state :strings do
|
52
52
|
rule %r/(%[A-Ba-z])?"""(?:.|\n)*?"""/, Str::Doc
|
53
53
|
rule %r/'''(?:.|\n)*?'''/, Str::Doc
|
54
|
-
rule %r/"/, Str::
|
55
|
-
rule %r/'
|
54
|
+
rule %r/"/, Str::Double, :dqs
|
55
|
+
rule %r/'/, Str::Single, :sqs
|
56
56
|
rule %r{(?<!\w)\?(\\(x\d{1,2}|\h{1,2}(?!\h)\b|0[0-7]{0,2}(?![0-7])\b[^x0MC])|(\\[MC]-)+\w|[^\s\\])}, Str::Other
|
57
|
-
|
58
57
|
end
|
59
58
|
|
60
59
|
state :dqs do
|
60
|
+
mixin :escapes
|
61
|
+
mixin :interpoling
|
62
|
+
rule %r/[^#"\\]+/, Str::Double
|
61
63
|
rule %r/"/, Str::Double, :pop!
|
62
|
-
|
64
|
+
rule %r/[#\\]/, Str::Double
|
65
|
+
end
|
66
|
+
|
67
|
+
state :sqs do
|
68
|
+
mixin :escapes
|
69
|
+
mixin :interpoling
|
70
|
+
rule %r/[^#'\\]+/, Str::Single
|
71
|
+
rule %r/'/, Str::Single, :pop!
|
72
|
+
rule %r/[#\\]/, Str::Single
|
63
73
|
end
|
64
74
|
|
65
75
|
state :interpoling do
|
@@ -71,17 +81,18 @@ module Rouge
|
|
71
81
|
mixin :root
|
72
82
|
end
|
73
83
|
|
84
|
+
state :escapes do
|
85
|
+
rule %r/\\x\h{2}/, Str::Escape
|
86
|
+
rule %r/\\u\{?\d+\}?/, Str::Escape
|
87
|
+
rule %r/\\[\\abdefnrstv0"']/, Str::Escape
|
88
|
+
end
|
89
|
+
|
74
90
|
state :interpoling_symbol do
|
75
91
|
rule %r/"/, Str::Symbol, :pop!
|
76
92
|
mixin :interpoling
|
77
93
|
rule %r/[^#"]+/, Str::Symbol
|
78
94
|
end
|
79
95
|
|
80
|
-
state :enddoublestr do
|
81
|
-
mixin :interpoling
|
82
|
-
rule %r/[^#"]+/, Str::Double
|
83
|
-
end
|
84
|
-
|
85
96
|
state :sigil_strings do
|
86
97
|
# ~-sigiled strings
|
87
98
|
# ~(abc), ~[abc], ~<abc>, ~|abc|, ~r/abc/, etc
|
@@ -0,0 +1,246 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
|
3
|
+
module Rouge
|
4
|
+
module Lexers
|
5
|
+
class Haxe < RegexLexer
|
6
|
+
title "Haxe"
|
7
|
+
desc "Haxe Cross-platform Toolkit (http://haxe.org)"
|
8
|
+
|
9
|
+
tag 'haxe'
|
10
|
+
aliases 'hx', 'haxe'
|
11
|
+
filenames '*.hx'
|
12
|
+
mimetypes 'text/haxe', 'text/x-haxe', 'text/x-hx'
|
13
|
+
|
14
|
+
def self.detect?(text)
|
15
|
+
return true if text.shebang? "haxe"
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.keywords
|
19
|
+
@keywords ||= Set.new %w(
|
20
|
+
break case cast catch class continue default do else enum false for
|
21
|
+
function if import interface macro new null override package private
|
22
|
+
public return switch this throw true try untyped while
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.imports
|
27
|
+
@imports ||= Set.new %w(
|
28
|
+
import using
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.declarations
|
33
|
+
@declarations ||= Set.new %w(
|
34
|
+
abstract dynamic extern extends from implements inline static to
|
35
|
+
typedef var
|
36
|
+
)
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.reserved
|
40
|
+
@reserved ||= Set.new %w(
|
41
|
+
super trace inline build autoBuild enum
|
42
|
+
)
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.constants
|
46
|
+
@constants ||= Set.new %w(true false null)
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.builtins
|
50
|
+
@builtins ||= %w(
|
51
|
+
Void Dynamic Math Class Any Float Int UInt String StringTools Sys
|
52
|
+
EReg isNaN parseFloat parseInt this Array Map Date DateTools Bool
|
53
|
+
Lambda Reflect Std File FileSystem
|
54
|
+
)
|
55
|
+
end
|
56
|
+
|
57
|
+
id = /[$a-zA-Z_][a-zA-Z0-9_]*/
|
58
|
+
|
59
|
+
state :comments_and_whitespace do
|
60
|
+
rule %r/\s+/, Text
|
61
|
+
rule %r(//.*?$), Comment::Single
|
62
|
+
rule %r(/\*.*?\*/)m, Comment::Multiline
|
63
|
+
end
|
64
|
+
|
65
|
+
state :expr_start do
|
66
|
+
mixin :comments_and_whitespace
|
67
|
+
|
68
|
+
rule %r/#(?:if|elseif|else|end).*/, Comment::Preproc
|
69
|
+
|
70
|
+
rule %r(~) do
|
71
|
+
token Str::Regex
|
72
|
+
goto :regex
|
73
|
+
end
|
74
|
+
|
75
|
+
rule %r/[{]/, Punctuation, :object
|
76
|
+
|
77
|
+
rule %r//, Text, :pop!
|
78
|
+
end
|
79
|
+
|
80
|
+
state :regex do
|
81
|
+
rule %r(/) do
|
82
|
+
token Str::Regex
|
83
|
+
goto :regex_end
|
84
|
+
end
|
85
|
+
|
86
|
+
rule %r([^/]\n), Error, :pop!
|
87
|
+
|
88
|
+
rule %r/\n/, Error, :pop!
|
89
|
+
rule %r/\[\^/, Str::Escape, :regex_group
|
90
|
+
rule %r/\[/, Str::Escape, :regex_group
|
91
|
+
rule %r/\\./, Str::Escape
|
92
|
+
rule %r{[(][?][:=<!]}, Str::Escape
|
93
|
+
rule %r/[{][\d,]+[}]/, Str::Escape
|
94
|
+
rule %r/[()?]/, Str::Escape
|
95
|
+
rule %r/./, Str::Regex
|
96
|
+
end
|
97
|
+
|
98
|
+
state :regex_end do
|
99
|
+
rule %r/[gim]+/, Str::Regex, :pop!
|
100
|
+
rule(//) { pop! }
|
101
|
+
end
|
102
|
+
|
103
|
+
state :regex_group do
|
104
|
+
# specially highlight / in a group to indicate that it doesn't
|
105
|
+
# close the regex
|
106
|
+
rule %r/\//, Str::Escape
|
107
|
+
|
108
|
+
rule %r([^/]\n) do
|
109
|
+
token Error
|
110
|
+
pop! 2
|
111
|
+
end
|
112
|
+
|
113
|
+
rule %r/\]/, Str::Escape, :pop!
|
114
|
+
rule %r/\\./, Str::Escape
|
115
|
+
rule %r/./, Str::Regex
|
116
|
+
end
|
117
|
+
|
118
|
+
state :bad_regex do
|
119
|
+
rule %r/[^\n]+/, Error, :pop!
|
120
|
+
end
|
121
|
+
|
122
|
+
state :root do
|
123
|
+
rule %r/\n/, Text, :statement
|
124
|
+
rule %r(\{), Punctuation, :expr_start
|
125
|
+
|
126
|
+
mixin :comments_and_whitespace
|
127
|
+
|
128
|
+
rule %r/@/, Name::Decorator, :metadata
|
129
|
+
rule %r(\+\+ | -- | ~ | && | \|\| | \\(?=\n) | << | >> | ==
|
130
|
+
| != )x,
|
131
|
+
Operator, :expr_start
|
132
|
+
rule %r([-:<>+*%&|\^/!=]=?), Operator, :expr_start
|
133
|
+
rule %r/[(\[,]/, Punctuation, :expr_start
|
134
|
+
rule %r/;/, Punctuation, :statement
|
135
|
+
rule %r/[)\]}.]/, Punctuation
|
136
|
+
|
137
|
+
rule %r/[?]/ do
|
138
|
+
token Punctuation
|
139
|
+
push :ternary
|
140
|
+
push :expr_start
|
141
|
+
end
|
142
|
+
|
143
|
+
rule id do |m|
|
144
|
+
if self.class.keywords.include? m[0]
|
145
|
+
token Keyword
|
146
|
+
push :expr_start
|
147
|
+
elsif self.class.imports.include? m[0]
|
148
|
+
token Keyword
|
149
|
+
push :namespace
|
150
|
+
elsif self.class.declarations.include? m[0]
|
151
|
+
token Keyword::Declaration
|
152
|
+
push :expr_start
|
153
|
+
elsif self.class.reserved.include? m[0]
|
154
|
+
token Keyword::Reserved
|
155
|
+
elsif self.class.constants.include? m[0]
|
156
|
+
token Keyword::Constant
|
157
|
+
elsif self.class.builtins.include? m[0]
|
158
|
+
token Name::Builtin
|
159
|
+
else
|
160
|
+
token Name::Other
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
rule %r/\-?\d+\.\d+(?:[eE]\d+)?[fd]?/, Num::Float
|
165
|
+
rule %r/0x\h+/, Num::Hex
|
166
|
+
rule %r/\-?[0-9]+/, Num::Integer
|
167
|
+
rule %r/"/, Str::Double, :str_double
|
168
|
+
rule %r/'/, Str::Single, :str_single
|
169
|
+
end
|
170
|
+
|
171
|
+
# braced parts that aren't object literals
|
172
|
+
state :statement do
|
173
|
+
rule %r/(#{id})(\s*)(:)/ do
|
174
|
+
groups Name::Label, Text, Punctuation
|
175
|
+
end
|
176
|
+
|
177
|
+
mixin :expr_start
|
178
|
+
end
|
179
|
+
|
180
|
+
# object literals
|
181
|
+
state :object do
|
182
|
+
mixin :comments_and_whitespace
|
183
|
+
rule %r/[}]/ do
|
184
|
+
token Punctuation
|
185
|
+
goto :statement
|
186
|
+
end
|
187
|
+
|
188
|
+
rule %r/(#{id})(\s*)(:)/ do
|
189
|
+
groups Name::Attribute, Text, Punctuation
|
190
|
+
push :expr_start
|
191
|
+
end
|
192
|
+
|
193
|
+
rule %r/:/, Punctuation
|
194
|
+
mixin :root
|
195
|
+
end
|
196
|
+
|
197
|
+
state :metadata do
|
198
|
+
rule %r/(#{id})(\()?/ do |m|
|
199
|
+
groups Name::Decorator, Punctuation
|
200
|
+
pop! unless m[2]
|
201
|
+
end
|
202
|
+
rule %r/:#{id}(?:\.#{id})*/, Name::Decorator, :pop!
|
203
|
+
rule %r/\)/, Name::Decorator, :pop!
|
204
|
+
mixin :root
|
205
|
+
end
|
206
|
+
|
207
|
+
# ternary expressions, where <id>: is not a label!
|
208
|
+
state :ternary do
|
209
|
+
rule %r/:/ do
|
210
|
+
token Punctuation
|
211
|
+
goto :expr_start
|
212
|
+
end
|
213
|
+
|
214
|
+
mixin :root
|
215
|
+
end
|
216
|
+
|
217
|
+
state :str_double do
|
218
|
+
mixin :str_escape
|
219
|
+
rule %r/"/, Str::Double, :pop!
|
220
|
+
rule %r/[^\\"]+/, Str::Double
|
221
|
+
end
|
222
|
+
|
223
|
+
state :str_single do
|
224
|
+
mixin :str_escape
|
225
|
+
rule %r/'/, Str::Single, :pop!
|
226
|
+
rule %r/\$\$/, Str::Single
|
227
|
+
rule %r/\$#{id}/, Str::Interpol
|
228
|
+
rule %r/\$\{/, Str::Interpol, :str_interpol
|
229
|
+
rule %r/[^\\$']+/, Str::Single
|
230
|
+
end
|
231
|
+
|
232
|
+
state :str_escape do
|
233
|
+
rule %r/\\[\\tnr'"]/, Str::Escape
|
234
|
+
rule %r/\\[0-7]{3}/, Str::Escape
|
235
|
+
rule %r/\\x\h{2}/, Str::Escape
|
236
|
+
rule %r/\\u\h{4}/, Str::Escape
|
237
|
+
rule %r/\\u\{\h{1,6}\}/, Str::Escape
|
238
|
+
end
|
239
|
+
|
240
|
+
state :str_interpol do
|
241
|
+
rule %r/\}/, Str::Interpol, :pop!
|
242
|
+
mixin :root
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
@@ -0,0 +1,139 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
|
3
|
+
module Rouge
|
4
|
+
module Lexers
|
5
|
+
load_lexer 'sql.rb'
|
6
|
+
|
7
|
+
class HQL < SQL
|
8
|
+
title "HQL"
|
9
|
+
desc "Hive Query Language SQL dialect"
|
10
|
+
tag 'hql'
|
11
|
+
filenames '*.hql'
|
12
|
+
|
13
|
+
def self.keywords
|
14
|
+
# sources:
|
15
|
+
# https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL
|
16
|
+
# https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF
|
17
|
+
@keywords ||= Set.new(%w(
|
18
|
+
ADD ADMIN AFTER ANALYZE ARCHIVE ASC BEFORE BUCKET BUCKETS CASCADE
|
19
|
+
CHANGE CLUSTER CLUSTERED CLUSTERSTATUS COLLECTION COLUMNS COMMENT
|
20
|
+
COMPACT COMPACTIONS COMPUTE CONCATENATE CONTINUE DATA DATABASES
|
21
|
+
DATETIME DAY DBPROPERTIES DEFERRED DEFINED DELIMITED DEPENDENCY DESC
|
22
|
+
DIRECTORIES DIRECTORY DISABLE DISTRIBUTE ELEM_TYPE ENABLE ESCAPED
|
23
|
+
EXCLUSIVE EXPLAIN EXPORT FIELDS FILE FILEFORMAT FIRST FORMAT FORMATTED
|
24
|
+
FUNCTIONS HOLD_DDLTIME HOUR IDXPROPERTIES IGNORE INDEX INDEXES INPATH
|
25
|
+
INPUTDRIVER INPUTFORMAT ITEMS JAR KEYS KEY_TYPE LIMIT LINES LOAD
|
26
|
+
LOCATION LOCK LOCKS LOGICAL LONG MAPJOIN MATERIALIZED METADATA MINUS
|
27
|
+
MINUTE MONTH MSCK NOSCAN NO_DROP OFFLINE OPTION OUTPUTDRIVER
|
28
|
+
OUTPUTFORMAT OVERWRITE OWNER PARTITIONED PARTITIONS PLUS PRETTY
|
29
|
+
PRINCIPALS PROTECTION PURGE READ READONLY REBUILD RECORDREADER
|
30
|
+
RECORDWRITER REGEXP RELOAD RENAME REPAIR REPLACE REPLICATION RESTRICT
|
31
|
+
REWRITE RLIKE ROLE ROLES SCHEMA SCHEMAS SECOND SEMI SERDE
|
32
|
+
SERDEPROPERTIES SERVER SETS SHARED SHOW SHOW_DATABASE SKEWED SORT
|
33
|
+
SORTED SSL STATISTICS STORED STREAMTABLE STRING STRUCT TABLES
|
34
|
+
TBLPROPERTIES TEMPORARY TERMINATED TINYINT TOUCH TRANSACTIONS UNARCHIVE
|
35
|
+
UNDO UNIONTYPE UNLOCK UNSET UNSIGNED URI USE UTC UTCTIMESTAMP
|
36
|
+
VALUE_TYPE VIEW WHILE YEAR IF
|
37
|
+
|
38
|
+
ALL ALTER AND ARRAY AS AUTHORIZATION BETWEEN BIGINT BINARY BOOLEAN
|
39
|
+
BOTH BY CASE CAST CHAR COLUMN CONF CREATE CROSS CUBE CURRENT
|
40
|
+
CURRENT_DATE CURRENT_TIMESTAMP CURSOR DATABASE DATE DECIMAL DELETE
|
41
|
+
DESCRIBE DISTINCT DOUBLE DROP ELSE END EXCHANGE EXISTS EXTENDED
|
42
|
+
EXTERNAL FALSE FETCH FLOAT FOLLOWING FOR FROM FULL FUNCTION GRANT
|
43
|
+
GROUP GROUPING HAVING IF IMPORT IN INNER INSERT INT INTERSECT
|
44
|
+
INTERVAL INTO IS JOIN LATERAL LEFT LESS LIKE LOCAL MACRO MAP MORE
|
45
|
+
NONE NOT NULL OF ON OR ORDER OUT OUTER OVER PARTIALSCAN PARTITION
|
46
|
+
PERCENT PRECEDING PRESERVE PROCEDURE RANGE READS REDUCE REVOKE RIGHT
|
47
|
+
ROLLUP ROW ROWS SELECT SET SMALLINT TABLE TABLESAMPLE THEN TIMESTAMP
|
48
|
+
TO TRANSFORM TRIGGER TRUE TRUNCATE UNBOUNDED UNION UNIQUEJOIN UPDATE
|
49
|
+
USER USING UTC_TMESTAMP VALUES VARCHAR WHEN WHERE WINDOW WITH
|
50
|
+
|
51
|
+
AUTOCOMMIT ISOLATION LEVEL OFFSET SNAPSHOT TRANSACTION WORK WRITE
|
52
|
+
|
53
|
+
COMMIT ONLY REGEXP RLIKE ROLLBACK START
|
54
|
+
|
55
|
+
ABORT KEY LAST NORELY NOVALIDATE NULLS RELY VALIDATE
|
56
|
+
|
57
|
+
CACHE CONSTRAINT FOREIGN PRIMARY REFERENCES
|
58
|
+
|
59
|
+
DETAIL DOW EXPRESSION OPERATOR QUARTER SUMMARY VECTORIZATION WEEK YEARS MONTHS WEEKS DAYS HOURS MINUTES SECONDS
|
60
|
+
|
61
|
+
DAYOFWEEK EXTRACT FLOOR INTEGER PRECISION VIEWS
|
62
|
+
|
63
|
+
TIMESTAMPTZ ZONE
|
64
|
+
|
65
|
+
TIME NUMERIC
|
66
|
+
|
67
|
+
NAMED_STRUCT CREATE_UNION
|
68
|
+
|
69
|
+
ROUND BROUND FLOOR CEIL CEILING RAND EXP LN LOG10 LOG2 LOG POW POWER SQRT BIN
|
70
|
+
HEX UNHEX CONV ABS PMOD SIN ASIN COS ACOS TAN ATAN DEGREES RADIANS POSITIVE
|
71
|
+
NEGATIVE SIGN E PI FACTORIAL CBRT SHIFTLEFT SHIFTRIGHT SHIFTRIGHTUNSIGNED
|
72
|
+
GREATEST LEAST WIDTH_BUCKET SIZE SIZE MAP_KEYS MAP_VALUES ARRAY_CONTAINS
|
73
|
+
SORT_ARRAY BINARY CAST FROM_UNIXTIME UNIX_TIMESTAMP UNIX_TIMESTAMP
|
74
|
+
UNIX_TIMESTAMP TO_DATE YEAR QUARTER MONTH DAY DAYOFMONTH HOUR MINUTE SECOND
|
75
|
+
WEEKOFYEAR EXTRACT DATEDIFF DATE_ADD DATE_SUB FROM_UTC_TIMESTAMP
|
76
|
+
TO_UTC_TIMESTAMP CURRENT_DATE CURRENT_TIMESTAMP ADD_MONTHS LAST_DAY NEXT_DAY
|
77
|
+
TRUNC MONTHS_BETWEEN DATE_FORMAT IF ISNULL ISNOTNULL NVL COALESCE CASE WHEN
|
78
|
+
then else end NULLIF ASSERT_TRUE ASCII BASE64 CHARACTER_LENGTH CHR CONCAT
|
79
|
+
CONTEXT_NGRAMS CONCAT_WS CONCAT_WS DECODE ELT ENCODE FIELD FIND_IN_SET
|
80
|
+
FORMAT_NUMBER GET_JSON_OBJECT IN_FILE INSTR LENGTH LOCATE LOWER LCASE LPAD LTRIM
|
81
|
+
NGRAMS OCTET_LENGTH PARSE_URL PRINTF REGEXP_EXTRACT REGEXP_REPLACE REPEAT
|
82
|
+
REPLACE REVERSE RPAD RTRIM SENTENCES SPACE SPLIT STR_TO_MAP SUBSTR SUBSTRING
|
83
|
+
SUBSTRING_INDEX TRANSLATE TRIM UNBASE64 UPPER UCASE INITCAP LEVENSHTEIN SOUNDEX
|
84
|
+
MASK MASK_FIRST_N MASK_LAST_N MASK_SHOW_FIRST_N MASK_SHOW_LAST_N MASK_HASH
|
85
|
+
JAVA_METHOD REFLECT HASH CURRENT_USER LOGGED_IN_USER CURRENT_DATABASE MD5 SHA1
|
86
|
+
SHA CRC32 SHA2 AES_ENCRYPT AES_DECRYPT VERSION COUNT SUM AVG MIN MAX VARIANCE
|
87
|
+
VAR_POP VAR_SAMP STDDEV_POP STDDEV_SAMP COVAR_POP COVAR_SAMP CORR PERCENTILE
|
88
|
+
PERCENTILE_APPROX PERCENTILE_APPROX REGR_AVGX REGR_AVGY REGR_COUNT
|
89
|
+
REGR_INTERCEPT REGR_R2 REGR_SLOPE REGR_SXX REGR_SXY REGR_SYY HISTOGRAM_NUMERIC
|
90
|
+
COLLECT_SET COLLECT_LIST NTILE EXPLODE EXPLODE POSEXPLODE INLINE STACK
|
91
|
+
|
92
|
+
JSON_TUPLE PARSE_URL_TUPLE
|
93
|
+
|
94
|
+
XPATH XPATH_SHORT XPATH_INT XPATH_LONG XPATH_FLOAT XPATH_DOUBLE
|
95
|
+
XPATH_NUMBER XPATH_STRING GET_JSON_OBJECT JSON_TUPLE
|
96
|
+
|
97
|
+
PARSE_URL_TUPLE
|
98
|
+
))
|
99
|
+
end
|
100
|
+
|
101
|
+
def self.keywords_type
|
102
|
+
# source: https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Types
|
103
|
+
@keywords_type ||= Set.new(%w(
|
104
|
+
TINYINT SMALLINT INT INTEGER BIGINT FLOAT DOUBLE PRECISION DECIMAL NUMERIC
|
105
|
+
TIMESTAMP DATE INTERVAL
|
106
|
+
STRING VARCHAR CHAR
|
107
|
+
BOOLEAN BINARY
|
108
|
+
ARRAY MAP STRUCT UNIONTYPE
|
109
|
+
))
|
110
|
+
end
|
111
|
+
|
112
|
+
prepend :root do
|
113
|
+
# a double-quoted string is a string literal in Hive QL.
|
114
|
+
rule %r/"/, Str::Double, :double_string
|
115
|
+
|
116
|
+
# interpolation of variables through ${...}
|
117
|
+
rule %r/\$\{/, Name::Variable, :hive_variable
|
118
|
+
end
|
119
|
+
|
120
|
+
prepend :single_string do
|
121
|
+
rule %r/\$\{/, Name::Variable, :hive_variable
|
122
|
+
rule %r/[^\\'\$]+/, Str::Single
|
123
|
+
end
|
124
|
+
|
125
|
+
prepend :double_string do
|
126
|
+
rule %r/\$\{/, Name::Variable, :hive_variable
|
127
|
+
# double-quoted strings are string literals so need to change token
|
128
|
+
rule %r/"/, Str::Double, :pop!
|
129
|
+
rule %r/[^\\"\$]+/, Str::Double
|
130
|
+
end
|
131
|
+
|
132
|
+
state :hive_variable do
|
133
|
+
rule %r/\}/, Name::Variable, :pop!
|
134
|
+
rule %r/[^\}]+/, Name::Variable
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|