shexSpec / shex

ShEx language issues, including new features for e.g. ShEx2.1
25 stars 8 forks source link

Support for flags in regex pattern #28

Closed labra closed 7 years ago

labra commented 7 years ago

The pattern facet in the current spec doesn't have support for the flags optional parameter.

The issue has already been detected as appears in the specification so adding this issue here is just to unify the issues in a single place.

How could we represent flags in the compact syntax?

ericprud commented 7 years ago

PROPOSAL: adopt ~/regexp/ syntax for regular expressions REASON: better than having no flags DIFFS: shexTest, shex.js

labra commented 7 years ago

I voted 👍 but I think the ShExC BNF grammar (and the ANTLR) still need to be updated to reflect the change.

Currently, we have production 34.

[34]  stringFacet      ::=         stringLength INTEGER
                                   | "PATTERN" string
                                   | "~" string

and I suppose it should be something like:

[34]  stringFacet      ::=         stringLength INTEGER
                                   | "~" "/" pattern "/" flags

where pattern and flags should also be defined.

ericprud commented 7 years ago

yep, i did this in my impl:

 [25]    stringFacet ::= stringLength INTEGER
                       | REGEXP
-                      | "PATTERN" string
-                      | '~' string  # shortcut for "PATTERN"
+[63]    REGEXP      ::= '/' ([^#x2f#x5C#xA#xD] | '\\' [tbnrf\\/] | UCHAR)* '/' [smix]*

which allows for repetition of flags but is pretty good otherwise. The edits are pretty small for spec/index.html and grammar/* so I didn't bother to create branches for them.

ericprud commented 7 years ago

merged with changes to /spec and /grammar