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

Modify the parser to handle the files from the BOSL2 library. #109

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

Conversation

icaven
Copy link

@icaven icaven commented May 17, 2024

The problem

The BOSL2 library has many useful features, and some of them require that the usual modules be overridden by functions supplied by the library, something that is supported by the OpenSCAD language. This leads to the plug-in not being able to parse the files, which leads to problems when editing code that uses the library (for example, code that is copied and pasted doesn't format properly).

The solution

To add the support for the library, I changed the recognition of some of the keywords in the lexer (circle, cube, cylinder, sphere, square, translate, scale, offset, mirror, hull, union, intersection, and difference), and allow the parser to determine them as overridable functions or modules. I have also extended the BNF grammar to account for other valid OpenSCAD statements that the library uses. I have extended the test suite to highlight most of these cases, by extracting the essence of them from BOSL2.

Comment out keywords in lexer that are overridden in BOSL2.
Update the tests.
icaven added 3 commits June 11, 2024 09:24
…ous issue).

Add an element in the parser to abstract assert and echo calls.

Flag as an error repeated commas.
Update the tests.
…, scale, etc. in the lexer.

This will allow these keywords to be highlighted.  These are now parsed as overridable keywords.

Modify the indentation of non-block statements.  This means that child operations are not indented unless surrounded by braces.

Update the tests.
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.

1 participant