Implemented string functions and regular expression engine #25
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Thingiverse project: http://www.thingiverse.com/thing:526023
Github project: https://github.com/davidson16807/relativity.scad
Also based in part off #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: