Repository navigation
Conversation
A parsed command tells a caller whether it names its keys, records or destinations as a collection, so that `select [name] from 1` and `select name from 1` parse to symbols a caller can tell apart. A bracketed list, even of one item, and an unbracketed list of more than one item are collections; one item without brackets is not. hasKeysInCollection() covers the keys of SelectSymbol, GetSymbol, NavigateSymbol and BrowseSymbol and the keys that SelectAndSetSymbol, GetAndSetSymbol and the await symbols read. CalculateSymbol has hasRecordsInCollection() and LinkSymbol has hasDestinationsInCollection(). Each symbol has a constructor that takes the flag. The other constructors keep their signatures and set the flag when there is more than one item. Every other accessor, equals and hashCode returns the same result for each form, so [name] and name parse to equal trees.
Grammar#KeyOrKeyCollection() and Grammar#AwaitKeys() keep their signatures and return only the keys, with null from AwaitKeys() for a bare `where`. The commands read the keys and whether they form a collection through the private productions NamedKeyOrKeyCollection() and NamedAwaitKeys(), which the public ones delegate to, so the parser's public API only gains members.
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
Concourse returns a result shaped for a collection whenever a command names a
collection of keys or records, even when the collection holds one item, and a
result for one item when the command names one bare item. CCL writes a
collection with brackets or commas:
select [name] from 1andselect name, age from 1name a collection of keys, andselect name from 1names one key.
Several parsed commands could not tell the two apart.
SelectSymbol,GetSymbol,NavigateSymbol,BrowseSymbol, the await symbols, and theread-and-set symbols put a bare key and a bracketed list of one key in the same
keys()collection.CalculateSymboldid the same for its records, andLinkSymbolfor its destinations. So Concourse ranselect [name] from 1as aselect of one key.
Change
Each of those symbols reports whether the command named its items as a
collection, beside the accessor that returns them.
The accessors are
hasKeysInCollection()onSelectSymbol,GetSymbol,NavigateSymbol,BrowseSymbol,AwaitSelectSymbol,AwaitGetSymbol,SelectAndSetSymbol,GetAndSetSymbol,AwaitSelectAndSetSymbol, andAwaitGetAndSetSymbol, where it describes the keys the command reads;CalculateSymbol#hasRecordsInCollection(); andLinkSymbol#hasDestinationsInCollection(). Each symbol gains a constructorthat takes the flag beside each constructor it already has.
The change is additive. The language, every existing constructor, accessor,
equals, andhashCode, and every public member of the generated parser keeptheir results, so a caller that does not read the new accessors sees no
difference.
Semantics
truewhen the command lists its items in brackets, even oneitem as in
[name], or lists more than one item, as inname, age. It isfalsefor one item without brackets.keys(),records(), anddestinations()return the same items for eitherform.
equalsandhashCodeignore the flag, so[name]andnamestill parseto equal trees for the symbols that implement them.
more than one item.