Skip to content

Commit a3d1a6b

Browse files
authored
Fix is_number() predicate to include Bool and clean up (#498)
1 parent 30109d4 commit a3d1a6b

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

src/kinds.jl

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,15 @@ register_kinds!(JuliaSyntax, 0, [
254254
"END_KEYWORDS"
255255

256256
"BEGIN_LITERAL"
257-
"Bool"
258-
"Integer"
259-
"BinInt"
260-
"HexInt"
261-
"OctInt"
262-
"Float"
263-
"Float32"
257+
"BEGIN_NUMBERS"
258+
"Bool"
259+
"Integer"
260+
"BinInt"
261+
"HexInt"
262+
"OctInt"
263+
"Float"
264+
"Float32"
265+
"END_NUMBERS"
264266
"String"
265267
"Char"
266268
"CmdString"
@@ -1114,6 +1116,7 @@ const _nonunique_kind_names = Set([
11141116
K"ErrorBidiFormatting"
11151117
K"ErrorInvalidOperator"
11161118

1119+
K"Bool"
11171120
K"Integer"
11181121
K"BinInt"
11191122
K"HexInt"
@@ -1176,17 +1179,18 @@ is_error(k::Kind) = K"BEGIN_ERRORS" <= k <= K"END_ERRORS" || k == K"ErrorInvalid
11761179
is_keyword(k::Kind) = K"BEGIN_KEYWORDS" <= k <= K"END_KEYWORDS"
11771180
is_block_continuation_keyword(k::Kind) = K"BEGIN_BLOCK_CONTINUATION_KEYWORDS" <= k <= K"END_BLOCK_CONTINUATION_KEYWORDS"
11781181
is_literal(k::Kind) = K"BEGIN_LITERAL" <= k <= K"END_LITERAL"
1182+
is_number(k::Kind) = K"BEGIN_NUMBERS" <= k <= K"END_NUMBERS"
11791183
is_operator(k::Kind) = K"BEGIN_OPS" <= k <= K"END_OPS"
11801184
is_word_operator(k::Kind) = (k == K"in" || k == K"isa" || k == K"where")
11811185

1182-
is_identifier(k) = is_identifier(kind(k))
1183-
is_contextual_keyword(k) = is_contextual_keyword(kind(k))
1184-
is_error(k) = is_error(kind(k))
1185-
is_keyword(k) = is_keyword(kind(k))
1186-
is_literal(k) = is_literal(kind(k))
1187-
is_operator(k) = is_operator(kind(k))
1188-
is_word_operator(k) = is_word_operator(kind(k))
1189-
1186+
is_identifier(x) = is_identifier(kind(x))
1187+
is_contextual_keyword(x) = is_contextual_keyword(kind(x))
1188+
is_error(x) = is_error(kind(x))
1189+
is_keyword(x) = is_keyword(kind(x))
1190+
is_literal(x) = is_literal(kind(x))
1191+
is_number(x) = is_number(kind(x))
1192+
is_operator(x) = is_operator(kind(x))
1193+
is_word_operator(x) = is_word_operator(kind(x))
11901194

11911195
# Predicates for operator precedence
11921196
# FIXME: Review how precedence depends on dottedness, eg
@@ -1215,10 +1219,6 @@ is_syntax_kind(x) = K"BEGIN_SYNTAX_KINDS"<= kind(x) <= K"END_SYNTAX_KINDS"
12151219
is_macro_name(x) = K"BEGIN_MACRO_NAMES" <= kind(x) <= K"END_MACRO_NAMES"
12161220
is_syntactic_assignment(x) = K"BEGIN_SYNTACTIC_ASSIGNMENTS" <= kind(x) <= K"END_SYNTACTIC_ASSIGNMENTS"
12171221

1218-
function is_number(x)
1219-
kind(x) in (K"Integer", K"BinInt", K"HexInt", K"OctInt", K"Float", K"Float32")
1220-
end
1221-
12221222
function is_string_delim(x)
12231223
kind(x) in (K"\"", K"\"\"\"")
12241224
end

0 commit comments

Comments
 (0)