Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Special characters in rule names cause Uncaught SyntaxError #173

Open
rien opened this issue Nov 15, 2023 · 2 comments
Open

Special characters in rule names cause Uncaught SyntaxError #173

rien opened this issue Nov 15, 2023 · 2 comments

Comments

@rien
Copy link

rien commented Nov 15, 2023

I've encountered this issue when trying to load the node bindings of the tree-sitter-r parser with their 'next' branch. This grammar contains a lot of special symbols and as the node bindings generate a new class for each rule with its name, this causes an Uncaught SyntaxError when the class definition is evaled.

Now I've tried to fix this by creating a PR (r-lib/tree-sitter-r#64) renaming all rules with special characters, but this is not as desired since it renames most of the original grammar.

What do you recommend a a good solution here? Should rule names with special characters be disallowed in grammars? Or should the node bindings be able to cope with these special characters as token names?

@verhovsky
Copy link
Collaborator

verhovsky commented Nov 17, 2023

of course the Node bindings should be able to cope with arbitrary text in token names, whatever is supported by the regular library.

@amaanq
Copy link
Member

amaanq commented Nov 17, 2023

I partially disagree - rules shouldn't be named like that, it makes no sense and it would be correct to abstract those rules to a node containing the special character text. I would argue R's grammar is not exactly written in the "standard" tree-sitter way of writing grammars

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants