I have implemented string functions common to the libraries I see in most modern languages. Unit tests can be found in the github project, above - these test do not fit the structure of MCAD's python unit tests, but they should provide better code coverage than simply ensuring valid syntax. I have omitted these tests from the pull request.
The regular expression engine is built using a spinoff of a standard implementation that first parses the regular expression to a syntax tree using the shunting yard algorithm, then traverses a string using the syntax tree in a manner reminiscent to Thompson's algorithm. Due to limitations in OpenSCAD, no validation is performed against regular expressions. Branching is performed through ternary conditionals. Looping is performed through recursion. Stacks are implemented via nested, right associative lists, i.e. "["foo", ["bar", []]]", which is easiest to work with given the current lack of a working "concat" in prod.
Thingiverse project: http://www.thingiverse.com/thing:526023 Github project: https://github.com/davidson16807/relativity.scad Also based in part off https://github.com/openscad/MCAD/pull/13
I have implemented string functions common to the libraries I see in most modern languages. Unit tests can be found in the github project, above - these test do not fit the structure of MCAD's python unit tests, but they should provide better code coverage than simply ensuring valid syntax. I have omitted these tests from the pull request.
The following functions are included:
The regular expression engine is built using a spinoff of a standard implementation that first parses the regular expression to a syntax tree using the shunting yard algorithm, then traverses a string using the syntax tree in a manner reminiscent to Thompson's algorithm. Due to limitations in OpenSCAD, no validation is performed against regular expressions. Branching is performed through ternary conditionals. Looping is performed through recursion. Stacks are implemented via nested, right associative lists, i.e. "["foo", ["bar", []]]", which is easiest to work with given the current lack of a working "concat" in prod.
Regular expressions support the following: