hhornbacher / node-scad-parser

Module to parse the abstract syntax tree of OpenSCAD files
5 stars 2 forks source link

Collaborate? #7

Open JeremyJStarcher opened 6 years ago

JeremyJStarcher commented 6 years ago

Just today I had started to map out how I would write an OpenSCAD -> JavaScript transpiler so I could rewrite OpenScad.net and get it working with the latest and greatest OpenSCAD versions.

When looking to see if anyone had written a parser, I stumbled across yours. I'm interested in the direction this project will take and if we might work at joining efforts.

hhornbacher commented 6 years ago

Hey Jeremy, I really appreciate, that you're interested into this project. I started programming the module to parse a syntax tree from a OpenSCAD file. I'm using this module in vscode-scad-integration, a plugin for VS Code to support code formatting, refactoring, definition lookup etc. for the OpenSCAD language. But this parser module should also be able to help with code generation, maybe as preprocessor and more advanced tasks, in future. The last months I didn't make any progress, but what's still missing at the moment for basic functionality is the parsing of if/else and switch statements. So if you're interested, and you think you could contribute in some way, it would be nice to join our efforts!

JeremyJStarcher commented 6 years ago

I've gone over your code and gotten a pretty good understanding of what you were doing.

I know nothing about the integration support I'm afraid, but it looks like you and I have different needs out of this.

I'm working on a more complete grammar set with the specific goal of code generation. In my learning, it also took me down the road of using moo as the tokenizer and I've stolen a large chunk of grammar out of a Yacc file and adapted it to OpenSCAD grammar.

I started work on just processing expression statements in the form of

a = (1 + 4) * 5;

but I think I'm good progress.

If you need that level of support, feel free to steal code from that. And if you actually need the whitespace tokens in your AST, let me know.

https://github.com/JeremyJStarcher/openscadtojs