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

Adding support for the OpenSCAD language #3532

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

Conversation

BenSiv
Copy link

@BenSiv BenSiv commented Nov 4, 2024

I added a syntax file for the language, plus a comment identifier for line commenting.

@@ -60,6 +60,7 @@ ft["yaml"] = "# %s"
ft["zig"] = "// %s"
ft["zscript"] = "// %s"
ft["zsh"] = "# %s"
ft["openscad"] = "// %s"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably go between "ocaml" and "pascal" to maintain the alphabetic ordering.


- constant: "\\b(pi|undef)\\b"

- identifier: "\\b($fn|$fa|$fs|$t|$children)\\b"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not familiar with OpenSCAD syntax but $ in regex marks the end of line so this is probably not what you want.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interestingly, it works properly without escaping the $ symbol. Perhaps it only sees it as "end of string" if it can be at the end of a string. I will test with it escaped and see if it still works with the change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, I was testing with my file, which does escape the $ symbol.

I withdraw my assertion that it works without escaping.

I got confused as to which syntax file the comment related to.

filename: "\\.scad$"

rules:
- statement: "\\b(module|function|include|use|let|for|if|else|true|false)\\b"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't true and false be constants?

@JoeKar
Copy link
Collaborator

JoeKar commented Nov 4, 2024

More or less a duplicate of #3410?

@BenSiv
Copy link
Author

BenSiv commented Nov 5, 2024 via email

@BenSiv
Copy link
Author

BenSiv commented Nov 5, 2024

Thank you for all your comments, I fixed the issues raised above.

@JoeKar
Copy link
Collaborator

JoeKar commented Nov 5, 2024

Could you please guide me on how to proceed with the PR process?

Maybe you have a look into the following two GitHub documentations:

  1. https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo
  2. https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork

Afterwards you edit the already existing scad.yaml and add the things you miss there. Then you can update this PR or close it and create a new one...depends what is easier for you to handle.

@BenSiv
Copy link
Author

BenSiv commented Nov 7, 2024

Thank you for the references, @JoeKar. I was asking about a specific issue here: as you mentioned, this seems to be a duplicate of a previous one that was resolved and merged to master, but the changes don't appear to be reflected in the repo.

@zyedidia, with your approval, I believe it's ready for merge now. Thank you for your time and consideration.

@Andriamanitra
Copy link
Contributor

@BenSiv It is definitely in the repo, maybe you missed it because the file is called scad.yaml instead of openscad.yaml like in this pull request? (Which is also why I didn't realize the syntax already exists when reviewing the PR.) Renaming it to openscad.yaml might be a good idea to be consistent with the other syntax files (nearly all of which are named after the language, not the file extension).

@BenSiv
Copy link
Author

BenSiv commented Nov 7, 2024

@Andriamanitra Thank you for your comment; you are absolutely right. I have merged the two files to the naming convention.

@JoeKar
Copy link
Collaborator

JoeKar commented Nov 7, 2024

@BenSiv It is definitely in the repo, maybe you missed it because the file is called scad.yaml instead of openscad.yaml like in this pull request?

That was the reason, why I referred to:

Afterwards you edit the already existing scad.yaml and add the things you miss there.

😉

Renaming it to openscad.yaml might be a good idea to be consistent with the other syntax files (nearly all of which are named after the language, not the file extension).

@jmcorey:
Does something speak against a rename of scad.yaml -> openscad.yaml, since you initially created the scad.yaml for #3410?
Furthermore it would be helpful if you can through your eyes on this PR for a review too, since you seem to use this language.

@jmcorey
Copy link
Contributor

jmcorey commented Nov 7, 2024

Thanks for the heads up! I hadn't noticed the conversation. I have no preference for whether the file is named openscad.yaml or scad.yaml. The actual files end in .scad rather than .openscad, though to be honest openscad is the main program that parses and recognizes these files, so I guess it reflects poorly on me that I couldn't figure out whether to call it scad or openscad. Probably just scad, but I'm fine either way.

@jmcorey
Copy link
Contributor

jmcorey commented Nov 7, 2024

As for whether it's ready to merge, there might be still more cleanup that could be done.

For example, I remember when I did my patch, I was encouraged to put all the statement keywords on one single line, rather than splitting it out based on abstract groupings, to reduce the overall number of rules in the file for the sake of efficiency. Right now, it looks like in the proposed file there are multiple different "statements" lines, and there is even duplication between them, for example see the "else" keyword.

It's also interesting that there's a numbers section in the middle of the file and one towards the end--suspect some duplication there as well, and am wondering if it's necessary to have them so far apart in the file.

@jmcorey
Copy link
Contributor

jmcorey commented Nov 7, 2024

When it's looking more like finished draft material, I'd be happy to help test. I assume there's no way to
do any kind of automated tests for these files...

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.

4 participants