[x3d-public] X3D regular expression (regex) improvements

Don Brutzman brutzman at nps.edu
Tue Aug 7 08:21:35 PDT 2018


Today's improvement: a diagram has been added (and attached for mail archives) showing the pattern for X3D n-Tuple Regular Expression Patterns.

Please note that the color-coded patterns are also reflected for each and every datatype regex in the Design Considerations section.

This makes the majority of the X3D data-type regexes very similar and much easier to maintain.

http://www.web3d.org/specifications/X3dRegularExpressions.html#Design
http://www.web3d.org/specifications/X3dRegularExpressions.png

Continuing:

On 8/6/2018 11:52 AM, Andreas Plesch wrote:
> Two quick points:
> 
> The hexadecimal pattern got corrupted. SFImage uses this pattern:
> 
> 0x([a-f]|[A-F]|\d]){1,8}
> 
> where \d is the digit character class.

Thanks, will work on that pattern next.

> There are two equivalent +- patterns
> (\+|\-)?
> [+|-]?
> Probably only one should be recommended and used subsequently.

Good catch, thank you.  Will scrutinize and normalize.

> I have no good idea how to detect a leading 0 0 0 as non-matching. My
> not so good idea would be to explicitly allow
> non-0 followed by x x or
> x followed by non-0 followed by x or
> x x followed by non-0
> 
> where non-0 is something [+-]?0?\.?[0-9]*[1-9]+[0-9]*([e|E][+-]?[0-9]+)*
> and x is a floating point number
> 
> -Andreas

Possibly, but am thinking it adds serious complexity that is hard to maintain.  So probably not but will think about it.

Thanks for the continuing review!  Very helpful.


> On Mon, Aug 6, 2018 at 11:36 AM Don Brutzman <brutzman at nps.edu> wrote:
>>
>> Much work and progress on X3D Regexes, with support and unit tests for most of the major types.
>>
>>          X3D Regular Expressions (regexes)
>>          http://www.web3d.org/specifications/X3dRegularExpressions.html
>>
>> Lots of detail provided for Design Considerations and also Whitespace.  These improvements are integrated into X3D v4 schema.
>>
>> Had thought I found a way to detect things like multiple commas and 0 0 0 axis starting an SFRotation value - but this uses "negative lookahead" which is not supported by XML Schema (XSD).  It is documented however since other regex engines can use it.  In general, regex constructs that are inconsistently implemented across major programming languages are avoided.
>>
>> Lots of unit tests are provided, see "regex101" online tests accompanying each type.  Also FieldObjectTests.java in the X3DJSAIL junit5 tests package has a large number of tests.
>>
>> X3DJSAIL performs regex testing on each attribute when validating, so I will next perform a thorough set of regression tests on all 3900 examples.
>>
>>          X3D Java Scene Access Interface Library (X3DJSAIL)
>>          http://www.web3d.org/specifications/java/X3DJSAIL.html
>>
>>          X3D Resources: Example Scene Archives for X3D
>>          http://www.web3d.org/x3d/content/examples/X3dResources.html#Examples
>>
>> Looking ahead:
>> a. TODO: SF/MFImage and matrix types.
>> b. Will collect and expose specialty regexes for error detection (for example, floating point numbers with two decimal points).
>> c. Am thinking we might well define field subtypes for additional authoring support by tools.  For example SFInt32NonNegative SFVec3fBoundingBox, SFFloatZeroToOne etc.
>>
>> This X3D Unified Object Model (X3DUOM) work is all part of
>>
>>          X3D Resources: Quality Assurance (QA)
>>          http://www.web3d.org/x3d/content/examples/X3dResources.html#QualityAssurance
>>
>> Have fun with X3D validation!  8)
>>
>> all the best, Don
>> --
>> Don Brutzman  Naval Postgraduate School, Code USW/Br       brutzman at nps.edu
>> Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA   +1.831.656.2149
>> X3D graphics, virtual worlds, navy robotics http://faculty.nps.edu/brutzman
> 
> 
> 
> --
> Andreas Plesch
> Waltham, MA 02453
> 


all the best, Don
-- 
Don Brutzman  Naval Postgraduate School, Code USW/Br       brutzman at nps.edu
Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA   +1.831.656.2149
X3D graphics, virtual worlds, navy robotics http://faculty.nps.edu/brutzman

-------------- next part --------------
A non-text attachment was scrubbed...
Name: X3dRegularExpressions.png
Type: image/png
Size: 50067 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20180807/4d1235c2/attachment-0001.png>


More information about the x3d-public mailing list