diff --git a/src/lib/openSCAD/parseParameter.ts b/src/lib/openSCAD/parseParameter.ts index 7bf98da..4aee53f 100644 --- a/src/lib/openSCAD/parseParameter.ts +++ b/src/lib/openSCAD/parseParameter.ts @@ -13,7 +13,7 @@ export default function parseParameters(script: string): Parameter[] { script = script.split(/^(module |function )/m)[0]; const parameters: Record = {}; - const parameterRegex = /^(\w+)\s*=\s*([^;]+)/gm; // TODO: Use AST parser instead of regex + const parameterRegex = /^([a-z0-9A-Z_\$]+)\s*=\s*([^;]+)/gm; // TODO: Use AST parser instead of regex const groupRegex = /^\/\*\s*\[([^\]]+)\]\s*\*\//gm; const groupSections: { id: string; group: string; code: string }[] = []; diff --git a/tests/__snapshots__/openSCADparseParameters.test.ts.snap b/tests/__snapshots__/openSCADparseParameters.test.ts.snap index 488eb9f..1b7275e 100644 --- a/tests/__snapshots__/openSCADparseParameters.test.ts.snap +++ b/tests/__snapshots__/openSCADparseParameters.test.ts.snap @@ -471,6 +471,39 @@ exports[`testing parameter parsing of openscad scripts testing slider.scad: slid ] `; +exports[`testing parameter parsing of openscad scripts testing specialChars.scad: specialChars.scad 1`] = ` +[ + { + "description": undefined, + "group": "Settings", + "name": "$fn", + "type": "number", + "value": 200, + }, + { + "description": undefined, + "group": "Settings", + "name": "width", + "type": "number", + "value": 30, + }, + { + "description": undefined, + "group": "Settings", + "name": "length", + "type": "number", + "value": 50, + }, + { + "description": undefined, + "group": "Hidden", + "name": "height", + "type": "number", + "value": 10, + }, +] +`; + exports[`testing parameter parsing of openscad scripts testing specialVector.scad: specialVector.scad 1`] = ` [ { diff --git a/tests/fixtures/openSCAD/specialChars.scad b/tests/fixtures/openSCAD/specialChars.scad new file mode 100644 index 0000000..209df74 --- /dev/null +++ b/tests/fixtures/openSCAD/specialChars.scad @@ -0,0 +1,13 @@ +// test + +/* [Settings] */ + +$fn = 200; +width = 30; +length = 50; + +/* [Hidden] */ + +height = 10; + +cube([width,length,height]);