1
+ _debug_log = nothing
2
+
1
3
# Adaptor for the API/ABI expected by the Julia runtime code.
2
4
function core_parser_hook (code, filename, lineno, offset, options)
3
5
try
@@ -8,6 +10,15 @@ function core_parser_hook(code, filename, lineno, offset, options)
8
10
(ptr,len) = code
9
11
code = String (unsafe_wrap (Array, ptr, len))
10
12
end
13
+ if ! isnothing (_debug_log)
14
+ print (_debug_log, """
15
+ #-#-#-------------------------------
16
+ # ENTER filename=$filename , lineno=$lineno , offset=$offset , options=$options "
17
+ #-#-#-------------------------------
18
+ """ )
19
+ write (_debug_log, code)
20
+ end
21
+
11
22
io = IOBuffer (code)
12
23
seek (io, offset)
13
24
@@ -37,6 +48,14 @@ function core_parser_hook(code, filename, lineno, offset, options)
37
48
# of one cancel here.
38
49
last_offset = last_byte (stream)
39
50
51
+ if ! isnothing (_debug_log)
52
+ println (_debug_log, """
53
+ #-#-#-
54
+ # EXIT last_offset=$last_offset
55
+ #-#-#-
56
+ """ )
57
+ end
58
+
40
59
# Rewrap result in an svec for use by the C code
41
60
return Core. svec (ex, last_offset)
42
61
catch exc
@@ -67,6 +86,14 @@ flisp parser for all parsing work.
67
86
That is, JuliaSyntax will be used for `include()` `Meta.parse()`, the REPL, etc.
68
87
"""
69
88
function enable_in_core! (enable= true )
89
+ debug_filename = get (ENV , " JULIA_SYNTAX_DEBUG_FILE" , nothing )
90
+ global _debug_log
91
+ if enable && ! isnothing (debug_filename)
92
+ _debug_log = open (debug_filename, " w" )
93
+ elseif ! enable && ! isnothing (_debug_log)
94
+ close (_debug_log)
95
+ _debug_log = nothing
96
+ end
70
97
parser = enable ? core_parser_hook : Core. Compiler. fl_parse
71
98
Base. eval (Core, :(_parse = $ parser))
72
99
nothing
0 commit comments