Skip to content

code lines removed with partial line comment #63

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

Closed
loziniak opened this issue Nov 28, 2022 · 5 comments
Closed

code lines removed with partial line comment #63

loziniak opened this issue Nov 28, 2022 · 5 comments

Comments

@loziniak
Copy link
Member

loziniak commented Nov 28, 2022

I'm trying to add Red support for extractor.
During CI tests extractor removed these lines altogether, not only comments and trailing whitespace:

x: 1 ; line comment 1
x: 2   ;-- line comment 2
x: 3		;@@ line comment 3

see discussion

My language config looks like this:

!e
;\p
Red [\p-->>]\pj
Red +[\p-->>]\pj
comment [\p-->>]\pj
comment +[\p-->>]\pj
comment {\p-->>}\pj
comment +{\p-->>}\pj
@ErikSchierboom
Copy link
Member

@joshiraez Thoughts?

@joshiraez
Copy link
Collaborator

Looking at it.

@joshiraez
Copy link
Collaborator

joshiraez commented Dec 16, 2022

Ok so the problem is in this rule. I'm having problems setting the code up (I'm etting problems with the json library just like in old times in this laptop and ashdkjahejknsakjdnskjad I'll get to slack to get support eventually as I plan to do some progress on this during xmas, but i'm digressing) but from the trace I'm quite sure this is what's happening

So Red [\j-->]\pj is parsed as follows.

Look for Red[ and skip it. (It's just, it's looking for something even if there's no whitespace)
Look for a \n, and skip the whole line up to that point. (There's no "partial" flag, so it will look for the next line break before anything else)
Look, in the following lines, for ] (Just)
As it's a "partial" clause, remove up until after the second token is found.

This means that in the test case:

          Red [] ; a comment
          ; single line comment
          x: 1 ; line comment 1
          x: 2   ;-- line comment 2
          x: 3		;@@ line comment 3
          comment ['this
          	'is 'multiline
          	'comment]
          comment   {and this
          	as well}
          function add100 [x [integer!]] [
          	"; this should not count as comment "
          	{ comment [and neither
          	 this] }
          ]

What is being skipped by that rule is this:

          *Red [**** -->>**] ; a comment
          ; single line comment
          x: 1 ; line comment 1
          x: 2   ;-- line comment 2
          x: 3		;@@ line comment 3
          comment ['this
          	'is 'multiline
          	'comment-**->>****]*
          comment   {and this
          	as well}
          function add100 [x [integer!]] [
          	"; this should not count as comment "
          	{ comment [and neither
          	 this] }
          ]

In fact with the current rules this will be the result I believe

          function add100 [x [integer!]] [
          	"
          	{ }
          ]

It should work if you set the just flag for everyone (this is something I have had in mind for a while and plan on "improve" in the new version of the extended extractor). I'm thinking on how to avoid the inside comments right now.

!e
;\p
Red [\pj-->>]\pj
Red +[\pj-->>]\pj
comment [\pj-->>]\pj
comment +[\pj-->>]\pj
comment {\pj-->>}\pj
comment +{\pj-->>}\pj

I can't try it out right now (because the project doesn't compile in my pc because it can't find the json library and ahhgahghagh) but please try that out and tell me if it works.

Also the second part, it's really not supported right now in the extractor as we have no way to tell it "hey, don't parse stuff in string literals". I have been thinking about that also, to add some kind of negative to skip places where it shouldn't parse. I'm seeing now that it'll have to be supported

Also sorry it took this so long but I moved recently ON TOP OF EVERYTHING so I barely have any time these days. I'll work on the snippet extractor as well with some new ideas that should help with this.

@loziniak
Copy link
Member Author

Hi! Thanks for looking at this. I did not expect string bypass to work, I just wanted to emphasize the issue. I'll check your language setup in a minute.

loziniak added a commit to loziniak/snippet-extractor that referenced this issue Dec 18, 2022
loziniak added a commit to loziniak/snippet-extractor that referenced this issue Dec 18, 2022
loziniak added a commit to loziniak/snippet-extractor that referenced this issue Dec 18, 2022
@loziniak
Copy link
Member Author

This seems to be OK now. Closing, thanks.

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

No branches or pull requests

3 participants