Skip to content
16 changes: 8 additions & 8 deletions Tokenize/src/lexer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ function lex_comment(l::Lexer, doemit=true)
while true
pc = peekchar(l)
if pc == '\n' || eof(pc)
return doemit ? emit(l, Tokens.COMMENT) : EMPTY_TOKEN(token_type(l))
return doemit ? emit(l, Tokens.COMMENT) : EMPTY_TOKEN
end
readchar(l)
end
Expand All @@ -534,7 +534,7 @@ function lex_comment(l::Lexer, doemit=true)
n_start, n_end = 1, 0
while true
if eof(c)
return doemit ? emit_error(l, Tokens.EOF_MULTICOMMENT) : EMPTY_TOKEN(token_type(l))
return doemit ? emit_error(l, Tokens.EOF_MULTICOMMENT) : EMPTY_TOKEN
end
nc = readchar(l)
if c == '#' && nc == '='
Expand All @@ -543,7 +543,7 @@ function lex_comment(l::Lexer, doemit=true)
n_end += 1
end
if n_start == n_end
return doemit ? emit(l, Tokens.COMMENT) : EMPTY_TOKEN(token_type(l))
return doemit ? emit(l, Tokens.COMMENT) : EMPTY_TOKEN
end
pc = c
c = nc
Expand Down Expand Up @@ -852,25 +852,25 @@ function lex_prime(l, doemit = true)
else
if accept(l, '\'')
if accept(l, '\'')
return doemit ? emit(l, Tokens.CHAR) : EMPTY_TOKEN(token_type(l))
return doemit ? emit(l, Tokens.CHAR) : EMPTY_TOKEN
else
# Empty char literal
# Arguably this should be an error here, but we generally
# look at the contents of the char literal in the parser,
# so we defer erroring until there.
return doemit ? emit(l, Tokens.CHAR) : EMPTY_TOKEN(token_type(l))
return doemit ? emit(l, Tokens.CHAR) : EMPTY_TOKEN
end
end
while true
c = readchar(l)
if eof(c)
return doemit ? emit_error(l, Tokens.EOF_CHAR) : EMPTY_TOKEN(token_type(l))
return doemit ? emit_error(l, Tokens.EOF_CHAR) : EMPTY_TOKEN
elseif c == '\\'
if eof(readchar(l))
return doemit ? emit_error(l, Tokens.EOF_CHAR) : EMPTY_TOKEN(token_type(l))
return doemit ? emit_error(l, Tokens.EOF_CHAR) : EMPTY_TOKEN
end
elseif c == '\''
return doemit ? emit(l, Tokens.CHAR) : EMPTY_TOKEN(token_type(l))
return doemit ? emit(l, Tokens.CHAR) : EMPTY_TOKEN
end
end
end
Expand Down
4 changes: 1 addition & 3 deletions Tokenize/src/token.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ function Token(kind::Kind, startbyte::Int, endbyte::Int)
end
Token() = Token(ERROR, 0, 0, UNKNOWN, false, false)


const _EMPTY_RAWTOKEN = Token()
EMPTY_TOKEN(::Type{Token}) = _EMPTY_RAWTOKEN
const EMPTY_TOKEN = Token()

function kind(t::Token)
isoperator(t.kind) && return OP
Expand Down
2 changes: 1 addition & 1 deletion Tokenize/src/token_kinds.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@enum(Kind,
@enum(Kind::UInt16,
NONE, # Placeholder; never emitted by lexer
ENDMARKER, # EOF
ERROR,
Expand Down
4 changes: 0 additions & 4 deletions src/green_tree.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ children(node::GreenNode) = node.args
span(node::GreenNode) = node.span
head(node::GreenNode) = node.head

# Predicates
is_trivia(node::GreenNode) = is_trivia(node.head)
is_error(node::GreenNode) = is_error(node.head)

Base.summary(node::GreenNode) = summary(node.head)

# Pretty printing
Expand Down
Loading