Introduce token modes - #127
Conversation
msujew
left a comment
There was a problem hiding this comment.
Nice! Can you resolve the merge conflict so we can check the performance in the GitHub CI? Locally, it seems to look good. Only a 2-3% loss on the statemachine example, which is acceptable.
|
@msujew I discovered a problem with my main grammar. The problem arises when I create a token mode and start to create token declarations within this token mode. As soon as I complete the word "token", the language server seems to end up in a endless loop. It does not react anymore. After completing the declaration and restarting the LS, it works. So the problem is during editing incomplete grammars :-/... The rule If I would refactor the grammar to have no common prefix in the subrules of Before I refactor it would be good to discuss whether these members have a good syntax or whether we should alternate it (which could remove the common prefix automatically). |
|
Ideas... Some quick fixes or code actions come into my mind:
Or
|
467be1d to
2996cda
Compare
There was a problem hiding this comment.
⚠️ Performance Alert ⚠️
Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.50.
| Benchmark suite | Current: 1ee2bcd | Previous: d803417 | Ratio |
|---|---|---|---|
BenchmarkWorkspaceCycle (typefox.dev/fastbelt/examples/statemachine) - MB/s |
11.92 MB/s |
5.21 MB/s |
2.29 |
This comment was automatically generated by workflow using github-action-benchmark.
No, it should fail out of the box. I can also complete this line as you started. But afterwards EDIT: I found out how to debug. Some kind of endless-loop in entered in this case. EDIT: Fixed the endless loop and another issue with the help of @msujew |
Lotes
left a comment
There was a problem hiding this comment.
Added some findings and also questions from my side.
msujew
left a comment
There was a problem hiding this comment.
Really solid contribution. Thanks a lot!
I noticed another few missing validations that we should add as part of this PR:
- Duplicate keyword/token definitions in the same token mode should result in an error. I.e. you can currently write
token mode default { "x" "x" }. - Similarly Token references should be unique in the same token mode. Right know, you can write something like
token mode default { hidden WS comment WS }without a validation error appearing. - When a token is declared, but not referenced in any token mode, the diagnostic appears on the first usage site. I would expect it on the token declaration itself. Also, similar to the keyword issue, this should be an error.
- A non-default token mode without a
popcommand should show a diagnostic.
# Conflicts: # internal/grammar/types_gen.go # Conflicts: # internal/grammar/types_gen.go
Signed-off-by: Markus Rudolph <markus.rudolph@typefox.io>
Signed-off-by: Markus Rudolph <markus.rudolph@typefox.io>
Signed-off-by: Markus Rudolph <markus.rudolph@typefox.io>
Signed-off-by: Markus Rudolph <markus.rudolph@typefox.io> # Conflicts: # lexer/lexer.go
Signed-off-by: Markus Rudolph <markus.rudolph@typefox.io>
Signed-off-by: Markus Rudolph <markus.rudolph@typefox.io>
Signed-off-by: Markus Rudolph <markus.rudolph@typefox.io>
Signed-off-by: Markus Rudolph <markus.rudolph@typefox.io>
Signed-off-by: Markus Rudolph <markus.rudolph@typefox.io>
Signed-off-by: Markus Rudolph <markus.rudolph@typefox.io>
Signed-off-by: Markus Rudolph <markus.rudolph@typefox.io>
Signed-off-by: Markus Rudolph <markus.rudolph@typefox.io>
Signed-off-by: Markus Rudolph <markus.rudolph@typefox.io>
Signed-off-by: Markus Rudolph <markus.rudolph@typefox.io>
Signed-off-by: Markus Rudolph <markus.rudolph@typefox.io>
Signed-off-by: Markus Rudolph <markus.rudolph@typefox.io>
17d7c0e to
557bdc7
Compare
Signed-off-by: Markus Rudolph <markus.rudolph@typefox.io>
msujew
left a comment
There was a problem hiding this comment.
Looking closer at some of the logic, I found some issues with some specific constellations. Works much better in general now, though!
Signed-off-by: Markus Rudolph <markus.rudolph@typefox.io>
Signed-off-by: Markus Rudolph <markus.rudolph@typefox.io>
Signed-off-by: Markus Rudolph <markus.rudolph@typefox.io>
Signed-off-by: Markus Rudolph <markus.rudolph@typefox.io>
Signed-off-by: Markus Rudolph <markus.rudolph@typefox.io>
Signed-off-by: Markus Rudolph <markus.rudolph@typefox.io>
Signed-off-by: Markus Rudolph <markus.rudolph@typefox.io>
Signed-off-by: Markus Rudolph <markus.rudolph@typefox.io>
Signed-off-by: Markus Rudolph <markus.rudolph@typefox.io>
Signed-off-by: Markus Rudolph <markus.rudolph@typefox.io>
Signed-off-by: Markus Rudolph <markus.rudolph@typefox.io>
There was a problem hiding this comment.
Good job @Lotes,
did a medium deep dive into this PR, Claude (Sonnet) did a much deeper one (the long headlined comments).
I like the tests you contributed a lot. However, esp. in the util tests I had trouble to get what the tested behavior is supposed to be.
Please add some docs, I left some remarks.
If the remarks provided by Claude don't make sense, feel free to ignore them.
(Maybe it's worth a comment, why they're invalid?)
Signed-off-by: Markus Rudolph <markus.rudolph@typefox.io>
Signed-off-by: Markus Rudolph <markus.rudolph@typefox.io>
Signed-off-by: Markus Rudolph <markus.rudolph@typefox.io>
Signed-off-by: Markus Rudolph <markus.rudolph@typefox.io>
Signed-off-by: Markus Rudolph <markus.rudolph@typefox.io>
Signed-off-by: Markus Rudolph <markus.rudolph@typefox.io>
Signed-off-by: Markus Rudolph <markus.rudolph@typefox.io>
Signed-off-by: Markus Rudolph <markus.rudolph@typefox.io>
Signed-off-by: Markus Rudolph <markus.rudolph@typefox.io>

Closes #50
push(name)to push a token mode onto the token mode stackpopto pop the topmost token modemode(name)to set the topmost token modeKeywordSelector