-
Notifications
You must be signed in to change notification settings - Fork 3
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
Support for Koka v3 #2
Comments
I am currently working on modifying the grammar, and updating the highlighting rules to accommodate these changes. |
Thanks for the heads up :) I was almost gonna pick some of it up when I had the time |
A quick recommendation for anyone attempting to update things: I originally based the grammar off of this file in the upstream repository. There have been some problems with it becoming out of date with respect to the actual implementation at points, but it seems like it's been updated pretty recently, so maybe you can use that. |
Thanks for the advice. I am having success with just modifying the highlighting queries and making minimal changes to the grammar, but I still don't know, and hence cannot check the full extent of Koka's syntax. I will look into updating the grammar to help me understand the aforementioned. |
I am currently updating the grammar using the grammar of Koka's parser. However, I do not understand Koka's lexer (yet), nor the external scanner of tree-sitter-koka. Can someone else check if the latter needs to be updated? |
Great! About the lexer, the main thing that's special about it is the layout rule. I took a quick look at the recent changes to the diff --git a/src/scanner.c b/src/scanner.c
index ade02bd..f7579fe 100644
--- a/src/scanner.c
+++ b/src/scanner.c
@@ -245,10 +245,10 @@ AFTER_WHITESPACE:
case '&':
case '*':
case '+':
- case '@':
+ case '~':
+ case '#':
case '\\':
case '^':
- case '?':
case '.':
case '=':
case ')': Not 100% sure though. It's probably best if you add these changes, and finish yours, then run the parser on all of Koka's examples/tests to see if we fail to parse anything. If you see any failures that look layout related, then there might still be other stuff I have to fix in the lexer, so please ping me if that happens. Back when I was developing this I believe I used something like the following for testing: for file in $(find $KOKA_ROOT/{lib/std,samples,test,util} -name '*.kk'); do
if tree-sitter parse $file | grep ERROR >/dev/null; then
echo $file
fi
done |
I am writing a script that converts the Yacc grammar to a TS grammar file, because I think that is more maintainable. Once I finish that, it will probably be finished very soon. |
Ok, it might be worth checking if any of the existing yacc -> tree-sitter converters work, cause it looks like there are some projects for that already, though they might be out of date. |
I really only found one: miks1965/yacc-to-tree-sitter, but it is unusable per this issue |
Building a yacc to treesitter converter will take some more time, but I have previously improved the highlighting groups and the grammar, giving a decent result on modern koka. I can upload this as a temporary fix, if you want. |
Sure, if it's not too much work to push things, feel free to create a pull request. |
Koka 3 added some new syntactical features. See the samples/syntax folder for example cases.
I notice the highlighting doesn't quite work for at least these files:
https://github.com/koka-lang/koka/blob/dev/samples/syntax/contexts.kk
https://github.com/koka-lang/koka/blob/dev/samples/syntax/qualifiers.kk
https://github.com/koka-lang/koka/blob/dev/samples/syntax/implicits.kk
The text was updated successfully, but these errors were encountered: