You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"generate_parser_in_directory" generates spurious "grammar.js" and "package.json" files when "grammar_path" is specified but not equal to "<repo_path>/grammar.js".
#3300
Open
Imisnew2 opened this issue
Apr 15, 2024
· 3 comments
Spurious files are created by generate::generate_parser_in_directory under the following conditions:
grammar_path is Some, but not equal to "{repo_path}/grammar.js".
repo_path is a directory
It looks like this was introduced around 2 months ago by commit 9e5bf65. The fix seems to be: also check whether grammar_path was specified before generating the grammar.js and package.js.
Also note, right below the added code, there's two paths for calling load_grammar_file:
If grammar_path is specified, it uses that file.
If grammar_path is not specified, it uses "{repo_path}/grammar.js".
This seems to suggest that the grammar path should be used if present, otherwise fall-back to "{repo_path}/grammar.js". So, one fix would be to first compute the grammar path to use at the top of the function, then checking it later. Something like:
Problem
Spurious files are created by
generate::generate_parser_in_directory
under the following conditions:grammar_path
isSome
, but not equal to"{repo_path}/grammar.js"
.repo_path
is a directoryIt looks like this was introduced around 2 months ago by commit 9e5bf65. The fix seems to be: also check whether
grammar_path
was specified before generating thegrammar.js
andpackage.js
.Also note, right below the added code, there's two paths for calling
load_grammar_file
:grammar_path
is specified, it uses that file.grammar_path
is not specified, it uses"{repo_path}/grammar.js"
.This seems to suggest that the grammar path should be used if present, otherwise fall-back to
"{repo_path}/grammar.js"
. So, one fix would be to first compute the grammar path to use at the top of the function, then checking it later. Something like:Steps to reproduce
Create the following directory structure
Then invoke
generate_parser_in_directory
:Expected behavior
If
grammar_path
is specified and exists, skeletongrammar.js
andpackage.json
are not generated underrepo_path
.Tree-sitter version (tree-sitter --version)
tree-sitter-cli 0.22.2
Operating system/version
All Versions
The text was updated successfully, but these errors were encountered: