You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## 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`
0 commit comments