-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Swappable entry point Core._parse for Julia parser
Add Core._parse binding as the internal entry point for parsing of Julia code. This is called by both C and Julia code which wishes to parse Julia. For now, it points at the flisp parser by default. Refactor include() implementation to be done in Julia code, and parsing rearrangement: * Implement include() and include_string() in Julia. This also reunifies the versions of include() in MainInclude and Base which had started diverging. * Add internal Core.Compiler.fl_parse and set this as the default value of the Core._parse binding. * Use Core._parse from Meta * Add `Meta.parseall()` for top-level parsing. For now as an internal function, but this will likely be made public shortly. Refactoring in C runtime code: * Remove flisp code from jl_parse_eval_all. This makes the top level parse-lower-eval loop independent of flisp internals. * Remove jl_parse_eval_all from use as the include implementation (still used during bootstrap). This also allowed the removal of mapexpr handling from the C code. * Keep jl_load and jl_load_file_string from julia.h unchanged for compatibility with the existing C API. (No julia code `ccall`s these anymore) * Unify flisp parsing to always parse from string rather than directly from file.
- Loading branch information
Showing
18 changed files
with
426 additions
and
278 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# This file is a part of Julia. License is MIT: https://julialang.org/license | ||
|
||
# Call Julia's builtin flisp-based parser. `offset` is 0-based offset into the | ||
# byte buffer or string. | ||
function fl_parse(text::Union{Core.SimpleVector,String}, | ||
filename::String, offset, options) | ||
if text isa Core.SimpleVector | ||
# Will be generated by C entry points jl_parse_string etc | ||
text, text_len = text | ||
else | ||
text_len = sizeof(text) | ||
end | ||
ccall(:jl_fl_parse, Any, (Ptr{UInt8}, Csize_t, Any, Csize_t, Any), | ||
text, text_len, filename, offset, options) | ||
end | ||
|
||
function fl_parse(text::AbstractString, filename::AbstractString, offset, options) | ||
fl_parse(String(text), String(filename), offset, options) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.