-
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
add optional semicolon to cfg #71
base: master
Are you sure you want to change the base?
Conversation
e73211e
to
4d48f58
Compare
Seeing these errors when trying to gen the lexer or parser
|
Early on I tried using the grammar kit's grade plugin to do that generation. IIRC, at some point or other those tasks even ran automatically during the build so generated code was always ephemeral, which was nice. Memory is fuzzy but I bailed on that because the plugin didn't support some features of grammar kit. #1 (comment) The bespoke lexer generator task (
I typically used the grammar kit plugin in IntelliJ to regenerate the lexer and parser code. You're probably going to need to update _FsdLexer.flex also. It annoyed me that the lexer was so involved, but it was the best way I could come up with to correctly tokenize |
@@ -42,7 +42,7 @@ | |||
|
|||
definition ::= (attribute_list* service_spec) markdown_remarks* | |||
|
|||
service_spec ::= service identifier service_items { pin=1 } | |||
service_spec ::= (service identifier service_items[';']) { pin=1 } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--- a/src/main/kotlin/io/github/facilityapi/intellij/fsd.bnf
+++ b/src/main/kotlin/io/github/facilityapi/intellij/fsd.bnf
@@ -42,8 +42,7 @@
definition ::= (attribute_list* service_spec) markdown_remarks*
-service_spec ::= service identifier service_items { pin=1 }
-service_items ::= ('{' decorated_service_item* '}') | decorated_service_item
+service_spec ::= (service identifier ';' decorated_service_item*) | (service identifier '{' decorated_service_item* '}') { pin=1 }
Will probably need something like this.
You get a good deal of control around how IntelliJ should handle invalid parser states, which is helpful for error messages in the editor. It definitely had some room for improvement before, but it's something else you might consider. That's what the pin and recoverWhile bits are about.
4d48f58
to
a9fa4e3
Compare
a9fa4e3
to
6124850
Compare
@@ -88,6 +88,7 @@ MARKDOWN_TEXT=.+ | |||
"errors" { yybegin(LIST_BODY); return ERRORS; } | |||
"enum" { yybegin(LIST_BODY); return ENUM; } | |||
|
|||
";" { return SEMI; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still doesn't account for markdown after the service body when braces are not used. This is tricky since rather than looking for both service member items and markdown items simultaneously, we look for only service member items then only markdown items when the service body is finished. The lexer works when curly braces are used because it knows when the service body is finished when it sees the right curly brace. This has been nuanced in the other parsers as well.
4d03012 Allows markdown to be lexicalized but the parser is having trouble with the first markdown header it sees. Adding lookahead in the parser for markdown fixes this but then breaks at the end of the file.
|
This reverts commit f6129f0.
Fixes #70