Skip to content

Commit cc760b3

Browse files
authored
Fixes for JuliaSyntax in Core / sysimage (#41)
* Fix copying of Tokenize source (clash with refactoring in #40) * Ensure the previous default parser is restored by `enable_in_core!()`. This could be other than Core.Compiler.fl_parse if we're using JuliaSyntax.jl to develop itself :)
1 parent 9a9f57d commit cc760b3

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

src/hooks.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ end
8282
# `Expr(:error)`.
8383
Base.Meta.ParseError(e::JuliaSyntax.ParseError) = e
8484

85+
const _default_parser = Core._parse
86+
8587
"""
8688
Connect the JuliaSyntax parser to the Julia runtime so that it replaces the
8789
flisp parser for all parsing work.
@@ -97,7 +99,7 @@ function enable_in_core!(enable=true)
9799
close(_debug_log)
98100
_debug_log = nothing
99101
end
100-
parser = enable ? core_parser_hook : Core.Compiler.fl_parse
102+
parser = enable ? core_parser_hook : _default_parser
101103
Base.eval(Core, :(_parse = $parser))
102104
nothing
103105
end

src/parse_stream.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ function untokenize(head::SyntaxHead; unique=true, include_flag_suff=true)
8484
end
8585

8686
#-------------------------------------------------------------------------------
87-
# Generic interface for types `T` which have kind and flags:
88-
# 1. Define kind(::T) and flags(::T) directly
87+
# Generic interface for types `T` which have kind and flags. Either:
88+
# 1. Define kind(::T) and flags(::T), or
8989
# 2. Define head(::T) to return a type like `SyntaxKind` for which `kind` and
9090
# `flags` are defined
9191
kind(x) = kind(head(x))

sysimage/compile.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ cd(@__DIR__)
1717
rm("JuliaSyntax", force=true, recursive=true)
1818
mkdir("JuliaSyntax")
1919
cp("../src", "JuliaSyntax/src")
20+
cp("../Tokenize", "JuliaSyntax/Tokenize")
2021
cp("../test", "JuliaSyntax/test")
2122
projstr = replace(read("../Project.toml", String),
2223
"70703baa-626e-46a2-a12c-08ffd08c73b4"=>"54354a4c-6cac-4c00-8566-e7c1beb8bfd8")

0 commit comments

Comments
 (0)