Skip to content

Commit 2b4f52e

Browse files
authored
Make is_error and K"" macro consistent with new lexer error kinds (#20)
1 parent f310f60 commit 2b4f52e

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

src/parse_stream.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ kind(x) = kind(head(x))
9292
flags(x) = flags(head(x))
9393

9494
# Predicates based on kind() / flags()
95-
is_error(x) = kind(x) == K"error"
95+
is_error(x) = is_error(kind(x))
9696
has_flags(x, test_flags) = has_flags(flags(x), test_flags)
9797
is_trivia(x) = has_flags(x, TRIVIA_FLAG)
9898
is_infix(x) = has_flags(x, INFIX_FLAG)

src/token_kinds.jl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,24 @@ const _str_to_kind = let Ts = TzTokens
77
Dict([
88
"None" => Ts.NONE
99
"EndMarker" => Ts.ENDMARKER
10-
"error" => Ts.ERROR
1110
"Comment" => Ts.COMMENT
1211
"Whitespace" => Ts.WHITESPACE
1312
"Identifier" => Ts.IDENTIFIER
1413
"@" => Ts.AT_SIGN
1514
"," => Ts.COMMA
1615
";" => Ts.SEMICOLON
1716

17+
"BEGIN_ERRORS" => Ts.begin_errors
18+
# Tokenization errors
19+
"ErrorEofMultiComment" => Ts.EOF_MULTICOMMENT
20+
"ErrorEofChar" => Ts.EOF_CHAR
21+
"ErrorInvalidNumericConstant" => Ts.INVALID_NUMERIC_CONSTANT
22+
"ErrorInvalidOperator" => Ts.INVALID_OPERATOR
23+
"ErrorInvalidInterpolationTerminator" => Ts.INVALID_INTERPOLATION_TERMINATOR
24+
# Generic error
25+
"error" => Ts.ERROR
26+
"END_ERRORS" => Ts.end_errors
27+
1828
"BEGIN_KEYWORDS" => Ts.begin_keywords
1929
"baremodule" => Ts.BAREMODULE
2030
"begin" => Ts.BEGIN

src/tokens.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ kind(raw::TzTokens.Token) = TzTokens.exactkind(raw)
4343
# Some renaming for naming consistency
4444
is_literal(k) = TzTokens.isliteral(kind(k))
4545
is_keyword(k) = TzTokens.iskeyword(kind(k))
46-
is_error(k) = TzTokens.iserror(kind(k))
46+
is_error(k::Kind) = TzTokens.iserror(k)
4747
is_contextual_keyword(k) = TzTokens.iscontextualkeyword(kind(k))
4848
is_operator(k) = TzTokens.isoperator(kind(k))
4949
is_word_operator(k) = TzTokens.iswordoperator(kind(k))

0 commit comments

Comments
 (0)