Re^2: YAML::XS perl/regexp (?u:(?u:
by shmem (Chancellor) on Dec 06, 2017 at 22:07 UTC
|
YAML should store the pattern (( re::regexp_pattern($re) )[0] ) and the modifiers ( ( re::regexp_pattern($re) )[1] ) separately.
...and YAML::XS should make use of XS(XS_re_regexp_pattern) in universal.c to achieve that. Inevitably, this raises backcompat issues.
perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'
| [reply] [d/l] [select] |
|
and YAML::XS should make use of XS(XS_re_regexp_pattern) in universal.c
And how does one do that? XS(XS_re_regexp_pattern) creates the Perl sub re::regexp_pattern, so that's a very weird way of saying that YAML::XS should call Perl sub re::regexp_pattern.
Inevitably, this raises backcompat issues.
This can be addressed by storing them as a different type than perl/regexp (perl/regexp_plus_mods?).
| [reply] [d/l] [select] |
|
i think shmem was talking about regexp_pattern only available since perl 5.10, while YAML and YAML::XS aim to spport 5.8. I wonder how your suggeestion addresses that. Can you elaborate or did you mean something else?
| [reply] [d/l] |
|
Re^2: YAML::XS perl/regexp (?u:(?u:
by tinita (Parson) on Dec 08, 2017 at 16:54 UTC
|
It would be possible to store a regex as a sequence and use the same tag for it:
---
re1: !!perl/regexp (?^usi:pattern)
re2: !!perl/regexp [ pattern, isu ]
For perl 5.8 the old behaviour could be used. This could be done for YAML and YAML::XS. Possibly also for YAML::Syck, which has the same problem, but I would have to ask Todd, the maintainer. | [reply] [d/l] |
|
You can add understanding of !!perl/regexp [ pattern, isu ] at any time, but backwards compatibility requires making the generation of that an option. Eventually, once support has been established, it could default to the new method.
| [reply] [d/l] |
|
Another possibility would be to continue just using a string. Check with regexp_pattern(), if there are any flags (ignoring u), just store the stringified regex, otherwise store the pattern itself.
This would still lead to unnecessary (?:...) but it wouldn't grow in roundtrips.
Have been looking into universal.c how regexp_pattern() is implemented. At the moment it's too much magic for me to understand.
| [reply] [d/l] [select] |
|
|
|