Closed ahelwer closed 9 months ago
This functionality is now implemented in the easy cases, where a keyword like ASSUME
or VARIABLE
or ----
or LOCAL
or whatever is encountered - it is unambiguously the beginning of a unit definition so the jlist is ended. See the implementation here and tests here (and duplicates in junctlist.txt). Note the interesting case that has to be handled to disambiguate between the ->
and ----
tokens here (caught with a test failure). The remaining cases, things like op(x, y) == e
and a \oplus b == e
, will take more work and are put off for now.
Need to be careful since some unit keywords can also occur inside LET/IN constructs. For example, RECURSIVE
and INSTANCE
.
There are possibly some additional keywords that require jlists to be terminated; see https://github.com/tlaplus-community/tree-sitter-tlaplus/issues/24#issuecomment-891305885
The state of this issue is that it is basically tractable, but extremely annoying due to all the C++ code that would have to be written in the external scanner to handle it:
id bound_infix_op_symbol id
of the many infix op symbols, their alternatives, and their unicode alternativesThis could possibly be accomplished using a notify feature and making DEDENT
tokens optional. It is on hold for now, as like https://github.com/tlaplus-community/tree-sitter-tlaplus/issues/9 it basically is only useful to handle the case of users indenting their spec in a really weird way.
Basically too much trouble and it's fine because 99% of people start new module-level definitions at the start of the line.
Implement logic in function https://github.com/tlaplus-community/tree-sitter-tlaplus/blob/a74a18b4e74ff5144ec288dbb0aab3e232df633d/src/scanner.cc#L111
This will handle the strange case where someone begins defining a new module-level unit definition as follows, instead of at the start of the next line:
A half-assed first attempt at this lives in the jlists-unit-termination branch. Shelved until I learn more about how to write a parser.
This would probably be easy to accomplish for constructs that are unambiguously new module units (
ASSUME
,LOCAL
, etc.) but more difficult for things likea \oplus b == expr
.