-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refined String-escaping behaviour (#22)
## What is the goal of this PR? During the recent refactor of Graql grammar, we accidentally the lexer for `STRING_` to be too strict: we disallowed `/` character. The reason for this was that the unescape-and-escape behaviour over `/` was not symmetrical. `unescape('/') -> '/'` and `escape('/') -> '\/'`, which means the user reads back characters that they did not write, and that's not acceptable. However, we need to bring back `/` characters in strings (issue #21) because it is widely used. During the investigation, we discovered that there is no need for Graql to be escaping/unescaping strings that are provided by the user in the first place. Given that the String that is parsed by ANTLR is already a valid String, we can store it "as is" (with the exception for Regular Expression, that still requires a special escape operation). I.e. what the user writes, is what the user reads, for any Unicode character accepted by ANTLR. Fixing the above also resulted in fixing our tests to expect the correct behaviour from Graql. ## What are the changes implemented in this PR? 1) Relaxed Graql grammar to accept `/` (fixes #21) 2) Remove `escapeString()` and `unescapeString()` from `StringUtil`, and all it's usage. 3) Introduced `escapeRegex()` and `escapeRegex()` in `StringUtil`, and used them in parsing and printing regex. 4) Fixed tests to comply with the newly refined behaviour of Graql string and regex parsing/printing. 5) Additionally, we reimplement `StringUtils.repeat()` with a simple `spaces(int len)` in `SyntaxError`, so we can remove the dependency to `org.apache.commons.lang`
- Loading branch information
1 parent
2dbf9b5
commit 8b21baf
Showing
14 changed files
with
80 additions
and
61 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters