slackhq / tree-sitter-hack

Hack grammar for tree-sitter
MIT License
33 stars 16 forks source link

Add enum classes #44

Closed 4e554c4c closed 2 years ago

4e554c4c commented 2 years ago

Summary: This change adds support for enum classes (both abstract and regular) to the parser. These differ quite a bit from ordinary enums and each-other; so new rules have been written for each.

Fixes #43

Test Plan: tree-sitter test succeeds

Requirements (place an x in each [ ])

4e554c4c commented 2 years ago

Not sure why the validate test is failing. It seems to be running bin/generate-corpus and checking for new changes, but I cannot verify this on my end as there are no changes locally after running bin/generate-corpus.

4e554c4c commented 2 years ago

The validate task is failing because of the changes to expressions.txt. Generally, the sort order should be stable (sort should sort alphabetically by default) but your diff indicates otherwise. It may be an issue with whitespace/hyphens in the name, and could be probably be fixed by updating

https://github.com/slackhq/tree-sitter-hack/blob/330470222a9abbaeaa09d2e7964aeb16b90b7a34/bin/generate-corpus#L18 to use the -d flag with sort. However, any insight into why your machine is using a different sort order than ubuntu and macos (where our tests run)?

ugh, I was thinking that this might be the case after that file changed. I'm using sort (GNU coreutils) 8.32 on Fedora. Will try to make it match the test machines.... somehow.

4e554c4c commented 2 years ago

well, i fixed the issues on my end by setting LC_ALL="C". Not sure what's going on with the checks (is it also using my new LC_ALL="C" version of the script?)

frankeld commented 2 years ago

The error is coming from the change that adds TSStateId *primary_state_ids - you must be running a more recent version of tree-sitter. Our package.json entry implies that we are compatible with the 0.20.X versions but perhaps we should be using ~ instead of ^. I can also try to upgrade to the more recent version.