Add support for formatting escript files #102
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #101
Copilot generated summary
This pull request introduces significant changes to the tokenizer implementation in the
efmt_core
library, replacing the use oferl_tokenize::Tokenizer
with a customTokenizer
that handles shebang lines. Additionally, support for.escript
files has been added. Here are the most important changes:Tokenizer Implementation:
efmt_core/src/lib.rs
: Replacederl_tokenize::Tokenizer
with the newTokenizer
in theformat_text
function.efmt_core/src/parse.rs
: AddedTokenOrShebang
andTokenizer
modules and made them publicly available.efmt_core/src/parse/token_stream.rs
: UpdatedTokenStream
to use the newTokenizer
and handleTokenOrShebang
variants. [1] [2] [3] [4]efmt_core/src/parse/tokenizer.rs
: Implemented the newTokenizer
struct andTokenOrShebang
enum to handle shebang lines.Support for
.escript
Files:src/files.rs
: Added.escript
to the list of format targets and updated the tokenizer usage. [1] [2] [3]src/lib.rs
: Updated theformat_file
andformat_text
functions to use the newTokenizer
. [1] [2]tests/lib.rs
: Added.escript
to the test file extensions.tests/testdata/factorial.escript
: Added a test.escript
file for factorial calculation.