|
|
|
@ -30,37 +30,35 @@ export const structure = {
|
|
|
|
* Looks ahead to determine if query feature is a range query. This involves locating at least one delimiter and no
|
|
|
|
* Looks ahead to determine if query feature is a range query. This involves locating at least one delimiter and no
|
|
|
|
* colon tokens.
|
|
|
|
* colon tokens.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param context -
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @returns {boolean} Is potential range query.
|
|
|
|
* @returns {boolean} Is potential range query.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function lookaheadIsRange(context) {
|
|
|
|
function lookahead_is_range() {
|
|
|
|
let type;
|
|
|
|
let type;
|
|
|
|
let offset = 0;
|
|
|
|
let offset = 0;
|
|
|
|
|
|
|
|
|
|
|
|
let count = 0;
|
|
|
|
let count = 0;
|
|
|
|
let delimFound = false;
|
|
|
|
let delim_found = false;
|
|
|
|
let noColon = true;
|
|
|
|
let no_colon = true;
|
|
|
|
|
|
|
|
|
|
|
|
// A range query has maximum 5 tokens when formatted as 'mf-range' /
|
|
|
|
// A range query has maximum 5 tokens when formatted as 'mf-range' /
|
|
|
|
// '<mf-value> <mf-lt> <mf-name> <mf-lt> <mf-value>'. So only look ahead maximum of 6 non-whitespace tokens.
|
|
|
|
// '<mf-value> <mf-lt> <mf-name> <mf-lt> <mf-value>'. So only look ahead maximum of 6 non-whitespace tokens.
|
|
|
|
do {
|
|
|
|
do {
|
|
|
|
type = context.lookupNonWSType(offset++);
|
|
|
|
type = this.lookupNonWSType(offset++);
|
|
|
|
if (type !== WhiteSpace) {
|
|
|
|
if (type !== WhiteSpace) {
|
|
|
|
count++;
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (type === Delim) {
|
|
|
|
if (type === Delim) {
|
|
|
|
delimFound = true;
|
|
|
|
delim_found = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (type === Colon) {
|
|
|
|
if (type === Colon) {
|
|
|
|
noColon = false;
|
|
|
|
no_colon = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (type === LeftCurlyBracket || type === RightParenthesis) {
|
|
|
|
if (type === LeftCurlyBracket || type === RightParenthesis) {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while (type !== EOF && count <= 6);
|
|
|
|
} while (type !== EOF && count <= 6);
|
|
|
|
|
|
|
|
|
|
|
|
return delimFound && noColon;
|
|
|
|
return delim_found && no_colon;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function parse() {
|
|
|
|
export function parse() {
|
|
|
|
@ -71,12 +69,12 @@ export function parse() {
|
|
|
|
|
|
|
|
|
|
|
|
// Parse potential container name.
|
|
|
|
// Parse potential container name.
|
|
|
|
if (this.tokenType === Ident) {
|
|
|
|
if (this.tokenType === Ident) {
|
|
|
|
const containerName = this.substring(this.tokenStart, this.tokenEnd);
|
|
|
|
const container_name = this.substring(this.tokenStart, this.tokenEnd);
|
|
|
|
|
|
|
|
|
|
|
|
// Container name doesn't match a query keyword, so assign it as container name.
|
|
|
|
// Container name doesn't match a query keyword, so assign it as container name.
|
|
|
|
if (!CONTAINER_QUERY_KEYWORDS.has(containerName.toLowerCase())) {
|
|
|
|
if (!CONTAINER_QUERY_KEYWORDS.has(container_name.toLowerCase())) {
|
|
|
|
name = containerName;
|
|
|
|
name = container_name;
|
|
|
|
this.eatIdent(containerName);
|
|
|
|
this.eatIdent(container_name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -100,7 +98,7 @@ export function parse() {
|
|
|
|
|
|
|
|
|
|
|
|
case LeftParenthesis:
|
|
|
|
case LeftParenthesis:
|
|
|
|
// Lookahead to determine if range feature.
|
|
|
|
// Lookahead to determine if range feature.
|
|
|
|
child = lookaheadIsRange(this) ? this.ContainerFeatureRange() : this.ContainerFeature();
|
|
|
|
child = lookahead_is_range.call(this) ? this.ContainerFeatureRange() : this.ContainerFeature();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
|