New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoiding =: in $rule =: integer etc #112
Comments
What the above doesn't help with is the following situation:
I'll look closer at this. I THINK what we can do is change:
to:
FYI-
We'd want to change |
This proposal means that JCR will no longer be a proper superset of JSON. I also think that people would find writing strings as regular expressions, even simple ones, to be an irritant. This is also not backwards compatible with the JCR already out there. I don't think there is a lot we can do here to avoid the issue. Here are some suggestions:
|
I'd missed the JSON superset bit. Yes, we don't want to lose that. I like your suggestions. If we call, e.g.,
In that case, something like
That gets us half way there. Then, say that, if you want a named rule that corresponds to only a So we have:
Other
I realise you're deep in other stuff, and this idea may benefit from stewing a little bit. But to me that looks pretty good, and fixes the biggest annoyance I have with JCR at the moment. |
I'm still not following the reason for doing a quoted regex. Perhaps my proposal was not clear, and I realize now that re-use of the My proposal is for string values to be quoted with either So string and regex values could have different quoting, but member names MUST be double quotes and slashes. Therefore
I hope I expressed it right this time. |
Allowing I think I'd get confused between I'd like to avoid having two ways to represent the same thing, if possible. Allowing different quoting of strings has precedent in other languages, so won't be difficult for people to take on board. I'm not so sure allowing both Looks like we can use any any non-alphanumeric, non-backslash, non-whitespace character (http://us.php.net/manual/en/regexp.reference.delimiters.php). What about using backticks for member names using regular expressions? That looks more 'member name-like' to me, and has a 'processed' connotation. We then get:
and
Or are there too many wildcarded JCR rules out in the wild now? |
I don't know how many existing projects use a regex for member names. Checking my projects, only one does it in one spot. My suspicion is that it is not a heavily used feature. So let's proceed with the above. |
Cool. I'll try coding it up in the validator. |
In answering Daniel's question on the JSON mailing list, it just occurred to me that another solution to this problem is to simply say that either a primitive assignment or member assignment requires the group syntax.
In fact, both work today. Just an observation. |
I think if we did that it would require another entry in the tip-and-tricks section, which I think would best be avoided. Also, looking at it, we have the same ambiguity in:
as:
(Parslet is doing a lot of back tracking to cover this up.) With this issue resolved as above, we'd disambiguate the two by doing:
I'd like to think about it some more. I might email you about it, and/or start a new issue to avoid the issue tracking diverging. |
Resolved by requiring the parser to disambiguate various scenarios. See PR #118. |
To capture what was sent by email...
I've been trying to think how we can avoid the ugliness of the : in =: when we use a type.
If I remember rightly, the issue is that if we have:
or:
Without the extra token, it's not clear whether they are names or types.
After some thought, I'd like to propose the following to address the issue:
1 - Remove the string-value type. If you need an explicit string as a type, rely on the string-range regex type. i.e. instead of:
do:
That way if you see a quoted string, you know it's a name. (But so far, if you see a regular expression, it's not clear if it's a name or type.)
So, 2 - Treat the string in a quoted string name as an implicitly anchored regular expression. We could call it a q-re-string, as a variation of a q-string.
For example, instead of:
we do:
Because the special regular expression characters ("(){}[]*+?|") rarely appear in object names, this is unlikely to cause a problem. Where it does, they can just be escaped.
With this arrangement, a quoted (regular expression) string is always a name, and a regular expression is always a type.
I think if we do this, the ambiguity between a name and a type is removed. So instead of having to do:
We can just do:
The text was updated successfully, but these errors were encountered: