Skip to content
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

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

bryankenote
Copy link
Contributor

@bryankenote bryankenote commented Jan 10, 2024

Fixes #70

@bryankenote
Copy link
Contributor Author

bryankenote commented Jan 10, 2024

Seeing these errors when trying to gen the lexer or parser

Some problems were found with the configuration of task ':generateLexer' (type 'GenerateLexerTask').
  - In plugin 'org.jetbrains.grammarkit' type 'org.jetbrains.grammarkit.tasks.GenerateLexerTask' property 'source' doesn't have a configured value.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
BUILD FAILED in 62ms
1 actionable task: 1 executed
Some problems were found with the configuration of task ':generateParser' (type 'GenerateParserTask').
  - In plugin 'org.jetbrains.grammarkit' type 'org.jetbrains.grammarkit.tasks.GenerateParserTask' property 'parserFile' doesn't have a configured value.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
BUILD FAILED in 60ms
1 actionable task: 1 executed

@jzbrooks
Copy link
Contributor

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 (generateFsdLexer) is still in there.

./gradlew tasks is misleading. It might be worthwhile to remove the grammar kit plugin from the build so it doesn't add those tasks to the project.

I typically used the grammar kit plugin in IntelliJ to regenerate the lexer and parser code.

Screenshot 2024-01-10 at 9 00 52 PM

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 method as a keyword in some syntactical contexts and as an annotation parameter name elsewhere (the HTTP annotation, I think).

@@ -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 }
Copy link
Contributor

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.

@bryankenote bryankenote marked this pull request as ready for review December 31, 2024 22:33
@@ -88,6 +88,7 @@ MARKDOWN_TEXT=.+
"errors" { yybegin(LIST_BODY); return ERRORS; }
"enum" { yybegin(LIST_BODY); return ENUM; }

";" { return SEMI; }
Copy link
Contributor Author

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.

@bryankenote
Copy link
Contributor Author

4d03012 Allows markdown to be lexicalized but the parser is having trouble with the first markdown header it sees.
Screenshot 2025-01-02 at 3 45 02 PM

Adding lookahead in the parser for markdown fixes this but then breaks at the end of the file.

(';' decorated_service_item* &markdown_remarks)

Screenshot 2025-01-03 at 11 56 16 AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Not parsing semicolon in namespace style service
2 participants