-
Notifications
You must be signed in to change notification settings - Fork 119
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
Fix sail-fmt block_comment indent #581
Conversation
Documentation comments are attached to the definitions they are associated with in the AST. Each top-level definition is annotated with a value of type Line 126 in 1edb36b
When pattern matching on a toplevel definition you do something like match def with
| DEF_aux (def, def_annot) -> (* def here is the actual definition within the aux wrapper *)
let comment = def_annot.doc_comment in You therefore don't need to add documentation comments to the 'Doc' in the lexer is the token type for a documentation comment, there are then rules in the parser that create documented definitions like:
the initial_check desugaring pass removes the separate Line 1305 in 1edb36b
Finally, the reason why the rule looks like:
is because in Menhir the lexbuf positions are used to get the span information in each parsing rule. Ocamllex will automatically advance the lexbuf positions as it scans the documentation comment using the doc_comment rule, but we want menhir to see |
Actually in the context of the formatter you can ignore what I said about def_annot and DEF_aux, as it is run on the AST before |
I fixed the bug that caused documentation comments to fail here: #592 Should also mean they appear in the formatted output, although there may be indentation issues if whatever they are commenting is indented. |
Looks good. I tried to modify ast before and added a DEF_doc_only to distinguish DEF_doc, and it also worked. |
Hi, update here the new code intend to fix indent issue
|
close, because #619 merged |
Hi, I'm going to test sail-fmt on riscv-sails
like this PR did riscv/sail-riscv#264, and then try to fix them one by one
This PR is for fix an error when formatting something like
seems to be related to #237
I have a few questions, could you explain
lexbuf.lex_start_p <- startpos;
it looks strange