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

Fails on chained discard #45

Closed
SevereOverfl0w opened this issue Dec 5, 2019 · 3 comments · Fixed by #55
Closed

Fails on chained discard #45

SevereOverfl0w opened this issue Dec 5, 2019 · 3 comments · Fixed by #55
Labels
hammock needed More time is required to solve this

Comments

@SevereOverfl0w
Copy link

Discards can be "chained" in order to discard the following form also. Parcera is not correctly ignoring following forms.

To give an example:

{#_#_:a :b} => {}

But parcera creates this AST, note how the :b is not discarded as it would be by the Clojure Reader.

(:code                                                                               
 (:parcera.core/failure                                                              
  (:map                                                                              
   (:discard (:discard (:simple_keyword "a")))                                       
   (:whitespace " ")                                                                 
   (:simple_keyword "b"))))     
@SevereOverfl0w SevereOverfl0w changed the title Fails on double discard Fails on chained discard Dec 5, 2019
@carocad
Copy link
Owner

carocad commented Dec 5, 2019

This one is definitely very hard to solve 🤔

I am not sure how to make it such that discard would ignore the already discarded form ...

I might not even be able to support this 😞

@SevereOverfl0w
Copy link
Author

The string #_#_ occurs 40 times in my ~/src dir. It's used a lot while debugging.

@carocad
Copy link
Owner

carocad commented Dec 5, 2019

currently I see 3 options:

  • dont allow this at all since #_#_:a :b is the same as #_:a #_:b which is arguably clearer. However this would mean that parcera is not 100% compatible with Clojure which I would not like
  • find a way to make discard take multiple elements like [:discard [:discard [:keyword "a"]] [:keyword "b"]]. This seems very twisted since discard only ignores the next element not multiple ones so making this work on the grammar is .... hard to say the least
  • remove the requirement that discard applies to a form and instead allow it inline such that #_#_:a :b becomes [:discard] [:discard] [:keyword "a"] [:whitespace " "] [:keyword "b"] which is closer to reality but not easy to consume since it is hard to know what the 'next' element is.

The third option is so far my favourite but I will need some hammock time to get this straight

@carocad carocad added the hammock needed More time is required to solve this label Dec 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hammock needed More time is required to solve this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants