Code style / formatting.

pull/8275/head
typhonrt 4 years ago
parent 15fa8ad0cc
commit 8f5fd3d6fe

@ -16,17 +16,17 @@ export const structure = {
value: ['Identifier', 'Number', 'Comparison', 'Dimension', 'QueryCSSFunction', 'Ratio', null]
};
function lookupNonWSTypeAndValue(offset, type, referenceStr) {
let currentType;
function lookup_non_WS_type_and_value(offset, type, referenceStr) {
let current_type;
do {
currentType = this.lookupType(offset++);
if (currentType !== WhiteSpace) {
current_type = this.lookupType(offset++);
if (current_type !== WhiteSpace) {
break;
}
} while (currentType !== 0); // NULL -> 0
} while (current_type !== 0); // NULL -> 0
return currentType === type ? this.lookupValue(offset - 1, referenceStr) : false;
return current_type === type ? this.lookupValue(offset - 1, referenceStr) : false;
}
export function parse() {
@ -39,7 +39,7 @@ export function parse() {
while (!this.eof && this.tokenType !== RightParenthesis) {
switch (this.tokenType) {
case Number:
if (lookupNonWSTypeAndValue.call(this, 1, Delim, '/')) {
if (lookup_non_WS_type_and_value.call(this, 1, Delim, '/')) {
child = this.Ratio();
} else {
child = this.Number();

@ -19,8 +19,8 @@ export function parse() {
const start = this.tokenStart;
let value = null;
const functionName = this.consumeFunctionName();
if (functionName !== 'style') {
const function_name = this.consumeFunctionName();
if (function_name !== 'style') {
this.error('Unknown container style query identifier; "style" is expected');
}

@ -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
* colon tokens.
*
* @param context -
*
* @returns {boolean} Is potential range query.
*/
function lookaheadIsRange(context) {
function lookahead_is_range() {
let type;
let offset = 0;
let count = 0;
let delimFound = false;
let noColon = true;
let delim_found = false;
let no_colon = true;
// 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.
do {
type = context.lookupNonWSType(offset++);
type = this.lookupNonWSType(offset++);
if (type !== WhiteSpace) {
count++;
}
if (type === Delim) {
delimFound = true;
delim_found = true;
}
if (type === Colon) {
noColon = false;
no_colon = false;
}
if (type === LeftCurlyBracket || type === RightParenthesis) {
break;
}
} while (type !== EOF && count <= 6);
return delimFound && noColon;
return delim_found && no_colon;
}
export function parse() {
@ -71,12 +69,12 @@ export function parse() {
// Parse potential container name.
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.
if (!CONTAINER_QUERY_KEYWORDS.has(containerName.toLowerCase())) {
name = containerName;
this.eatIdent(containerName);
if (!CONTAINER_QUERY_KEYWORDS.has(container_name.toLowerCase())) {
name = container_name;
this.eatIdent(container_name);
}
}
@ -100,7 +98,7 @@ export function parse() {
case LeftParenthesis:
// Lookahead to determine if range feature.
child = lookaheadIsRange(this) ? this.ContainerFeatureRange() : this.ContainerFeature();
child = lookahead_is_range.call(this) ? this.ContainerFeatureRange() : this.ContainerFeature();
break;
default:

Loading…
Cancel
Save