Skip to content

Commit 950b730

Browse files
committed
Tokenize: Add doc contextural keyword
1 parent f411224 commit 950b730

File tree

3 files changed

+38
-29
lines changed

3 files changed

+38
-29
lines changed

Tokenize/src/lexer.jl

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,8 +1142,6 @@ function simple_hash(str)
11421142
end
11431143

11441144
kws = [
1145-
Tokens.ABSTRACT,
1146-
Tokens.AS,
11471145
Tokens.BAREMODULE,
11481146
Tokens.BEGIN,
11491147
Tokens.BREAK,
@@ -1165,22 +1163,26 @@ Tokens.LET,
11651163
Tokens.LOCAL,
11661164
Tokens.MACRO,
11671165
Tokens.MODULE,
1168-
Tokens.MUTABLE,
1169-
Tokens.OUTER,
1170-
Tokens.PRIMITIVE,
11711166
Tokens.QUOTE,
11721167
Tokens.RETURN,
11731168
Tokens.STRUCT,
11741169
Tokens.TRY,
1175-
Tokens.TYPE,
11761170
Tokens.USING,
1177-
Tokens.VAR,
11781171
Tokens.WHILE,
11791172
Tokens.IN,
11801173
Tokens.ISA,
11811174
Tokens.WHERE,
11821175
Tokens.TRUE,
11831176
Tokens.FALSE,
1177+
1178+
Tokens.ABSTRACT,
1179+
Tokens.AS,
1180+
Tokens.DOC,
1181+
Tokens.MUTABLE,
1182+
Tokens.OUTER,
1183+
Tokens.PRIMITIVE,
1184+
Tokens.TYPE,
1185+
Tokens.VAR,
11841186
]
11851187

11861188
const kw_hash = Dict(simple_hash(lowercase(string(kw))) => kw for kw in kws)

Tokenize/src/token_kinds.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
begin_contextural_keywords,
4141
ABSTRACT,
4242
AS,
43+
DOC,
4344
MUTABLE,
44-
NEW,
4545
OUTER,
4646
PRIMITIVE,
4747
TYPE,

Tokenize/test/lexer.jl

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,7 @@ end
234234
end
235235

236236
@testset "keywords" begin
237-
for kw in ["function",
238-
"abstract",
239-
"as",
240-
"baremodule",
237+
for kw in ["baremodule",
241238
"begin",
242239
"break",
243240
"catch",
@@ -248,27 +245,31 @@ end
248245
"elseif",
249246
"end",
250247
"export",
251-
#"false",
252248
"finally",
253249
"for",
254250
"function",
255251
"global",
256-
"let",
257-
"local",
258252
"if",
259253
"import",
254+
"let",
255+
"local",
260256
"macro",
261257
"module",
262-
"mutable",
263-
"primitive",
264258
"quote",
265259
"return",
266260
"struct",
267-
#"true",
268261
"try",
269-
"type",
270262
"using",
271-
"while"]
263+
"while",
264+
265+
"abstract",
266+
"as",
267+
"doc",
268+
"mutable",
269+
"outer",
270+
"primitive",
271+
"type",
272+
"var"]
272273

273274
@test T.kind(tok(kw)) == T.KEYWORD
274275
end
@@ -752,8 +753,8 @@ end
752753
@test all(s->Base.isoperator(Symbol(s)) == Tokens.isoperator(first(collect(tokenize(s))).kind), allops)
753754
end
754755

755-
const all_kws = Set(["abstract",
756-
"as",
756+
const all_kws = Set([
757+
# Keywords
757758
"baremodule",
758759
"begin",
759760
"break",
@@ -775,22 +776,28 @@ const all_kws = Set(["abstract",
775776
"local",
776777
"macro",
777778
"module",
778-
"mutable",
779-
"outer",
780-
"primitive",
781779
"quote",
782780
"return",
783781
"struct",
784782
"try",
785-
"type",
786783
"using",
787784
"while",
788-
"in",
789-
"isa",
785+
# Contextural keywords
786+
"abstract",
787+
"as",
788+
"doc",
789+
"mutable",
790+
"outer",
791+
"primitive",
792+
"type",
790793
"var",
791-
"where",
794+
# Literals
792795
"true",
793796
"false",
797+
# Word-like operators
798+
"in",
799+
"isa",
800+
"where",
794801
])
795802

796803
function check_kw_hashes(iter)

0 commit comments

Comments
 (0)