mvdXML icon indicating copy to clipboard operation
mvdXML copied to clipboard

string parsing

Open berlotti opened this issue 11 years ago • 2 comments

use something else than strings for rules

berlotti avatar Jan 23 '14 21:01 berlotti

Yes, this topic is open for discussion. Please add you opinion to this issue!

This question already came up for mvdXML 1.1, but we then decided to keep the string-based solution because of compatibility reasons and to add a grammar to support rule-parsing. I am not sure how far we can go with this solution. So, please comment on this issue and describe your prefered solution (maybe as an implementer or an mvdXML developer).

MatthiasWeise avatar Jan 24 '14 08:01 MatthiasWeise

Here's an approach consistent with most execution environments -- indicate each operation underneath the Constraint tag using something like:

{Operation operator="or"} {Operation operator="equals"} {Operation operator="loadfield" operand="PredefinedType"/} {Operation operator="loadstring" operand="NOTDEFINED"/} {/Operation} {Operation operator="notequals"} {Operation operator="loadfield" operand="ObjectType"/} {Operation operator="loadnull"} {/Operation} {/Operation}

This approach would be extensible and correspond directly to virtual machines (e.g. Java runtime, .NET runtime) executing op codes, where the "operator" corresponds to a specific op code and stack behavior (i.e. types of values pushed or popped from stack). The "operand" would depend on the particular operation.

List of operators (could be expanded later): and -- pops two values, pushes true if either is true or xor equals -- pops two values, pushes true if equal notequals greaterthan lessthan greaterthanorequal lessthanorequal loadfield -- pushes a value by reference (identifies a particular EntityRule by ID) loadlen -- pushes length of array/collection loadstring -- pushes a string constant loadinteger -- pushes an integer constant loadnull -- pushes NULL onto the stack isinst -- checks if object is an instance of type

This structure is now used internally with IfcDoc, where it makes it easy to compile this into executable functions and transform it into different representations (e.g. EXPRESS, C#, Excel formula notation).

We could keep the existing string-based solution which could be used as backup/informational for easily viewing and retaining compatibility.

timchipman avatar Feb 24 '14 21:02 timchipman