-
Notifications
You must be signed in to change notification settings - Fork 6
Retain escape sequences in lexer, fixes #5 #21
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,19 +69,15 @@ else if (comp.equals("<>")) { | |
| //remember quote char | ||
| char mark = c; | ||
| qi++; | ||
| boolean escaped = false; | ||
| buf.setLength(0); //reset buffer | ||
| while (qi < ql) { | ||
| if (!escaped && qs.charAt(qi) == mark) //terminator | ||
| break; | ||
| if (escaped && strchr("*?^\\", qs.charAt(qi))) //no escaping for d-quote | ||
| buf.append("\\"); | ||
| if (!escaped && qs.charAt(qi) == '\\') { //escape-char | ||
| escaped = true; | ||
| while (qi < ql && qs.charAt(qi) != mark) { | ||
| if (qs.charAt(qi) == '\\') { //escape-char | ||
| if (qi == ql - 1) { | ||
| break; //unterminated | ||
| } | ||
| buf.append(qs.charAt(qi)); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand the intent of this section at all. It looks like it can't lex
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, good to see. My code-reading foo is depressed. |
||
| qi++; | ||
| continue; | ||
| } | ||
| escaped = false; //reset escape | ||
| buf.append(qs.charAt(qi)); | ||
| qi++; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -229,7 +229,7 @@ static String maybeQuote(String str) { | |
| str.indexOf('/') != -1 || | ||
| str.indexOf('(') != -1 || | ||
| str.indexOf(')') != -1) { | ||
| str = '"' + str.replace("\"", "\\\"") + '"'; | ||
| str = '"' + str + '"'; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm probably missing something, but this looks wrong to me. It looks like it will render
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I repeat:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're asserting a precondition that where
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The bare quote case is now considered.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you. |
||
| } | ||
|
|
||
| return str; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,5 +3,5 @@ | |
| <relation> | ||
| <value>=</value> | ||
| </relation> | ||
| <term>term\*\?\^</term> | ||
| <term>te\rm\*\?\^</term> | ||
| </searchClause> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We discussed this briefly on Slack, but I still don't understand why the change. Yes this needs to round-trip correctly — but all strings in any CQL query (hence all strings that we generate in the query generator) need to round-trip correctly. So why do we care what this one is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR changes the term so that escape sequences are retained (preserved). If a term includes
"it will always be preceded by backslash.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you saying that only some terms are round-tripped correctly?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep. If a term contained a bare ", that would not be round-tripped correctly. But that would never be the result of parsing.