Repository navigation
Conversation
1 task
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
A
ValueSymbolprints its value as CCL, and a caller that prints a condition from its symbols relies on that text parsing back as the same condition. Concourse'sCriteria.ccl()prints its CCL this way, and RestQL's canonical query string is the CCL that ccl prints for aCriteria(cinchapi/restql#51).Before this change, a string value printed without quotes unless it read as a number, backticks wrapped it, or it contained a space or
=. So a string that contains a character CCL reads as syntax, such asa),[a],a;bor one with a tab, printed as text that did not parse or that parsed as another value. The same happened to a string that CCL reads as a token of its own, such as$id$,andorwhere. A string that was already within quotes, such as'a', printed as is and parsed back without its quotes. And a string that printed within quotes did not parse back as the same string when it had a backslash before a double quote or at its end.This change fixes the value side of #79, which stays open for keys. The grammar has no quoted form for a key, and #85 made only command, preposition and page words parse as keys, so a key spelled like
whereorandstill prints as text that does not parse.Change
A
ValueSymbolprints a string unquoted only when CCL reads the unquoted text back as the same string. Otherwise it prints the string within quotes, with the backslashes that keep it intact. A string whose text already parsed back keeps that text. For example, here is the CCL that aCriteriawith three string values prints before and after this change.To decide whether a string can print unquoted,
ValueSymbolasks the CCL lexer whether it reads the whole text as one unquoted value. So the rule follows the grammar, including every reserved word and operator, and there is no list of characters or words to keep in step with it.Semantics
jeff,a.b,a*orjeff@cinchapi.com.$or\$, such as$target, prints unquoted whenever the lexer reads it as one unquoted value. The parser then reads it as a reference to local data or as the escape for one, soCompiler#parse(String, Multimap)resolves the text the wayCompiler#parse(List, Multimap)resolves the symbol.a;b,where,$id$or'a'. A string that reads as a number, such as1, or that backticks wrap also prints within quotes, so that it reads back as a string rather than as a number or a Tag.it's "x"prints as"it's \"x\"", andC:\Program Files\prints as"C:\Program Files\\".it's \\. Such a string prints within double quotes, and its text does not parse back as the string.Compiler's value parser, which turns the text of a value into an object, can read unquoted text as a type other than a string. For example, Concourse's value parser readstrueas a boolean,@1as a link and|now|as a timestamp, so a string with that text prints unquoted and reads back as that type.