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 option to ignore parens in lisp/scheme block comments #80

Merged
merged 11 commits into from Jun 23, 2020

Conversation

mnacamura
Copy link
Contributor

@mnacamura mnacamura commented Jun 15, 2020

Closes #66
(This PL is built on top of #79, so please merge #79, if it is okay, before this.)

Scheme and Common Lisp support nested block comment:

#| depth 1 comment started
    #| depth 2 comment |#
    here is still in comment of depth 1
|#

This PL enables parinfer-rust to ignore parens inside the nested block comment.

For doing so, I did a bit of refactoring for function on_char() and now it dispatches depending not only on char but also on parser context (i.e., reading code, reading comment, reading string, reading Janet long string, etc.) It works fine for me practically but introduces a failing test case:

test indent_mode ... FAILED
test smart_mode ... ok

failures:

---- indent_mode stdout ----
thread 'indent_mode' panicked at 'assertion failed: `(left == right)`
  left: `"(let [a 1] ;\n  ret)"`,
 right: `String("(let [a 1]) ;\n  ret")`: case 538: text', tests/cases.rs:34:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.


failures:
    indent_mode

test result: FAILED. 8 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out

Looks like related to JSON serialization. @eraserhd Could you kindly give me any suggestion to fix this if you have time and if interested in this PL?Fixed!

@mnacamura mnacamura marked this pull request as draft June 16, 2020 06:25
@mnacamura mnacamura force-pushed the lisp-block-comment branch 2 times, most recently from b555ebf to 8eb0fc7 Compare June 16, 2020 11:52
Seems OK but test fails:

test indent_mode ... FAILED

failures:

---- indent_mode stdout ----
thread 'indent_mode' panicked at 'assertion failed: `(left == right)`
  left: `"(let [a 1] ;\n  ret)"`,
 right: `String("(let [a 1]) ;\n  ret")`: case 538: text', tests/cases.rs:34:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
@mnacamura
Copy link
Contributor Author

Another glitch has been found. Block comment in one line works:

(let ([x 1])
  #|comment|#
  x)

But in multi lines, it fails:

(let ([x 1
  #|com
  ment|#
  x)

@mnacamura
Copy link
Contributor Author

Fixed.

@mnacamura mnacamura marked this pull request as ready for review June 16, 2020 17:48
@eraserhd
Copy link
Owner

Thanks for this!

Please add an entry to CHANGELOG.adoc and add your name to "Contributors" in README.adoc if you like.

This happened because # was not recognized as closable by is_closable().
@mnacamura
Copy link
Contributor Author

I pushed (hopefully) the final bug fix for this PL and updated the documents. I feel really honored to be counted as a contributor. Thanks!

@eraserhd eraserhd merged commit 2998d32 into eraserhd:master Jun 23, 2020
@eraserhd
Copy link
Owner

Thank you for the work!

@mnacamura mnacamura deleted the lisp-block-comment branch June 24, 2020 00:10
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.

Block comment support?
2 participants